Skip to content

Commit

Permalink
Do not log the same error multiple times, and clear errors after beac…
Browse files Browse the repository at this point in the history
…oning
  • Loading branch information
Philip Tellis committed Jul 28, 2014
1 parent e55a4a0 commit c6b4a1a
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions boomerang.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ impl = {

vars: {},

errors: [],
errors: {},

disabled_plugins: {},

Expand Down Expand Up @@ -739,7 +739,12 @@ boomr = {
err = "[" + src + "] " + err;
}

impl.errors.push(err);
if (impl.errors[err]) {
impl.errors[err]++;
}
else {
impl.errors[err] = 1;
}
},

addVar: function(name, value) {
Expand Down Expand Up @@ -800,7 +805,7 @@ boomr = {
},

sendBeacon: function() {
var k, data, url, img, nparams;
var k, data, url, img, nparams, errors=[];

BOOMR.debug("Checking if we can send beacon");

Expand All @@ -826,10 +831,18 @@ boomr = {
impl.vars["if"] = "";
}

if(impl.errors.length > 0) {
impl.vars.errors = impl.errors.join("\n");
for (k in impl.errors) {
if (impl.errors.hasOwnProperty(k)) {
errors.push(k + (impl.errors[k] > 1 ? " (*" + impl.errors[k] + ")" : ""));
}
}

if(errors.length > 0) {
impl.vars.errors = errors.join("\n");
}

impl.errors = {};

// If we reach here, all plugins have completed
impl.fireEvent("before_beacon", impl.vars);

Expand Down

0 comments on commit c6b4a1a

Please sign in to comment.