Created
April 24, 2019 17:45
-
-
Save sperand-io/b160e885340fef9d4f62eae9cf04a319 to your computer and use it in GitHub Desktop.
Auryc update
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
// adds a check (`g.auryc[fn] !== wrapper`) to prevent the recursion when auryc isn’t loaded yet | |
// fixed the usage of `arguments` | |
function safeInvoke(g, fn) { | |
return function wrapper() { | |
if (g.auryc && typeof g.auryc[fn] !== 'undefined' && g.auryc[fn] !== wrapper) { | |
g.auryc[fn].call(this, Array.prototype.slice.call(arguments, 0)); | |
} | |
else { | |
g.aurycReadyCb.push(function () { | |
g.auryc[fn].call(this, Array.prototype.slice.call(arguments, 0)); | |
}); | |
} | |
} | |
} | |
(function (g) { | |
g.aurycReadyCb = g.aurycReadyCb || []; | |
g.auryc = g.auryc || {}; | |
var fns = ['identify', 'addUserProperties', 'track', 'addSessionProperties', 'pause', 'resume']; | |
each(fns, function (fn) { | |
g.auryc[fn] = safeInvoke(g, fn); | |
}); | |
})(window) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment