From 363338ea830165d73cfd0020c63edcbe6a05a492 Mon Sep 17 00:00:00 2001 From: Matěj Cepl Date: Mon, 10 Oct 2011 23:11:21 +0200 Subject: Original vesion by tlrobinson --- tlrobinson/JSON Diff_files/mixpanel.js | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 tlrobinson/JSON Diff_files/mixpanel.js (limited to 'tlrobinson/JSON Diff_files/mixpanel.js') diff --git a/tlrobinson/JSON Diff_files/mixpanel.js b/tlrobinson/JSON Diff_files/mixpanel.js new file mode 100644 index 0000000..98e54a3 --- /dev/null +++ b/tlrobinson/JSON Diff_files/mixpanel.js @@ -0,0 +1,29 @@ +var MixpanelLib=function(k,n,m){function j(a,e,b){if(a.length){var d;for(d=0;d=3)return a[2];return""}function v(){if(!r){r=!0;document.removeEventListener&&(document.removeEventListener("DOMContentLoaded",v,!1),document.removeEventListener("load",v,!1));for(;z.length>0;){var a=z.shift();b[a[0]].apply(b,a.slice(1))}}}var b={},K=!1,r=!1,z=[];b.config={cross_subdomain_cookie:!0,cookie_name:"mp_super_properties",test:!1,store_google:!0,save_referrer:!0,debug:!1,track_links_timeout:300,img:!1};b.jsonp_callback=function(){};b.super_properties= +{all:{},events:{},funnels:{}};b.funnels={};var o={log:function(){if(typeof window.console!=="undefined"&&window.console&&b.config.debug)try{window.console.log.apply(window.console,arguments)}catch(a){var e=Array.prototype.slice.call(arguments);window.console.log(e.join("\n"))}},error:function(){if(typeof window.console!=="undefined"&&window.console&&b.config.debug)try{window.console.error.apply(window.console,arguments)}catch(a){var e=Array.prototype.slice.call(arguments);window.console.error(e.join("\n"))}}}, +p=function(){};p.prototype.track=function(){if(!r)return z.push([this.function_name].concat(u(arguments))),!0;var a=arguments.length>0?arguments[0]:void 0;if(a===void 0)o.error("Invalid arguments for track_forms:",arguments);else if(typeof a==="string"&&B(a))return this.track_query.apply(this,arguments);else if(w(a))return arguments[0]=u(a),this.track_dom.apply(this,arguments);else o.error("Invalid arguments for track_links:",arguments);return!1};p.prototype.track_query=function(a,b,c,d){var a=C(a), +f=null;a.type==="class"?f=D(a.query):a.type==="id"&&(a=E(a.query),f=a!==null?[a]:[]);a=f;if(a===null)return!1;return this.track_dom(a,b,c,d)};p.prototype.track_dom=function(a,b,c,d){if(!b)return o.error("No event name provided to mpmetrics."+this.function_name),!1;c=c||{};j(a,function(a){if(typeof a!=="object"||typeof a.nodeName==="undefined")return o.error("Invalid element provided to "+this.function_name,a),!1;var g=this.update_properties(a,c);F(a,this.override_event,b,g,this.callback_generator(a, +d))},this);return!0};p.prototype.update_properties=function(a,b){var c={};j(b,function(a,b){c[b]=a});return c};A(q,p);q.prototype.callback_generator=function(a,b){return function(c,d,f){b&&b(c,d)===!1||f.new_tab_click||a.href!==void 0&&a.href!==null&&setTimeout(function(){window.location=a.href},0)}};q.prototype.update_properties=function(a,b){var c=q.superclass.update_properties.call(this,a,b);if(a.href)c.url=a.href;return c};A(y,p);y.prototype.callback_generator=function(a,b){return function(c, +d){b&&b(c,d)===!1||setTimeout(function(){document.createElement("form").submit.call(a)},0)}};b.track_links=function(){var a=new q;return a.track.apply(a,arguments)};b.track_forms=function(){var a=new y;return a.track.apply(a,arguments)};b.send_request=function(a,e){var c;c=/google web preview/i.test(navigator.userAgent)?!0:!1;if(!c){if(b.config.test)e.test=1;if(b.config.img)e.img=1;e._=(new Date).getTime().toString();a+="?"+b.http_build_query(e);if(b.config.img)c=document.createElement("img"),c.src= +a,document.body.appendChild(c);else{c=document.createElement("script");c.type="text/javascript";c.async=!0;c.defer=!0;c.src=a;var d=document.getElementsByTagName("script")[0];d.parentNode.insertBefore(c,d)}}};b.get_query_param=function(a,b){var b=b.replace(/[\[]/,"\\[").replace(/[\]]/,"\\]"),c=RegExp("[\\?&]"+b+"=([^&#]*)").exec(a);return c===null||c&&typeof c[1]!=="string"&&c[1].length?"":unescape(c[1]).replace(/\+/g," ")};b.track=function(a,e,c,d){if(a){b.load_super_once();d=d||"events";e=e||{}; +e.token=e.token||b.token;var f=Math.floor(Math.random()*1E4),g=b.callback_fn;c!==void 0&&(b.jsonp_callback[""+f]=c,g+='["'+f+'"]');e.time=b.get_unixtime();b.save_campaign_params();b.save_search_info(document.referrer);b.config.save_referrer&&b.save_referrer_info(document.referrer);c={};s(c,{$os:I(),$browser:H(),$referrer:document.referrer,$referring_domain:J(document.referrer)},function(a){return a.length});s(c,b.super_properties.all);d!="all"&&s(c,b.super_properties[d]);s(c,e);d={event:a,properties:c}; +c=b.base64_encode(b.json_encode(d));b.config.debug&&(o.log("-------------- REQUEST --------------"),o.log(d));b.send_request(b.api_host+"/track/",{data:c,ip:1,callback:g});b.track_predefined_funnels(a,e);return d}else o.error("No event name provided to mpmetrics.track")};b.track_funnel=function(a,e,c,d,f){d=d||{};d.funnel=a;d.step=parseInt(e,10);d.goal=c;return b.track("mp_funnel",d,f,"funnels")};b.track_pageview=function(){b.track("mp_page_view",b.get_pageview_info())};b.identify=function(a){b.register_once({distinct_id:a}, +"all",null,30)};b.name_tag=function(a){b.register({mp_name_tag:a},"all",30)};b.register_once=function(a,e,c,d){if(t(a)){b.load_super_once();e=e||"all";c===void 0&&(c="None");d===void 0&&(d=7);if(b.super_properties.hasOwnProperty(e)){var f=b.super_properties[e];j(a,function(a,d){if(!f[d]||f[d]===c)b.super_properties[e][d]=a})}b.config.cross_subdomain_cookie&&b.clear_old_cookie();b.set_cookie(b.config.cookie_name,b.json_encode(b.super_properties),d,b.config.cross_subdomain_cookie);return!0}else return!1}; +b.register=function(a,e,c){return t(a)?(b.load_super_once(),e=e||"all",c===void 0&&(c=7),b.super_properties.hasOwnProperty(e)&&j(a,function(a,c){b.super_properties[e][c]=a}),b.config.cross_subdomain_cookie&&b.clear_old_cookie(),b.set_cookie(b.config.cookie_name,b.json_encode(b.super_properties),c,b.config.cross_subdomain_cookie),!0):!1};b.http_build_query=function(a,b){var c,d,f=[];b||(b="&");j(a,function(a,b){c=encodeURIComponent(a.toString());d=encodeURIComponent(b);f[f.length]=d+"="+c});return f.join(b)}; +b.get_unixtime=function(){return parseInt((new Date).getTime().toString().substring(0,10),10)};b.json_encode=function(a){var b=function(a){var b=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,e={"\u0008":"\\b","\t":"\\t","\n":"\\n","\u000c":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"};b.lastIndex=0;return b.test(a)?'"'+a.replace(b,function(a){var b=e[a];return typeof b==="string"?b:"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)})+ +'"':'"'+a+'"'},c=function(a,f){var g="",h=0,i=h="",i=0,k=g,j=[],l=f[a];l&&typeof l==="object"&&typeof l.toJSON==="function"&&(l=l.toJSON(a));switch(typeof l){case "string":return b(l);case "number":return isFinite(l)?String(l):"null";case "boolean":case "null":return String(l);case "object":if(!l)return"null";g+=" ";j=[];if(Object.prototype.toString.apply(l)==="[object Array]"){i=l.length;for(h=0;h>18&63,c=f>>12&63,d=f>>6&63,f&=63,i[h++]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(e)+"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(c)+ +"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(d)+"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(f);while(g127&&h<2048?String.fromCharCode(h>>6|192)+String.fromCharCode(h& +63|128):String.fromCharCode(h>>12|224)+String.fromCharCode(h>>6&63|128)+String.fromCharCode(h&63|128);i!==null&&(d>c&&(b+=a.substring(c,d)),b+=i,c=d=g+1)}d>c&&(b+=a.substring(c,a.length));return b};b.set_cookie=function(a,e,c,d){var f=new Date,d=d?b.parse_domain(document.location.hostname):"",a=a+"="+escape(e);f.setDate(f.getDate()+c);a+=c===null?"":";expires="+f.toGMTString();a+="; path=/";a+=d?";domain=."+d:"";document.cookie=a};b.get_cookie=function(a){var b;if(document.cookie.length>0&&(document.cookie.match("^"+ +a+"=")?b=0:(b=document.cookie.search("; "+a+"="),b!==-1&&(b+=2)),b!==-1)){b=b+a.length+1;a=document.cookie.indexOf(";",b);if(a==-1)a=document.cookie.length;return unescape(document.cookie.substring(b,a))}return""};b.delete_cookie=function(a,e){b.set_cookie(a,"",-1,e)};b.parse_domain=function(a){return(a=a.match(/[a-z0-9][a-z0-9\-]+\.[a-z\.]{2,6}$/i))?a[0]:""};b.get_super=function(){var a=eval("("+b.get_cookie(b.config.cookie_name)+")")||{};j(a,function(a,c){b.super_properties[c]=a});return b.super_properties}; +b.load_super_once=function(){if(!K)try{b.get_super(),K=!0}catch(a){}};b.register_funnel=function(a,e){b.funnels[a]=e};b.track_predefined_funnels=function(a,e){var c,d;if(a&&b.funnels)for(c in b.funnels)if(b.funnels.hasOwnProperty(c))for(d=0;d