Is there a way to run Boomerang bandwidth (by AKAMAI) with an on-click event multiple times?

81 views Asked by At

Currently, I have an on-click event that runs the Boomerang bandwidth metrics when a button is clicked, but I have an issue where it will only run the first time and not until I refresh my page. Is it unable to run multiple times, or am I missing something?

I only want to log the network metrics and nothing else.

Here's a link to the REPO/Documentation: https://akamai.github.io/boomerang/BOOMR.plugins.BW.html

Here's the on-click event:

$('#boomerangTest').on('click', function (event) {
        debugger
        //var pathname = window.location.pathname;
        //var url = window.location.href;
        //var origin = window.location.origin;
        //var imageURL = origin + '';

        var loc = window.location.pathname;
        var dir = loc.substring(0, loc.lastIndexOf('/'));
        var imageURL = dir + "/assets/images/boomr/"

        var data = {
            UserName: cb.Win.FindHandleID('#spanUserName').html().replace('Logged in as: ', '')
        };

        data.UserName = data.UserName.substr(0, data.UserName.indexOf('(')).trim();

        if (data.UserName === '') {
            cb.Win.ErrDialog('Network Metrics', 'Please Login before running a network test');
        }
        else {
            $('#main_content').cbAjaxLoader('big');
            BOOMR.init({
                beacon_url: '',
                 BW: {
                     base_url: imageURL,
                     block_beacon: true,
                     cookie: "AK_BW"
                 },
                 RT: {
                     enabled: true,
                     clearOnBeacon: true
                 }
             });

            BOOMR.subscribe('before_beacon', function (o) {
                debugger
                var html = "",
                    t_name,
                    t_other,
                    others = [],
                    bandwidthMetrics = {};

                if (!o.t_other) o.t_other = "";

                for (var k in o) {
                    if (!k.match(/^(t_done|t_other|bw|lat|bw_err|lat_err|u|r2?)$/)) {
                        if (k.match(/^t_/)) {
                            o.t_other += "," + k + "|" + o[k];
                        }
                        else {
                            others.push(k + " = " + o[k]);
                        }
                    }
                }

                if (o.t_done) {
                    html += "This page took " + o.t_done + " ms to load<br>";
                    bandwidthMetrics.LoadDuration = o.t_done;
                }

                if (o.bw) {
                    html += "Your bandwidth to this server is " + parseInt(o.bw / 1024) + " kbps (&#x00b1;" + parseInt(o.bw_err * 100 / o.bw) + "%)<br>";
                    bandwidthMetrics.DownSpeed = parseInt(o.bw / 1024);
                }

                if (o.lat) {
                    html += "Your latency to this server is " + parseInt(o.lat) + " ms (&#x00b1;" + parseInt(o.lat_err * 100 / o.lat) + "%)<br>";
                    bandwidthMetrics.Latency = parseInt(o.lat);
                }

                cb.Win.ErrDialog('Network Metric Results', html, 'main_content');
                $('#main_content').cbAjaxLoaderRemove();

            });

            $('#main_content').cbAjaxLoaderRemove();
        }
    });
1

There are 1 answers

1
bluesmoon On

boomerang stores the results in a cookie and will not rerun the test for 7 days on the same network. If you need it to rerun the test, then disable the BW cookie.

Note that the boomerang team very rarely monitors Stackoverflow, you'll get a faster response by posting directly to the github issues list.