Log CLI Tracks events in the terminal during npm start - #4396
Merged
Conversation
CLI-emitted events like studio_site_start printed nothing in a plain dev run, unlike the desktop's studio_app_launch. Treat NODE_ENV=development as an escape hatch in the CLI tracks wrapper so events reach the shared core, which logs 'Would have recorded...' and no-ops the network in dev. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Collaborator
📊 Performance Test ResultsComparing b99a24b vs trunk app-size
site-editor
site-startup
Results are median values from multiple test runs. Legend: 🟢 Improvement (faster) | 🔴 Regression (slower) | ⚪ No change (<50ms diff) |
sejas
approved these changes
Jul 31, 2026
| const telemetryAllowed = | ||
| __ENABLE_CLI_TELEMETRY__ || | ||
| process.env.STUDIO_FORCE_CLI_TELEMETRY || | ||
| process.env.NODE_ENV === 'development'; |
Member
There was a problem hiding this comment.
Should we just set STUDIO_FORCE_CLI_TELEMETRY to true in vite.config.dev.ts?
studio/apps/cli/vite.config.dev.ts
Line 17 in b99a24b
Contributor
Author
There was a problem hiding this comment.
If we set it in vite.config.dev.ts, it would be included in the dev builds, which are used during E2E, but it wouldn't change anything when we run the app in dev mode locally.
__ENABLE_CLI_TELEMETRY__enables telemetry for all users on production build and npm release (but no for dev builds)STUDIO_FORCE_CLI_TELEMETRYallows testing telemetry for built dev buildsNODE_ENVhandles app running in dev mode.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Related issues
How AI was used in this PR
Claude Code investigated why CLI Tracks events were invisible in dev, proposed and implemented the fix, added tests, and updated the design doc. I reviewed the reasoning — in particular confirming the new
NODE_ENV === 'development'condition is a strict subset of the shared core's dev/E2E no-op, so it cannot cause a real pixel to fire in any shipped or CI build.Proposed Changes
When running Studio locally with
npm start, the desktop Main process already logs aWould have recorded Tracks event: studio_app_launch { … }line for each event — useful when debugging analytics or reviewing a Tracks PR. CLI-emitted events (notablystudio_site_start) printed nothing in a plain dev run, so there was no parity: you couldn't see a CLI event fire without a manual multi-env-var incantation.This makes CLI Tracks events log the same
Would have recorded…line automatically duringnpm start, matching the desktop behavior with no extra setup. The CLI wrapper now treatsNODE_ENV === 'development'(inherited by the forked CLI child from the desktop) as an escape hatch, letting the call reach the shared core — which logs the line and no-ops the network in dev.This is a debug-visibility change only. The shared core remains the single guardian that no real pixel fires in dev/E2E, and the new condition is a strict subset of that no-op condition, so it cannot leak analytics. The build-time
__ENABLE_CLI_TELEMETRY__gate still fully protects standalone dev CLI builds and all shipped/CI builds (verified nothing outside test files setsNODE_ENV=development). It also fixes a small asymmetry: the desktop already fell through to the shared core in dev while the CLI's stricter gate did not.Testing Instructions
Automated:
npm test -- apps/cli/lib/tests/tracks.test.ts— includes new cases for the dev pass-through and that opt-out still wins in dev.npm run typecheckEnd-to-end (manual):
npm run cli:buildnpm startnpm startterminal. You should see, alongside the existingstudio_app_launchline:Confirmed working locally. No real network request is made (shared core no-ops in dev).
Pre-merge Checklist