fix(telemetry): capture command errors to Sentry#145
Conversation
Stricli catches exceptions thrown in commands and doesn't re-throw them, so errors were never reaching the withTelemetry catch block. This adds Sentry.captureException in the exceptionWhileRunningCommand callback where Stricli gives us access to the exception.
Semver Impact of This PR🟢 Patch (bug fixes) 📋 Changelog PreviewThis is how your changes will appear in the changelog. Bug Fixes 🐛Telemetry
🤖 This preview updates automatically when you update the PR. |
Codecov Results 📊✅ Patch coverage is 100.00%. Project has 1779 uncovered lines. Files with missing lines (24)
Coverage diff@@ Coverage Diff @@
## main #PR +/-##
==========================================
+ Coverage 69.98% 69.98% —%
==========================================
Files 51 51 —
Lines 5926 5926 —
Branches 0 0 —
==========================================
+ Hits 4147 4147 —
- Misses 1779 1779 —
- Partials 0 0 —Generated by Codecov Action |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.
| exceptionWhileRunningCommand: (exc: unknown, ansiColor: boolean): string => { | ||
| // Report all command errors to Sentry. Stricli catches exceptions and doesn't | ||
| // re-throw, so we must capture here to get visibility into command failures. | ||
| Sentry.captureException(exc); |
There was a problem hiding this comment.
Expected user errors reported to Sentry as bugs
Medium Severity
The Sentry.captureException(exc) call reports all exceptions to Sentry, including expected CliError instances like authentication failures, validation errors, and missing context errors. These are user-facing errors by design (they have custom format() methods for friendly display), not bugs that need tracking. This will flood Sentry with noise and make actual bugs harder to identify. The capture call needs to exclude CliError instances.


Summary
Fixes a bug where errors thrown in CLI commands were never reported to Sentry.
Stricli catches command exceptions internally and does not re-throw them, so they
never reached the
withTelemetrycatch block.Changes
Adds
Sentry.captureException(exc)in theexceptionWhileRunningCommandcallbackin
src/app.ts- this is where Stricli gives us access to the exception beforeformatting it for display.
Test plan
Verified locally by adding a test throw and confirming the capture is called:
Closes #146