npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

tauri-plugin-sentry-api

v0.2.0

Published

Tauri Plugin for Sentry

Downloads

236

Readme

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:

  • Browser events are enriched with Rust, OS and device context
    • Events from both Rust and browser will have the same context for filtering
  • Breadcrumbs are merged from both the Rust and browser SDKs
    • See what was happening in the Rust backend and the browser frontend at the time of the event

Installation

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: npm run tauri add sentry
  • yarn: yarn run tauri add sentry
  • pnpm: pnpm tauri add sentry
  • cargo: cargo tauri add sentry

however, make sure that you have sentry:default in your capabilities:

src-tauri/capabilities/*.json
{
  "$schema": "./../gen/schemas/windows-schema.json",
  "identifier": "main",
  "local": true,
  "windows": [
    "main"
  ],
  "permissions": [
    "sentry:default" // <- important
  ]
}

Usage

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:

  • By default injects and initialises @sentry/browser in every web-view
  • Includes beforeSend and beforeBreadcrumb hooks that intercept events and breadcrumbs and passes them to the Rust SDK via the Tauri invoke API
  • Tauri + serde + existing Sentry Rust types = Deserialisation mostly Just Works™️

Custom Sentry Browser Configuration

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
   */
});

Example App

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