UNPKG

mixpanel-browser

Version:

The official Mixpanel JavaScript browser client library

6 lines (5 loc) 2.91 kB
(function(d,e){if(!e.__SV){var m,c;window.mixpanel=e;e._i=[];e.init=function(b,f,l){function t(k,g){var n=g.split(".");2==n.length&&(k=k[n[0]],g=n[1]);k[g]=function(){k.push([g].concat(Array.prototype.slice.call(arguments,0)))}}var h=e;"undefined"!==typeof l?h=e[l]=[]:l="mixpanel";h.people=h.people||[];h.toString=function(k){var g="mixpanel";"mixpanel"!==l&&(g+="."+l);k||(g+=" (stub)");return g};h.people.toString=function(){return h.toString(1)+".people (stub)"};m="disable time_event track track_pageview track_links track_forms track_with_groups add_group set_group remove_group register register_once alias unregister identify name_tag set_config reset opt_in_tracking opt_out_tracking has_opted_in_tracking has_opted_out_tracking clear_opt_in_out_tracking start_batch_senders start_session_recording stop_session_recording people.set people.set_once people.unset people.increment people.append people.union people.track_charge people.clear_charges people.delete_user people.remove".split(" "); for(c=0;c<m.length;c++)t(h,m[c]);var q="set set_once union unset remove delete".split(" ");h.get_group=function(){function k(r){g[r]=function(){h.push([n,[r].concat(Array.prototype.slice.call(arguments,0))])}}for(var g={},n=["get_group"].concat(Array.prototype.slice.call(arguments,0)),p=0;p<q.length;p++)k(q[p]);return g};e._i.push([b,f,l])};e.__SV=1.2;var a=d.createElement("script");a.type="text/javascript";a.async=!0;a.src="undefined"!==typeof MIXPANEL_CUSTOM_LIB_URL?MIXPANEL_CUSTOM_LIB_URL:"file:"=== d.location.protocol&&"//cdn.mxpnl.com/libs/mixpanel-2-latest.min.js".match(/^\/\//)?"https://cdn.mxpnl.com/libs/mixpanel-2-latest.min.js":"//cdn.mxpnl.com/libs/mixpanel-2-latest.min.js";d=d.getElementsByTagName("script")[0];d.parentNode.insertBefore(a,d)}})(document,window.mixpanel||[]); (function(d,e){if(d.mixpanel&&"function"===typeof d.mixpanel.init){var m="add_group alias clear_opt_in_out_tracking disable identify opt_in_tracking opt_out_tracking register register_once remove_group reset set_config set_group start_session_recording stop_session_recording time_event track track_forms track_links track_pageview track_with_groups unregister people.append people.clear_charges people.delete_user people.increment people.remove people.set people.set_once people.track_charge people.union people.unset group.remove group.set group.set_once group.union group.unset".split(" ");d[e]= d[e]||function(){var c=[].slice.call(arguments,0),a=c.shift(),b=null,f=a.match(/^([^.]+)\.(.+)$/);f&&3===f.length&&!/people|group/.test(f[1])&&(b=f[1],a=f[2]);if((b=b?window.mixpanel[b]:window.mixpanel)&&-1!==m.indexOf(a))return/^people\./.test(a)?(a=a.split(".").pop(),b.people[a].apply(b.people,c),c=void 0):/^group\./.test(a)?(a=a.split(".").pop(),f=c.shift(),Array.isArray(f)&&2===f.length&&(b=b.get_group.apply(b,f),b[a].apply(b,c)),c=void 0):c=b.push.apply(b,[[a].concat(c)]),c}}})(window,"_mixpanel")