Conversation
) * feat(analytics): GPC-gated PostHog with pageviews + waitlist events Adds PostHog product analytics to being.fyi as the first analytics ever on the site. Output of a 5-step agent review sequence (compliance → product → architect → product priority → compliance) — see plan file. Compliance gave conditional sign-off pending three items (all addressed: upstream PR, Notion disclosure, /privacy/multi-state link). # Scope (Tier B-trimmed) Three events only: - $pageview (PostHog default) - waitlist_signup_submitted { source } - waitlist_signup_failed { source, reason } No autocapture. No session replay. No heatmaps. No surveys. No email hash identify (deferred to PR #2). EU data residency (Frankfurt). # GPC structural kill AnalyticsGate (client component, useSyncExternalStore) returns null when ANY of: - being_gpc=1 cookie set by middleware on Sec-GPC: 1 - navigator.globalPrivacyControl === true (browsers exposing the JS API without the HTTP header, e.g. older Brave) - NEXT_PUBLIC_POSTHOG_KEY missing (local dev) - SSR (getServerSnapshot=true, safe default) Null → PosthogProvider never mounts → dynamic import('posthog-js') never fires → posthog-js chunk never fetched → no init, no ph_* cookie, no beacon. Structurally enforced; not "suppressed after load." Diverged from architect's server-component design because cookies() in next/headers would force the parent layout into dynamic rendering, undoing force-static on legal pages and re-introducing the per-request marked() parse that PR #33 fixed. Client-side gate preserves both force-static AND the no-load guarantee. Confirmed by compliance re-review. # CI structural-regression gate tests/analytics-gpc-gate.test.tsx test #6 is a grep gate: if any file under app/, components/, lib/ statically imports posthog-js (outside PosthogProvider.tsx's dynamic import), the build fails. This is the regression vector that would bypass the gate; locking it in CI. # CSP additions - script-src += eu-assets.i.posthog.com - connect-src += eu.i.posthog.com eu-assets.i.posthog.com - img-src += eu.i.posthog.com (PostHog pixel fallback) - worker-src 'self' blob: (PostHog web worker for batching) # /cookies page rewrite - Removed "No PostHog" denial (was false the moment this PR ships) - Headline: "Two Functional Cookies + Privacy-Respecting Analytics" - New ph_* cookie disclosure with EU residency, kill conditions, scope - "What We Don't Use" updated: no GA/Mixpanel/Amplitude/Segment, no autocapture, no session replay (explicit even for PostHog) - GPC section: structurally enforced kill described accurately # Hard dependency This PR depends on MP2EZ/being#106 landing first (privacy policy §5.2 split into in-app vs web subsections + Notion added to §5.1 service providers). CI sync pulls from being@development; until #106 merges, the website ships analytics with a stale policy = FTC §5 issue. # Out of scope (PR #2+) - cta_clicked, crisis_resource_clicked, ab_variant_assigned events - Email-hash identify (server-side SHA-256 + identifyByEmailHash helper) - PostHog feature flags / experiments (we have being_ab_variant) - Session replay / heatmaps / surveys (categorically off) Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * feat(analytics): register surface: 'web' super-property Tags every PostHog event from the marketing site with surface: 'web' so the website's data stays distinguishable from the being-app's data in the shared PostHog project (free tier = 1 project per account; sharing is the right call pre-launch and a deliberate design choice). The app mirrors this with posthog.register({ surface: 'app' }) in a parallel change to ~/dev/being's PostHogProvider. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.
Production cutover — first analytics ever on being.fyi
Single commit since the last `preview → main` cutover (#41):
This is the moment of cutover for product analytics. After merging, being.fyi visitors who don't send GPC will get a `ph_*` cookie + their pageview / waitlist-conversion events will land in the shared PostHog project (tagged `surface: 'web'`). GPC-honoring browsers will continue to see zero PostHog footprint.
What goes live on being.fyi
Behavior changes:
$pageview,waitlist_signup_submitted,waitlist_signup_failedevents fire (non-GPC visitors only)ph_*PostHog cookie set (non-GPC visitors only)eu.i.posthog.com+eu-assets.i.posthog.comDisclosure changes:
ph_*disclosure with kill conditions addedNo-op for GPC users: if your browser sends
Sec-GPC: 1(Brave, DuckDuckGo, Firefox+ext), nothing changes. AnalyticsGate returns null → PosthogProvider never mounts → posthog-js never loads → no cookie, no beacon.Already-verified pre-merge
Auto-fires post-merge
Manual launch-day verification (after deploy completes)
Two minutes of browser checks:
posthog-jschunk loads fromeu-assets.i.posthog.com/decidePOST fires toeu.i.posthog.com$pageviewcapture firesph_*distinct ID cookie seteu.i.posthog.comrequestsph_*cookiewaitlist_signup_submittedevent appears in PostHog dashboard withsource: 'download'+surface: 'web'propertiesOut of scope (separate PRs)
identifyByEmailHash) for cross-device + app-to-web stitching — gated behind a separate §5.2 update when it shipscta_clicked,crisis_resource_clicked,ab_variant_assignedevents🤖 Generated with Claude Code