fix(cli): redact two-segment app ids and use a stable install id for telemetry - #2947
Merged
riderx merged 1 commit intoAug 8, 2026
Conversation
…telemetry
Two telemetry-correctness fixes in cli/src/posthog.ts:
- Widen the app-id scrubber from `{2,}` to `{1,}` so two-segment ids
(com.phantom) get redacted, not only ids with three or more segments.
Raw customer app ids no longer reach the error-tracking title.
- Replace the `cli:<version>:<command>` distinct_id with an anonymous,
stable per-install id. It holds no personal data, is generated once and
persisted in the CLI config directory, and makes "users affected" count
real installs. The version and command name still ship as the
cli_version and function_name properties.
Generated-By: PostHog Code
Task-Id: 6afc8b8f-3bdd-416e-8e37-08261732fbce
riderx
marked this pull request as ready for review
August 8, 2026 17:42
riderx
deleted the
posthog-self-driving/fixcli-redact-2-segment-app-ids-and-fix-a3e2b5
branch
August 8, 2026 17:43
Contributor
Merging this PR will not alter performance
Comparing Footnotes
|
|
posthog-eu Bot
added a commit
that referenced
this pull request
Aug 9, 2026
A transient database failure in `getUserIdFromApikey` returned null, which the files service reported as `400 user_not_found`. The CLI showed users a bad-key message and opened an error-tracking issue for each failure. Backend: - `getUserIdFromApikey` now rethrows a query failure instead of returning null, so a backend blip surfaces as a 500, not a missing user. - `checkWriteAppAccess` returns `401 user_not_found` (was 400), matching how `invalid_apikey` behaves on the same route. CLI: - Add a shared `buildTusUploadError` helper that turns a tus failure into a real Error carrying the HTTP status, backend message, and request id. `uploadTUS` and the delta path (`partial.ts`) both use it, so the delta path no longer rejects the raw tus blob that leaked the URL and per-file object key. - The attached `.status` and the new `user_not_found` marker let `isExpectedUserError` classify the auth failure and skip error tracking. Merging this fix cuts a CLI release that also carries the earlier fixes (#2885, #2933, #2934, #2947) that no released build contains yet. Generated-By: PostHog Code Task-Id: c66eba6b-af49-4627-84ac-2c007ed83bc0
5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Summary
Two contained telemetry-correctness fixes in
cli/src/posthog.ts, both independent.Why
distinct_idwascli:<version>:<command>, not a person — so "users affected" on every CLI error-tracking issue counted version-by-command pairs, and each release minted a fresh synthetic person. Triage read that number as users when it never meant that.<app_id>scrubber matched only ids with three or more dot-separated segments, so two-segment ids reached the error title raw —App com.phantom already exists.cli/src/analytics/error-category.tspromises telemetry "never leaks error text, paths, or user input"; the exception path must hold to that too.Changes
(?:\.[\w-]+){2,}— needs 3+ segments(?:\.[\w-]+){1,}— redacts two-segment ids toodistinct_idcli:${version}:${command}cli_versionandfunction_nameproperties.Scope note: the CLI's usage-analytics events (
cli/src/analytics/track.ts) are actor-scoped through the Capgo backend by API key and org id — they carry no PostHogdistinct_id.capturePosthogExceptionis the only direct PostHog sender in the CLI, so the install id applies there.Test plan
bun run test:posthog-exception— updated to assert the anonymous UUIDdistinct_id(no version, no command), its persistence, and two-segment app-id redaction (App com.phantom already exists→App <app_id> already exists).bun run cli:lintbun run cli:typecheckbun run cli:buildScreenshots
Not applicable — telemetry payload change only, no user-facing output.
Checklist
bun run lint:backend && bun run lint.accordingly.
my tests
Agent context
cli/src/analytics/, not the PostHog exception path.{1,}widening rather than a narrower reverse-DNS match: over-redaction is the safe direction (it never leaks), and the message text is not part of the exception fingerprint, so it does not split issues.Created with PostHog Desktop from this inbox report.
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.