Add PostHog analytics integration - #116
Open
posthog[bot] wants to merge 1 commit into
Open
Conversation
Generated-By: PostHog Code Task-Id: 445e0ae2-381a-4346-a36f-241967c83fcb
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
vinay-lgtm-code
marked this pull request as ready for review
August 3, 2026 02:09
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds PostHog product analytics to Sequence using the
posthog-jsbrowser SDK (installed via npm,posthog-js@^1.409.5).src/components/posthog-client.tsx— new client component that initializes PostHog (posthog.init) with exception autocapture enabled, and identifies/resets the user against Supabase auth state (useAuth()), covering both real and demo sessions.src/components/providers.tsx— mounts<PostHogClient />inside the app-wideProviderstree.src/app/global-error.tsx— new Next.js App Router global error boundary that forwards uncaught root-level errors toposthog.captureException.src/app/(app)/layout.tsx,src/components/idle-timeout-modal.tsx— callposthog.reset()on sign-out (both manual sign-out and idle-timeout sign-out).src/app/(auth)/login/page.tsx— callsposthog.identify()right after a successful Supabase login.lead_created(src/app/(app)/leads/new/page.tsx)lead_import_completed(src/app/(app)/import/page.tsx)lead_stage_changed,lead_activity_logged(src/app/(app)/leads/[id]/page.tsx)cadence_created(src/app/(app)/cadences/new/page.tsx)cadence_enrolled(src/components/leads/enroll-cadence-modal.tsx)template_created(src/app/(app)/templates/new/page.tsx)team_invitation_sent(src/app/(app)/team/invite/page.tsx)brevo_connection_tested(src/app/(app)/integrations/brevo/page.tsx)document_uploaded(src/components/documents/upload-document.tsx)document_request_sent(src/components/documents/request-documents-modal.tsx)onboarding_completed(src/app/(onboarding)/onboarding/page.tsx).env.example— documents the two new PostHog env vars (see below).package.json/package-lock.json— addsposthog-js.No server-side PostHog SDK was added — the wizard's review step removed an unused server SDK dependency to keep the integration to client-side capture only.
Insights and dashboards created
How to verify
npm run devlocally with them set).$pageview,lead_created, etc. arriving within a minute.Environment variables (action needed before PostHog works)
This app deploys to Vercel (see
vercel.jsonfor cron config), which keeps environment variables in the Vercel dashboard rather than in a file committed to this repository — there's no.vercelproject link or committed.env.productionin this repo for me to update automatically, so these need to be set manually before the integration will send data in production.Environment variables are named settings your hosting provider passes to the app when it runs — they let the app know things (like the PostHog project token below) without hardcoding them into the source code. PostHog will not receive any events until both of these are set:
NEXT_PUBLIC_POSTHOG_PROJECT_TOKENphc_wrbmQPXYrK6YhzZjVeZxgZHNdSJpWPlKtBKw1qBMaEpNEXT_PUBLIC_POSTHOG_HOSThttps://us.i.posthog.comTo set them via the Vercel dashboard:
Setting environment variables via a local CLI
If you have the Vercel CLI installed and linked to this project, you can set them from a terminal instead:
Created with PostHog Code