From 1b0c5a30f893774eb1597bd8e2b0a6c4165915d1 Mon Sep 17 00:00:00 2001 From: ghamm Date: Sun, 8 Feb 2015 21:08:57 -0500 Subject: [PATCH] Modified BW plugin to allow it to optionally block for beacon completion and to bypass the cookie and run anyways --- plugins/bw.js | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/plugins/bw.js b/plugins/bw.js index d04e8cac0..d52a432dc 100644 --- a/plugins/bw.js +++ b/plugins/bw.js @@ -55,6 +55,8 @@ impl = { nruns: 5, latency_runs: 10, user_ip: "", + run_always: false, + block_for_beacon: false, test_https: false, cookie_exp: 7*86400, cookie: "BA", @@ -411,7 +413,10 @@ impl = { } this.complete = true; - //BOOMR.sendBeacon(); + + if (this.block_for_beacon === true) + BOOMR.sendBeacon(); + this.running = false; }, @@ -486,6 +491,14 @@ BOOMR.plugins.BW = { impl.user_ip = config.user_ip; } + if(config && config.BW && config.BW.run_always) { + impl.run_always = config.BW.run_always; + } + + if(config && config.BW && config.BW.block_for_beacon) { + impl.block_for_beacon = config.BW.block_for_beacon; + } + if(!impl.base_url) { return this; } @@ -500,7 +513,7 @@ BOOMR.plugins.BW = { BOOMR.removeVar("ba", "ba_err", "lat", "lat_err"); - if(!impl.setVarsFromCookie()) { + if(impl.run_always || !impl.setVarsFromCookie()) { BOOMR.subscribe("page_ready", this.run, null, this); } @@ -527,7 +540,10 @@ BOOMR.plugins.BW = { BOOMR.info("HTTPS detected, skipping bandwidth test", "bw"); impl.complete = true; - //BOOMR.sendBeacon(); + + if (impl.block_for_beacon === true) + BOOMR.sendBeacon(); + return this; } @@ -550,7 +566,15 @@ BOOMR.plugins.BW = { } }, - is_complete: function() { return true; } + is_complete: function() { + if (impl.block_for_beacon === true) + { + return impl.complete; + } + else { + return true; + } + } }; }());