fix(server): Make telemetry configurable and 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 enabled-by-default to opt-in, which is a significant runtime behavior change affecting data collection. The scope of behavioral modification to the analytics system warrants human review. You can customize Macroscope's approvability policy. Learn more. |
b60f868 to
9f24d09
Compare
9f24d09 to
60a0857
Compare
d462374 to
38d97ef
Compare
9539b73 to
0ddc9f7
Compare
9cd7281 to
c0896eb
Compare
cbf171a to
09b184d
Compare
09b184d to
2f0ccf9
Compare
443f8f7 to
8379c93
Compare
8379c93 to
faa9ec0
Compare
b961b57 to
1b0e33c
Compare
There was a problem hiding this comment.
One Effect service-convention violation in the telemetry service. See inline comments.
Posted via Macroscope — Effect Service Conventions
f74a8e0 to
e430d5b
Compare
5de643e to
83a8eec
Compare
399dc84 to
cc577a7
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort 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 cc577a7. Configure here.
Address Bugbot review: gate telemetry identifier behind opt-in checks
cc577a7 to
36c175b
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 by default and expose a toggle in the Settings UI
telemetryEnabledandtelemetryPreferenceSetinServerSettings.AnalyticsServicereadsServerSettings.telemetryEnabledto gate all recording and flushing; events are buffered but not sent when disabled, and batches are re-queued on settings read failures or missing identifiers.T3CODE_TELEMETRY_ENABLED=truecan seed an opt-in when no saved preference exists, but cannot override an explicit user opt-out.normalizeDecodedPersistedServerSettingsdetects a previously persistedtelemetryEnabledvalue in raw JSON and markstelemetryPreferenceSet=true, preserving existing preferences across schema changes.Macroscope summarized 36c175b.
Note
Medium Risk
Changes default telemetry behavior and preference precedence (env vs persisted settings), which affects privacy expectations and existing installs that relied on implicit opt-in without the env var.
Overview
PostHog telemetry is opt-in by default instead of being enabled unless
T3CODE_TELEMETRY_ENABLED=false. Server settings gaintelemetryEnabledandtelemetryPreferenceSet, with load/patch helpers so a saved choice (including opt-out) sticks and legacysettings.jsonthat mentionstelemetryEnabledcounts as an explicit preference.AnalyticsServicenow decides whether to record, resolve an anonymous ID, or flush from persisted settings: disabled telemetry skips buffering and network I/O;T3CODE_TELEMETRY_ENABLED=truecan seed opt-in when no preference exists;falseforces off over a saved opt-in; explicit user opt-out is not overridden by env. Flush paths clear or retain buffers when telemetry turns off or settings/identifier reads fail; flush errors log at debug instead of error.The General Settings UI adds a Telemetry switch (sets preference on toggle), reset/restore-defaults handling via
buildRestoreDefaultsPatch, and CLI integration tests wire inServerSettingsService.layerTest().Reviewed by Cursor Bugbot for commit cc577a7. Bugbot is set up for automated code reviews on this repo. Configure here.