diff --git a/apps/desktop/src/backend/DesktopBackendConfiguration.test.ts b/apps/desktop/src/backend/DesktopBackendConfiguration.test.ts index 66fffb84f10989d6b079ae20095ed04d5c445935..3b282c1c1db94c660bddf6605d55a22fc7db6d38 100644 --- a/apps/desktop/src/backend/DesktopBackendConfiguration.test.ts +++ b/apps/desktop/src/backend/DesktopBackendConfiguration.test.ts @@ -979,9 +979,11 @@ describe("DesktopBackendConfiguration", () => { const previousWslEnv = process.env.WSLENV; const previousDisabled = process.env.OTEL_SDK_DISABLED; + const previousTelemetry = process.env.T3CODE_TELEMETRY_ENABLED; try { delete process.env.WSLENV; process.env.OTEL_SDK_DISABLED = "true"; + process.env.T3CODE_TELEMETRY_ENABLED = "false"; yield* Effect.gen(function* () { const configuration = yield* DesktopBackendConfiguration.DesktopBackendConfiguration; @@ -989,6 +991,8 @@ describe("DesktopBackendConfiguration", () => { assert.equal(config.env.OTEL_SDK_DISABLED, "true"); assert.include((config.env.WSLENV ?? "").split(":"), "OTEL_SDK_DISABLED"); + assert.equal(config.env.T3CODE_TELEMETRY_ENABLED, "false"); + assert.include((config.env.WSLENV ?? "").split(":"), "T3CODE_TELEMETRY_ENABLED"); }).pipe( Effect.provide( DesktopBackendConfiguration.layer.pipe( @@ -1009,6 +1013,7 @@ describe("DesktopBackendConfiguration", () => { } finally { restoreEnv("WSLENV", previousWslEnv); restoreEnv("OTEL_SDK_DISABLED", previousDisabled); + restoreEnv("T3CODE_TELEMETRY_ENABLED", previousTelemetry); } }).pipe(Effect.scoped, Effect.provide(NodeServices.layer)), ); diff --git a/apps/desktop/src/backend/DesktopBackendConfiguration.ts b/apps/desktop/src/backend/DesktopBackendConfiguration.ts index a19e4ef7179edb5d48152bf578ca2fbf9a700e07..289e3fb321f065abf7ac07956e7e15b9c2316d3d 100644 --- a/apps/desktop/src/backend/DesktopBackendConfiguration.ts +++ b/apps/desktop/src/backend/DesktopBackendConfiguration.ts @@ -101,6 +101,7 @@ const DESKTOP_BACKEND_ENV_NAMES = [ const WSL_FORWARDED_ENV_NAMES = [ "OPENAI_API_KEY", "ANTHROPIC_API_KEY", + "T3CODE_TELEMETRY_ENABLED", // Otherwise the WSL server keeps exporting to endpoints from the bootstrap. "T3CODE_OTEL_SDK_DISABLED", "OTEL_SDK_DISABLED", diff --git a/apps/desktop/src/shell/DesktopShellEnvironment.test.ts b/apps/desktop/src/shell/DesktopShellEnvironment.test.ts index 5111ea4ee53349fbb4c11d7919bbbcdc99038490..bf0fd1f6da70a13faa21cf13bbad0fc00d3e4f69 100644 --- a/apps/desktop/src/shell/DesktopShellEnvironment.test.ts +++ b/apps/desktop/src/shell/DesktopShellEnvironment.test.ts @@ -268,11 +268,13 @@ describe("DesktopShellEnvironment", () => { envOutput({ PATH: "/home/linuxbrew/.linuxbrew/bin:/usr/bin", SSH_AUTH_SOCK: "/tmp/secretive.sock", + T3CODE_TELEMETRY_ENABLED: "false", }), }); assert.equal(env.PATH, "/home/linuxbrew/.linuxbrew/bin:/usr/bin"); assert.equal(env.SSH_AUTH_SOCK, "/tmp/secretive.sock"); + assert.equal(env.T3CODE_TELEMETRY_ENABLED, "false"); }), ); diff --git a/apps/desktop/src/shell/DesktopShellEnvironment.ts b/apps/desktop/src/shell/DesktopShellEnvironment.ts index 1143ed057b2b88c3bc01096c1394fc1db739e259..01f194ea05445d9082b63c440295457b3ccbea84 100644 --- a/apps/desktop/src/shell/DesktopShellEnvironment.ts +++ b/apps/desktop/src/shell/DesktopShellEnvironment.ts @@ -85,6 +85,7 @@ const LOGIN_SHELL_ENV_NAMES = [ "XDG_SESSION_DESKTOP", "XDG_SESSION_TYPE", "WAYLAND_DISPLAY", + "T3CODE_TELEMETRY_ENABLED", ] as const; const WINDOWS_PROFILE_ENV_NAMES = ["PATH", "FNM_DIR", "FNM_MULTISHELL_PATH"] as const; const LOCALE_ENV_NAMES = ["LANG", "LC_ALL", "LC_CTYPE"] as const; @@ -450,6 +451,8 @@ const installPosixEnvironment = Effect.fn("desktop.shellEnvironment.installPosix "XDG_DATA_HOME", "XDG_RUNTIME_DIR", "WAYLAND_DISPLAY", + // The telemetry opt-out is documented as a shell variable; GUI launches never see it. + "T3CODE_TELEMETRY_ENABLED", ] as const) { if (!config.env[name] && shellEnvironment[name]) { config.env[name] = shellEnvironment[name]; diff --git a/docs/user/telemetry.md b/docs/user/telemetry.md index 5fd4f91c9327ca2510abf83689574782afcef4f0..2f7e44825dc690ac1a3cea9f71235337aae14ce5 100644 --- a/docs/user/telemetry.md +++ b/docs/user/telemetry.md @@ -9,3 +9,6 @@ raw provider events, or child-agent output. Child-agent token use is excluded fr To disable collection, set `T3CODE_TELEMETRY_ENABLED=false` in the server's environment before starting it. This stops product events from being recorded or sent. + +The desktop app reads the variable from your shell profile (for example `~/.zshrc`) on macOS and +Linux, so export it there and restart the app. On Windows, set it as a user environment variable.