Repository navigation
feat(analytics): add PostHog + Vercel Analytics with self-host opt-in posture - #13
Merged
Merged
Conversation
… 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)
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Merged
This branch was successfully deployed
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.
Adds product analytics infrastructure that is fully active on the
managed cloud but ships zero telemetry from a self-hosted build.
Wiring:
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.
track / identify / reset / setPersonProperties helpers that
silently no-op when PostHog isn't loaded.
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):
Env:
set; override for self-hosted PostHog instances)