early telemetry (#870)

This commit is contained in:
Mathias Rasmussen
2016-09-02 00:58:02 +02:00
committed by DC
parent 9dcbc1b1f6
commit df16b14586
2 changed files with 11 additions and 10 deletions

View File

@@ -128,10 +128,6 @@ function logUncaughtError (procName, e) {
var stack = ''
if (e == null) {
message = 'Unexpected undefined error'
} else if (e.message) {
// err is either an Error or a plain object {message, stack}
message = e.message
stack = e.stack
} else if (e.error) {
// Uncaught Javascript errors (window.onerror), err is an ErrorEvent
if (!e.error.message) {
@@ -140,6 +136,10 @@ function logUncaughtError (procName, e) {
message = e.error.message
stack = e.error.stack
}
} else if (e.message) {
// err is either an Error or a plain object {message, stack}
message = e.message
stack = e.stack
} else {
// Resource errors (captured element.onerror), err is an Event
if (!e.target) {

View File

@@ -59,6 +59,13 @@ function onState (err, _state) {
if (err) return onError(err)
state = window.state = _state // Make available for easier debugging
telemetry.init(state)
// Log uncaught JS errors
window.addEventListener('error',
(e) => telemetry.logUncaughtError('window', e),
true /* capture */)
// Create controllers
controllers = {
media: new MediaController(state),
@@ -114,11 +121,6 @@ function onState (err, _state) {
// ...window visibility state.
document.addEventListener('webkitvisibilitychange', onVisibilityChange)
// Log uncaught JS errors
window.addEventListener('error',
(e) => telemetry.logUncaughtError('window', e),
true /* capture */)
// Done! Ideally we want to get here < 500ms after the user clicks the app
sound.play('STARTUP')
console.timeEnd('init')
@@ -128,7 +130,6 @@ function onState (err, _state) {
function delayedInit () {
lazyLoadCast()
sound.preload()
telemetry.init(state)
}
// Lazily loads Chromecast and Airplay support