fix(server): Make telemetry opt in#3051
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
6737c77 to
5aaf1a4
Compare
5aaf1a4 to
b60f868
Compare
ApprovabilityVerdict: Needs human review This PR changes telemetry from opt-out to opt-in, fundamentally altering the default behavior for all users. While privacy-positive, the runtime behavior change and layer initialization ordering adjustments warrant human review to confirm intended product behavior. You can customize Macroscope's approvability policy. Learn more. |
b60f868 to
9f24d09
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 9f24d09. Configure here.
9f24d09 to
60a0857
Compare
da248f2 to
5af588c
Compare
Default PostHog telemetry to disabled unless T3CODE_TELEMETRY_ENABLED=true or the server setting enables it. When disabled, use a no-op analytics service without creating a telemetry identifier. Add the settings toggle for analytics, keep analytics wired to the same ServerSettingsService instance as the settings API, stop flushing buffered telemetry if the setting is disabled mid-run, and preserve buffered events when identifier resolution is temporarily unavailable.
5af588c to
8a8bf45
Compare


Summary
T3CODE_TELEMETRY_ENABLED=trueenvironment override for explicit opt-in.Addresses #1397.
Problem and Fix
T3CODE_TELEMETRY_ENABLED=false.recordandflushthrough the current telemetry setting and clear buffered events when telemetry is disabled.ERROR: Failed to flush telemetry.UI Changes
The new Telemetry setting appears in Settings near Diagnostics.
Screenshot is also available in this PR comment.
Validation
pnpm exec vp test run packages/contracts/src/settings.test.ts apps/server/src/serverSettings.test.ts apps/server/src/telemetry/Layers/AnalyticsService.test.tspnpm --filter @t3tools/web test:browser -- src/components/settings/SettingsPanels.browser.tsxpnpm exec vp run typecheckpnpm exec vp check(passed with existing unrelated lint warnings)pnpm run dist:desktop:linux.release/T3-Code-0.0.27-x86_64.AppImageand confirmed the Telemetry setting appears near Diagnostics with default value off.telemetryEnabledpersisted override, no fallbackanonymous-id, nosendBatchspans, and no current-run PostHog or telemetry flush log entries.telemetryEnabled: truewas persisted and successfulsendBatchspans were emitted.recordspans reached the telemetry gate but no newsendBatchspans were emitted after disabling telemetry again.Checklist
Note
Make telemetry opt-in via server settings and environment flag
telemetryEnabledto theServerSettingsandServerSettingsPatchschemas, defaulting tofalse.TelemetryEnvConfigdefault from enabled to disabled; telemetry is now only active when the env flag is set or the user enables it via settings.ServerSettingsServiceintomakeAnalyticsServiceso the analytics layer readstelemetryEnabledat flush/record time; when disabled, recording is a no-op and flush clears buffered events without sending.updateSettings({ telemetryEnabled })on change.Macroscope summarized 8a8bf45.
Note
Medium Risk
Changes default telemetry behavior for all deployments (privacy-sensitive) and alters when events and anonymous IDs are created, though gating is covered by new tests.
Overview
Makes anonymous PostHog telemetry opt-in instead of on by default, aligned with product messaging and a new Settings control.
Server & contracts: Adds persisted
telemetryEnabledtoServerSettings/ patches (defaults false, including legacy empty configs).T3CODE_TELEMETRY_ENABLEDnow defaults to false but still forces telemetry on when set true. The analytics layer depends onServerSettingsService, starts its settings watcher, and gatesrecordandflushon env override ortelemetryEnabled; when off it skips buffering/sending, clears the buffer on flush, resolves the anonymous id only when sending, and logs flush failures at debug instead of error. Runtime wiring movesServerSettingsLivealongsideAnalyticsServiceLayerLiveso analytics can read settings.UI: General Settings → About gets a Telemetry switch (“Share anonymous telemetry”), wired to
updateSettings, restore-defaults, and browser tests.Note: Existing installs that relied on the old default-on behavior will stop sending telemetry until users opt in or set the env flag.
Reviewed by Cursor Bugbot for commit 8a8bf45. Bugbot is set up for automated code reviews on this repo. Configure here.