Skip to content

Commit 78c9fca

Browse files
fix(desktop): honor the telemetry opt-out from the shell profile (pingdotgg#16563)
Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
1 parent 3dfe373 commit 78c9fca

5 files changed

Lines changed: 14 additions & 0 deletions

File tree

‎apps/desktop/src/backend/DesktopBackendConfiguration.test.ts‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -979,16 +979,20 @@ describe("DesktopBackendConfiguration", () => {
979979

980980
const previousWslEnv = process.env.WSLENV;
981981
const previousDisabled = process.env.OTEL_SDK_DISABLED;
982+
const previousTelemetry = process.env.T3CODE_TELEMETRY_ENABLED;
982983
try {
983984
delete process.env.WSLENV;
984985
process.env.OTEL_SDK_DISABLED = "true";
986+
process.env.T3CODE_TELEMETRY_ENABLED = "false";
985987

986988
yield* Effect.gen(function* () {
987989
const configuration = yield* DesktopBackendConfiguration.DesktopBackendConfiguration;
988990
const config = yield* configuration.resolveWsl({ port: 5050, distro: null });
989991

990992
assert.equal(config.env.OTEL_SDK_DISABLED, "true");
991993
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");
992996
}).pipe(
993997
Effect.provide(
994998
DesktopBackendConfiguration.layer.pipe(
@@ -1009,6 +1013,7 @@ describe("DesktopBackendConfiguration", () => {
10091013
} finally {
10101014
restoreEnv("WSLENV", previousWslEnv);
10111015
restoreEnv("OTEL_SDK_DISABLED", previousDisabled);
1016+
restoreEnv("T3CODE_TELEMETRY_ENABLED", previousTelemetry);
10121017
}
10131018
}).pipe(Effect.scoped, Effect.provide(NodeServices.layer)),
10141019
);

‎apps/desktop/src/backend/DesktopBackendConfiguration.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ const DESKTOP_BACKEND_ENV_NAMES = [
101101
const WSL_FORWARDED_ENV_NAMES = [
102102
"OPENAI_API_KEY",
103103
"ANTHROPIC_API_KEY",
104+
"T3CODE_TELEMETRY_ENABLED",
104105
// Otherwise the WSL server keeps exporting to endpoints from the bootstrap.
105106
"T3CODE_OTEL_SDK_DISABLED",
106107
"OTEL_SDK_DISABLED",

‎apps/desktop/src/shell/DesktopShellEnvironment.test.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,11 +268,13 @@ describe("DesktopShellEnvironment", () => {
268268
envOutput({
269269
PATH: "/home/linuxbrew/.linuxbrew/bin:/usr/bin",
270270
SSH_AUTH_SOCK: "/tmp/secretive.sock",
271+
T3CODE_TELEMETRY_ENABLED: "false",
271272
}),
272273
});
273274

274275
assert.equal(env.PATH, "/home/linuxbrew/.linuxbrew/bin:/usr/bin");
275276
assert.equal(env.SSH_AUTH_SOCK, "/tmp/secretive.sock");
277+
assert.equal(env.T3CODE_TELEMETRY_ENABLED, "false");
276278
}),
277279
);
278280

‎apps/desktop/src/shell/DesktopShellEnvironment.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ const LOGIN_SHELL_ENV_NAMES = [
8585
"XDG_SESSION_DESKTOP",
8686
"XDG_SESSION_TYPE",
8787
"WAYLAND_DISPLAY",
88+
"T3CODE_TELEMETRY_ENABLED",
8889
] as const;
8990
const WINDOWS_PROFILE_ENV_NAMES = ["PATH", "FNM_DIR", "FNM_MULTISHELL_PATH"] as const;
9091
const LOCALE_ENV_NAMES = ["LANG", "LC_ALL", "LC_CTYPE"] as const;
@@ -450,6 +451,8 @@ const installPosixEnvironment = Effect.fn("desktop.shellEnvironment.installPosix
450451
"XDG_DATA_HOME",
451452
"XDG_RUNTIME_DIR",
452453
"WAYLAND_DISPLAY",
454+
// The telemetry opt-out is documented as a shell variable; GUI launches never see it.
455+
"T3CODE_TELEMETRY_ENABLED",
453456
] as const) {
454457
if (!config.env[name] && shellEnvironment[name]) {
455458
config.env[name] = shellEnvironment[name];

‎docs/user/telemetry.md‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,6 @@ raw provider events, or child-agent output. Child-agent token use is excluded fr
99

1010
To disable collection, set `T3CODE_TELEMETRY_ENABLED=false` in the server's environment before
1111
starting it. This stops product events from being recorded or sent.
12+
13+
The desktop app reads the variable from your shell profile (for example `~/.zshrc`) on macOS and
14+
Linux, so export it there and restart the app. On Windows, set it as a user environment variable.

0 commit comments

Comments
 (0)