-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathga-task-manager.js
5 lines (5 loc) · 1.74 KB
/
ga-task-manager.js
1
2
3
4
5
(function(){function f(a){var b=this;this.c=a;this.a={};this.b="customTask previewTask checkProtocolTask validationTask checkStorageTask historyImportTask samplerTask buildHitTask sendHitTask timingTask displayFeaturesTask".split(" ");this.addFunctionToTask=this.addFunctionToTask.bind(this);this.removeFunctionFromTask=this.removeFunctionFromTask.bind(this);this.setCustomDimension=this.setCustomDimension.bind(this);this.unsetCustomDimension=this.unsetCustomDimension.bind(this);this.b.forEach(function(c){b.a[c]=
{};b.addFunctionToTask(c,"original",a.get(c));b.c.set(c,function(a){for(var d in b.a[c])if(b.a[c].hasOwnProperty(d))b.a[c][d](a)})})}f.prototype.addFunctionToTask=function(a,b,c){this.a[a]&&(this.a[a][b]=c)};f.prototype.removeFunctionFromTask=function(a,b){this.a[a]&&this.a[a][b]&&delete this.a[a][b]};
f.prototype.setCustomDimension=function(a,b,c){this.addFunctionToTask(void 0===c?"customTask":c,"customDimension"+a,function(c){var d=b;if("function"==typeof b){var d=b(),e=typeof d;if("string"!=e&&"number"!=e)throw Error("Function "+b.name+" must return a string or number. Got "+e+"instead.");}"number"===typeof d&&(d=d.toString());c.set("dimension"+a,d)})};f.prototype.unsetCustomDimension=function(a,b){this.removeFunctionFromTask(void 0===b?"customTask":b,"customDimension"+a)};
f.prototype.remove=function(){var a=this;this.b.forEach(function(b){a.c.set(b,a.a[b].original)})};(function(a,b){var c=window.GoogleAnalyticsObject||"ga";window[c]=window[c]||function(b){for(var a=[],e=0;e<arguments.length;++e)a[e-0]=arguments[e];(window[c].q=window[c].q||[]).push(a)};window[c]("provide",a,b);window.gaplugins=window.gaplugins||{};window.gaplugins[a.charAt(0).toUpperCase()+a.slice(1)]=b})("gaTaskManager",f);})();
//# sourceMappingURL=ga-task-manager.js.map