feat: Sentry error reporting across all three processes - #90
Merged
Conversation
Opt-out error reporting across the three processes the Electron app runs. The forked backend needs @sentry/node rather than @sentry/electron, and is both the process where the errors we care about happen and the one most likely to break when bundled.
Every package in packages/ has one; theiaext lint fails without it. The plan's scaffold task omitted it, so fix the plan too.
…reference The forked backend uses @sentry/node; Electron main and the renderer use @sentry/electron, bridged through a contributed preload module because Theia runs the renderer with contextIsolation. PreferenceChange omits newValue, so the writer re-reads the resolved preference instead - which also handles scope correctly.
Sentry only captures unhandled exceptions on its own, but the failures a user actually reports are caught and rendered as a chat message - so nothing was reporting them. That left the feature unable to answer the question that motivated it (#88). The language model now hands caught failures to an optional ErrorReporter. Policy stays with the code that understands the errors: CookbotError.isExpected excludes spent quotas, missing AI plans, dropped connections, expired sessions and context-window overflows, so real defects are not buried. The telemetry package supplies only the mechanism, and the injection is @optional() so the language model keeps working without it.
The original goal said 'unhandled errors', which would not have met the goal - Sentry's defaults never see the caught failures users report.
This was referenced Aug 13, 2026
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.
Adds opt-out error reporting to the packaged app. Closes #88.
Design:
docs/superpowers/specs/2026-08-12-sentry-error-reporting-design.mdPlan:
docs/superpowers/plans/2026-08-12-sentry-error-reporting.mdWhy
Diagnosing #86 (
Cookbot is busy right now) took a dive into the cookbot server source in a sibling checkout, because the editor persists no log and reports nothing.~/.theia/logs/<timestamp>/is created but never written to, and a Finder-launched app sendsconsole.errorto a stdout nobody captures.Note that server-side Sentry would not have caught it either: a quota rejection is an expected
tonic::Status, never an exception. The gap was specifically client-side.Three processes, two SDKs
The Electron app runs three processes, and the one that matters most is not covered by
@sentry/electron:@sentry/electron/main@sentry/electron/renderer(+ contributed preload bridge forcontextIsolation)fork()atelectron-main-application.ts:738)@sentry/node@sentry/nodeis pinned to10.67.0because@sentry/electron@7.16.0depends on that exact version; a mismatch loads two copies of@sentry/core.Four separate
theiaExtensionsentries, not one object with four keys — targets in the same entry replace rather than merge, which has silently dropped a module here before.Scope change during implementation
The spec said "unhandled errors". That would not have met its own goal. Sentry's defaults are
onUncaughtException+onUnhandledRejectiononly, and every Cookbot failure is caught and rendered as a chat message — so nothing would have been reported, and #88 would have stayed open with the feature apparently shipped.Fixed by handing caught failures over explicitly, with mechanism and policy separated:
ErrorReporterin the telemetry package. Carries no policy; no-ops when there is no client.CookbotError.isExpectedincooklang-ai, which owns the knowledge. Spent quota, plan without AI, dropped connection, expired session, context-window overflow and oversized message are normal outcomes and are not reported, or they would bury real defects.Injection is
@optional(), so the language model works without the telemetry extension (tested).The spec has been amended to record this rather than left describing something we didn't build.
Privacy
Opt-out via
cooklang.telemetry.errorReporting.enabled(takes effect on restart; the flag is mirrored to~/.theia/cook-telemetry.jsonbecause Sentry initialises before preferences exist, in two processes that have no preference service).Scrubbing uses an allowlist, not a denylist — a leak of recipe content cannot be undone:
~in exception values, stack frames (filenameandabs_path) and breadcrumbsauthToken/Authorization/sessionId/ bearer / JWT-shaped values →[redacted](CookbotGrpcClientholds a live token)extraandcontextsallowlisted, sorecipeContentandchatPromptare droppedrequestalways droppedSentry.setUser— anonymous crash data rather than per-user records. Correlating with server-side Sentry would be useful but is a separate privacy decision.Development builds stay silent unless
COOK_TELEMETRY_DEV=1.Verification
cooklang-ai(7 new for the report/don't-report policy), 28 incooklang-telemetrynpm run compile— 47 projects; lint cleanSentry.initactive: loads and starts clean. I checked this specifically because the backend bundle pulls inrequire-in-the-middle(Sentry's auto-instrumentation), the same dynamic-require pattern that broke protobufjs here before — no webpack externals entry is neededasarUnpackneeds no change:@sentry/node-nativeis an optional peer, so no native binary ships.dmginspected: 48cooklang-telemetry/libentries, 4645@sentry/*, and the packaged preload really calls the bridgeNot verified
Being explicit rather than implying a full pass:
COOKBOT_ADDRESSyieldsUNAVAILABLE, which the policy correctly treats as expected and does not report. ACook Editor: Send Test Errordiagnostic command would make this repeatable for every release — worth doing as a follow-up.npm run test:theiawas never run locally: Node 22+ disappeared from my machine mid-session, leaving only v20.19.1, which the guard from fix: makenpm run testrunnable and enforce it in CI #85 correctly refuses. Per-package runs pass. CI runs the full suite, so this PR is the first real check of that gate.