Crates.io | tauri-plugin-sentry |
lib.rs | tauri-plugin-sentry |
version | 0.2.0 |
source | src |
created_at | 2024-10-19 11:17:04.535742 |
updated_at | 2024-10-19 21:13:35.279727 |
description | An experimental Tauri Plugin for Sentry |
homepage | |
repository | https://github.com/timfish/sentry-tauri |
max_upload_size | |
id | 1415271 |
size | 388,984 |
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.1"
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!(),
..Default::default()
},
));
// Caution! Everything before here runs in both app and crash reporter processes
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-viewbeforeSend
and beforeBreadcrumb
hooks that intercept events and
breadcrumbs and passes them 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