Add Sentry Bun SDK for error and performance monitoring - #13
Open
macuzi wants to merge 1 commit into
Open
Conversation
Initialize Sentry via a shared src/instrument.ts imported first in both process entry points (the CLI and the index-sources script). The DSN is read only from SENTRY_DSN and no-ops when unset, so the DSN never lives in source and the app runs normally without it. Capture and flush caught errors before process.exit in the ask command and indexing script, since the SDK's global handlers never see them and the process exits too fast for the background transport otherwise. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Installs and wires up
@sentry/bunfor error and performance monitoring across both process entry points (thebrendaCLI and theindex-sourcesscript).Changes
src/instrument.ts(new) — sharedinitSentry()that reads the DSN only fromSENTRY_DSNand no-ops when unset. Self-initializes on import.src/cli/index.ts/scripts/index-sources.ts—importthe instrument module first, before any other module (ES imports are hoisted, so import order is what guarantees Sentry initializes before instrumented code loads — the canonical Sentry ESM pattern).src/cli/commands/ask.ts/scripts/index-sources.ts—captureException+Sentry.flush(2000)beforeprocess.exit(1), since the SDK's global handlers never see swallowed errors and the process exits too fast for the background transport otherwise..env.example— documentsSENTRY_DSN=(empty) andSENTRY_ENVIRONMENT.Key decisions
.env.compare.tsleft alone — itsprocess.exit(1)paths are all expected user-input validation (bad hex), which would be noise. Genuine runtime errors there are still caught by the global handlersSentry.init()installs.@sentry/bun(not@sentry/node) — the app runs on the Bun runtime; the Bun SDK instruments Bun's native APIs and installs global error handlers automatically.Verification
bun test— 9 pass, 0 failSENTRY_DSNset → Sentry client is active; without it → no client (no-op, app runs normally)brenda --helpstarts cleanly (no startup regression)To activate
Add a DSN to
.env:🤖 Generated with Claude Code