From cdb4871836e6e97e0ce4fea1335d338c2007f79d Mon Sep 17 00:00:00 2001 From: brennanb2025 Date: Tue, 5 May 2026 21:36:08 -0700 Subject: [PATCH] chore(telemetry): silence dev-mode console mirror in track() Drop the `[telemetry] ` console.debug from the non-official-build short-circuit and the shutdown-gate branch in `track()`. Both were noise in `pnpm dev` (every emit printed to DevTools); transmit behavior in official stable/rc builds is unchanged. Updated the corresponding test to assert silent-drop. Co-authored-by: Orca --- src/main/telemetry/client.test.ts | 7 +++---- src/main/telemetry/client.ts | 13 +++++++------ 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/main/telemetry/client.test.ts b/src/main/telemetry/client.test.ts index a5361b64395..2b76dd44c36 100644 --- a/src/main/telemetry/client.test.ts +++ b/src/main/telemetry/client.test.ts @@ -361,16 +361,15 @@ describe('setOptIn()', () => { expect(order).toEqual(['optIn', 'capture:telemetry_opted_in']) }) - it('console-mirrors telemetry_opted_in when no PostHog client is initialized', async () => { + it('drops telemetry_opted_in silently in non-official builds', async () => { settings.telemetry!.optedIn = false _setPostHogClientForTests(null) _enableTransportForTests(false) await setOptIn('settings', true) - expect(console.debug).toHaveBeenCalledWith('[telemetry]', 'telemetry_opted_in', { - via: 'settings' - }) + expect(mock.capture).not.toHaveBeenCalled() + expect(console.debug).not.toHaveBeenCalled() }) it('fires app_opened once after pending-banner opt-in enables the SDK', async () => { diff --git a/src/main/telemetry/client.ts b/src/main/telemetry/client.ts index 5ee4ac4b956..b8216c4c341 100644 --- a/src/main/telemetry/client.ts +++ b/src/main/telemetry/client.ts @@ -248,20 +248,21 @@ function waitForCaptureEnqueue(client: PostHog, event: EventName, uuid: string): }) } +// In `pnpm dev` and any contributor / non-official build, `track()` is a +// no-op: it returns immediately without transmitting, logging, or running +// the burst-cap / consent / validator pipeline. Telemetry only flows in +// official stable/rc builds where CI injects `ORCA_BUILD_IDENTITY` and +// `ORCA_POSTHOG_WRITE_KEY`. export function track(name: N, props: EventProps): void { - // Console mirror: always in non-official builds (so the whole team — - // contributors included — sees exactly what would transmit) and also in - // official builds when `TELEMETRY_ENABLED` is off (PR 2 verification). - // These are the only two paths that short-circuit before the pipeline. if (!testTransportEnabled && (!IS_OFFICIAL_BUILD || !TELEMETRY_ENABLED)) { - console.debug('[telemetry]', name, props) + void name + void props return } // (1) Shutdown gate. Late IPC arrivals should not attempt to enqueue // against a client that is actively flushing. if (shuttingDown) { - console.debug('[telemetry] shutdown-gate drop:', name) return } if (!posthog || !commonProps || !storeRef) {