Skip to content

fix(telemetry): capture command errors to Sentry#145

Merged
betegon merged 1 commit intomainfrom
fix/capture-command-errors-to-sentry
Jan 31, 2026
Merged

fix(telemetry): capture command errors to Sentry#145
betegon merged 1 commit intomainfrom
fix/capture-command-errors-to-sentry

Conversation

@betegon
Copy link
Member

@betegon betegon commented Jan 31, 2026

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 withTelemetry catch block.

Changes

Adds Sentry.captureException(exc) in the exceptionWhileRunningCommand callback
in src/app.ts - this is where Stricli gives us access to the exception before
formatting it for display.

Test plan

Verified locally by adding a test throw and confirming the capture is called:

TEST_SENTRY_ERROR=1 bun run src/bin.ts help
# Output showed: [DEBUG] Capturing exception to Sentry: ...

Closes #146

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.
@github-actions
Copy link
Contributor

github-actions bot commented Jan 31, 2026

Semver Impact of This PR

🟢 Patch (bug fixes)

📋 Changelog Preview

This is how your changes will appear in the changelog.
Entries from this PR are highlighted with a left border (blockquote style).


Bug Fixes 🐛

Telemetry

  • Capture command errors to Sentry by betegon in #145
  • Capture command errors to Sentry by betegon in #145

🤖 This preview updates automatically when you update the PR.

@github-actions
Copy link
Contributor

Codecov Results 📊

✅ Patch coverage is 100.00%. Project has 1779 uncovered lines.
✅ Project coverage is 69.98%. Comparing base (base) to head (head).

Files with missing lines (24)
File Patch % Lines
human.ts 31.87% ⚠️ 682 Missing
resolve-target.ts 20.82% ⚠️ 251 Missing
oauth.ts 25.39% ⚠️ 191 Missing
api-client.ts 71.60% ⚠️ 146 Missing
resolver.ts 3.23% ⚠️ 120 Missing
errors.ts 5.94% ⚠️ 95 Missing
migration.ts 47.44% ⚠️ 82 Missing
api.ts 89.80% ⚠️ 47 Missing
seer.ts 75.54% ⚠️ 45 Missing
seer.ts 79.87% ⚠️ 30 Missing
preload.ts 39.02% ⚠️ 25 Missing
detector.ts 87.79% ⚠️ 16 Missing
schema.ts 64.10% ⚠️ 14 Missing
auth.ts 94.78% ⚠️ 7 Missing
utils.ts 97.59% ⚠️ 4 Missing
index.ts 95.06% ⚠️ 4 Missing
colors.ts 91.84% ⚠️ 4 Missing
telemetry.ts 97.16% ⚠️ 4 Missing
env-file.ts 97.17% ⚠️ 3 Missing
sentry-urls.ts 82.35% ⚠️ 3 Missing
alias.ts 98.56% ⚠️ 2 Missing
project-aliases.ts 97.40% ⚠️ 2 Missing
java.ts 97.22% ⚠️ 1 Missing
parser.ts 98.63% ⚠️ 1 Missing
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

@betegon betegon marked this pull request as ready for review January 31, 2026 21:02
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Fix in Cursor Fix in Web

@betegon betegon merged commit 8ecdaf6 into main Jan 31, 2026
25 checks passed
@betegon betegon deleted the fix/capture-command-errors-to-sentry branch January 31, 2026 21:10
betegon added a commit that referenced this pull request Jan 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Command errors not reported to Sentry

1 participant