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.
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)
Thank you for response @benvinegar. I'm going to create PR soon.
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.
@joerick Your solution is about "how to setup Raven in electron app". But we talk about source maps support here.
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.
To setup Raven for Electron applications right now, you can use:
raven-node
for main processraven-js
for renderer processIn 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.
There is a full Electron SDK now: https://github.com/getsentry/sentry-electron
@jan-auer do you know if the sdk support sourcemap? I can't find any documentation for the sourcemap.
@steverandy Source Maps – Sentry Documentation
Most helpful comment
To setup Raven for Electron applications right now, you can use:
raven-node
for main processraven-js
for renderer processIn order to use source maps correctly, it's required now to manually update filepaths, as @arusakov already mentioned.
I'll work on fixing this directly in
raven
, so we won't need any plugins for this.