Skip to content

feat(cli): add opt-in anonymous PostHog EU telemetry - #6

Merged
lucasbraum merged 2 commits into
mainfrom
codex/opt-in-telemetry
Oct 4, 2026
Merged

lucasbraum merged 2 commits into
mainfrom
codex/opt-in-telemetry

Conversation

@lucasbraum

Copy link
Copy Markdown
Collaborator

Adds anonymous CLI telemetry with explicit consent. The first eligible interactive command asks once, defaults to no, and saves that choice. uptide telemetry on|off|status|show manages the preference and lets users inspect the last sanitized event. UPTIDE_TELEMETRY=0 always disables collection; CI requires UPTIDE_TELEMETRY=1 even when local consent is saved.

Privacy and delivery

  • Reconstruct an allowlisted payload: random installation ID, HMAC repository hash with a secret per-install salt, command/version, proven public npm versions, aggregate counts, verification result, durations, cost and exit status. No source, paths, repo/user names, arguments, diagnostics or credentials are serialized.
  • Add provenance to existing npm metadata cache entries. Only unauthenticated public npm responses prove a package/version eligible; custom/authenticated registries and older unproven cache entries are omitted. Telemetry performs no extra registry lookup.
  • Plain HTTPS capture to PostHog EU, without an SDK. Explicit $ip: null, $geoip_disable: true and $process_person_profile: false.
  • Send through a detached process with a 750 ms absolute deadline. No retries, redirects, flush waits or telemetry failures affecting the command. Turning off telemetry clears local IDs, salt and the last event.
  • Update README, CLI help, security/contributor docs, release docs, Docker smoke coverage and a minor changeset.

Release configuration

Both manual release workflows now read the write-only capture key from the UPTIDE_TELEMETRY_BUILD_KEY repository secret and embed the EU host. No real key is committed; builds without a key send nothing. UPTIDE_TELEMETRY_HOST overrides the HTTPS origin for testing.

Before setting the release secret, the project owner must enable Discard client IP data and arrange/verify automatic deletion after 90 days in PostHog EU. The CLI cannot enforce server retention, and this PR does not configure the remote project. docs/telemetry.md documents the exact fields, controls, local storage and deployment requirements.

Validation

  • pnpm lint, pnpm typecheck, pnpm test: passed.
  • Final focused privacy/telemetry/README run: 36 tests passed, including payload injection, private package omission, consent/CI precedence, HTTPS capture, stalled receiver, refused connection and redirect handling.
  • pnpm smoke 22: all assertions passed in Docker across npm, npm workspaces, pnpm, Yarn classic and Yarn Berry; includes telemetry controls with forced opt-out.
  • pnpm public:check: clean with the external denylist loaded only into the command environment.
  • Real TTY test: Enter saves no without creating identifiers; the next run does not prompt.
  • Built CLI against a local HTTPS collector that never answered: five off/on runs had identical output and exit status, with all five opted-in events captured locally. No events were sent to PostHog.
Missing-package check (exit 2) Five foreground durations Median
Telemetry off 171, 168, 166, 167, 197 ms 168 ms
Telemetry on, collector stalled 170, 168, 169, 169, 190 ms 169 ms

These timings demonstrate that foreground completion does not wait for the sender's network deadline; they are a local smoke measurement, not a general performance guarantee.

@lucasbraum
lucasbraum merged commit 1000909 into main Oct 4, 2026
4 checks passed
@lucasbraum
lucasbraum deleted the codex/opt-in-telemetry branch October 4, 2026 18:17
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