make sure we do not flood raygun with errors

pull/248/head
nightwing 2016-01-29 18:43:26 +04:00
rodzic 803c4ccf4a
commit 29d1e1da17
1 zmienionych plików z 15 dodań i 11 usunięć

Wyświetl plik

@ -1419,12 +1419,13 @@ window.TraceKit = TraceKit;
} }
var blackListedErrors = { var blackListedErrors = {
'Error with empty message': {}, count: 0,
'Script error.': {}, '#Error with empty message': {},
'DealPly is not defined': { factor: 10e5 }, '#Script error.': {},
"Cannot read property 'style' of null": { factor: 10e3 }, '#DealPly is not defined': { factor: 10e5 },
"Project with id '<id>' does not exist": { factor: 10e2 }, "#Cannot read property 'style' of null": { factor: 10e3 },
"Workspace not found": { factor: 10e2 }, "#Project with id '<id>' does not exist": { factor: 10e2 },
"#Workspace not found": { factor: 10e2 },
}; };
var groupedErrors = [{ var groupedErrors = [{
regex: /^((?:Project|User) with id ')(\d+)(' does not exist)/i, regex: /^((?:Project|User) with id ')(\d+)(' does not exist)/i,
@ -1511,13 +1512,16 @@ window.TraceKit = TraceKit;
} }
}); });
if (blackListedErrors.hasOwnProperty(message)) { var blackListEntry = blackListedErrors["#" + message];
var count = (blackListedErrors[message].count || 0) + 1; if (blackListEntry) {
blackListedErrors[message].count = count; var count = (blackListEntry.count || 0) + 1;
if (count % (blackListedErrors[message].factor || 10) !== 1) { blackListEntry.count = count;
if (count % (blackListEntry.factor || 10) !== 1) {
return; return;
} }
finalCustomData.$blackList = blackListedErrors[message]; finalCustomData.$blackList = blackListEntry;
} else if (blackListedErrors.count < 10000) {
blackListedErrors["#" + message] = {};
} }
var payload = { var payload = {