diff --git a/crash-reporter.js b/crash-reporter.js new file mode 100644 index 00000000..c470e79a --- /dev/null +++ b/crash-reporter.js @@ -0,0 +1,15 @@ +module.exports = { + init +} + +var config = require('./config') +var electron = require('electron') + +function init () { + electron.crashReporter.start({ + companyName: config.APP_NAME, + productName: config.APP_NAME, + submitURL: config.CRASH_REPORT_URL + }) + console.log('crash reporter started') +} diff --git a/main/index.js b/main/index.js index 4628cbb0..2ad0c939 100644 --- a/main/index.js +++ b/main/index.js @@ -1,11 +1,11 @@ var electron = require('electron') var app = electron.app -var crashReporter = electron.crashReporter var ipcMain = electron.ipcMain var autoUpdater = require('./auto-updater') var config = require('../config') +var crashReporter = require('../crash-reporter') var handlers = require('./handlers') var ipc = require('./ipc') var log = require('./log') @@ -47,8 +47,8 @@ function init () { ipc.init() app.on('will-finish-launching', function () { + crashReporter.init() autoUpdater.init() - setupCrashReporter() }) app.on('ready', function () { @@ -129,11 +129,3 @@ function processArgv (argv) { } }) } - -function setupCrashReporter () { - crashReporter.start({ - companyName: config.APP_NAME, - productName: config.APP_NAME, - submitURL: config.CRASH_REPORT_URL - }) -} diff --git a/renderer/index.js b/renderer/index.js index bbe02a8b..e44a1c54 100644 --- a/renderer/index.js +++ b/renderer/index.js @@ -16,6 +16,7 @@ var patch = require('virtual-dom/patch') var App = require('./views/app') var errors = require('./lib/errors') var config = require('../config') +var crashReporter = require('../crash-reporter') var TorrentPlayer = require('./lib/torrent-player') var util = require('./util') var {setDispatch} = require('./lib/dispatcher') @@ -31,7 +32,6 @@ var Cast = null var ipcRenderer = electron.ipcRenderer var clipboard = electron.clipboard -var crashReporter = electron.crashReporter var dialog = remote.require('dialog') // For easy debugging in Developer Tools @@ -39,6 +39,10 @@ var state = global.state = State.getInitialState() var vdomLoop +// Report crashes back to our server. +// Not global JS exceptions, not like Rollbar, handles segfaults/core dumps only +crashReporter.init() + // All state lives in state.js. `state.saved` is read from and written to a file. // All other state is ephemeral. First we load state.saved then initialize the app. loadState(init) @@ -49,8 +53,6 @@ loadState(init) * the dock icon and drag+drop. */ function init () { - setupCrashReporter() - // Push the first page into the location history state.location.go({ url: 'home' }) @@ -1004,14 +1006,6 @@ function playInterfaceSound (name) { audio.play() } -function setupCrashReporter () { - crashReporter.start({ - companyName: config.APP_NAME, - productName: config.APP_NAME, - submitURL: config.CRASH_REPORT_URL - }) -} - // Finds the longest common prefix function findCommonPrefix (a, b) { for (var i = 0; i < a.length && i < b.length; i++) { diff --git a/renderer/webtorrent.js b/renderer/webtorrent.js index 21975a84..c8f99e4b 100644 --- a/renderer/webtorrent.js +++ b/renderer/webtorrent.js @@ -10,9 +10,14 @@ var fs = require('fs') var mkdirp = require('mkdirp') var musicmetadata = require('musicmetadata') var networkAddress = require('network-address') +var path = require('path') + +var crashReporter = require('../crash-reporter') var config = require('../config') var torrentPoster = require('./lib/torrent-poster') -var path = require('path') + +// Report when the process crashes +crashReporter.init() // Send & receive messages from the main window var ipc = electron.ipcRenderer