diff --git a/apps/desktop/src/components/welcome-modal/index.tsx b/apps/desktop/src/components/welcome-modal/index.tsx index 5bf97c1f62..51bde5cbb4 100644 --- a/apps/desktop/src/components/welcome-modal/index.tsx +++ b/apps/desktop/src/components/welcome-modal/index.tsx @@ -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"; @@ -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(null); const [currentStep, setCurrentStep] = useState< | "welcome" @@ -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"); }; diff --git a/apps/desktop/src/routes/app.tsx b/apps/desktop/src/routes/app.tsx index de2a4490fd..2887d18b6d 100644 --- a/apps/desktop/src/routes/app.tsx +++ b/apps/desktop/src/routes/app.tsx @@ -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"; @@ -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); @@ -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}` });