Sentry Telemetry Integration
Relevant source files
The following files were used as context for generating this wiki page:
Keynobi implements a dual-layer Sentry telemetry system to provide crash and error reporting for both the Rust backend and the SolidJS frontend. The integration is designed with a "privacy-first" approach, requiring explicit user opt-in and performing extensive data scrubbing before any event is transmitted. Telemetry is gated by runtime settings and compile-time features, ensuring that only builds intended for distribution with an embedded Data Source Name (DSN) can report events.
Sources: src/lib/telemetry/sentry-web.ts:1-12, src-tauri/src/services/telemetry_sentry.rs:1-15
Architecture Overview
The integration is split into two distinct implementations:
- Native (Rust) Layer: Handles crashes, panics, and internal errors in the Tauri backend using the
sentrycrate. - Web (Frontend) Layer: Captures rendering errors and exceptions within the WKWebView using
@sentry/browser.
Both layers share a common runtime configuration via the application settings, where "Anonymous crash reporting" must be enabled by the user.
Telemetry Initialization Flow
The following diagram illustrates how the system determines whether to initialize the Sentry clients at runtime.
Implementation Details
Native Layer (Rust)
The native integration is an optional feature defined in Cargo.toml. It requires the telemetry feature flag and a compile-time environment variable SENTRY_DSN.
- Feature Flag:
telemetry = ["sentry"]inCargo.toml. - Initialization: Managed in
src-tauri/src/lib.rsduring the Tauri setup phase. - Security: The backend client only starts at launch if telemetry is already enabled. Changes in settings require an app restart to initialize the native client.
Sources: src-tauri/Cargo.toml:47, src-tauri/src/lib.rs:135-141, src-tauri/src/commands/telemetry.rs:16-22
Web Layer (SolidJS)
The frontend uses a reactive effect to synchronize the Sentry client state with the user's settings.
- Dynamic Sync: Unlike the native layer, the web client can be initialized or closed dynamically without a restart using
syncSentryWebWithTelemetry(). - Reactive Hook:
createEffectinApp.tsxmonitorssettingsState.telemetry.enabledto trigger initialization.
Sources: src/lib/telemetry/sentry-web.ts:103-138, src/App.tsx:93-97
Privacy and Data Scrubbing
A core principle of the integration is the total removal of Personally Identifiable Information (PII) and local file paths.
Scrubbing Rules
| Data Type | Action | Implementation |
|---|---|---|
| User Info | Set to null/undefined | event.user = None |
| Paths | Redacted to base filename | scrub_frame / scrubWebFrameFilename |
| Contexts | Cleared or limited | scrub_contexts / event.request = undefined |
| Breadcrumbs | Dropped entirely | beforeBreadcrumb returns null |
| Home Dirs | Replaced with <redacted> | scrub_string using dirs::home_dir() |
Sources: src-tauri/src/services/telemetry_sentry.rs:88-142, src/lib/telemetry/sentry-web.ts:36-74
Native Scrubbing Logic
The Rust implementation redacts specific macOS patterns, such as per-user temp roots (/var/folders/...). It also strips absolute paths from stack frames, keeping only the filename.
pub fn scrub_string(input: &str, home: Option<&str>) -> String {
let mut out = input.to_string();
if let Some(h) = home {
out = out.replace(h, "<redacted>");
}
// Redact macOS temp folders
if let Ok(re) = regex::Regex::new(r"/var/folders/[^/\s]+/[^/\s]+/T/[^\s]+") {
out = re.replace_all(&out, "<redacted>").into_owned();
}
out
}
Sources: src-tauri/src/services/telemetry_sentry.rs:32-45
Build and Release Configuration
Telemetry is injected during the build process. Production binaries are built with specific environment variables that are captured by the compiler.
| Variable | Target | Purpose |
|---|---|---|
SENTRY_DSN | Rust (Backend) | Embedded via option_env! in the binary. |
VITE_SENTRY_DSN | Web (Frontend) | Injected into the Vite bundle. |
SENTRY_AUTH_TOKEN | CI/CD | Used to upload frontend source maps during release. |
Release Workflow
The release process automatically builds DMGs with the telemetry feature enabled. If the DSN secrets are missing in the CI environment, the build still succeeds, but the telemetry layers remain inert.
Sources: RELEASING.md:41-55, vite.config.ts:25-45
Diagnostics and Testing
Developers can verify the integration using the command palette (Cmd+Shift+P) in development builds.
- Native Test: Invokes
send_native_sentry_test_event. It checks if the build has a DSN, if the feature is enabled, and if the client is active before sending anInfolevel message. - Web Test: Uses
captureSentryExceptionto send a simulated rendering error.
Diagnostic Flow
Conclusion
The Sentry Telemetry Integration in Keynobi provides a robust mechanism for monitoring application health across both native and web layers. By prioritizing privacy through aggressive data scrubbing and requiring explicit user opt-in, the system balances the need for diagnostic data with user confidentiality. The use of compile-time DSN injection and CI-integrated source map uploads ensures that production releases are fully supported for crash analysis.