diff --git a/config/Symphony.config b/config/Symphony.config index a114cf43..99e7cbdc 100644 --- a/config/Symphony.config +++ b/config/Symphony.config @@ -6,5 +6,10 @@ "notificationSettings": { "position": "upper-right", "display": "" - } + }, + "crashReporter": { + "submitURL": "https://localhost:1127/post", + "companyName": "Symphony", + "uploadToServer": true + } } \ No newline at end of file diff --git a/js/main.js b/js/main.js index 3fd8f093..80963a16 100644 --- a/js/main.js +++ b/js/main.js @@ -14,6 +14,8 @@ const {getConfigField, updateUserConfigWin, updateUserConfigMac} = require('./co const { isMac, isDevEnv } = require('./utils/misc.js'); const protocolHandler = require('./protocolHandler'); const getCmdLineArg = require('./utils/getCmdLineArg.js'); +const log = require('./log.js'); +const logLevels = require('./enums/logLevels.js'); require('electron-dl')(); @@ -32,7 +34,22 @@ require('./memoryMonitor.js'); const windowMgr = require('./windowMgr.js'); -crashReporter.start({companyName: 'Symphony', submitURL: 'http://localhost:3000', uploadToServer: false, extra: {'process': 'main'}}); +getConfigField('url') +.then(initializeCrashReporter) +.catch(app.quit); + +function initializeCrashReporter(podUrl) { + + getConfigField('crashReporter') + .then((crashReporterConfig) => { + crashReporter.start({companyName: crashReporterConfig.companyName, submitURL: crashReporterConfig.submitURL, uploadToServer: crashReporterConfig.uploadToServer, extra: {'process': 'main', podUrl: podUrl}}); + log.send(logLevels.INFO, 'initialized crash reporter on the main process!'); + }) + .catch((err) => { + log.send(logLevels.ERROR, 'Unable to initialize crash reporter in the main process. Error is -> ' + err); + }); + +} // only allow a single instance of app. const shouldQuit = app.makeSingleInstance((argv) => { diff --git a/js/preload/preloadMain.js b/js/preload/preloadMain.js index 3f248d1b..79bab139 100644 --- a/js/preload/preloadMain.js +++ b/js/preload/preloadMain.js @@ -60,7 +60,6 @@ const throttledSetBadgeCount = throttle(1000, function(count) { }); }); -crashReporter.start({companyName: 'Symphony', submitURL: 'http://localhost:3000', uploadToServer: false, extra: {'process': 'preload script / renderer'}}); createAPI(); // creates API exposed from electron. @@ -336,6 +335,12 @@ function createAPI() { }); + local.ipcRenderer.on('register-crash-reporter', (event, arg) => { + if (arg) { + crashReporter.start({companyName: arg.companyName, submitURL: arg.submitURL, uploadToServer: arg.uploadToServer, extra: {'process': arg.process, podUrl: arg.podUrl}}); + } + }); + function updateOnlineStatus() { local.ipcRenderer.send(apiName, { cmd: apiCmds.isOnline, diff --git a/js/windowMgr.js b/js/windowMgr.js index 205f7863..49b00c5b 100644 --- a/js/windowMgr.js +++ b/js/windowMgr.js @@ -93,7 +93,6 @@ function doCreateMainWindow(initialUrl, initialBounds) { let url = initialUrl; let key = getGuid(); - crashReporter.start({companyName: 'Symphony', submitURL: 'http://localhost:3000', uploadToServer: false, extra: {'process': 'renderer / main window'}}); log.send(logLevels.INFO, 'creating main window url: ' + url); let newWinOpts = { @@ -252,6 +251,23 @@ function doCreateMainWindow(initialUrl, initialBounds) { }); }); + getConfigField('url') + .then(initializeCrashReporter) + .catch(app.quit); + + function initializeCrashReporter(podUrl) { + getConfigField('crashReporter') + .then((crashReporterConfig) => { + log.send(logLevels.INFO, 'Initializing crash reporter on the main window!'); + crashReporter.start({companyName: crashReporterConfig.companyName, submitURL: crashReporterConfig.submitURL, uploadToServer: crashReporterConfig.uploadToServer, extra: {'process': 'renderer / main window', podUrl: podUrl}}); + log.send(logLevels.INFO, 'initialized crash reporter on the main window!'); + mainWindow.webContents.send('register-crash-reporter', {companyName: crashReporterConfig.companyName, submitURL: crashReporterConfig.submitURL, uploadToServer: crashReporterConfig.uploadToServer, process: 'preload script / main window renderer'}); + }) + .catch((err) => { + log.send(logLevels.ERROR, 'Unable to initialize crash reporter in the main window. Error is -> ' + err); + }); + } + // bug in electron is preventing this from working in sandboxed evt... // https://github.com/electron/electron/issues/8841 mainWindow.webContents.on('will-navigate', function(event, willNavUrl) { @@ -336,7 +352,19 @@ function doCreateMainWindow(initialUrl, initialBounds) { if (browserWin) { log.send(logLevels.INFO, 'loaded pop-out window url: ' + newWinParsedUrl); - crashReporter.start({companyName: 'Symphony', submitURL: 'http://localhost:3000', uploadToServer: false, extra: {'process': 'renderer / pop out window - winKey -> ' + newWinKey}}); + getConfigField('url') + .then((podUrl) => { + getConfigField('crashReporter') + .then((crashReporterConfig) => { + crashReporter.start({companyName: crashReporterConfig.companyName, submitURL: crashReporterConfig.submitURL, uploadToServer: crashReporterConfig.uploadToServer, extra: {'process': 'renderer / child window', podUrl: podUrl}}); + log.send(logLevels.INFO, 'initialized crash reporter on a child window!'); + browserWin.webContents.send('register-crash-reporter', {companyName: crashReporterConfig.companyName, submitURL: crashReporterConfig.submitURL, uploadToServer: crashReporterConfig.uploadToServer, process: 'preload script / child window renderer'}); + }) + .catch((err) => { + log.send(logLevels.ERROR, 'Unable to initialize crash reporter in the child window. Error is -> ' + err); + }); + }) + .catch(app.quit); browserWin.winName = frameName; browserWin.setAlwaysOnTop(alwaysOnTop); @@ -363,7 +391,7 @@ function doCreateMainWindow(initialUrl, initialBounds) { mainWindow.close(); } }); - }); + }); addWindowKey(newWinKey, browserWin); @@ -371,12 +399,12 @@ function doCreateMainWindow(initialUrl, initialBounds) { let throttledBoundsChange = throttle(1000, sendChildWinBoundsChange.bind(null, browserWin)); browserWin.on('move', throttledBoundsChange); - browserWin.on('resize', throttledBoundsChange); + browserWin.on('resize', throttledBoundsChange); } }); } else { event.preventDefault(); - openUrlInDefaultBrower(newWinUrl) + openUrlInDefaultBrower(newWinUrl); } });