Integrate Sentry error tracking across Electron and Rust#7643
Integrate Sentry error tracking across Electron and Rust#7643
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 329a5ec0a9
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f5fc8531c3
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d0571a735a
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ca5bc55a62
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
- Add @sentry/electron to the desktop app (main, preload, renderer) - Add sentry crate to goose-server with tower layers for distributed tracing - Tag events with environment (production for packaged app, development otherwise) - Pass GOOSE_ENVIRONMENT from Electron to goosed for consistent environment tagging - Configure Vite to properly bundle @sentry/electron in preload and main builds
- Electron main: use beforeSend to drop events until telemetry is confirmed enabled - Electron renderer: same beforeSend gate, enabled alongside existing analytics flag - Rust: skip Sentry init entirely when telemetry is disabled (empty DSN) - Respects GOOSE_TELEMETRY_OFF env var and GOOSE_TELEMETRY_ENABLED config
Remove the hard-coded Sentry DSN from source code and instead inject it
via the SENTRY_DSN environment variable at build time. This ensures that
cloned/forked builds don't send errors to our Sentry project, while
official release and canary builds get the DSN from a GitHub Actions
secret.
- Rust: use option_env!("SENTRY_DSN") for compile-time injection
- Electron: use process.env.SENTRY_DSN via Vite define block
- CI: pass SENTRY_DSN secret through release and canary workflows
- Cross.toml: add SENTRY_DSN to passthrough for cross-compiled builds
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Disable sentry's default features (which pull in native-tls/openssl-sys) and explicitly enable the needed features with rustls instead, matching the rest of the codebase which uses rustls with aws_lc_rs. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sentry was only initialized when is_telemetry_enabled() was true at process startup, so first-run sessions (where the user opts in after goosed starts) silently dropped all backend errors and traces. Mirror the Electron pattern: always init Sentry when a DSN is present but use before_send / traces_sampler hooks that re-evaluate consent on every event, so opt-in (and opt-out) take effect immediately without restart. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
TelemetrySettings treated null (no choice yet) as enabled, while renderer.tsx and the Rust backend both treat it as disabled. This caused the Settings toggle to show "on" even though telemetry was actually off for the session. Use value === true consistently. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Both renderer and main process called Sentry.init() at import time, which started collecting breadcrumbs and scope data before the user consented. The beforeSend hooks only filtered at send time, so the first post-consent error could include pre-consent breadcrumbs. Defer Sentry.init() into an ensureSentryInitialized() guard that runs only when setSentryTelemetryEnabled(true) / enableSentryTelemetry(true) is called. This ensures no data is collected before consent. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Clean install to ensure all platform-specific optional dependencies are present in the lockfile, fixing CI validation failure. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 61c5fb6dbd
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
Use app.getVersion() and app.isPackaged instead of process.env vars that are only set during npm scripts. This ensures packaged desktop builds report the correct release version and production environment. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3bd880b47d
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
is_telemetry_enabled() calls Config::get_param() which reads and parses the config file from disk on every invocation. In the Sentry traces_sampler callback this runs on every transaction, adding unnecessary latency. Cache the result in an AtomicBool with a 5-second TTL so consent changes still take effect promptly. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 80323f02e9
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
Replace the TTL-based cache with a Lazy<AtomicBool> that is initialised once from config and updated immediately via set_telemetry_enabled() whenever the telemetry key is written through the /config/upsert, /config/remove, or CLI configure paths. This gives hot paths (Sentry before_send / traces_sampler) zero disk I/O while ensuring opt-in and opt-out take effect instantly. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b542d0ad89
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
The env-var kill switch is a hard disable. Prevent config writes from re-enabling telemetry when GOOSE_TELEMETRY_OFF is set. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Summary
Adds Sentry error tracking across the full stack — Electron desktop app and Rust backend — with the DSN injected at build time so it never appears in source code.
Sentry integration (Electron + Rust)
@sentry/electron/maininitialized at app startup@sentry/electron/preloadimported for IPC bridge between main and renderer@sentry/electron/rendererinitialized for frontend error capturesentrycrate withtower,tower-http, andtracingfeatures;NewSentryLayerandSentryHttpLayeradded to axum for distributed tracingTelemetry consent gating
beforeSend/beforeSendTransactionhooks (Electron) andis_telemetry_enabled()check (Rust)Build-time DSN injection
The Sentry DSN is not hard-coded in source. Instead, it's injected at build time via the
SENTRY_DSNenvironment variable:option_env!("SENTRY_DSN")reads the env var at compile time; if unset, Sentry is fully disabledprocess.env.SENTRY_DSNinjected via Vitedefineblock; if empty, Sentry SDK initializes in disabled modeSENTRY_DSNpassed as a GitHub Actions secret through release and canary workflows to all bundle-desktop reusable workflowsSENTRY_DSNadded toCross.tomlpassthrough list for Linux cross-compiled buildsThis means:
SENTRY_DSNsecret)SENTRY_DSN=... cargo build)Environment tagging
GOOSE_ENVIRONMENTenv var when spawning goosed (productionfor packaged app,developmentotherwise)GOOSE_ENVIRONMENT, defaulting todevelopmentif unsetSetup required
After merging, add a repository secret named
SENTRY_DSNwith the DSN value.Test plan
cargo check -p goose-servercompiles withoutSENTRY_DSNset (no DSN baked in)SENTRY_DSN=test cargo check -p goose-servercompiles with DSN baked inSENTRY_DSNis not set🤖 Generated with Claude Code