Skip to content
TypeScript

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

Julius Marminge78c9fcaafcbe
diff --git a/apps/desktop/src/backend/DesktopBackendConfiguration.test.ts b/apps/desktop/src/backend/DesktopBackendConfiguration.test.ts
index 66fffb84f10..3b282c1c1db 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 a19e4ef7179..289e3fb321f 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 5111ea4ee53..bf0fd1f6da7 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 1143ed057b2..01f194ea054 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 5fd4f91c932..2f7e44825dc 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.