Communication with electron, Ref. #13

This commit is contained in:
ziajka
2018-04-06 13:15:23 +02:00
parent 37acae2697
commit 0ee66da007
5 changed files with 56 additions and 21 deletions

View File

@ -1,6 +1,8 @@
const { SentryClient } = require('@sentry/electron');
var fs = require('fs');
const fs = require('fs');
const { ipcMain } = require('electron');
let crashReportsEnabled = true;
const DSN =
'https://cb7b474b2e874afb8e400c47d1452ecc:7876224cbff543d992cb0ac4021962f8@sentry.io/1040940';
@ -8,8 +10,17 @@ const isDev = () => {
return fs.existsSync('.git');
};
if (!isDev()) {
SentryClient.create({
dsn: DSN
});
}
const shouldSendCallback = () => {
return !isDev() && crashReportsEnabled;
};
ipcMain.on('settings.changed', function (event, settings) {
crashReportsEnabled = settings.crash_reports;
});
SentryClient.create({
dsn: DSN,
shouldSendCallback: shouldSendCallback
});