Last active
May 30, 2019 12:48
-
-
Save hcodes/014e345424e5b469c263 to your computer and use it in GitHub Desktop.
Отслеживание js-ошибок с помощью Метрики
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
window.onerror = function(msg, file, line, col, err) { | |
if (!window.JSON) { | |
return; | |
} | |
var counterId = 12345, | |
siteInfo = {}, | |
pointer = siteInfo; | |
path = [ | |
'JS errors', | |
msg, | |
err && err.stack || (file + ':' + line + ':' + col) | |
]; | |
for (var i = 0; i < path.length - 1; i++) { | |
var item = path[i]; | |
pointer[item] = {}; | |
pointer = pointer[item]; | |
} | |
pointer[path[i]] = 1; | |
new Image().src = 'https://mc.yandex.ru/watch/' + counterId + | |
'/?site-info=' + encodeURIComponent(JSON.stringify(siteInfo)) | |
'&rnd=' + Math.random(); | |
}; |
{
'JS errors': {
'mgs': {
'error stack': 1 // Для подсчёта ошибок, вес ошибки, см. отчёты в Метрике.
}
}
}
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@hcodes, what this line of code is used for ?
pointer[path[i]] = 1;