question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

What is the right way to setup Sentry Electron SDK with Vite & Vue 3

See original GitHub issue

Versions + Platform

  • SDK version - @sentry/electron@v3.0.7
  • Electron version - electron@v19.0.8
  • Platform - macOS

Description

I am using @sentry/vue package to collect exceptions from renderer process, it is not very straightforward and I have to revise the Sentry event before sending it to server, otherwise source mapping doesn’t work.

import * as Sentry from '@sentry/vue';
Sentry.init({
  app,
  dsn: __SENTRY_DSN__,
  release: __SENTRY_RELEASE__,
  beforeSend: (event: Sentry.Event, hint: Sentry.EventHint) => {

    // update the stacktrace before sending it to Sentry, this will strip out the asar path - i.e. those between two brackets:
    // file:///[myapp.app/Contents/Resources/app.asar/]packages/renderer/dist/index.f3984842.js

    if (event.exception?.values) {
      event.exception.values = event.exception.values.map(e => {
        if (e.stacktrace?.frames) {
          e.stacktrace.frames = e.stacktrace.frames.map(f => {
            if (f.filename) {
              f.filename = f.filename.replace(/.*app\.asar/, 'app://');
            }
            return f;
          });
        }
        return e;
      });
    }
    return event;
  },
});

It works with this approach but I would like to check if there is an easier / better way available. I firstly tried @sentry/electron package but it doesn’t capture exceptions in renderer process for me, maybe it is because I am using Vue 3 and not vanilla.

My other question is, it seems the exceptions in renderer process won’t be printed in console anymore once they are reported to Sentry, is this an intended behavior?

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:10

github_iconTop GitHub Comments

1reaction
timfishcommented, Sep 7, 2022

Today I upgraded @sentry/electron to 4.0.0, and sentry/vue to 7.12.1

v4.0.0 of the Electron SDK uses 7.8.1 of the JavaScript SDKs.

We should probably include this version in the readme so it’s obvious from npm!

1reaction
timfishcommented, Jul 9, 2022

As everything is now sent from the main process, would BrowserTracing still work?

Yes, BrowserTracing still works, the transaction is just passed through the main process.

Type 'EventToMain' is not assignable to type 'Integration'.

This suggest that you have multiple versions of Sentry SDKs in your dependencies.

@sentry/electron is pinned to a specific version of the underlying JavaScript SDKs because it uses internal APIs that don’t follow semantic versioning.

If you are using the latest Electron SDK release (v3.0.7), you should use v6.19.2 of the @sentry/vue SDK.

v4 of the Electron SDK is on the way (watch this issue to get notified when the beta is published) and this is pinned to v7.3.1 on the JavaScript SDKs.

Unfortunately npm doesn’t appear to surface the dependency versions so the only easy way to get this version is to check package.json at a specific Git tag. I will add the underlying SDK version to the README so this level of digging isn’t required.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Set Up ELECTRON in Vite and Vue 3 - YouTube
In today's video we're going to taking a look at how to build a Vue 3 desktop application from your Vite app.To do...
Read more >
Vue - Sentry Documentation
On this page, we get you up and running with Sentry's SDK, so that it will automatically report errors and exceptions in your...
Read more >
Electron + Vue 3 + Vite Boilerplate - Made With Vue.js
Electron Vue Vite ​​ "This simple boilerplate provides a setup for desktop apps built with Electron, Vue 3 and Vite 2."
Read more >
Building a Vue 3 Desktop App with Vite and Electron - LearnVue
In this article, we're going to be taking a look at how to Vue 3 Desktop Project from a Vite app.
Read more >
Electron + Sentry: Monitoring your production app ... - Requestly
How to add sentry to your electron app? Create a new file sentryInit.js which initialize sentry for both main and renderer process using...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found