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

Drop the `[telemetry] <event> <props>` 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 <help@stably.ai>
This commit is contained in:
brennanb2025
2026-05-05 21:36:08 -07:00
co-authored by Orca
parent 97b177d24c
commit cdb4871836
2 changed files with 10 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 () => {
+7 -6
View File
@@ -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<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)
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) {