36 lines
1003 B
JavaScript
36 lines
1003 B
JavaScript
window.COREID_ERROR_LOG_URL = window.COREID_ERROR_LOG_URL || '/api/v1/log-error'
|
|
|
|
async function logError(error) {
|
|
try {
|
|
await fetch(window.COREID_ERROR_LOG_URL, {
|
|
method: 'POST',
|
|
cache: 'no-cache',
|
|
headers: {
|
|
'Accept': 'application/json',
|
|
'Content-Type': 'application/json',
|
|
},
|
|
body: JSON.stringify({
|
|
full_url: window.location.href,
|
|
trace: [
|
|
error.name + ': ' + error.message,
|
|
error.stack,
|
|
].join('\n')
|
|
}),
|
|
})
|
|
} catch (e) {}
|
|
}
|
|
|
|
;(function() {
|
|
var old_onerror = window.onerror
|
|
|
|
window.onerror = function(msg, src, line, col, error) {
|
|
logError(error).then(function() {
|
|
if ( typeof old_onerror === 'function' ) {
|
|
try {
|
|
old_onerror(msg, src, line, col, error)
|
|
} catch(e) {}
|
|
}
|
|
})
|
|
}
|
|
})()
|