fix(cli): stop error-tracking noise from duplicate-version uploads
Merged
PO
3mo ago+43+43+01234567890123456789-20-20-01234567890123456789
Summary
- Who it hurts: the team, not the user. A duplicate-version
bundle upload— a normal outcome the user fixes by bumping the version — still minted an error-tracking$exceptionissue on every run, crowding out real CLI crashes. - Last week's fix added
CliUserError+ a type filter inshouldCapturePosthogException, butVersion X already existswas never wired into it:uploadFailthrew a bareError, which the message-substring filter never matched. - The fingerprint made it worse — it hashed the minified top-frame symbol and the full install path, so the same abort split into a fresh issue per npx cache hash, bunx, pnpm store, and release.
Two small changes:
| Area | Before | After |
|---|---|---|
| Upload aborts | uploadFail throws bare Error → captured | throws CliUserError → filtered by type |
Plan-upgrade checks + app add | bare Error → captured | CliUserError → filtered |
| Fingerprint | fn:kind:name:symbol:filename:status | fn:kind:name:status |
| Graceful-exit warning | names --silent-fail (does not exist) | names --version-exists-ok |
Behaviour kept intact: non-zero exit, the printed message, and the trackCommandFailed analytics events. Only the $exception capture goes away.
Why drop the frame instead of normalizing it: the CLI ships as one minified dist/index.js, so the top-frame symbol is renamed on every release and every frame's filename is the same install-path-prefixed index.js. Neither carries stable, discriminating signal — the command path, error kind, error name, and exit status do.
Test plan
bun test/test-posthog-exception.mjs— added cases:CliUserError('Version X already exists')andUpload cancelled by userare not captured; fingerprint no longer contains the symbol or filename.bun test/test-init-app-conflict.mjs—isAppAlreadyExistsErrorstill matches the rewordedapp adderror (id moved tocontext,"already exists"kept in the message).bun test/test-plan-validation.mjs,bun test/test-trial-warning.mjs,bun test/test-analytics-error-category.mjs,bun test/test-app-created-source.mjs— all pass.tsgo --noEmitandoxlintclean.
Screenshots
Not applicable — no visible CLI output changes except the corrected --version-exists-ok flag name in one warning line.
Checklist
- My code follows the code style of this project and passes
bun run lint:backend && bun run lint. - My change requires a change to the documentation.
- I have updated the documentation accordingly.
- My change has adequate E2E test coverage.
- I have tested my code manually, and I have provided steps how to reproduce my tests
Created with PostHog Desktop from this inbox report.
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.