From 8d6141deaa563b1a9d7da80f6cb4d2e81de57b36 Mon Sep 17 00:00:00 2001 From: Yordis Prieto Date: Tue, 24 Nov 2026 11:49:06 -0500 Subject: [PATCH 1/3] feat(server): product telemetry is opt-in Users of this fork should not report usage to upstream or have their provider login files read unless they choose to. Signed-off-by: Yordis Prieto --- apps/desktop/src/ipc/methods/window.test.ts | 17 ++++---- apps/desktop/src/ipc/methods/window.ts | 3 +- apps/server/src/serverRuntimeStartup.ts | 4 +- .../src/telemetry/AnalyticsService.test.ts | 43 +++++++++++++++++-- apps/server/src/telemetry/AnalyticsService.ts | 22 +++++++--- docs/internals/08_product-analytics.md | 4 +- docs/user/faq.md | 2 +- docs/user/telemetry.md | 13 +++--- packages/shared/src/otelEnvironment.test.ts | 12 ++++-- packages/shared/src/otelEnvironment.ts | 2 +- 10 files changed, 89 insertions(+), 33 deletions(-) diff --git a/apps/desktop/src/ipc/methods/window.test.ts b/apps/desktop/src/ipc/methods/window.test.ts index 02f60ef3358ac..933006386a850 100644 --- a/apps/desktop/src/ipc/methods/window.test.ts +++ b/apps/desktop/src/ipc/methods/window.test.ts @@ -309,17 +309,17 @@ describe("installRelayTelemetryEnabled", () => { it.effect("reads the desktop host opt-out before returning the renderer policy", () => Effect.gen(function* () { assert.deepEqual(yield* relayTelemetryEnabled({ T3CODE_TELEMETRY_ENABLED: "false" }), { - beforeDiscovery: false, + beforeDiscovery: null, afterDiscovery: false, }); - // Undecided until the login shell is read, so the renderer asks again instead of opting out. + // Off unless opted in; undecided until the login shell is read, so the renderer asks again. assert.deepEqual(yield* relayTelemetryEnabled({}), { beforeDiscovery: null, - afterDiscovery: true, + afterDiscovery: false, }); assert.deepEqual( - yield* relayTelemetryEnabled({}, undefined, { T3CODE_TELEMETRY_ENABLED: "false" }), - { beforeDiscovery: null, afterDiscovery: false }, + yield* relayTelemetryEnabled({}, undefined, { T3CODE_TELEMETRY_ENABLED: "true" }), + { beforeDiscovery: null, afterDiscovery: true }, ); }), ); @@ -334,11 +334,12 @@ describe("installRelayTelemetryEnabled", () => { const after = function* (...args: Parameters) { return (yield* relayTelemetryEnabled(...args)).afterDiscovery; }; - assert.isFalse(yield* after({}, policy({ telemetry: false }))); - assert.isTrue(yield* after({}, policy({ webhookTasks: false }))); + const optedIn = { T3CODE_TELEMETRY_ENABLED: "true" }; + assert.isFalse(yield* after(optedIn, policy({ telemetry: false }))); + assert.isTrue(yield* after(optedIn, policy({ webhookTasks: false }))); // A policy that cannot be read fails closed. assert.isFalse( - yield* after({}, new ManagedPolicyFileError({ path: "/test", reason: "bad JSON" })), + yield* after(optedIn, new ManagedPolicyFileError({ path: "/test", reason: "bad JSON" })), ); }), ); diff --git a/apps/desktop/src/ipc/methods/window.ts b/apps/desktop/src/ipc/methods/window.ts index ac69c40d4a917..c11cf89b801d4 100644 --- a/apps/desktop/src/ipc/methods/window.ts +++ b/apps/desktop/src/ipc/methods/window.ts @@ -102,8 +102,9 @@ export const installRelayTelemetryEnabled = Effect.fn("desktop.ipc.window.instal result: Schema.NullOr(Schema.Boolean), handler: () => shellEnvironment.discoveryFinished.pipe( + // Opting in can come from the login shell, so stay undecided until it is read. Effect.map((known) => - !policyAllows || !isRelayTracingEnabled(env) ? false : known ? true : null, + !policyAllows ? false : known ? isRelayTracingEnabled(env) : null, ), ), }), diff --git a/apps/server/src/serverRuntimeStartup.ts b/apps/server/src/serverRuntimeStartup.ts index 0f5c52478b998..3dfd79c686f01 100644 --- a/apps/server/src/serverRuntimeStartup.ts +++ b/apps/server/src/serverRuntimeStartup.ts @@ -171,11 +171,11 @@ const recordStartupHeartbeat = Effect.gen(function* () { ), ); - yield* analytics.record("server.boot.heartbeat", { + const recorded = yield* analytics.record("server.boot.heartbeat", { threadCount, projectCount, }); - yield* analytics.recordOwners(yield* getServerOwners, "server"); + if (recorded) yield* analytics.recordOwners(yield* getServerOwners, "server"); }); const getAutoBootstrapThreadModelSelection = (): ModelSelection => ({ diff --git a/apps/server/src/telemetry/AnalyticsService.test.ts b/apps/server/src/telemetry/AnalyticsService.test.ts index 4d3c2d5421279..ecdabe950c57c 100644 --- a/apps/server/src/telemetry/AnalyticsService.test.ts +++ b/apps/server/src/telemetry/AnalyticsService.test.ts @@ -113,7 +113,11 @@ const recordTwentyEvents = Effect.gen(function* () { } }); -const analyticsLayerWith = (client: HttpClient.HttpClient, policy?: ManagedPolicyDocument) => +const analyticsLayerWith = ( + client: HttpClient.HttpClient, + policy?: ManagedPolicyDocument, + telemetryEnabled: boolean | null = true, +) => AnalyticsService.layer.pipe( Layer.provideMerge( ServerConfig.ServerConfig.layerTest(process.cwd(), { prefix: "t3-telemetry-retry-" }), @@ -121,7 +125,7 @@ const analyticsLayerWith = (client: HttpClient.HttpClient, policy?: ManagedPolic Layer.provide( ConfigProvider.layer( ConfigProvider.fromUnknown({ - T3CODE_TELEMETRY_ENABLED: true, + ...(telemetryEnabled === null ? {} : { T3CODE_TELEMETRY_ENABLED: telemetryEnabled }), T3CODE_POSTHOG_KEY: "phc_test_key", T3CODE_POSTHOG_HOST: "http://localhost", }), @@ -151,6 +155,7 @@ const sendFor = ( AnalyticsService.AnalyticsService | Effect.Services > = recordTwentyEvents, policy?: ManagedPolicyDocument, + telemetryEnabled: boolean | null = true, ) => Effect.gen(function* () { const batches: Array> = []; @@ -165,7 +170,7 @@ const sendFor = ( return yield* respond(request); }), ); - const runtimeLayer = analyticsLayerWith(client, policy); + const runtimeLayer = analyticsLayerWith(client, policy, telemetryEnabled); yield* Effect.gen(function* () { yield* record; @@ -177,6 +182,38 @@ const sendFor = ( }); it.layer(Layer.mergeAll(NodeServices.layer, NodeCrypto.layer))("AnalyticsService test", (it) => { + it.effect("sends nothing unless telemetry is opted in", () => + Effect.gen(function* () { + const batches = yield* sendFor( + 1, + respondWithStatus(204), + recordTwentyEvents, + undefined, + null, + ); + assert.deepEqual(batches, []); + }), + ); + + it.effect("stays off after desktop shell discovery when the shell sets no preference", () => + Effect.gen(function* () { + const env: NodeJS.ProcessEnv = { T3CODE_DESKTOP_SHELL_DISCOVERY_PENDING: "1" }; + const batches = yield* sendFor( + 0, + respondWithStatus(204), + Effect.gen(function* () { + const analytics = yield* AnalyticsService.AnalyticsService; + delete env.T3CODE_DESKTOP_SHELL_DISCOVERY_PENDING; + yield* analytics.record("test.no-preference"); + yield* analytics.flush; + }), + undefined, + null, + ).pipe(Effect.provideService(HostProcess.Environment, env)); + assert.deepEqual(batches, []); + }), + ); + it.effect("waits for desktop shell consent and honors a late telemetry opt-out", () => Effect.gen(function* () { const env: NodeJS.ProcessEnv = { T3CODE_DESKTOP_SHELL_DISCOVERY_PENDING: "1" }; diff --git a/apps/server/src/telemetry/AnalyticsService.ts b/apps/server/src/telemetry/AnalyticsService.ts index eb222ae743a7d..98df09ee1b517 100644 --- a/apps/server/src/telemetry/AnalyticsService.ts +++ b/apps/server/src/telemetry/AnalyticsService.ts @@ -71,7 +71,7 @@ const TelemetryEnvConfig = Config.all({ posthogHost: Config.String("T3CODE_POSTHOG_HOST").pipe( Config.withDefault("https://ingest.t3.codes"), ), - enabled: Config.Boolean("T3CODE_TELEMETRY_ENABLED").pipe(Config.withDefault(true)), + enabled: Config.Boolean("T3CODE_TELEMETRY_ENABLED").pipe(Config.withDefault(false)), flushBatchSize: Config.Number("T3CODE_TELEMETRY_FLUSH_BATCH_SIZE").pipe(Config.withDefault(20)), maxBufferedEvents: Config.Number("T3CODE_TELEMETRY_MAX_BUFFERED_EVENTS").pipe( Config.withDefault(1_000), @@ -128,13 +128,13 @@ export const make = Effect.gen(function* () { ManagedPolicy.deniedBy(yield* ManagedPolicy.ManagedPolicy, "telemetry") === undefined; // A cached PATH does not establish consent from the current login shell. const telemetryEnabled = Effect.suspend(() => { - if (!telemetryConfig.enabled || !policyAllows) return Effect.succeed(false); - if (!awaitingShellConsent) return Effect.succeed(true); + if (!policyAllows) return Effect.succeed(false); + if (!awaitingShellConsent) return Effect.succeed(telemetryConfig.enabled); if (hostEnvironment.T3CODE_DESKTOP_SHELL_DISCOVERY_PENDING === "1") return Effect.succeed(false); const preference = hostEnvironment.T3CODE_TELEMETRY_ENABLED; return Config.Boolean("T3CODE_TELEMETRY_ENABLED").pipe( - Config.withDefault(true), + Config.withDefault(false), Effect.provideService( ConfigProvider.ConfigProvider, ConfigProvider.fromEnv({ @@ -146,7 +146,13 @@ export const make = Effect.gen(function* () { }); const httpClient = yield* HttpClient.HttpClient; const serverConfig = yield* ServerConfig.ServerConfig; - const { distinctId, installId } = yield* getTelemetryIdentity; + // Provider login files are read only once telemetry is on. + const telemetryIdentity = yield* Effect.cached( + Effect.provideContext( + getTelemetryIdentity, + yield* Effect.context>(), + ), + ); const crypto = yield* SecureRandom.SecureRandom; const bufferRef = yield* Ref.make>([]); const deliveryRef = yield* Ref.make({ @@ -200,7 +206,9 @@ export const make = Effect.gen(function* () { const sendBatch = Effect.fn("AnalyticsService.sendBatch")(function* ( events: ReadonlyArray, ) { - if (!(yield* telemetryEnabled) || !distinctId) return; + if (!(yield* telemetryEnabled)) return; + const { distinctId, installId } = yield* telemetryIdentity; + if (!distinctId) return; const payload = { api_key: telemetryConfig.posthogKey, @@ -312,7 +320,7 @@ export const make = Effect.gen(function* () { const record: AnalyticsService["Service"]["record"] = Effect.fn("AnalyticsService.record")( function* (event, properties) { - if (!(yield* telemetryEnabled) || !distinctId) return false; + if (!(yield* telemetryEnabled) || !(yield* telemetryIdentity).distinctId) return false; // Catch Node UUID defects too; best-effort telemetry drops events without UUIDs. const uuid = yield* Effect.exit(crypto.uuidV7()); diff --git a/docs/internals/08_product-analytics.md b/docs/internals/08_product-analytics.md index 375f6be84b857..fd59ba2e9034d 100644 --- a/docs/internals/08_product-analytics.md +++ b/docs/internals/08_product-analytics.md @@ -38,5 +38,5 @@ an authenticated connection does not count as product use. - Delivery ([`AnalyticsService.ts`](../../apps/server/src/telemetry/AnalyticsService.ts)) attaches a UUID per event, backs off on failure, and drops batches after bounded retries so a stuck batch cannot loop forever. -- Dev-runner servers and CI smoke tests disable telemetry (and relay tracing) by default so they do - not inflate install counts; set `T3CODE_TELEMETRY_ENABLED=true` to test locally. +- Telemetry and relay tracing are opt-in: nothing is sent, and provider login files are not read + for identity, unless `T3CODE_TELEMETRY_ENABLED=true`. Set it to test locally. diff --git a/docs/user/faq.md b/docs/user/faq.md index d06a1ec43e049..d1c6d26e71898 100644 --- a/docs/user/faq.md +++ b/docs/user/faq.md @@ -73,7 +73,7 @@ No. T3 Code is a serious developer tool. Locally runnable models are not capable ## Does my code go to T3 servers? -No. Your code and prompts go from your machine to your provider (Anthropic, OpenAI, etc.), not to us. With T3 Connect, traffic rides a Cloudflare tunnel (`cloudflared` on your machine). Our relay sets up the link. It does not proxy your HTTP or WebSocket sessions. T3 Code does send basic product usage events (provider, model, token totals, that kind of thing). No prompts, no file contents. That is the same on Tailscale, LAN, or T3 Connect. Set `T3CODE_TELEMETRY_ENABLED=false` if you want it off. [Product usage data](./telemetry.md) +No. Your code and prompts go from your machine to your provider (Anthropic, OpenAI, etc.), not to us. With T3 Connect, traffic rides a Cloudflare tunnel (`cloudflared` on your machine). Our relay sets up the link. It does not proxy your HTTP or WebSocket sessions. T3 Code can send basic product usage events (provider, model, token totals, that kind of thing) if you opt in with `T3CODE_TELEMETRY_ENABLED=true`. No prompts, no file contents. That is the same on Tailscale, LAN, or T3 Connect. [Product usage data](./telemetry.md) ## Worktrees are eating my disk. How do I clean them up? diff --git a/docs/user/telemetry.md b/docs/user/telemetry.md index be7fdd938ff06..68fce277b7559 100644 --- a/docs/user/telemetry.md +++ b/docs/user/telemetry.md @@ -1,6 +1,9 @@ # Product usage data -The T3 Code server sends product usage events to T3 Code's own endpoint at `ingest.t3.codes`, +Product usage events and relay connection traces are off unless you opt in. Set +`T3CODE_TELEMETRY_ENABLED=true` in the server's environment to turn them on. + +When enabled, the T3 Code server sends product usage events to T3 Code's own endpoint at `ingest.t3.codes`, associated with a hashed account or installation identifier. To count how many installations one person uses, the server also sends hashed account identifiers: your T3 Connect account, your OpenAI and Claude accounts when you are signed in, and a random identifier for each device that connects. The endpoint keeps a copy of each @@ -68,16 +71,16 @@ separate from product events. Depending on the client version, traces can includ timings, environment identifiers and the connected machine's name. Failed spans can include error messages and stack traces; error text can quote a value the app was handling. -To disable product events and relay tracing from the server, set -`T3CODE_TELEMETRY_ENABLED=false` in its environment before starting it. Relay tracing also stops -when `T3CODE_OTEL_SDK_DISABLED` or `OTEL_SDK_DISABLED` turns OpenTelemetry export off. +Product events and relay tracing from the server stay off unless `T3CODE_TELEMETRY_ENABLED=true` +is in its environment when it starts. Relay tracing also stops when `T3CODE_OTEL_SDK_DISABLED` or +`OTEL_SDK_DISABLED` turns OpenTelemetry export off. An administrator can turn product events and relay tracing off in the server and desktop app with a [managed policy](./managed-policy.md#other-capabilities). This does not control traces sent by separate browser or mobile clients. The desktop app reads `T3CODE_TELEMETRY_ENABLED` 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. +Linux, so export it there to opt in and restart the app. On Windows, set it as a user environment variable. The web app in a browser, including one the `t3` CLI opens, does not read these environment variables. When its build has relay tracing configured, it sends its own connection traces even diff --git a/packages/shared/src/otelEnvironment.test.ts b/packages/shared/src/otelEnvironment.test.ts index 21df52609ff29..7f7153f511152 100644 --- a/packages/shared/src/otelEnvironment.test.ts +++ b/packages/shared/src/otelEnvironment.test.ts @@ -387,17 +387,23 @@ describe("OtelEnvironment", () => { }); describe("isRelayTracingEnabled", () => { - it("defaults on and respects the T3CODE SDK override of the standard kill switch", () => { - assert.isTrue(OtelEnvironment.isRelayTracingEnabled({})); - assert.isFalse(OtelEnvironment.isRelayTracingEnabled({ OTEL_SDK_DISABLED: "true" })); + it("defaults off and respects the T3CODE SDK override of the standard kill switch", () => { + const optedIn = { T3CODE_TELEMETRY_ENABLED: "true" }; + assert.isFalse(OtelEnvironment.isRelayTracingEnabled({})); + assert.isTrue(OtelEnvironment.isRelayTracingEnabled(optedIn)); + assert.isFalse( + OtelEnvironment.isRelayTracingEnabled({ ...optedIn, OTEL_SDK_DISABLED: "true" }), + ); assert.isTrue( OtelEnvironment.isRelayTracingEnabled({ + ...optedIn, OTEL_SDK_DISABLED: "true", T3CODE_OTEL_SDK_DISABLED: "false", }), ); assert.isFalse( OtelEnvironment.isRelayTracingEnabled({ + ...optedIn, OTEL_SDK_DISABLED: "false", T3CODE_OTEL_SDK_DISABLED: "true", }), diff --git a/packages/shared/src/otelEnvironment.ts b/packages/shared/src/otelEnvironment.ts index 95392206a8c7c..39fdbd3337230 100644 --- a/packages/shared/src/otelEnvironment.ts +++ b/packages/shared/src/otelEnvironment.ts @@ -324,7 +324,7 @@ export const isRelayTracingEnabled = (env: Readonly telemetry.value !== false && !(t3.value ?? spec.value ?? false), + ({ telemetry, t3, spec }) => telemetry.value === true && !(t3.value ?? spec.value ?? false), ), Effect.provide(ConfigProvider.layer(ConfigProvider.fromEnvRecord(env))), Effect.orDie, From 6c9f6f25b595bd61a491b2d199630201703db21c Mon Sep 17 00:00:00 2001 From: Yordis Prieto Date: Tue, 24 Nov 2026 11:52:51 -0500 Subject: [PATCH 2/3] fix(server): opting in to telemetry no longer reports to upstream Opting in should send events only where the user points them, not to upstream's ingest endpoint with its hardcoded key. Signed-off-by: Yordis Prieto --- .../src/telemetry/AnalyticsService.test.ts | 32 +++++++++++-------- apps/server/src/telemetry/AnalyticsService.ts | 21 ++++++------ docs/user/telemetry.md | 16 +++++----- 3 files changed, 37 insertions(+), 32 deletions(-) diff --git a/apps/server/src/telemetry/AnalyticsService.test.ts b/apps/server/src/telemetry/AnalyticsService.test.ts index ecdabe950c57c..794617e62fe11 100644 --- a/apps/server/src/telemetry/AnalyticsService.test.ts +++ b/apps/server/src/telemetry/AnalyticsService.test.ts @@ -113,24 +113,19 @@ const recordTwentyEvents = Effect.gen(function* () { } }); +const destination = { T3CODE_POSTHOG_KEY: "phc_test_key", T3CODE_POSTHOG_HOST: "http://localhost" }; +const optedIn = { T3CODE_TELEMETRY_ENABLED: true, ...destination }; + const analyticsLayerWith = ( client: HttpClient.HttpClient, policy?: ManagedPolicyDocument, - telemetryEnabled: boolean | null = true, + config: Readonly> = optedIn, ) => AnalyticsService.layer.pipe( Layer.provideMerge( ServerConfig.ServerConfig.layerTest(process.cwd(), { prefix: "t3-telemetry-retry-" }), ), - Layer.provide( - ConfigProvider.layer( - ConfigProvider.fromUnknown({ - ...(telemetryEnabled === null ? {} : { T3CODE_TELEMETRY_ENABLED: telemetryEnabled }), - T3CODE_POSTHOG_KEY: "phc_test_key", - T3CODE_POSTHOG_HOST: "http://localhost", - }), - ), - ), + Layer.provide(ConfigProvider.layer(ConfigProvider.fromUnknown(config))), Layer.provide( Layer.mergeAll( Layer.succeed(HostProcess.Platform, "win32"), @@ -155,7 +150,7 @@ const sendFor = ( AnalyticsService.AnalyticsService | Effect.Services > = recordTwentyEvents, policy?: ManagedPolicyDocument, - telemetryEnabled: boolean | null = true, + config: Readonly> = optedIn, ) => Effect.gen(function* () { const batches: Array> = []; @@ -170,7 +165,7 @@ const sendFor = ( return yield* respond(request); }), ); - const runtimeLayer = analyticsLayerWith(client, policy, telemetryEnabled); + const runtimeLayer = analyticsLayerWith(client, policy, config); yield* Effect.gen(function* () { yield* record; @@ -189,12 +184,21 @@ it.layer(Layer.mergeAll(NodeServices.layer, NodeCrypto.layer))("AnalyticsService respondWithStatus(204), recordTwentyEvents, undefined, - null, + destination, ); assert.deepEqual(batches, []); }), ); + it.effect("sends nothing when opted in without a destination", () => + Effect.gen(function* () { + const batches = yield* sendFor(1, respondWithStatus(204), recordTwentyEvents, undefined, { + T3CODE_TELEMETRY_ENABLED: true, + }); + assert.deepEqual(batches, []); + }), + ); + it.effect("stays off after desktop shell discovery when the shell sets no preference", () => Effect.gen(function* () { const env: NodeJS.ProcessEnv = { T3CODE_DESKTOP_SHELL_DISCOVERY_PENDING: "1" }; @@ -208,7 +212,7 @@ it.layer(Layer.mergeAll(NodeServices.layer, NodeCrypto.layer))("AnalyticsService yield* analytics.flush; }), undefined, - null, + destination, ).pipe(Effect.provideService(HostProcess.Environment, env)); assert.deepEqual(batches, []); }), diff --git a/apps/server/src/telemetry/AnalyticsService.ts b/apps/server/src/telemetry/AnalyticsService.ts index 98df09ee1b517..5f7996c3dea18 100644 --- a/apps/server/src/telemetry/AnalyticsService.ts +++ b/apps/server/src/telemetry/AnalyticsService.ts @@ -65,12 +65,9 @@ function retryDelayMs(failures: number, random: number): number { } const TelemetryEnvConfig = Config.all({ - posthogKey: Config.String("T3CODE_POSTHOG_KEY").pipe( - Config.withDefault("phc_XOWci4oZP4VvLiEyrFqkFjP4CZn55mjYYBMREK5Wd6m"), - ), - posthogHost: Config.String("T3CODE_POSTHOG_HOST").pipe( - Config.withDefault("https://ingest.t3.codes"), - ), + // No default destination: opting in sends nothing until the user names their own endpoint. + posthogKey: Config.String("T3CODE_POSTHOG_KEY").pipe(Config.option), + posthogHost: Config.String("T3CODE_POSTHOG_HOST").pipe(Config.option), enabled: Config.Boolean("T3CODE_TELEMETRY_ENABLED").pipe(Config.withDefault(false)), flushBatchSize: Config.Number("T3CODE_TELEMETRY_FLUSH_BATCH_SIZE").pipe(Config.withDefault(20)), maxBufferedEvents: Config.Number("T3CODE_TELEMETRY_MAX_BUFFERED_EVENTS").pipe( @@ -121,6 +118,10 @@ function serverOsFromNodePlatform(platform: string): ClientOs { /** @public */ export const make = Effect.gen(function* () { const telemetryConfig = yield* TelemetryEnvConfig; + const destination = Option.all({ + apiKey: telemetryConfig.posthogKey, + host: telemetryConfig.posthogHost, + }); const hostEnvironment = yield* HostProcess.Environment; const awaitingShellConsent = hostEnvironment.T3CODE_DESKTOP_SHELL_DISCOVERY_PENDING === "1"; // A managed policy can switch analytics off over the environment, never on. @@ -128,7 +129,7 @@ export const make = Effect.gen(function* () { ManagedPolicy.deniedBy(yield* ManagedPolicy.ManagedPolicy, "telemetry") === undefined; // A cached PATH does not establish consent from the current login shell. const telemetryEnabled = Effect.suspend(() => { - if (!policyAllows) return Effect.succeed(false); + if (!policyAllows || Option.isNone(destination)) return Effect.succeed(false); if (!awaitingShellConsent) return Effect.succeed(telemetryConfig.enabled); if (hostEnvironment.T3CODE_DESKTOP_SHELL_DISCOVERY_PENDING === "1") return Effect.succeed(false); @@ -206,12 +207,12 @@ export const make = Effect.gen(function* () { const sendBatch = Effect.fn("AnalyticsService.sendBatch")(function* ( events: ReadonlyArray, ) { - if (!(yield* telemetryEnabled)) return; + if (!(yield* telemetryEnabled) || Option.isNone(destination)) return; const { distinctId, installId } = yield* telemetryIdentity; if (!distinctId) return; const payload = { - api_key: telemetryConfig.posthogKey, + api_key: destination.value.apiKey, batch: events.map((event) => ({ uuid: event.uuid, event: event.event, @@ -236,7 +237,7 @@ export const make = Effect.gen(function* () { })), }; - yield* HttpClientRequest.post(`${telemetryConfig.posthogHost}/batch/`).pipe( + yield* HttpClientRequest.post(`${destination.value.host}/batch/`).pipe( HttpClientRequest.bodyJson(payload), Effect.flatMap(httpClient.execute), Effect.flatMap(HttpClientResponse.filterStatusOk), diff --git a/docs/user/telemetry.md b/docs/user/telemetry.md index 68fce277b7559..7335258823f38 100644 --- a/docs/user/telemetry.md +++ b/docs/user/telemetry.md @@ -1,13 +1,13 @@ # Product usage data -Product usage events and relay connection traces are off unless you opt in. Set -`T3CODE_TELEMETRY_ENABLED=true` in the server's environment to turn them on. - -When enabled, the T3 Code server sends product usage events to T3 Code's own endpoint at `ingest.t3.codes`, -associated with a hashed account or installation identifier. To count how many installations one person -uses, the server also sends hashed account identifiers: your T3 Connect account, your OpenAI and -Claude accounts when you are signed in, and a random identifier for each device that connects. The endpoint keeps a copy of each -event and forwards events to PostHog. Events include the provider, model, reasoning effort, +Product usage events and relay connection traces are off unless you opt in. Product usage events +have no default destination: set `T3CODE_TELEMETRY_ENABLED=true` together with `T3CODE_POSTHOG_HOST` +and `T3CODE_POSTHOG_KEY` for a PostHog-compatible endpoint you choose. + +When enabled, the T3 Code server sends product usage events to that endpoint, associated with a +hashed account or installation identifier. To count how many installations one person uses, the +server also sends hashed account identifiers: your T3 Connect account, your OpenAI and Claude +accounts when you are signed in, and a random identifier for each device that connects. Events include the provider, model, reasoning effort, permission mode, turn and request results, duration, release channel, and token counts when available. Child-agent token counts are reported separately from the main agent's. Events include the model ID the provider used, including custom models and models served by a custom endpoint. From 6dd67e2629c3a110da89b5a43d00a3d44b6a433a Mon Sep 17 00:00:00 2001 From: Yordis Prieto Date: Tue, 24 Nov 2026 12:05:45 -0500 Subject: [PATCH 3/3] chore(server): keep upstream telemetry defaults for reference Signed-off-by: Yordis Prieto --- apps/server/src/telemetry/AnalyticsService.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/apps/server/src/telemetry/AnalyticsService.ts b/apps/server/src/telemetry/AnalyticsService.ts index 5f7996c3dea18..826035660b7c6 100644 --- a/apps/server/src/telemetry/AnalyticsService.ts +++ b/apps/server/src/telemetry/AnalyticsService.ts @@ -66,6 +66,9 @@ function retryDelayMs(failures: number, random: number): number { const TelemetryEnvConfig = Config.all({ // No default destination: opting in sends nothing until the user names their own endpoint. + // Upstream defaults, kept for reference: + // posthogKey: Config.String("T3CODE_POSTHOG_KEY").pipe(Config.withDefault("phc_XOWci4oZP4VvLiEyrFqkFjP4CZn55mjYYBMREK5Wd6m")), + // posthogHost: Config.String("T3CODE_POSTHOG_HOST").pipe(Config.withDefault("https://ingest.t3.codes")), posthogKey: Config.String("T3CODE_POSTHOG_KEY").pipe(Config.option), posthogHost: Config.String("T3CODE_POSTHOG_HOST").pipe(Config.option), enabled: Config.Boolean("T3CODE_TELEMETRY_ENABLED").pipe(Config.withDefault(false)),