mirror of
https://github.com/supabase/supabase.git
synced 2026-12-03 23:18:57 +00:00
Every first-party PostHog event now carries a `platform` property naming
the supabase.com app that sent it. Each app passes its directory name
(`studio`, `www`, `docs`, `kb`, `learn`, `ui-library`) once at telemetry
setup, and I stamp it on both send paths.
**Changed:**
- **Events sent through the Management API**
(`/platform/telemetry/event`): `buildTelemetryEventRequest` adds
`platform` to `custom_properties`. This also covers kb's search events,
which build the request without `sendTelemetryEvent`.
- **Events sent by posthog-js** (pageviews, page leaves, identify,
experiment exposures): a `before_send` hook stamps `platform` at send
time.
- **App setup**: `PageTelemetry` takes a required `platform` prop, and
kb's island sets the value directly. While unset, the property is left
off instead of defaulting to an app.
**Note:** I used `before_send` instead of `posthog.register()`. Super
properties persist in localStorage, which every supabase.com app shares,
so events sent before `register()` runs would carry the previous app's
value.
**Do not merge yet.** Studio's `trackFeatureFlag` body still needs
`platform`. That commit waits for the Management API change that accepts
the field to reach production, plus an `api-types` regen. The flag-track
body is strict, so sending `platform` early returns 400 on every flag
call.
## To test
On each app's preview, accept cookies and add `?__posthog_debug=true` to
the URL.
- [x] Studio: load a page, expect `$pageview` with `properties.platform:
"studio"` (seen at ingestion: the staging PostHog project has
`$pageview` and `$pageleave` events from the studio-staging preview
host, all with `platform: "studio"`)
- [x] www: load the homepage, expect `send "$pageview"` with `platform:
"www"`; click "Start your project", expect the
`/platform/telemetry/event` request body to have
`custom_properties.platform: "www"` (both seen)
- [x] docs: load a guide, expect `send "$pageview"` with `platform:
"docs"` (seen); added: "Copy as Markdown" sends `custom_properties:
{"pageType":"guide","platform":"docs"}`
- [x] kb: load a page, expect `send "$pageview"` with `platform: "kb"`;
run a search, expect the `/platform/telemetry/event` body to have
`custom_properties.platform: "kb"` (seen on both `kb_search_submitted`
and `kb_search_result_clicked`)
- [ ] learn and ui-library: load a page, expect `send "$pageview"` with
`platform: "learn"` and `"ui-library"` respectively. Not checkable on
previews: learn has no preview deployment, and the ui-library preview
host is not on the consent provider's allowlist, so telemetry never
starts there.
- [x] Added, negative check: on docs, kb and www, no captured posthog-js
event had `platform` unset or set to another app
- [x] Added, ingestion: in the staging PostHog project,
`copy_as_markdown_clicked` (docs) and `start_project_button_clicked`
(www) carry `platform` as a top-level event property
## Linear
- fixes GROWTH-1450