chore(telemetry): silence dev-mode console mirror in track() (#1489)

Co-authored-by: Orca <help@stably.ai>
This commit is contained in:
Brennan Benson
2026-05-05 21:50:58 -07:00
committed by GitHub
co-authored by Orca
parent 97b177d24c
commit 0df075f2d2
2 changed files with 8 additions and 10 deletions
+3 -4
View File
@@ -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 () => {
+5 -6
View File
@@ -248,20 +248,19 @@ 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<N extends EventName>(name: N, props: EventProps<N>): 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)
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) {