akamai / boomerang

End user oriented web performance testing and beaconing
http://akamai.github.io/boomerang/
Other
1.86k stars 292 forks source link

Access Data without Firing Beacon #310

Closed MLKendall closed 3 years ago

MLKendall commented 3 years ago

We are looking for a way to access and use the data in the beacon on the front end without actually firing the beacon itself (there is no server endpoint to hit, and we have another service we need to send it off to that needs it to be transformed from a flat object first.). At the moment, I have the beacon url pointing to #, am subscribing to the before_beacon and doing what I need to do with the data, but the beacon still fires after that, so we get a 404 error in our console.

Is there any way to either prevent the beacon from firing or access the data without firing the beacon at all?

Thanks.

bluesmoon commented 3 years ago

IIRC you can set the beacon url to an empty string.

nicjansma commented 3 years ago

Correct, if beacon_url is set to anything falsy ("" or false), no beacon will be sent.

Please let us know if that doesn't work!

richb-hanover commented 3 years ago

Yes. Here's what I did to prevent the beacon from being sent. I subscribed to 'before_beacon' to capture the beacon data...

BOOMR.init( {
    beacon_url: "",
    ...
BOOMR.subscribe("before_beacon",beaconData);

function beaconData(beacon) {
    console.log(beacon.rt.si); 
}