fix(consent): gate PostHog analytics on CookieYes consent#7971
Conversation
PostHog initialised with capture_pageview and no consent gate, so it set cookies and fired a pageview on load before the visitor interacted with the CookieYes banner — analytics tracking before consent (GDPR/ePrivacy issue). Add a shared CookieYes consent helper (packages/ui/src/lib/consent.ts) that reads the same signals as the GTM consent bridge (cookieyes_consent_update / cookieyes_banner_load events + getCkyConsent()), and use it in all three apps (docs, site, blog) to init PostHog opted-out, opting in only once analytics consent is granted and reacting to live consent changes. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
WalkthroughA new ChangesPostHog CookieYes Consent Gating
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Comment |
|
The latest updates on your projects. Learn more about Argos notifications ↗︎
|
Problem
PostHog was initialised with
capture_pageviewand no consent gate in all three apps (docs,site,blog). On page load it set cookies/localStorage and fired a pageview before the visitor interacted with the CookieYes banner — i.e. analytics tracking before consent, a GDPR/ePrivacy issue. This was flagged via the DPO.Audit of the other trackers showed they are already compliant, so the scope here is PostHog only:
denied, bridged to CookieYestype="text/plain"+data-cookieyes, inert until consentContext
Consent-gating for PostHog previously existed but was reverted in #7884. That implementation was also buggy: it listened for
cookieyes-consent-update(hyphens) and read acookieyes-consentcookie, while the actual CookieYes integration (the GTM bridge) usescookieyes_consent_update(underscores) +getCkyConsent(). The wrong event name likely meant the old gate never fired.Fix
packages/ui/src/lib/consent.ts—hasAnalyticsConsent()andonAnalyticsConsentChange(), reading the same CookieYes signals the GTM bridge already uses (one source of truth).opt_out_capturing_by_default: true, opt in immediately for returning visitors who already consented, and opt in/out live as consent changes. No cookies or events until analytics consent is granted.Verify
Summary by CodeRabbit
Release Notes