diff --git a/.agents/skills/telemetry-standards/SKILL.md b/.agents/skills/telemetry-standards/SKILL.md index d79530bb533..19c9314a8e2 100644 --- a/.agents/skills/telemetry-standards/SKILL.md +++ b/.agents/skills/telemetry-standards/SKILL.md @@ -3,8 +3,8 @@ name: telemetry-standards description: PostHog event tracking standards for Supabase Studio. Use when adding useTrack() calls, defining events in packages/common/telemetry-constants.ts, implementing tracking for a new feature, or reviewing PRs for telemetry compliance. - Covers event naming, property conventions, approved patterns, and implementation - guide. + Covers event naming, property conventions, privacy rules for event properties, + URL state and consent, approved patterns, and implementation guide. --- # Telemetry Standards for Supabase Studio @@ -41,7 +41,7 @@ enabled, disabled, copied, exposed, failed, converted, closed, completed, applie ## Property Standards -**Casing:** camelCase preferred for new events. The codebase has existing snake_case properties (e.g., `schema_name`, `table_name`) — when adding properties to an existing event, match its established convention. +**Casing:** camelCase preferred for new events. The codebase has existing snake_case properties (e.g., `schema_name`, `table_name`) — when adding properties to an existing event, match its established casing. Match casing only: don't copy these properties into new events, because they carry user-defined names (see [Privacy](#privacy-user-defined-names-and-identifiers)). **Names must be self-explanatory:** @@ -65,8 +65,66 @@ enabled, disabled, copied, exposed, failed, converted, closed, completed, applie **Exception:** `_exposed` events for A/B experiment exposure tracking are valid even though they fire on render. +## Privacy: User-Defined Names and Identifiers + **Never track PII** (emails, names, IPs, etc.) in event properties. +Event properties must also never contain anything a user chose or typed for their own project. These are customer data even though they are not PII, and sending them is outside our privacy policy. Mask or omit: + +- Schema, table, column, function, bucket, policy, project and branch names +- Any other user-defined name or label (index, trigger, role, extension setting, edge function, secret key, and so on) +- SQL text, filters, search terms, file or object paths, and other free-text input +- Row, object or record IDs, and any ID or ref not already attached by `useTrack` +- Raw error messages or stack traces, which often quote schema, table or column names. Send an error code or category instead + +`useTrack` attaches `groups.project` (project ref) and `groups.organization` (org slug) whenever a project or org is selected. Don't add these, or other IDs, as properties. To attribute an event to a different project or org (one that was just created, for example), pass it as the third argument to `track()`. + +**Send a count, enum, boolean or action category instead of the raw value.** Type new properties as string-literal unions or `boolean`/`number` rather than plain `string`, so a raw name is harder to pass by accident. Feature flag values are a separate case and follow the feature flag section below. + +```typescript +// Don't (illustrative): raw names identify the customer's data model +track('table_copied', { schemaName: 'billing_internal', tableName: 'invoices' }) + +// Do (illustrative): categories, counts and booleans carry the same product insight +track('database_schema_visualizer_copied', { content: 'table_sql' }) +track('database_schema_selector_updated', { schemaType: 'custom' }) // 'public' | 'protected' | 'custom' +track('policy_created', { operation: 'select', hasCheckExpression: true }) +``` + +If you need to tell values apart, derive a category (`public` / `protected` / `custom`), a count (`tableCount`), or a boolean (`isDefaultSchema`). If a raw name seems essential, stop and ask before adding it. + +This section takes precedence over "match similar events" guidance elsewhere in this skill: if a similar event carries a user-defined name, don't copy that property. + +`data-attr` attributes are not tracked while PostHog autocapture is off (`autocapture: false` in `packages/common/posthog-client.ts`). Keep their values static strings, and never build them from user-defined names, in case autocapture is enabled later. + +## Privacy: Secrets, Project Content and URL State + +Telemetry only runs for visitors who accepted analytics. Consent does not make it acceptable to collect secrets or the data customers keep in their projects. + +**Also never send, in any property:** + +- Secrets: API keys, JWTs, access or refresh tokens, passwords, connection strings, invite or OAuth codes. Pasted input often contains them +- Content read from a project: row values, log lines, query results, AI responses +- Ids of a customer's end users, and phone numbers + +**Helpers that send the shape instead of the text:** + +- Search input: `describeSearchQuery` in `packages/common/search-query-telemetry.ts` +- Errors: `useTrackFunnelError` in `apps/studio/lib/telemetry/use-track-funnel-error.ts`, which only accepts a classified reason from `funnel-errors.ts` + +**The page URL goes out with every event.** Pageviews and custom events carry the current URL and the referrer automatically, so URL state is telemetry: + +- Do not put tokens, user input or row values in the query string or hash of a route +- If a feature needs URL state like that, redact it in `packages/common/telemetry-utils.ts` in the same PR and add a test + +## Consent and Transport + +- Send events only through `useTrack` (Studio) or the app's `useSendTelemetryEvent`, and pageviews through `PageTelemetry`. They check consent. Never import `posthog-js` outside `packages/common/posthog-client.ts` or post to an analytics endpoint directly +- Always pass the real consent state to `posthogClient` methods. Never rely on a parameter default +- Do not write analytics cookies or storage (ids, attribution, experiment assignment) before the visitor accepts. Anything stored after consent must be cleared in `revokeTrackingConsent` (`packages/common/consent-state.ts`) when consent is withdrawn +- A new third-party script, pixel or embed that receives visitor data needs a consent gate and a Legal review before it merges. Ask @supabase/growth-eng to route it +- Nothing may be sent when `IS_PLATFORM` is false. Self-hosted Studio sends no telemetry + ## Required Pattern Import `useTrack` from `@/lib/telemetry/track` (within `apps/studio/`). @@ -128,7 +186,7 @@ export interface MyFeatureClickedEvent { action: 'my_feature_clicked' properties: { /** Description of property */ - featureType: string + featureType: 'basic' | 'advanced' } groups: TelemetryGroups } @@ -146,6 +204,8 @@ When reviewing a PR, flag these as **required changes:** 3. **Unnecessary view tracking** — events that fire on page load without user interaction 4. **Inaccurate docs** — `@source`/`@page` descriptions that don't match the actual implementation 5. **Unmeasured feature flags** — a PostHog flag gates new behavior but its value is not captured in any `track()` call, or there is no outcome tracking for the gated behavior +6. **User-defined names or identifiers in properties** — schema, table, column, function, bucket, policy, project or branch names, SQL or other free text, raw error messages, or extra IDs sent as property values, or a new property typed as plain `string` that could hold one (feature flag values excepted). Required even when the value looks harmless; ask for a count, enum, boolean or category instead +7. **Secrets, project content, URL state or consent** — a property that can carry a secret or content read from a project; new query-string or hash state holding tokens, user input or row values with no redaction; a send path that bypasses the consent check; analytics storage written before consent When a PR adds user-facing interactions (buttons, forms, toggles, modals) **without** tracking, suggest: @@ -199,4 +259,8 @@ To add tracking for a user action: - [ ] Using the `useTrack` hook - [ ] Not tracking passive views/appearances - [ ] No PII in event properties (emails, names, IPs, etc.) +- [ ] No user-defined names or identifiers in properties (schema, table, column, function, bucket, policy, project, branch), and no free text, raw error messages or extra IDs +- [ ] New properties are typed as string-literal unions, booleans or numbers, not plain `string` (feature flag values excepted) +- [ ] No secrets or content read from a project in any property +- [ ] No new query-string or hash state that holds tokens, user input or row values - [ ] Property names consistent with similar events diff --git a/.agents/skills/test-the-docs/sandbox/Dockerfile b/.agents/skills/test-the-docs/sandbox/Dockerfile index e08243d4848..827c69f862b 100644 --- a/.agents/skills/test-the-docs/sandbox/Dockerfile +++ b/.agents/skills/test-the-docs/sandbox/Dockerfile @@ -1,5 +1,5 @@ # Runner for /test-the-docs: executes MDX fences inside the container. -FROM node:24-bookworm-slim +FROM node:26-bookworm-slim ARG TARGETARCH ARG SUPABASE_CLI_VERSION=2.39.2 diff --git a/.nvmrc b/.nvmrc index 229b3ce85a6..a2e8115a72f 100644 --- a/.nvmrc +++ b/.nvmrc @@ -1 +1 @@ -24.22.3 +26.13.1 diff --git a/AGENTS.md b/AGENTS.md index cb955cc3d75..4759cdc105d 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -1,6 +1,6 @@ # Supabase Monorepo -pnpm 11 + Turborepo monorepo. Requires Node 24 (see `.nvmrc`). +pnpm 12 + Turborepo monorepo. Requires Node 26 (see `.nvmrc`). ## Structure diff --git a/apps/design-system/app/Providers.tsx b/apps/design-system/app/Providers.tsx index 46dce708544..dd91920c974 100644 --- a/apps/design-system/app/Providers.tsx +++ b/apps/design-system/app/Providers.tsx @@ -1,19 +1,39 @@ 'use client' -import { ThemeProvider } from 'common' +import { FrameworkProvider, ThemeProvider, type FrameworkContextValue } from 'common' import { Provider as JotaiProvider } from 'jotai' +import NextImage from 'next/image' +import NextLink from 'next/link' +import { usePathname, useRouter } from 'next/navigation' +import { useMemo } from 'react' import { TooltipProvider } from 'ui' import { MobileSidebarProvider } from '@/context/mobile-sidebar-context' export function Providers({ children }: { children: React.ReactNode }) { + const pathname = usePathname() + const router = useRouter() + + const framework = useMemo( + () => ({ + Link: NextLink, + Image: NextImage, + pathname, + asPath: pathname, + push: (path) => router.push(path), + }), + [pathname, router] + ) + return ( - - - - {children} - - - + + + + + {children} + + + + ) } diff --git a/apps/docs/app/api/crawlers/route.test.ts b/apps/docs/app/api/crawlers/route.test.ts index d25fd4b3551..f7b1bdcea67 100644 --- a/apps/docs/app/api/crawlers/route.test.ts +++ b/apps/docs/app/api/crawlers/route.test.ts @@ -1,3 +1,4 @@ +import { LLMS_TXT_URL } from 'common/markdown-affordance' import { beforeEach, describe, expect, it, vi } from 'vitest' const reference = vi.hoisted(() => ({ @@ -36,6 +37,15 @@ beforeEach(() => { reference.sections = [] }) +describe('crawler reference html', () => { + it('points agents at llms.txt before the navigation', async () => { + reference.sections = [section('introduction', 'Introduction')] + const page = await html('/reference/javascript/introduction') + expect(page).toContain(`href="${LLMS_TXT_URL}"`) + expect(page.indexOf(LLMS_TXT_URL)).toBeLessThan(page.indexOf('