mirror of
https://github.com/supabase/supabase.git
synced 2026-12-05 07:59:03 +00:00
## Problem The KB has a consent banner but sends no pageviews. `PageTelemetry` imports Next modules, so it can't run in Astro. Part of [GROWTH-1352](https://linear.app/supabase/issue/GROWTH-1352/add-consent-posthog-tracking-to-new-kb-app). ## Solution - Moved `handlePageTelemetry`, `handlePageLeaveTelemetry` and their first-touch helper into `common/page-telemetry.ts`, with no Next imports. Other apps are unchanged. - Added `PageTelemetryIsland` to the KB layout. After consent it sends one `$pageview` per page load and `$pageleave` on `beforeunload`. First-touch UTMs and the `_sb_first_referrer` and mw-diag cookies go only on a tab's first pageview after consent (a `sessionStorage` flag) or on arrival from an external site. - Needs `NEXT_PUBLIC_POSTHOG_KEY` and `NEXT_PUBLIC_POSTHOG_HOST` (`https://ph.supabase.com`) on the KB Vercel project. Both are set on Preview and Production. ## Review instructions 1. Check the `telemetry.tsx` removals match `page-telemetry.ts`. 2. On a KB preview page, accept cookies and check the network tab for `$pageview`, then `$pageleave` after navigating. KB and studio telemetry tests pass. From the kb preview, PostHog prod received `$pageview` on `/kb`, `$pageleave` on `/kb`, then `$pageview` on `/kb/guides/migrate-from-neon`. ## Checklist - [x] I have read [CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md) - [ ] If I wrote a new docs topic or edited an existing topic, I used the `/write-the-docs` or `/edit-the-docs` skill, which applies the docs [style guide](https://github.com/supabase/supabase/tree/master/apps/docs/style-guide)