Repository navigation
eddie/add posthog - #180
8ddieHu0314 wants to merge 2 commits into
Conversation
Initialize posthog-js in a client provider in the root layout, reading NEXT_PUBLIC_POSTHOG_KEY and NEXT_PUBLIC_POSTHOG_HOST. Nothing is sent when the key is unset. Pageviews follow App Router navigation through the history_change default. Identify signed-in users by their Supabase user id and reset PostHog on sign out. Sign out runs as a server action, so the browser auth listener never sees it; each sign-out control resets PostHog before calling it. Cover PostHog analytics, session recordings and surveys in the privacy policy, and document the env vars in ONBOARDING.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
|
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
|
Summary
Adds PostHog to the frontend for product analytics and session replay and updates the privacy policy
Changes
PostHogProviderto the root layout. WhenNEXT_PUBLIC_POSTHOG_KEYis set, it records pageviews (including App Router navigation) and clicks, and identifies signed-in users by their Supabase user id.posthog.reset()beforesignOut()in all five sign-out controls. Sign-out redirects without reloading the page, so the auth listener alone would miss it.How to test
NEXT_PUBLIC_POSTHOG_KEYandNEXT_PUBLIC_POSTHOG_HOST (check Slack) tofrontend/.env.dev, runpnpm install`, then start the backend and frontend as usual. Open PostHog → Activity → Live events./buyer/browseand click into a fundraiser. You should see a$pageviewfor each page (the second without a page reload) and a click event, under an anonymous id.$identify, then events under your Supabase user id. Sign out from the account menu: the next pageview uses a new anonymous id.ADMIN_EMAILSinbackend/.env.dev, open/admin, and sign out from its header. You should see the same switch to a new anonymous id.NEXT_PUBLIC_POSTHOG_KEYand restart. The app should work normally and send nothing to posthog.comChecklist
mainpnpm assembleand both dev serversschema.prismachanged: migration file is included and existing rows are backfilledcommon/changed:pnpm buildincommonand both consumers updated.env*files, keys, or real user data in the diff or screenshots