Adjusting how JS errors are tracked.

- Checking for a valid lineno instead of the filename to filter out
  "(0): Script error." logging
- Tracking stack traces separately from exceptions to make debugging
  easier
This commit is contained in:
Jeff Avallone 2015-01-04 18:50:16 -05:00
parent 0600d18bb5
commit 66c9d445da

View File

@ -9,20 +9,22 @@ window._gaq = (typeof _gaq !== 'undefined') ? _gaq : {
(function() { (function() {
window.addEventListener('error', function(error) { window.addEventListener('error', function(error) {
if (typeof error.error !== 'undefined' && typeof error.error.stack !== 'undefined') { if (error.lineno !== 0) {
_gaq.push([
'_trackEvent',
'global',
'exception',
error.error.stack
]);
} else if (error.filename !== '') {
_gaq.push([ _gaq.push([
'_trackEvent', '_trackEvent',
'global', 'global',
'exception', 'exception',
`${error.filename}(${error.lineno},${error.colno}): ${error.message}` `${error.filename}(${error.lineno},${error.colno}): ${error.message}`
]); ]);
if (typeof error.error !== 'undefined' && typeof error.error.stack !== 'undefined') {
_gaq.push([
'_trackEvent',
'global',
'stack trace',
error.error.stack
]);
}
} }
}); });