mirror of
https://github.com/supabase/supabase.git
synced 2026-12-04 15:39:13 +00:00
create-pull-request/patch
9
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
3f005ed135 | fix(telemetry): restore www click tracking, remove dead Studio events (#54588) | ||
|
|
6bd006dc08 |
feat(docs): layout toggle (#53688)
## Problem - docs layout v2 (variant `option-1` of the `docs-ia-mvp-v1` flag) is about to roll out and a reader in the rollout has no way back to the classic layout ## Solution - adds a toggle button bottom of the guide right column so user in the rollout can switch back - adds a dialog that asks for an optional reason when a reader switches back to classic, and stores the reason in `feedback_comments` with `metadata.source = 'docs_layout_switch'` so we relying on existing - adds the `docs_layout_updated` event and stops new experiment exposures for readers who picked a layout | toggle | survey | | -------|------| | <img width="654" height="312" alt="image" src="https://github.com/user-attachments/assets/69bcd4b8-7dd2-4fd3-9045-e3246625ccf9" /> | <img width="654" height="312" alt="image" src="https://github.com/user-attachments/assets/4b18eb76-b9f1-4d96-be25-14a960b11475" /> | <!-- ## Preview links If relevant, include links to changed pages for easy review access. Copy the preview base URL from the Vercel bot comment on this PR. Use the following table as an example template. | Site | Live | Preview | Search for | | -------------- | ------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------ | ----------------------------- | | WWW | [/blog/your-post](https://supabase.com/blog/your-post) | [/blog/your-post](https://zone-www-dot-com-git-branch-name-supabase.vercel.app/blog/your-post) | unique phrase from the change | | Docs | [/docs/guides/your-page](https://supabase.com/docs/guides/your-page) | [/docs/guides/your-page](https://docs-git-branch-name-supabase.vercel.app/docs/guides/your-page) | unique phrase from the change | | Studio | [/dashboard](https://supabase.com/dashboard) | [/dashboard](https://studio-git-branch-name-supabase.vercel.app/dashboard) | unique phrase from the change | | Design system | [/design-system](https://supabase.com/design-system) | [/design-system](https://design-system-git-branch-name-supabase.vercel.app/design-system) | unique phrase from the change | | UI library | [/library](https://supabase.com/library) | [/library](https://ui-library-git-branch-name-supabase.vercel.app/library) | unique phrase from the change | | Knowledge base | [/kb/guides/your-page](https://supabase.com/kb/guides/your-page) | [/kb/guides/your-page](https://kb-git-branch-name-supabase.vercel.app/kb/guides/your-page) | unique phrase from the change | --> <!-- ## Additional context Optionally add any other context or screenshots. --> ## Review instructions 1. open [/docs/guides/database/prisma?docs-ia-mvp-v1=option-1](https://docs-git-antlio-feat-docs-layout-switch-v2-supabase.vercel.app/docs/guides/database/prisma?docs-ia-mvp-v1=option-1) 2. click "Switch to classic layout" in the notice and make sure that a dialog asks "What made you switch back?" ## Checklist Check all before review: - [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) |
||
|
|
62d6bf56f8 |
fix(telemetry): send the live posthog session id on custom events (#53504)
Custom events sent through the telemetry endpoint often carry a session id the browser's PostHog session has already left: 8.9% of server-captured events in a recent week had an id more than 24 hours old, against 0.046% of browser-captured ones. Two things on the client cause it. The `session_id` in the request body is parsed out of the PostHog cookie without going through posthog-js, so a custom event never rotates an expired session. And the `session_id` cookie, which the API reads for the events it emits itself, was written on each pageview before posthog-js rotated the session, so the first pageview after an idle period stored the previous session's id. **Changed:** - **Custom events carry the live session id**: I changed `buildTelemetryEventRequest` to ask posthog-js for the session id the way a captured event does, so an expired session rotates first. Until posthog-js has loaded it sends the cookie-parsed id, as before. - **The `session_id` cookie follows the session**: I moved the write from the pageview handler to posthog-js's session-change callback, plus one write when posthog-js loads, so the cookie changes when the session does. - **The cookie stays cleared after an opt-out**: when a visitor withdraws consent, posthog-js resets the session, and the new id would have been written back over the cleared cookie. I skip the write once the visitor has opted out, in this tab or another. Unit tests cover this one: preview builds accept consent by default, so withdrawal can't be exercised there. - **Session metrics will step**: custom events now count as session activity. A long-lived tab that sends events without navigating stays in one session, so expect fewer, longer sessions from the day this reaches each app. **Note:** The API starts reading the body's `session_id` in a companion change on its side. Either can deploy first: the field is already sent today and ignored. ## To test Tested on the PR preview: - [x] In Studio with the Network tab open, open the user dropdown in the header. Expect the `telemetry/event` request body's `session_id` to equal the `session_id` cookie. - [x] Open the dropdown again right away. Expect the same `session_id` as in the first request. - [x] Leave that tab untouched for 35 minutes, then open the user dropdown again without navigating. Expect a different `session_id` in the request body than in the first step, and the `session_id` cookie to equal the new one. Observed after 38 idle minutes. - [x] Navigate to another Studio page. Expect the `session_id` cookie to keep the value from the previous step. Observed on an in-app navigation to the account page. ## Linear - fixes GROWTH-1509 |
||
|
|
8c2d8d51ac |
feat(telemetry): stamp PostHog flags on tracked events (#53588)
Events sent through `sendTelemetryEvent` now include the app's loaded
PostHog flags as `$feature/<key>` properties, as `$pageview` already
does. The backend already adds these keys by evaluating flags remotely
for each event. The browser's values now take precedence over that
evaluation, so a follow-up can turn the per-event lookup off without
losing flag properties on events.
**Changed:**
- **Browser flag values on every tracked event**: `FeatureFlagProvider`
passes its PostHog flag map to the event builder each time flags load,
and the builder adds one `$feature/<key>` property per flag. A property
the caller sends under the same key wins.
- **Value source**: `$feature/*` on an event is now the value the app
rendered with. It follows the flag store, so for a moment after sign-in,
sign-out or an org or project switch it holds the previous values until
the refetch lands. The backend-computed `$active_feature_flags` is
unchanged and can differ from it in that window.
- **Logged-out docs, learn and ui-library events**: `$feature/*` now
holds the flag value the page was served. Until now the backend
evaluated it per visitor, so trends on those properties shift on each
app's deploy date.
- **Apps without PostHog flags**: www (`ph: false`) and kb (no provider)
keep an empty map, so their events get no new properties.
**Note:** I set the flags in the provider right before its state update
because an exposure event fired from a child effect, on the render where
its flag first resolves, must already see them. An effect in the
provider would run after that child effect. Events sent before the first
flag load still go out without browser flag values.
## To test
Tested on the PR preview:
- [x] Sign in to Studio and open the new project form. In the network
panel, find the `POST /platform/telemetry/event` request with action
`project_creation_default_privileges_exposed`: expect
`custom_properties` to include `$feature/dataApiRevokeOnCreateDefault`,
equal to `dataApiRevokeOnCreateDefaultEnabled`. Observed: both `false`,
response 201.
- [x] In Studio, after `GET /platform/telemetry/feature-flags` returns,
trigger any tracked event: expect its `custom_properties` to hold one
`$feature/<key>` entry per key in that response, with the same values.
Observed on `command_menu_opened` and the exposure event: every key in
the flags response present with the same value, no extra keys.
- [x] On the docs preview, trigger a tracked event after the flags
request returns: expect `$feature/<key>` entries matching the docs flags
response. Observed on `docs_search_v2_opened`: all keys match the
logged-out flags response.
- [x] On the www preview, trigger a tracked event: expect no
`$feature/*` keys in `custom_properties`. Observed on
`start_project_button_clicked`: `custom_properties` is
`{"buttonLocation":"Header Nav","platform":"www"}`, and www made no
feature-flags request.
## Linear
- fixes GROWTH-1395
|
||
|
|
aad6ac1adc |
feat(docs): ai layout breadcrumbs page actions (#52974)
Closes DOCS-1470 ## Problem - reference pages have no breadcrumbs, so a reader on `/reference/cli/supabase-init` sees no path back to the cli reference - a guide breadcrumb can repeat its parent, for example "Connecting to your database" twice under Database > Fundamentals - redesign needs page actions in the top bar to copy a page as markdown and to set up an agent ## Solution - adds reference breadcrumbs, so a reference page shows the reference home and its library - adds the current version to the library breadcrumb when the library has more than one version - removes a breadcrumb that repeats its parent with the same url and name - adds a copy page split button and a set up agent menu, with telemetry events for each action - changes `ui-patterns` to export `CrossfadeIcon`, so the copy button reuses its copied state animation #52972 must merge first, because the breadcrumbs skip the overview row that it adds <!-- ## Preview links If relevant, include links to changed pages for easy review access. Copy the preview base URL from the Vercel bot comment on this PR. Use the following table as an example template. | Site | Live | Preview | Search for | | -------------- | ------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------ | ----------------------------- | | WWW | [/blog/your-post](https://supabase.com/blog/your-post) | [/blog/your-post](https://zone-www-dot-com-git-branch-name-supabase.vercel.app/blog/your-post) | unique phrase from the change | | Docs | [/docs/guides/your-page](https://supabase.com/docs/guides/your-page) | [/docs/guides/your-page](https://docs-git-branch-name-supabase.vercel.app/docs/guides/your-page) | unique phrase from the change | | Studio | [/dashboard](https://supabase.com/dashboard) | [/dashboard](https://studio-git-branch-name-supabase.vercel.app/dashboard) | unique phrase from the change | | Design system | [/design-system](https://supabase.com/design-system) | [/design-system](https://design-system-git-branch-name-supabase.vercel.app/design-system) | unique phrase from the change | | UI library | [/library](https://supabase.com/library) | [/library](https://ui-library-git-branch-name-supabase.vercel.app/library) | unique phrase from the change | | Knowledge base | [/kb/guides/your-page](https://supabase.com/kb/guides/your-page) | [/kb/guides/your-page](https://kb-git-branch-name-supabase.vercel.app/kb/guides/your-page) | unique phrase from the change | --> <!-- ## Additional context Optionally add any other context or screenshots. --> ## Review instructions 1. run `pnpm --filter docs exec vitest run lib/breadcrumbs.test.ts`, and make sure that all tests pass 2. read the new telemetry events in `packages/common/telemetry-constants.ts`, and make sure that each event names what the user did 3. the top bar shows the page actions in the next pr, so check them on the preview of that pr ## Checklist Check all before review: - [ 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) |
||
|
|
a73c5086fd |
feat(kb): send search opened and closed events (#53188)
## Problem kb search sends no event when the dialog opens or closes, so search usage has no denominator. Docs sends `docs_search_v2_opened` and `docs_search_v2_closed`. Resolves GROWTH-1474. ## Solution - adds `kb_search_opened` (`triggerType`: `keyboard_shortcut`, `search_input`) and `kb_search_closed` (`closeReason`: `dismissed`, `result_navigated`), the docs values kb can produce - `KbSearch` fires each event only on a real open or close, so Cmd+K toggling or a second open can't double-send - Enter on a result now closes the dialog before navigating, like a click does - `kb_search_closed` sends with `keepalive`, since a result click leaves the page ## Review instructions 1. `pnpm --filter kb test` 2. `NEXT_PUBLIC_IS_PLATFORM=true pnpm --filter kb dev`, accept cookies, filter network by `telemetry/event` 3. open search with the header button, press Escape, then Cmd+K twice: one opened and one closed per cycle Tested: kb and `common` tests pass, `common` typecheck passes. On `astro dev` with consent set, each open and close sent one event. Result-click close is unit-tested only (no local search API). ## 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) |
||
|
|
c62f07f940 |
fix(kb): ai tools events (#53180)
## Problem - kb guide sidebar shows the AI tools block from docs, with the same shared `AiTools` component - docs sends `agent_setup_clicked`, `copy_as_markdown_clicked` and `ask_ai_clicked` from that block, but kb sends no event for any click ## Solution - adds the docs events to the kb AI tools block, so a kb click sends the same event as a docs click - adds `kb` to the `pageType` values, because the kb sidebar also shows on troubleshooting pages, so `guide` is not correct - changes `agent_setup_clicked` to send with `keepalive`, because the connect link opens a page in the same tab and the browser can cancel the request - moves the kb telemetry sender to one module, so kb search and the sidebar use the same platform and consent checks - adds a test that clicks each AI tools item and checks the event that kb sends <!-- ## Preview links If relevant, include links to changed pages for easy review access. Copy the preview base URL from the Vercel bot comment on this PR. Use the following table as an example template. | Site | Live | Preview | Search for | | -------------- | ------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------ | ----------------------------- | | WWW | [/blog/your-post](https://supabase.com/blog/your-post) | [/blog/your-post](https://zone-www-dot-com-git-branch-name-supabase.vercel.app/blog/your-post) | unique phrase from the change | | Docs | [/docs/guides/your-page](https://supabase.com/docs/guides/your-page) | [/docs/guides/your-page](https://docs-git-branch-name-supabase.vercel.app/docs/guides/your-page) | unique phrase from the change | | Studio | [/dashboard](https://supabase.com/dashboard) | [/dashboard](https://studio-git-branch-name-supabase.vercel.app/dashboard) | unique phrase from the change | | Design system | [/design-system](https://supabase.com/design-system) | [/design-system](https://design-system-git-branch-name-supabase.vercel.app/design-system) | unique phrase from the change | | UI library | [/library](https://supabase.com/library) | [/library](https://ui-library-git-branch-name-supabase.vercel.app/library) | unique phrase from the change | | Knowledge base | [/kb/guides/your-page](https://supabase.com/kb/guides/your-page) | [/kb/guides/your-page](https://kb-git-branch-name-supabase.vercel.app/kb/guides/your-page) | unique phrase from the change | --> <!-- ## Additional context Optionally add any other context or screenshots. --> ## Review instructions 1. run `pnpm --filter kb test`, and make sure that `GuideSidebar.test.tsx` and `KbSearch.test.tsx` pass 2. open [/kb/guides/best-supabase-auth-providers](https://kb-git-antlio-fix-kb-ai-tools-event-supabase.vercel.app/kb/guides/best-supabase-auth-providers) and accept the cookie banner 3. open the browser network panel, turn on "Preserve log" and filter the requests by `telemetry/event` 4. click "Copy as Markdown", "Ask ChatGPT" and "Ask Claude" in the AI tools block 5. make sure that each click sends one request, and that `custom_properties` has `pageType: "kb"` and `platform: "kb"` 6. go back to the guide and click "Connect your AI agent" 7. make sure that the log shows one `agent_setup_clicked` request after the docs page opens 8. search for a term in the kb header, and make sure that `kb_search_submitted` still sends ## Checklist Check all before review: - [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) |
||
|
|
d862ac18f2 |
feat(telemetry): stamp the app's platform on every event (#53078)
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
|
||
|
|
5ac0a4843b |
feat(kb): send search and result click telemetry events (#52981)
## Problem KB search sends no events. Part of [DOCS-1514](https://linear.app/supabase/issue/DOCS-1514) (Add telemetry to search). ## Solution Two events through `/telemetry/event`, sent only on platform and after consent: - `kb_search_submitted`: `queryLength`, `resultCount`, `hasResults` - `kb_search_result_clicked`: `resultPath`, `resultPosition` (1-based), `resultCount`, sent with keepalive Query text isn't sent: it can contain personal data. New `buildTelemetryEventRequest` builds the body for `sendTelemetryEvent`. KB posts it with plain `fetch` and no auth header, so no GoTrue client starts on the shared dashboard session. ## Additional context Tested on `astro dev` with Playwright: - `rls`: `{queryLength: 3, resultCount: 10, hasResults: true}` - `zzqxjv`: `{queryLength: 6, resultCount: 0, hasResults: false}` - 2nd result clicked: `{resultPosition: 2, resultCount: 10}`, no `Authorization` header - No consent: nothing sent Also ran `common` and Studio typecheck, KB tests, and `astro build` (no GoTrue in the bundle). ## Review instructions 1. `pnpm --filter kb dev` on platform, accept cookies. 2. Search `rls`, click a result, and check both `/telemetry/event` requests. 3. Decline cookies and repeat: nothing sends. ## Checklist - [x] I have read [CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md) - [x] 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) --------- Co-authored-by: Kody Jackson <kody.jackson@supabase.io> |