fix(cli): stop error tracking minting a new issue per "not logged in"

Merged
PO
2mo ago
+28-2

Summary

Recurrence of the alert noise fixed in #2885 — the shipped code is intact, but that PR's follow-up list named two gaps and neither was closed. Every time someone runs the CLI without capgo login, error tracking still mints a brand-new issue (top 30 fingerprints for this message are almost all a count of one). This closes both gaps.

  • Who it hurts: the team, via a "new issue created" alert per occurrence for what is just someone who never logged in.
  • findSavedKey "not logged in" throw is now a CliUserError (which shouldCapturePosthogException already filters) instead of a bare Error. Its text matched none of the expected-user-error markers, so it was waved straight through to error tracking.
  • Message is now static — dropped the interpolated package-manager runner, so one condition renders as one value (npx / pnpm dlx users no longer see two different strings).
  • Fingerprint drops the top stack frame's function/filename. Bundles are minified, so the top frame is a per-build, per-call-site symbol (T0, CDA, …) — proven by six distinct fingerprints on cli_version 8.32.7 alone. It now keys only on the stable command path, error kind, error name and exit status.
-    topFrame?.function || payload.functionName,
-    topFrame && 'filename' in topFrame ? topFrame.filename : 'unknown',
     String(payload.status ?? 1),

Test plan

  • bun test/test-posthog-exception.mjs — extended to assert the new fingerprint shape, that two occurrences with different minified top frames collapse to one fingerprint, and that the "not logged in" CliUserError is skipped by exception capture.
  • bun run typecheck and bun run lint pass.

Screenshots

N/A — no user-visible UI change; the only user-facing effect is a slightly clearer, consistent CLI error message.

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

Agent context

Confirmed no competing work: no open PR, recent branch, or assigned issue touches the fingerprint logic, the error markers, or the findSavedKey throw. The two open PRs touching these files (#2906, #2703) only import findSavedKey.


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.