Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions apps/desktop/src/components/welcome-modal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import { commands as dbCommands } from "@hypr/plugin-db";
import { commands as localLlmCommands } from "@hypr/plugin-local-llm";
import { AudioPermissionsView } from "./audio-permissions-view";
// import { CalendarPermissionsView } from "./calendar-permissions-view";
import { useHypr } from "@/contexts";
import { commands as analyticsCommands } from "@hypr/plugin-analytics";
import { DownloadProgressView } from "./download-progress-view";
import { LanguageSelectionView } from "./language-selection-view";
import { ModelSelectionView } from "./model-selection-view";
Expand All @@ -28,6 +30,7 @@ interface WelcomeModalProps {
export function WelcomeModal({ isOpen, onClose }: WelcomeModalProps) {
const navigate = useNavigate();
const queryClient = useQueryClient();
const { userId } = useHypr();
const [port, setPort] = useState<number | null>(null);
const [currentStep, setCurrentStep] = useState<
| "welcome"
Expand Down Expand Up @@ -87,6 +90,42 @@ export function WelcomeModal({ isOpen, onClose }: WelcomeModalProps) {
}
}, [isOpen]);

useEffect(() => {
if (currentStep === "audio-permissions" && userId) {
analyticsCommands.event({
event: "onboarding_reached_audio",
distinct_id: userId,
});
}
}, [currentStep, userId]);

useEffect(() => {
if (currentStep === "model-selection" && userId) {
analyticsCommands.event({
event: "onboarding_reached_model_selection",
distinct_id: userId,
});
}
}, [currentStep, userId]);

useEffect(() => {
if (currentStep === "download-progress" && userId) {
analyticsCommands.event({
event: "onboarding_reached_download_progress",
distinct_id: userId,
});
}
}, [currentStep, userId]);

useEffect(() => {
if (currentStep === "language-selection" && userId) {
analyticsCommands.event({
event: "onboarding_reached_language_selection",
distinct_id: userId,
});
}
}, [currentStep, userId]);

const handleStartLocal = () => {
setCurrentStep("audio-permissions");
};
Expand Down
9 changes: 8 additions & 1 deletion apps/desktop/src/routes/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import {
useRightPanel,
} from "@/contexts";
import { commands } from "@/types";
import { commands as analyticsCommands } from "@hypr/plugin-analytics";
import { events as windowsEvents, getCurrentWebviewWindowLabel } from "@hypr/plugin-windows";
import { ResizableHandle, ResizablePanel, ResizablePanelGroup } from "@hypr/ui/components/ui/resizable";
import { OngoingSessionProvider, SessionsProvider } from "@hypr/utils/contexts";
Expand All @@ -39,7 +40,7 @@ export const Route = createFileRoute("/app")({

function Component() {
const router = useRouter();
const { thankYouSessionId } = useHypr();
const { thankYouSessionId, userId } = useHypr();
const { sessionsStore, ongoingSessionStore, isOnboardingNeeded, isIndividualizationNeeded } = Route.useLoaderData();

const [onboardingCompletedThisSession, setOnboardingCompletedThisSession] = useState(false);
Expand Down Expand Up @@ -89,6 +90,12 @@ function Component() {
onClose={() => {
setOnboardingCompletedThisSession(true);

// Add posthog analytics
analyticsCommands.event({
event: "onboarding_all_steps_completed",
distinct_id: userId,
});

// Navigate to thank you session if it exists
if (thankYouSessionId) {
router.navigate({ to: `/app/note/${thankYouSessionId}` });
Expand Down
Loading