Skip to content

Hotfix: PostHog analytics live on being.fyi (with GPC kill)#43

Merged
MP2EZ merged 1 commit into
mainfrom
preview
May 31, 2026
Merged

Hotfix: PostHog analytics live on being.fyi (with GPC kill)#43
MP2EZ merged 1 commit into
mainfrom
preview

Conversation

@MP2EZ
Copy link
Copy Markdown
Owner

@MP2EZ MP2EZ commented May 31, 2026

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_failed events fire (non-GPC visitors only)
  • ph_* PostHog cookie set (non-GPC visitors only)
  • ✅ Updated CSP allows eu.i.posthog.com + eu-assets.i.posthog.com

Disclosure changes:

No-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:

  1. Regular Chrome (no GPC) on https://being.fyi/home
    • DevTools Network shows posthog-js chunk loads from eu-assets.i.posthog.com
    • /decide POST fires to eu.i.posthog.com
    • $pageview capture fires
    • DevTools Application → Cookies shows ph_* distinct ID cookie set
  2. Brave or Firefox+extension (sends GPC) on https://being.fyi/home
    • DevTools Network shows NO posthog-js fetch
    • NO eu.i.posthog.com requests
    • NO ph_* cookie
  3. Submit waitlist from being.fyi/download
    • waitlist_signup_submitted event appears in PostHog dashboard with source: 'download' + surface: 'web' properties

Out of scope (separate PRs)

  • Email-hash identify (identifyByEmailHash) for cross-device + app-to-web stitching — gated behind a separate §5.2 update when it ships
  • cta_clicked, crisis_resource_clicked, ab_variant_assigned events
  • Session replay, heatmaps, surveys (categorically off per /cookies disclosure)

🤖 Generated with Claude Code

)

* 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>
@MP2EZ MP2EZ merged commit 83b69c7 into main May 31, 2026
3 checks passed
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