Telemetry: address PR comments

This commit is contained in:
DC
2016-06-21 21:41:48 -07:00
parent e62527de23
commit b983559763
3 changed files with 11 additions and 15 deletions

View File

@@ -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
}

View File

@@ -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')

View File

@@ -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)
}