Skip to content

eddie/add posthog - #180

Open
8ddieHu0314 wants to merge 2 commits into
mainfrom
eddie/add-posthog
Open

8ddieHu0314 wants to merge 2 commits into
mainfrom
eddie/add-posthog

Conversation

@8ddieHu0314

Copy link
Copy Markdown
Member

Summary

Adds PostHog to the frontend for product analytics and session replay and updates the privacy policy

Changes

  • Adds PostHogProvider to the root layout. When NEXT_PUBLIC_POSTHOG_KEY is set, it records pageviews (including App Router navigation) and clicks, and identifies signed-in users by their Supabase user id.
  • Calls posthog.reset() before signOut() in all five sign-out controls. Sign-out redirects without reloading the page, so the auth listener alone would miss it.
  • Updates the privacy policy to cover analytics, session recordings and surveys, and documents the env vars in ONBOARDING.

How to test

  1. Add NEXT_PUBLIC_POSTHOG_KEY and NEXT_PUBLIC_POSTHOG_HOST (check Slack) to frontend/.env.dev, run pnpm install`, then start the backend and frontend as usual. Open PostHog → Activity → Live events.
  2. Signed out: open /buyer/browse and click into a fundraiser. You should see a $pageview for each page (the second without a page reload) and a click event, under an anonymous id.
  3. Buyer: sign in with a Cornell Google account. You should see $identify, then events under your Supabase user id. Sign out from the account menu: the next pageview uses a new anonymous id.
  4. Admin (optional): add your email to ADMIN_EMAILS in backend/.env.dev, open /admin, and sign out from its header. You should see the same switch to a new anonymous id.
  5. Replay: in PostHog → Session replay, your session should be listed and play back the pages you visited.
  6. No key: remove NEXT_PUBLIC_POSTHOG_KEY and restart. The app should work normally and send nothing to posthog.com

Checklist

  • Targets main
  • Runs locally with pnpm assemble and both dev servers
  • If schema.prisma changed: migration file is included and existing rows are backfilled
  • If common/ changed: pnpm build in common and both consumers updated
  • No .env* files, keys, or real user data in the diff or screenshots
  • I read every line of this diff and can explain it in review

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.
@vercel

vercel Bot commented Oct 28, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
curaise Ready Ready Preview Oct 28, 2026 6:02pm UTC

@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@coderabbitai

coderabbitai Bot commented Oct 28, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: QUIET
  • Plan: Advanced
  • Run ID: ddf3f742-7d2b-4285-89ec-02a77b8c0171

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@8ddieHu0314 8ddieHu0314 changed the title Eddie/add posthog eddie/add posthog Oct 28, 2026

This branch was successfully deployed

1 active deployment
Preview — 072ca059 Deployed Oct 28, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants