Created
April 5, 2020 14:04
-
-
Save omrilotan/12746c379c918f4600193a2402afdae5 to your computer and use it in GitHub Desktop.
This file contains 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
const errorsHistory = []; | |
function abortErrorReport(message, file, line, column, error) { | |
// Close the log behind a rollout mechanism to protect your infrastructure | |
if (!errorLoggingEnabled) return true; | |
// Limit the amount of errors from one page | |
if (errorsHistory.length > 10) return true; | |
// Send the same error twice from the same page can create false multiplications | |
if (errorsHistory.includes(message)) return true; | |
errorsHistory.push(message); | |
// A page may be considered stale if it's been open for over, lets say, an hour | |
if (window.performance.now() > 36e5) return true; | |
// Add more rules that suit your consideration | |
return false; | |
} | |
function myOnErrorHandler(...args) { | |
if(abortErrorReport(...args)) { | |
return; | |
} | |
... | |
sendError(record); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment