Last active
April 20, 2022 13:20
-
-
Save nicjansma/21c3075b6391a715d46fef59a3f6f293 to your computer and use it in GitHub Desktop.
Boomerang plugin that duplicates any mPulse Custom Timers that are logged in the beacon's t_other parameter into distinct beacon parameters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* The `DuplicateTimersToBeacon` Boomerang plugin duplicates any mPulse Custom Timers | |
* that are logged in the beacon's `t_other` parameter into distinct beacon parameters. | |
* | |
* e.g: | |
* | |
* t_other=boomerang|17,boomr_fb|2516,boomr_ld|2351,boomr_lat|165,custom5|2112,custom0|27 | |
* | |
* Will add two more beacon parameters: | |
* | |
* timer_custom5=2112 | |
* timer_custom0=27 | |
*/ | |
(function(w) { | |
if (!w) { | |
return; | |
} | |
BOOMR = w.BOOMR || {}; | |
BOOMR.plugins = BOOMR.plugins || {}; | |
BOOMR.plugins.DuplicateTimersToBeacon = { | |
varsAdded: [], | |
onBeforeBeacon: function(beaconData) { | |
var tOther = beaconData ? beaconData.t_other : false; | |
if (tOther) { | |
var tOthers = tOther.split(","); | |
for (var i = 0; i < tOthers.length; i++) { | |
var nameValue = tOthers[i].split("|"); | |
if (nameValue[0].indexOf("custom") === 0) { | |
beaconData["timer_" + nameValue[0]] = nameValue[1]; | |
this.varsAdded.push("timer_" + nameValue[0]); | |
} | |
} | |
} | |
}, | |
init: function() { | |
BOOMR.subscribe("before_beacon", this.onBeforeBeacon, {}, this); | |
BOOMR.subscribe("before_custom_beacon", this.onBeforeBeacon, {}, this); | |
// remove vars after each beacon | |
BOOMR.subscribe("beacon", function() { | |
BOOMR.removeVar(this.varsAdded); | |
this.varsAdded = []; | |
}, {}, this); | |
}, | |
is_complete: function() { | |
return true; | |
} | |
}; | |
})(window); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment