Skip to content

fix(telemetry): make telemetry opt-in and anonymize install ID - #61

Merged
Patel230 merged 1 commit into
mainfrom
fix/telemetry-privacy-optin
Aug 3, 2026
Merged

fix(telemetry): make telemetry opt-in and anonymize install ID#61
Patel230 merged 1 commit into
mainfrom
fix/telemetry-privacy-optin

Conversation

@Patel230

@Patel230 Patel230 commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Problem

Phase 3 medium audit finding (C5): the CLI's detached telemetry:

  • Used a hardware-derived machine ID (machineid.ProtectedID("trace-cli")) as the PostHog distinct_id, so events could be correlated to a physical machine across installs.
  • Was opt-out only (TRACE_TELEMETRY_OPTOUT) — telemetry was ON by default for every user.

Fix

  • Replace the hardware machine ID with anonymousID(): a random 128-bit value generated on first use and cached at os.UserConfigDir()/trace/telemetry-id (dir 0700, file 0600). Stable per install, not correlated to hardware.
  • Make telemetry opt-in: only sent when TRACE_TELEMETRY_OPTIN=1 is set. The legacy TRACE_TELEMETRY_OPTOUT still force-disables regardless.
  • Extract a sendDetached dispatch var so tests can assert dispatch behavior without spawning subprocesses.
  • userConfigDir is now a var so tests isolate the ID file from the real user config dir (relevant on macOS where XDG_CONFIG_HOME is ignored).
  • Drop the now-unused github.com/denisbrodbeck/machineid dependency.

Tests

  • TestTrackCommandDetachedRespectsOptOut — opt-out wins over opt-in
  • TestTrackCommandDetachedDisabledByDefault — no opt-in ⇒ no dispatch
  • TestTrackCommandDetachedEnabledWithOptIn — opt-in ⇒ exactly 1 dispatch
  • TestTrackPluginDetachedDisabledByDefault / TestTrackPluginDetachedEnabledWithOptIn
  • Existing payload serialization tests unchanged

Verified: go build ./..., go vet ./..., go test ./... all green.

@Patel230
Patel230 force-pushed the fix/telemetry-privacy-optin branch from bf4654a to 4d823f9 Compare August 3, 2026 00:30
@Patel230
Patel230 merged commit 1cd0fc5 into main Aug 3, 2026
13 checks passed
@Patel230
Patel230 deleted the fix/telemetry-privacy-optin branch August 3, 2026 00:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant