| Crates.io | tauri-plugin-sentry |
| lib.rs | tauri-plugin-sentry |
| version | 0.5.0 |
| created_at | 2024-10-19 11:17:04.535742+00 |
| updated_at | 2025-09-03 11:55:38.162078+00 |
| description | An experimental Tauri Plugin for Sentry |
| homepage | |
| repository | https://github.com/timfish/sentry-tauri |
| max_upload_size | |
| id | 1415271 |
| size | 529,385 |
tauri-plugin-sentryA Sentry plugin for Tauri v2.
It's perfectly reasonable to use Sentry's Rust and browser SDKs separately in a Tauri app. However, this plugin passes browser breadcrumbs and events through the Rust backend which has a number of advantages:
sentry-rust-minidump is re-exported by sentry-tauri so you don't need to add
it as dependencies.
Add sentry and tauri-plugin-sentry to dependencies in Cargo.toml:
[dependencies]
sentry = "0.42"
tauri-plugin-sentry = "0.5"
Run one of these commands to add the capabilities:
npm run tauri add sentryyarn run tauri add sentrypnpm tauri add sentrycargo tauri add sentryhowever, make sure that you have sentry:default in your capabilities:
{
"$schema": "./../gen/schemas/windows-schema.json",
"identifier": "main",
"local": true,
"windows": [
"main"
],
"permissions": [
"sentry:default" // <- important
]
}
This example also shows usage of
sentry_rust_minidump which
allows you to capture minidumps for native crashes from a separate crash
reporting process.
use sentry;
use tauri_plugin_sentry;
pub fn run() {
let client = sentry::init((
"__YOUR_DSN__",
sentry::ClientOptions {
release: sentry::release_name!(),
auto_session_tracking: true,
..Default::default()
},
));
// Caution! Everything before here runs in both app and crash reporter processes
#[cfg(not(target_os = "ios"))]
let _guard = tauri_plugin_sentry::minidump::init(&client);
// Everything after here runs in only the app process
tauri::Builder::default()
.plugin(tauri_plugin_sentry::init(&client))
.run(tauri::generate_context!())
.expect("error while running tauri app");
}
The Plugin:
@sentry/browser in every web-viewtransport and beforeBreadcrumb hook that passes events and
breadcrumbs to the Rust SDK via the Tauri invoke APIserde + existing Sentry Rust types = Deserialisation mostly Just
Works™️By default the plugin injects a pre-minified version of @sentry/browser. If
you want to configure Sentry in the browser yourself, you can disable the
injection and pass the default config to Sentry.init.
Disable automatic injection:
tauri::Builder::default()
.plugin(tauri_plugin_sentry::init_with_no_injection(&client))
.run(tauri::generate_context!())
.expect("error while running tauri app");
import { defaultOptions } from "tauri-plugin-sentry-api";
import * as Sentry from "@sentry/browser";
Sentry.init({
...defaultOptions,
/**
* Your custom configuration here
*/
});
Clone this repository and install dependencies:
> yarn install
In examples/basic-app/src-tauri/src/main.rs replace the DSN with your DSN
Run in development mode:
> yarn example