Open source Loom alternative. Beautiful, shareable screen recordings.
Rust appcapcossloommacnextjsnextjs15open-sourceossreactrecordrustscreen-capturescreen-recorderscreenshotsolidjstauritauri-apptypescriptvite
feat(web): add AnalyticsIdentify client component
Richie McIlroy0ef93bdcee2c
diff --git a/apps/web/app/Layout/AnalyticsIdentify.tsx b/apps/web/app/Layout/AnalyticsIdentify.tsxnew file mode 100644index 000000000..132e12e0c--- /dev/null+++ b/apps/web/app/Layout/AnalyticsIdentify.tsx@@ -0,0 +1,41 @@+"use client";++import { Suspense, useEffect } from "react";+import { checkAndMarkUserSignedUpTracked } from "@/actions/analytics/track-user-signed-up";+import { identifyUser, trackEvent } from "../utils/analytics";+import { useCurrentUser } from "./AuthContext";++export function AnalyticsIdentify() {+ return (+ <Suspense>+ <Inner />+ </Suspense>+ );+}++function Inner() {+ const user = useCurrentUser();++ useEffect(() => {+ // Anonymous visitors need no setup: OpenPanel assigns a device profile on+ // its own and merges it into the identified profile once `identify` runs.+ if (!user) return;++ identifyUser({+ id: user.id,+ email: user.email,+ name: user.name,+ lastName: user.lastName,+ });++ (async () => {+ const { shouldTrack } = await checkAndMarkUserSignedUpTracked();+ if (shouldTrack) {+ trackEvent("user_signed_up");+ }+ trackEvent("user_signed_in");+ })();+ }, [user]);++ return null;+}