JSFiddle - React, Tailwind, and code Playground
by kouty79
JavaScript
function gtag() {
console.log(arguments);
}
function trackGlobalErrors() {
window.addEventListener('error', function (evt) {
const { message, filename, lineno, colno, error } = evt;
gtag('event', 'exception', {
'description': `$m=${message};f=${filename };l=${lineno};c=${colno};e=${error}`,
'fatal': false
});
});
window.addEventListener("unhandledrejection", function (event) {
gtag('event', 'exception', {
'description': event.reason,
'fatal': false
});
});
}
trackGlobalErrors();
setTimeout(() => {
// throw 'Sblindi';
new Promise((_, reject) => reject('nello'));
}, 2000);