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(); | |
}; |
Author
hcodes
commented
May 30, 2019
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment