Crates.io | tauri-plugin-sentry |
lib.rs | tauri-plugin-sentry |
version | |
source | src |
created_at | 2024-10-19 11:17:04.535742+00 |
updated_at | 2025-01-20 19:45:36.807382+00 |
description | An experimental Tauri Plugin for Sentry |
homepage | |
repository | https://github.com/timfish/sentry-tauri |
max_upload_size | |
id | 1415271 |
Cargo.toml error: | TOML parse error at line 23, column 1 | 23 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include` |
size | 0 |
tauri-plugin-sentry
A 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
and sentry-rust-minidump
are re-exported by sentry-tauri
so you
don't need to add them as dependencies.
Add tauri-plugin-sentry
to dependencies in Cargo.toml
:
[dependencies]
tauri-plugin-sentry = "0.4"
Run one of these commands to add the capabilities:
npm run tauri add sentry
yarn run tauri add sentry
pnpm tauri add sentry
cargo tauri add sentry
however, 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 tauri_plugin_sentry::{minidump, 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 = 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