From 417ae7e927086bff1d53274a6cba5d4418efd0f9 Mon Sep 17 00:00:00 2001 From: Quentin DECAUNES Date: Tue, 6 Aug 2019 13:52:49 +0200 Subject: [PATCH] fix: Linux was unable to start properly in some cases. --- js/app.js | 30 +----------------------------- js/methods.js | 45 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 29 deletions(-) diff --git a/js/app.js b/js/app.js index b40ad36..9fb3dbd 100644 --- a/js/app.js +++ b/js/app.js @@ -1,36 +1,8 @@ ready(function(){ - const uuidv4 = require('uuid/v4'); const settings = require('electron-settings'); const fixPath = require('fix-path'); document.isStarting = true; - Sentry.init({ - dsn: 'https://f80fd3ea297141a8bdc04ce812762f39@sentry.io/1513427', - release: require('./package.json').version, - beforeSend: (event) => { - event.exception.values = event.exception.values.map((value) => { - if (value.stacktrace) { - value.stacktrace.frames = value.stacktrace.frames.map((frame) => { - frame.filename = frame.filename.replace(/^.*ryzen(|-)controller\//g, ""); - return frame; - }); - } - return value; - }); - if (event.request.url) { - event.request.url = event.request.url.replace(/^.*ryzen(|-)controller\//g, ""); - } - return event; - } - }); - Sentry.configureScope((scope) => { - if (!settings.get('userid')) { - settings.set('userid', uuidv4()); - } - const userid = settings.get('userid'); - scope.setUser({ - id: userid - }); - }); + addSentry(); fixPath(); displayOptions(); preFillSettings(); diff --git a/js/methods.js b/js/methods.js index 80660d9..922d492 100644 --- a/js/methods.js +++ b/js/methods.js @@ -1,3 +1,48 @@ +/** + * Will enable Sentry. + */ +function addSentry() { + const uuidv4 = require('uuid/v4'); + const settings = require('electron-settings'); + + var waitSentry = setInterval(() => { + if (!Sentry) { + console.log('waitSentry'); + return; + } + clearInterval(waitSentry); + console.log('sentryOk'); + Sentry.init({ + dsn: 'https://f80fd3ea297141a8bdc04ce812762f39@sentry.io/1513427', + release: require('./package.json').version, + beforeSend: (event) => { + event.exception.values = event.exception.values.map((value) => { + if (value.stacktrace) { + value.stacktrace.frames = value.stacktrace.frames.map((frame) => { + frame.filename = frame.filename.replace(/^.*ryzen(|-)controller\//g, ""); + return frame; + }); + } + return value; + }); + if (event.request.url) { + event.request.url = event.request.url.replace(/^.*ryzen(|-)controller\//g, ""); + } + return event; + } + }); + Sentry.configureScope((scope) => { + if (!settings.get('userid')) { + settings.set('userid', uuidv4()); + } + const userid = settings.get('userid'); + scope.setUser({ + id: userid + }); + }); + }, 100); +} + /** * Will load options_data.json and display them into index.html. */