Telemetry: address PR comments
This commit is contained in:
@@ -3,8 +3,7 @@
|
||||
module.exports = {
|
||||
init,
|
||||
logUncaughtError,
|
||||
logPlayAttempt,
|
||||
getSummary
|
||||
logPlayAttempt
|
||||
}
|
||||
|
||||
const crypto = require('crypto')
|
||||
@@ -13,7 +12,7 @@ const https = require('https')
|
||||
const os = require('os')
|
||||
const url = require('url')
|
||||
|
||||
const config = require('./config')
|
||||
const config = require('../../config')
|
||||
|
||||
var telemetry
|
||||
|
||||
@@ -109,8 +108,8 @@ function getApproxNumTorrents (state) {
|
||||
return 1 << Math.round(log2)
|
||||
}
|
||||
|
||||
// An uncaught error happened in the main process or one in one of the windows
|
||||
function logUncaughtError (process, err) {
|
||||
// An uncaught error happened in the main process or in one of the windows
|
||||
function logUncaughtError (procName, err) {
|
||||
var message, stack
|
||||
if (typeof err === 'string') {
|
||||
message = err
|
||||
@@ -125,7 +124,7 @@ function logUncaughtError (process, err) {
|
||||
if (message.length > 1000) message = message.substring(0, 1000)
|
||||
if (stack.length > 1000) stack = stack.substring(0, 1000)
|
||||
|
||||
telemetry.uncaughtErrors.push({process, message, stack})
|
||||
telemetry.uncaughtErrors.push({process: procName, message, stack})
|
||||
}
|
||||
|
||||
// The user pressed play. It either worked, timed out, or showed the
|
||||
@@ -139,8 +138,3 @@ function logPlayAttempt (result) {
|
||||
attempts.total = (attempts.total || 0) + 1
|
||||
attempts[result] = (attempts[result] || 0) + 1
|
||||
}
|
||||
|
||||
// Gets a summary JSON object to send to the server
|
||||
function getSummary () {
|
||||
return telemetry
|
||||
}
|
||||
@@ -15,8 +15,8 @@ var diff = require('virtual-dom/diff')
|
||||
var patch = require('virtual-dom/patch')
|
||||
|
||||
var config = require('../config')
|
||||
var telemetry = require('../telemetry')
|
||||
var App = require('./views/app')
|
||||
var telemetry = require('./lib/telemetry')
|
||||
var errors = require('./lib/errors')
|
||||
var sound = require('./lib/sound')
|
||||
var State = require('./lib/state')
|
||||
@@ -96,7 +96,8 @@ function onState (err, _state) {
|
||||
document.addEventListener('webkitvisibilitychange', onVisibilityChange)
|
||||
|
||||
// Log uncaught JS errors
|
||||
window.addEventListener('error', (err) => telemetry.logUncaughtError('window', err.error), true)
|
||||
window.addEventListener('error',
|
||||
(e) => telemetry.logUncaughtError('window', e.error), true)
|
||||
|
||||
// Done! Ideally we want to get here < 500ms after the user clicks the app
|
||||
sound.play('STARTUP')
|
||||
|
||||
@@ -63,8 +63,9 @@ function init () {
|
||||
|
||||
ipc.send('ipcReadyWebTorrent')
|
||||
|
||||
window.addEventListener('error', (err) =>
|
||||
ipc.send('wt-uncaught-error', {message: err.error.message, stack: err.error.stack}))
|
||||
window.addEventListener('error', (e) =>
|
||||
ipc.send('wt-uncaught-error', {message: e.error.message, stack: e.error.stack}),
|
||||
true)
|
||||
|
||||
setInterval(updateTorrentProgress, 1000)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user