fix(cli): stop error-tracking noise from duplicate-version uploads

Merged
PO
3mo ago
+43-20

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 $exception issue on every run, crowding out real CLI crashes.
  • Last week's fix added CliUserError + a type filter in shouldCapturePosthogException, but Version X already exists was never wired into it: uploadFail threw a bare Error, 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:

AreaBeforeAfter
Upload abortsuploadFail throws bare Error → capturedthrows CliUserError → filtered by type
Plan-upgrade checks + app addbare Error → capturedCliUserError → filtered
Fingerprintfn:kind:name:symbol:filename:statusfn:kind:name:status
Graceful-exit warningnames --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') and Upload cancelled by user are not captured; fingerprint no longer contains the symbol or filename.
  • bun test/test-init-app-conflict.mjs — isAppAlreadyExistsError still matches the reworded app add error (id moved to context, "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 --noEmit and oxlint clean.

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.


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.