Skip to content

fix(cli): make the telemetry opt-out hold on every path - #7811

Draft
pamelachia wants to merge 6 commits into
developfrom
pamchia/growth-1573-cli-telemetry-opt-out
Draft

pamelachia wants to merge 6 commits into
developfrom
pamchia/growth-1573-cli-telemetry-opt-out

Conversation

@pamelachia

@pamelachia pamelachia commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

The three documented telemetry opt-outs (supabase telemetry disable, SUPABASE_TELEMETRY_DISABLED=1, DO_NOT_TRACK=1) stop events on the normal path, but five paths still sent or re-enabled after a user had opted out. I closed those paths, removed the user-chosen project name from the project group, and corrected the notice and docs.

Changed:

  • telemetry disable reported the opt-out, and could write it to the wrong place: consent is read before the handler writes the file, so the command sent its own cli_command_executed. It now sends nothing (this reverses fix(cli): telemetry enable/disable fire cli_command_executed on pre-toggle consent #5798 for disable only; the Go CLI behaviour it matched no longer exists). telemetry enable and disable also resolved SUPABASE_HOME from the shell alone while the CLI reads consent from the settings, so with SUPABASE_HOME in a project .env the opt-out landed in a directory nothing read. All state reads and writes now use the runtime's resolved directory.
  • A damaged or unreadable telemetry.json re-enabled telemetry: a file that could not be read or decoded counted as "no file", and the next write regenerated it as enabled. It now reads as an opt-out, and undecodable content is rewritten as one. Only a missing or empty file is a first run. A home directory that cannot be searched and a file with an empty device or session id read as an opt-out too. The per-command state writes used to overwrite the file in place, so a run killed mid-write left an empty file that read as a first run. They now go through a temporary file and a rename. The one-time write that stores the account id after the first authenticated response still writes in place.
  • Env opt-outs left state behind and telemetry status ignored them: every command wrote an enabled telemetry.json under DO_NOT_TRACK=1, which later suppressed the first-run notice. While opted out the CLI now updates an existing file but creates none, and status prints Telemetry is disabled (DO_NOT_TRACK=1).
  • The first interactive run sent before the user could react: the notice printed in the same invocation as the first event. That invocation now sends nothing, and sending starts with the next one. Non-interactive first runs are unchanged. The notice no longer says "anonymous", and project groups send the organization slug without the project name.

Note: several existing tests asserted the old behaviour as intended (regenerate a malformed file as enabled, disable emits its event, status creates the file or repairs a corrupted one). I changed those assertions on purpose, and I changed the e2e status tests to run without the harness's env opt-out so they read the file's consent. Two measurement effects for opted-in users follow from the first-run change: is_first_run = true no longer appears together with is_tty = true, and a first interactive supabase login persists the account id without sending the alias, which loses nothing because that device has no earlier events to merge.

Linear

  • part of GROWTH-1573

@pamelachia pamelachia self-assigned this Nov 25, 2026
@pamelachia

pamelachia commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor Author

Manual verification on a build of this branch (re-run at a4a068a4a), with a throwaway HOME and SUPABASE_HOME and SUPABASE_TELEMETRY_POSTHOG_HOST pointed at a local listener that counts requests:

  • Run DO_NOT_TRACK=1 supabase --version, then SUPABASE_TELEMETRY_DISABLED=1 supabase --version: 0 requests each.
  • Fresh home, no terminal, run supabase telemetry status: 1 request, prints Telemetry is enabled. Then supabase telemetry disable: 0 requests. Then supabase telemetry status: 0 requests, prints Telemetry is disabled.
  • Write a telemetry.json with "enabled": false and "session_last_active": "not-a-time", run supabase projects list, then supabase telemetry status: 0 requests for both, status prints Telemetry is disabled.
  • Write a valid opted-out telemetry.json, chmod 000 it, run supabase telemetry status, then supabase projects list: 0 requests for both, status prints Telemetry is disabled., and the file keeps its mode and content.
  • In a project whose supabase/.env sets SUPABASE_HOME to another directory, run supabase telemetry disable, then supabase telemetry status: 0 requests, prints Telemetry is disabled., and the opt-out file is in the .env directory. Before the second commit the same steps printed Telemetry is enabled. and sent 1 request.
  • Fresh home, run DO_NOT_TRACK=1 supabase telemetry status: prints Telemetry is disabled (DO_NOT_TRACK=1). and creates no telemetry.json. Still no file after DO_NOT_TRACK=1 supabase projects list.
  • Run DO_NOT_TRACK=1 supabase __complete tel: 0 requests.
  • Fresh home in a pseudo-terminal, run supabase telemetry status: the notice prints, 0 requests. Run it again: 1 request, with is_first_run: false.
  • Not run against the listener: the login alias and supabase link under an opt-out, since both need a Management API. They pass through the same consent gate, and the link, bootstrap and linked-project cache integration tests assert the project group no longer carries the project name.

@pamelachia
pamelachia marked this pull request as ready for review November 25, 2026 15:19
@pamelachia
pamelachia requested a review from a team as a code owner November 25, 2026 15:19
@github-actions

Copy link
Copy Markdown
Contributor

CLI benchmark (Lightweight Commands): no changes found

Commit a4a068a against develop at 7b14224 · 10 runs each · report only, never blocks merging

Command Workload Before After Change
supabase --version version 278 ms 257 ms no real change (-7%, within normal variation)
supabase --help help 269 ms 247 ms no real change (-8%, within normal variation)
supabase init init 222 ms 209 ms no real change (-6%, within normal variation)
supabase migration new bench migration-new 231 ms 255 ms no real change (+11%, within normal variation)
supabase config convert config-convert 189 ms 199 ms no real change (+5%, within normal variation)
supabase config validate config-validate 222 ms 220 ms no real change
supabase gen types --lang typescript --project-id replayfixtureprojref gen-types 236 ms 241 ms no real change
supabase projects list projects-list 256 ms 268 ms no real change
supabase functions list --project-ref replayfixtureprojref functions-list 416 ms 454 ms no real change (+9%, within normal variation)

API calls: unchanged for all 9 commands.

Binary size: 135.7 MB, up 4.0 KB from 135.7 MB.

Details: timing ranges, API calls per command, slowest phases

Timing ranges

Command Workload Before range After range Change Verdict
supabase --version version 234-371 ms 238-327 ms -20 ms (-7%) within noise
supabase --help help 239-310 ms 223-325 ms -22 ms (-8%) within noise
supabase init init 195-299 ms 199-243 ms -14 ms (-6%) within noise
supabase migration new bench migration-new 200-389 ms 210-496 ms +24 ms (+11%) within noise
supabase config convert config-convert 175-252 ms 174-223 ms +10 ms (+5%) within noise
supabase config validate config-validate 191-301 ms 191-273 ms -3 ms (-1%) within noise
supabase gen types --lang typescript --project-id replayfixtureprojref gen-types 227-258 ms 212-324 ms +5 ms (+2%) within noise
supabase projects list projects-list 230-315 ms 231-410 ms +12 ms (+5%) within noise
supabase functions list --project-ref replayfixtureprojref functions-list 320-571 ms 347-528 ms +38 ms (+9%) within noise

API calls per command

Command Workload Before After Endpoint changes
supabase --version version 0 0
supabase --help help 0 0
supabase init init 0 0
supabase migration new bench migration-new 0 0
supabase config convert config-convert 0 0
supabase config validate config-validate 0 0
supabase gen types --lang typescript --project-id replayfixtureprojref gen-types 2 2
supabase projects list projects-list 1 1
supabase functions list --project-ref replayfixtureprojref functions-list 2 2

Slowest phases

No command moved beyond noise, so there are no phase deltas.

Workflow run

Comment /bench to run the lightweight benchmark (this comment) again on the latest commit, or /bench full to also run the integration-heavy benchmark, which posts in its own comment.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 AI Review

CLI reference prose guidance: snapshot supabase/supabase@6a305cd supplied to reviewers (advisory, not a style pass).

The PR closes several telemetry opt-out gaps, but an existence-check failure can still let a run send with a saved opt-out, and an interrupted state write can erase that opt-out. The consent reader and state writer also disagree on which files are valid. Two regression tests can pass without proving the intended behavior, two code comments are stale, and first-run suppression makes the config conversion reference inaccurate. The reference guidance snapshot was available, and the diff contains no changed CLI reference prose. Findings were verified by reading the code. The CLI test suite was not run because dependencies were absent.

Findings

Severity Location Category Sources Claim
🟠 MAJOR apps/cli/src/shared/telemetry/consent.ts:94 privacy codex A transient failure in the existence check can let the CLI send telemetry even when a subsequent read finds a saved opt-out.
🟠 MAJOR apps/cli/src/shared/telemetry/consent.ts:97 privacy codex A state file with granted consent and an empty device ID can let the current command send telemetry, then be rewritten as opted out for later commands.
🟠 MAJOR apps/cli/src/telemetry/telemetry-state.layer.ts:465 persistence codex An interrupted identity update can erase a saved opt-out and cause a later non-interactive invocation to send telemetry.
🟡 MINOR apps/cli/src/commands/telemetry/telemetry.integration.test.ts:290 test-coverage codex The home-resolution regression test passes if both disable and status use the wrong home.
🟡 MINOR apps/cli/src/telemetry/telemetry-state.layer.unit.test.ts:232 test-coverage codex The malformed-file login test can pass without exercising the rewrite that must preserve the opt-out.
🟡 MINOR apps/cli/docs/supabase/config/convert.md:29 docs-drift codex The config conversion reference promises that the optional reason is recorded with command telemetry, but the first interactive conversion can still ask for a reason and then discard it.
⚪ NIT apps/cli/src/telemetry/telemetry-state.layer.ts:489 documentation claude The layer comment still says every command writes state and fresh state is always enabled.
⚪ NIT apps/cli/src/telemetry/telemetry-state.service.ts:10 documentation claude The stitchLogin contract says distinct_id is always written, although the service can stamp it only in memory.

Findings outside the diff

  • 🟡 MINOR apps/cli/docs/supabase/config/convert.md:29 — The config conversion reference promises that the optional reason is recorded with command telemetry, but the first interactive conversion can still ask for a reason and then discard it.
  • ⚪ NIT apps/cli/src/telemetry/telemetry-state.service.ts:10 — The stitchLogin contract says distinct_id is always written, although the service can stamp it only in memory.

Stats

Claude findings: 2 · Codex findings: 5 · Confirmed: 8 · Refuted: 0 · Uncertain: 0


Models: claude-opus-5-5 + gpt-6.2-sol · Trigger: auto · Workflow run

This review runs once per PR. A maintainer can request another with a /ai-review comment.

@pamelachia

Copy link
Copy Markdown
Contributor Author

On the two AI review findings outside the diff, and the failed e2e shard:

  • telemetry-state.service.ts:10: fixed in f716657. The stitchLogin doc now says the id is stamped in memory, written to telemetry.json in persistent runtimes, and written only to an existing file while the user is opted out.
  • docs/supabase/config/convert.md:29: declining. This needs the first ever invocation on a device to be an interactive config convert --to toml, and that invocation is the one that shows the telemetry notice. Not worth a second copy of the first-run predicate.
  • cli-e2e 1/2: fixed in a3661c5. The harness sets SUPABASE_TELEMETRY_DISABLED=1 on every run, which telemetry status now reports ahead of the file's state, so I changed the status tests to run without it. I also dropped the assertion that status repairs a corrupted file, because status only reads now.

@pamelachia
pamelachia marked this pull request as draft November 25, 2026 17:15

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant