Dev Toolbar Review dev-toolbar-review
Safety rules for the dev toolbar, PostHog client, and feature flags.
Use it when writing or reviewing any change to packages/dev-tools/, packages/common/posthog-client.ts, or packages/common/feature-flags.tsx. Covers environment guards, flag override cookies, telemetry event subscription, and SSE stream safety.
- Our test
- 8/10✓ Verified
- tested Dec 6, 2026
- GitHub stars
- 116k
- supabase/supabase
- Added by
- 0
- members
- Updated
- Dec 6
- commit 9140cc7
- Content
- 1 file
- no scripts · 6 KB
- License
- Apache 2.0
- free to use
What our test found
Le guide fournit une checklist ciblée et directement exploitable pour évaluer les changements de flags, notamment les protections d’environnement et les cas de revue manuelle.
Limits spotted
- The guide depends on internal details and specific paths that may become outdated.
- It describes the checks to perform, but does not specify how to concretely validate module elimination or production behavior.
name: dev-toolbar-review description: Safety rules for the dev toolbar, PostHog client, and feature flags. Use when writing or reviewing any change to packages/dev-tools/, packages/common/posthog-client.ts, or packages/common/feature-flags.tsx. Covers environment guards, flag override cookies, telemetry event subscription, and SSE stream safety.
Dev Toolbar Review Guide
Review checklist for PRs touching the dev toolbar (packages/dev-tools/) and its integration points in packages/common/. The toolbar surfaces telemetry events and allows feature flag overrides in local and staging environments only.
When This Applies
PRs modifying any of these paths need growth eng review:
packages/dev-tools/**(owned by@supabase/growth-engin CODEOWNERS)packages/common/posthog-client.ts(owned by@supabase/growth-engin CODEOWNERS; flag override reads, event subscription)packages/common/feature-flags.tsx(flag override merge logic)- App-level mounting:
DevToolbarProvider/DevToolbar/DevToolbarTriggerinapps/studio/,apps/www/,apps/docs/
Note: packages/common/feature-flags.tsx is NOT in CODEOWNERS for @supabase/growth-eng, so PRs touching only that file won't auto-request review. Watch for these in the PR feed.
Review Checklist
1. Environment Guards
Files: packages/dev-tools/index.ts, DevToolbar.tsx, DevToolbarTrigger.tsx, DevToolbarContext.tsx
The toolbar uses two layers of protection:
- Build-time tree-shaking in
index.ts: the bundler inlinesprocess.env.NEXT_PUBLIC_ENVIRONMENT, soisToolbarEnabled = env === 'local' || env === 'staging'makes the export ternaries static. Outside those two environments every export is a stub (DevToolbarandDevToolbarTriggerrendernull,DevToolbarProviderpasses children through,useDevToolbarreturns a no-op context) and the implementation modules are eliminated from the bundle. The same literalprocess.envcheck is duplicated inDevToolbarContext.tsx,DevToolbar.tsx,DevToolbarTrigger.tsx, andfeature-flags.tsxbecause the bundler must see it directly — keep them in sync. - Runtime guards inside the implementation:
IS_LOCAL_DEV = env === 'local'gates the local-only pieces — the SSE event stream inDevToolbarContext.tsxand local-only UI inDevToolbar.tsx— so staging gets the toolbar without them.
Check for:
- Guards being removed or broadened. The toolbar is enabled only for
localandstaging; preview and production builds must keep getting the stubs. - Tree-shaking ternaries in
index.tsstaying intact — these are the primary production safety mechanism. - New components or exports that bypass the existing guard pattern.
2. Flag Override Cookies
Files: packages/dev-tools/DevToolbar.tsx, packages/common/posthog-client.ts, packages/common/feature-flags.tsx
The toolbar writes two cookies that override feature flags locally:
x-ph-flag-overrides— PostHog flag overridesx-cc-flag-overrides— ConfigCat flag overrides
These are read by:
posthog-client.ts:getFeatureFlag()— checks the PostHog override cookie before querying the SDKfeature-flags.tsx— merges both override cookies into the flag store during initialization
Check for:
- Cookie name changes (must stay in sync across writer and all readers)
- Changes to the merge/precedence logic in
feature-flags.tsx(currently:vercel-flag-overridesfirst, thenx-cc-flag-overridestakes precedence whenisDevToolsEnabledis true inlocalorstaging) - Override cookies being read outside their environment guards (
isDevToolsEnabledinfeature-flags.tsxforlocal/staging;process.env.NODE_ENV === 'development'inposthog-client.ts:getFeatureFlag()) — overrides must never affect production flag evaluation - Changes to
parseOverrideValueorvaluesAreEqualinpackages/dev-tools/utils.tsthat could cause type coercion bugs
3. Telemetry Event Subscription
Files: packages/common/posthog-client.ts, packages/dev-tools/DevToolbarContext.tsx
The toolbar subscribes to client-side PostHog events via posthogClient.subscribeToEvents(). The PostHog client calls emitToDevListeners() after capturePageView, capturePageLeave, and identify. Note: captureExperimentExposure calls posthog.capture() directly without emitting to dev listeners — experiment exposure events are invisible in the toolbar.
Check for:
- Changes to
emitToDevListenersorsubscribeToEventsthat could introduce side effects on the actual capture path (e.g., throwing errors, blocking, mutating event data) - The listener set (
devListeners) being iterated synchronously in a way that could delay event dispatch - New PostHog client methods that capture events but don't call
emitToDevListeners(gap in toolbar visibility)
4. SSE Server Telemetry Stream
Files: packages/dev-tools/DevToolbarContext.tsx
The toolbar connects to ${apiUrl}/telemetry/stream via Server-Sent Events to display server-side telemetry. Uses exponential backoff on connection errors.
Check for:
- Changes to the SSE endpoint URL or
session_idcookie handling - Reconnection logic changes that could cause excessive retries or connection leaks
- Note: the stream endpoint lives in the platform repo — cross-repo changes need coordinated review
5. App-Level Mounting
Provider + toolbar panel (DevToolbarProvider, DevToolbar):
apps/studio/routes/__root.tsx(also mountsDevToolbarTrigger)apps/www/pages/_app.tsx,apps/www/app/providers.tsxapps/docs/features/app.providers.tsx
Trigger button (DevToolbarTrigger) — rendered separately in nav/header components for www and docs:
apps/www/components/Nav/index.tsxapps/docs/components/Navigation/NavigationMenu/TopNavBar.tsx
Check for:
- Provider being added or removed from an app
apiUrlprop changes (must point to the correct platform API)- Rendering order changes that could affect the toolbar's access to PostHog context
What Doesn't Need Growth Review
Changes that are purely UI/UX within the toolbar panel itself — styling, layout, copy changes, drag behavior, popover positioning — don't need growth eng review unless they also touch the integration points above.