Skip to content

feat(analytics): add PostHog + Vercel Analytics with self-host opt-in posture - #13

Merged
gkhngyk merged 1 commit into
mainfrom
feat/analytics-posthog-and-vercel
May 14, 2026
Merged

gkhngyk merged 1 commit into
mainfrom
feat/analytics-posthog-and-vercel

Conversation

@gkhngyk

@gkhngyk gkhngyk commented May 14, 2026

Copy link
Copy Markdown
Contributor

Adds product analytics infrastructure that is fully active on the
managed cloud but ships zero telemetry from a self-hosted build.

Wiring:

  • posthog-provider boots only when NEXT_PUBLIC_POSTHOG_KEY is set;
    without the env var the SDK never initialises (no network, no
    bundle on the wire, no events anywhere). Initialised PostHog is
    exposed on window so the analytics wrapper can find it.
  • lib/analytics.ts is the only place app code talks to PostHog —
    track / identify / reset / setPersonProperties helpers that
    silently no-op when PostHog isn't loaded.
  • Vercel Analytics is mounted unconditionally for Web Vitals and
    pageview metrics; it no-ops outside Vercel preview/prod so it's
    safe to keep on for everyone.

Initial event coverage (extend as funnels are built out):

  • signup_completed on email signup success
  • signin_completed + identify on email signin
  • onboarding_brand_created when the brand step finishes
  • onboarding_prompts_saved when the prompt set is persisted
  • analytics reset on sign-out so PostHog drops the identity

Env:

  • NEXT_PUBLIC_POSTHOG_KEY (empty = telemetry off)
  • NEXT_PUBLIC_POSTHOG_HOST (defaults to us.i.posthog.com when key is
    set; override for self-hosted PostHog instances)

… posture

Adds product analytics infrastructure that is fully active on the
managed cloud but ships zero telemetry from a self-hosted build.

Wiring:
  - posthog-provider boots only when NEXT_PUBLIC_POSTHOG_KEY is set;
    without the env var the SDK never initialises (no network, no
    bundle on the wire, no events anywhere). Initialised PostHog is
    exposed on window so the analytics wrapper can find it.
  - lib/analytics.ts is the only place app code talks to PostHog —
    track / identify / reset / setPersonProperties helpers that
    silently no-op when PostHog isn't loaded.
  - Vercel Analytics is mounted unconditionally for Web Vitals and
    pageview metrics; it no-ops outside Vercel preview/prod so it's
    safe to keep on for everyone.

Initial event coverage (extend as funnels are built out):
  - signup_completed on email signup success
  - signin_completed + identify on email signin
  - onboarding_brand_created when the brand step finishes
  - onboarding_prompts_saved when the prompt set is persisted
  - analytics reset on sign-out so PostHog drops the identity

Env:
  - NEXT_PUBLIC_POSTHOG_KEY (empty = telemetry off)
  - NEXT_PUBLIC_POSTHOG_HOST (defaults to us.i.posthog.com when key is
    set; override for self-hosted PostHog instances)
@vercel

vercel Bot commented May 14, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
ansvisor Ready Ready Preview, Comment May 14, 2026 8:46pm

Request Review

@gkhngyk
gkhngyk merged commit 656f102 into main May 14, 2026
2 checks passed
@gkhngyk
gkhngyk deleted the feat/analytics-posthog-and-vercel branch May 14, 2026 20:53
@gkhngyk gkhngyk mentioned this pull request May 26, 2026

This branch was successfully deployed

1 active deployment
Preview — ca7a1620 Deployed May 14, 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.

1 participant