|
window.fbqSpy=window.fbqSpy||function(n){function e(){var e,n=c._fbqOrig=window[u];for(e in r("Hijack",n._fbqOrig?"(already hijacked)":""),window[u]=c,n)n.hasOwnProperty(e)&&(window[u][e]=n[e]===n?c:n[e])}var o,t,a=function(e){if(n=null,e.debugLogPrefix=e.debugLogPrefix||"fbqSpy",e.debug=!!e.debug,!e.callback||"function"!=typeof e.callback){if(e.debug)throw new Error("["+e.debugLogPrefix+"] Aborting; No listener callback provided.");e.callback=function(){}}return e.fbqObjName=e.fbqObjName||"fbq",e}("function"==typeof n?{callback:n}:n),u=a.fbqObjName,i=window[u],r=window.console&&a.debug?function(){var e=[].slice.call(arguments);e.unshift("["+a.debugLogPrefix+"]"),console.log.apply(console,e)}:function(){},l=function(o){var e,n,t={args:o,the:{}},u=t.the;"object"==typeof o[o.length-1]&&o[o.length-1];for(a.debug&&function(e,n){for(e="Intercepted: fbq(",n=0;n<o.length;n++)e+="string"==typeof o[n]?'"'+o[n]+'"':o[n],n+1<o.length&&(e+=", ");r(e+=")")}(),u.command=o[0],"track"!==u.command&&"trackCustom"!==u.command||(u.eventName=o[0]),u.parameters={},e=0;e<o.length;e++)if(o[e]&&"object"==typeof o[e])for(n in o[e])o[e].hasOwnProperty(n)&&(u.parameters[n]=o[e][n]);return r("Run listener callback",u),!1!==a.callback(t)},c=function(){var e=[].slice.call(arguments);if(a.debug){if(!l(e))return r("Command blocked.")}else try{if(!l(e))return}catch(e){}return r("Command allowed:",e),c._fbqOrig.apply(c._fbqOrig,e)},f="callMethod";if(r("Config:",a),i||(r("Instantiating FB command queue"),((i=window[u]=window._fbq=function(){i[f]?i[f].apply(i,arguments):i.queue.push(arguments)}).push=i).loaded=!0,i.version="2.0",i.queue=[]),i[f])r("Loaded after fbevents.js; cannot see previous commands"),e();else if(i.queue){if(r("Command queue instantiated, but library not yet loaded"),i.queue.length){for(r("Applying listener to",i.queue.length," queued commands"),o=[],t=0;t<i.queue.length;t++)l([].slice.call(i.queue[t]))&&o.push(i.queue[t]);i.queue=o}else i.queue=[];e()}else if(a.debug)throw new Error("["+a.debugLogPrefix+"] Aborting; `"+u+"` is not the FB command queue.")}; |