Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plugin for Electron #634

Closed
arusakov opened this issue Jun 30, 2016 · 11 comments
Closed

Plugin for Electron #634

arusakov opened this issue Jun 30, 2016 · 11 comments

Comments

@arusakov
Copy link

arusakov commented Jun 30, 2016

Do we need it?
I can spend some time for that, because I'm setting up sentry for electron based app and source maps support is needed.
I think electron-plugin should only strip urls like react-native-plugin does it.

@benvinegar
Copy link
Contributor

Hey @arusakov – yeah, probably. But to be honest I think we're going to start moving towards having dedicated repos/packages for raven-js environments, including React Native.

e.g. sentry-electron (we're also starting to get rid of the Raven name)

@arusakov
Copy link
Author

Thank you for response @benvinegar. I'm going to create PR soon.

@arusakov
Copy link
Author

arusakov commented Jul 1, 2016

#637

@joerick
Copy link

joerick commented Oct 22, 2016

In the meantime, this is working okay for me:

module.exports.setup = function () {
    if (process.type === 'browser') {
        // main process
        const raven = require('raven');
        const client = new raven.Client('https://622ec62626b041af8d8deadbeefdeadbeef:[email protected]/100000');
        client.patchGlobal();

        process.on('uncaughtException', (err) => {
            const dialog = require('electron').dialog;

            dialog.showMessageBox({
                type: 'error',
                message: 'A JavaScript error occurred in the main process',
                detail: err.stack,
                buttons: ['OK'],
            })
        });
    } else if (process.type === 'renderer') {
        // renderer process
        const Raven = require('raven-js');

        Raven
            .config('https://[email protected]/100000')
            .install();
    }
}

I call it from both main and renderer processes. I added a dialog box as Electron doesn't show one after sentry gets installed.

@arusakov
Copy link
Author

@joerick Your solution is about "how to setup Raven in electron app". But we talk about source maps support here.

@steverandy
Copy link

I have an electron app that need sourcemap support too.
I'm using remote hosted JS file now, but if sentry can support local JS files (source+sourcemap), it will be much better.

@kamilogorek
Copy link
Contributor

kamilogorek commented Sep 28, 2017

To setup Raven for Electron applications right now, you can use:

In order to use source maps correctly, it's required now to manually update filepaths, as @arusakov already mentioned.

function normalizeUrl (url) {  
  return 'app:///' + url.replace(/.*\//, '');
}

Raven.config('__DSN__', {
  dataCallback: function (data) { 
    data.culprit = normalizeUrl(data.culprit);
    data.exception.values.forEach(function (value) {
      value.stacktrace.frames.forEach(function (frame) {
        frame.filename = normalizeUrl(frame.filename)
      });
    });
    return data;
  }
}).install();

I'll work on fixing this directly in raven, so we won't need any plugins for this.

@jan-auer
Copy link
Member

There is a full Electron SDK now: https://github.com/getsentry/sentry-electron

@steverandy
Copy link

@jan-auer do you know if the sdk support sourcemap? I can't find any documentation for the sourcemap.

@ncaq
Copy link

ncaq commented May 12, 2018

Copy link
Contributor

A PR closing this issue has just been released 🚀

This issue was referenced by PR #14540, which was included in the 8.43.0 release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants