authorgravatar for julius0216@outlook.comJulius Marminge <julius0216@outlook.com> 2026-10-06 13:55:06-07:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2026-10-06 13:55:06-07:00
log78c9fcaafcbee9e2b941d8b0129a9f968373c6b2
tree7bd9ab85d18d90afa871dbe5699fc902f72428d2
parent3dfe373fddb966101371805b0b102ae5af75b15b
signature Signed by PGP key B5690EEEBB952194

fix(desktop): honor the telemetry opt-out from the shell profile (#16563)

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

5 files changed, 14 insertions(+), 0 deletions(-)

apps/desktop/src/backend/DesktopBackendConfiguration.test.ts+5
...@@ -979,9 +979,11 @@ describe("DesktopBackendConfiguration", () => {...@@ -979,9 +979,11 @@ describe("DesktopBackendConfiguration", () => {
979979
980 const previousWslEnv = process.env.WSLENV;980 const previousWslEnv = process.env.WSLENV;
981 const previousDisabled = process.env.OTEL_SDK_DISABLED;981 const previousDisabled = process.env.OTEL_SDK_DISABLED;
982 const previousTelemetry = process.env.T3CODE_TELEMETRY_ENABLED;
982 try {983 try {
983 delete process.env.WSLENV;984 delete process.env.WSLENV;
984 process.env.OTEL_SDK_DISABLED = "true";985 process.env.OTEL_SDK_DISABLED = "true";
986 process.env.T3CODE_TELEMETRY_ENABLED = "false";
985987
986 yield* Effect.gen(function* () {988 yield* Effect.gen(function* () {
987 const configuration = yield* DesktopBackendConfiguration.DesktopBackendConfiguration;989 const configuration = yield* DesktopBackendConfiguration.DesktopBackendConfiguration;
...@@ -989,6 +991,8 @@ describe("DesktopBackendConfiguration", () => {...@@ -989,6 +991,8 @@ describe("DesktopBackendConfiguration", () => {
989991
990 assert.equal(config.env.OTEL_SDK_DISABLED, "true");992 assert.equal(config.env.OTEL_SDK_DISABLED, "true");
991 assert.include((config.env.WSLENV ?? "").split(":"), "OTEL_SDK_DISABLED");993 assert.include((config.env.WSLENV ?? "").split(":"), "OTEL_SDK_DISABLED");
994 assert.equal(config.env.T3CODE_TELEMETRY_ENABLED, "false");
995 assert.include((config.env.WSLENV ?? "").split(":"), "T3CODE_TELEMETRY_ENABLED");
992 }).pipe(996 }).pipe(
993 Effect.provide(997 Effect.provide(
994 DesktopBackendConfiguration.layer.pipe(998 DesktopBackendConfiguration.layer.pipe(
...@@ -1009,6 +1013,7 @@ describe("DesktopBackendConfiguration", () => {...@@ -1009,6 +1013,7 @@ describe("DesktopBackendConfiguration", () => {
1009 } finally {1013 } finally {
1010 restoreEnv("WSLENV", previousWslEnv);1014 restoreEnv("WSLENV", previousWslEnv);
1011 restoreEnv("OTEL_SDK_DISABLED", previousDisabled);1015 restoreEnv("OTEL_SDK_DISABLED", previousDisabled);
1016 restoreEnv("T3CODE_TELEMETRY_ENABLED", previousTelemetry);
1012 }1017 }
1013 }).pipe(Effect.scoped, Effect.provide(NodeServices.layer)),1018 }).pipe(Effect.scoped, Effect.provide(NodeServices.layer)),
1014 );1019 );
apps/desktop/src/backend/DesktopBackendConfiguration.ts+1
...@@ -101,6 +101,7 @@ const DESKTOP_BACKEND_ENV_NAMES = [...@@ -101,6 +101,7 @@ const DESKTOP_BACKEND_ENV_NAMES = [
101const WSL_FORWARDED_ENV_NAMES = [101const WSL_FORWARDED_ENV_NAMES = [
102 "OPENAI_API_KEY",102 "OPENAI_API_KEY",
103 "ANTHROPIC_API_KEY",103 "ANTHROPIC_API_KEY",
104 "T3CODE_TELEMETRY_ENABLED",
104 // Otherwise the WSL server keeps exporting to endpoints from the bootstrap.105 // Otherwise the WSL server keeps exporting to endpoints from the bootstrap.
105 "T3CODE_OTEL_SDK_DISABLED",106 "T3CODE_OTEL_SDK_DISABLED",
106 "OTEL_SDK_DISABLED",107 "OTEL_SDK_DISABLED",
apps/desktop/src/shell/DesktopShellEnvironment.test.ts+2
...@@ -268,11 +268,13 @@ describe("DesktopShellEnvironment", () => {...@@ -268,11 +268,13 @@ describe("DesktopShellEnvironment", () => {
268 envOutput({268 envOutput({
269 PATH: "/home/linuxbrew/.linuxbrew/bin:/usr/bin",269 PATH: "/home/linuxbrew/.linuxbrew/bin:/usr/bin",
270 SSH_AUTH_SOCK: "/tmp/secretive.sock",270 SSH_AUTH_SOCK: "/tmp/secretive.sock",
271 T3CODE_TELEMETRY_ENABLED: "false",
271 }),272 }),
272 });273 });
273274
274 assert.equal(env.PATH, "/home/linuxbrew/.linuxbrew/bin:/usr/bin");275 assert.equal(env.PATH, "/home/linuxbrew/.linuxbrew/bin:/usr/bin");
275 assert.equal(env.SSH_AUTH_SOCK, "/tmp/secretive.sock");276 assert.equal(env.SSH_AUTH_SOCK, "/tmp/secretive.sock");
277 assert.equal(env.T3CODE_TELEMETRY_ENABLED, "false");
276 }),278 }),
277 );279 );
278280
apps/desktop/src/shell/DesktopShellEnvironment.ts+3
...@@ -85,6 +85,7 @@ const LOGIN_SHELL_ENV_NAMES = [...@@ -85,6 +85,7 @@ const LOGIN_SHELL_ENV_NAMES = [
85 "XDG_SESSION_DESKTOP",85 "XDG_SESSION_DESKTOP",
86 "XDG_SESSION_TYPE",86 "XDG_SESSION_TYPE",
87 "WAYLAND_DISPLAY",87 "WAYLAND_DISPLAY",
88 "T3CODE_TELEMETRY_ENABLED",
88] as const;89] as const;
89const WINDOWS_PROFILE_ENV_NAMES = ["PATH", "FNM_DIR", "FNM_MULTISHELL_PATH"] as const;90const WINDOWS_PROFILE_ENV_NAMES = ["PATH", "FNM_DIR", "FNM_MULTISHELL_PATH"] as const;
90const LOCALE_ENV_NAMES = ["LANG", "LC_ALL", "LC_CTYPE"] as const;91const LOCALE_ENV_NAMES = ["LANG", "LC_ALL", "LC_CTYPE"] as const;
...@@ -450,6 +451,8 @@ const installPosixEnvironment = Effect.fn("desktop.shellEnvironment.installPosix...@@ -450,6 +451,8 @@ const installPosixEnvironment = Effect.fn("desktop.shellEnvironment.installPosix
450 "XDG_DATA_HOME",451 "XDG_DATA_HOME",
451 "XDG_RUNTIME_DIR",452 "XDG_RUNTIME_DIR",
452 "WAYLAND_DISPLAY",453 "WAYLAND_DISPLAY",
454 // The telemetry opt-out is documented as a shell variable; GUI launches never see it.
455 "T3CODE_TELEMETRY_ENABLED",
453 ] as const) {456 ] as const) {
454 if (!config.env[name] && shellEnvironment[name]) {457 if (!config.env[name] && shellEnvironment[name]) {
455 config.env[name] = shellEnvironment[name];458 config.env[name] = shellEnvironment[name];
docs/user/telemetry.md+3
...@@ -9,3 +9,6 @@ raw provider events, or child-agent output. Child-agent token use is excluded fr...@@ -9,3 +9,6 @@ raw provider events, or child-agent output. Child-agent token use is excluded fr
99
10To disable collection, set `T3CODE_TELEMETRY_ENABLED=false` in the server's environment before10To disable collection, set `T3CODE_TELEMETRY_ENABLED=false` in the server's environment before
11starting it. This stops product events from being recorded or sent.11starting it. This stops product events from being recorded or sent.
12
13The desktop app reads the variable from your shell profile (for example `~/.zshrc`) on macOS and
14Linux, so export it there and restart the app. On Windows, set it as a user environment variable.