Repository navigation
fix(analytics): consent gate, label plumbing, IP scrub, engagement dashboards - #318
Merged
Merged
Conversation
…shboards - Gate Vercel Analytics behind same consent check as PostHog/self-hosted - Plumb cta_click label through self-hosted tracker (PendingEvent.l) - Remove raw proxied IP from analytics ingest logs (rate-limit key only) - Surface browsers, scroll_depth funnel, quiz funnel on /admin/analytics - Add getEngagement() reading existing daily counters (zero new collection) - Export BROWSER_KEYS, SCROLL_THRESHOLDS for shared use - Add FunnelChart component (reuses existing bar chart pattern) - 4 new regression tests + extended existing admin test
- Move BROWSER_KEYS to tracking-store.ts as single source of truth - tracking.ts imports from tracking-store.ts (implicit sync via detector output) - Add ScrollDepthMap type alias for getEngagement return type
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.
What
Four verified analytics defects fixed:
Consent leak — Vercel
track()fired unconditionally even after user declined. Now all three emitters (Vercel, PostHog, self-hosted) share onegetConsent() !== 'declined'gate.Dropped CTA labels —
usePageTrackingandTrackedButtonsentdata-track-label, butanalytics.tsforwarded onlypath/valueto self-hosted store. PlumbedlthroughPendingEvent→TrackedEvent→ ingest validation (capped 200 chars).Raw IP in logs — Ingest endpoint logged the raw proxied IP in 3 places while
tracking.tsclaimed "no IPs are stored". IP still used for rate-limit key; only log payloads changed.Collected-but-invisible data —
browsers,scroll_depthand quiz funnel were aggregated but never rendered. AddedgetEngagement()reading existing daily counters (zero new collection) plus three panels on/admin/analytics(browsers via reusedDevicePie, scroll/quiz via newFunnelChart).Why
How
src/lib/analytics.ts: consent gate + label forwardsrc/lib/tracking.ts:PendingEvent.lsrc/lib/tracking-store.ts:TrackedEvent.l,scroll:*mirror counters, exportedBROWSER_KEYS/SCROLL_THRESHOLDS, newgetEngagement()src/app/api/analytics/event/route.ts: validatel, remove IP from logssrc/components/admin/AdminCharts.tsx: newFunnelChartsrc/app/admin/analytics/page.tsx: three new panelsValidation
lintcleantypecheckclean737/737unit tests passnext buildclean