From 6a16393ec8552ef2cd94326c9a954156e4ebb9f7 Mon Sep 17 00:00:00 2001 From: Tim Glaser Date: Fri, 14 Feb 2020 16:11:39 -0800 Subject: [PATCH] Update array.js to use api_host rather than app_host for editor --- bin/copy_tr | 12 ------------ frontend/dist/array.js | 6 +++--- 2 files changed, 3 insertions(+), 15 deletions(-) delete mode 100755 bin/copy_tr diff --git a/bin/copy_tr b/bin/copy_tr deleted file mode 100755 index 3e70958ef8e..00000000000 --- a/bin/copy_tr +++ /dev/null @@ -1,12 +0,0 @@ -cd ../mixpanel-js -npm run build-dist -cd ../posthog - -cp ../mixpanel-js/build/mixpanel.min.js frontend/dist/tr.js -sed -i -e 's/mixpanel/posthog/g' frontend/dist/tr.js -sed -i -e 's/Mixpanel/Posthog/g' frontend/dist/tr.js -sed -i -e 's/mp_/ph_/g' frontend/dist/tr.js -sed -i -e 's/track\//e\//g' frontend/dist/tr.js -sed -i -e 's/api-js\./t\./g' frontend/dist/tr.js - -git add frontend/dist/tr.js -f \ No newline at end of file diff --git a/frontend/dist/array.js b/frontend/dist/array.js index 436d0c8090d..275825b8f89 100644 --- a/frontend/dist/array.js +++ b/frontend/dist/array.js @@ -5,7 +5,7 @@ parcelRequire=function(e,r,t,n){var i,o="function"==typeof parcelRequire&&parcel },{"./config":"itQ5"}],"RYfg":[function(require,module,exports) { "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getClassName=r,exports.getSafeText=n,exports.isElementNode=s,exports.isTag=o,exports.isTextNode=c,exports.shouldCaptureDomEvent=u,exports.shouldCaptureElement=a,exports.shouldCaptureValue=p,exports.usefulElements=void 0;var e=require("./utils");function t(e){return(t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function r(e){switch(t(e.className)){case"string":return e.className;case"object":return e.className.baseVal||e.getAttribute("class")||"";default:return""}}function n(t){var r="";return a(t)&&t.childNodes&&t.childNodes.length&&e._.each(t.childNodes,function(t){c(t)&&t.textContent&&(r+=e._.trim(t.textContent).split(/(\s+)/).filter(p).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255))}),e._.trim(r)}function s(e){return e&&1===e.nodeType}function o(e,t){return e&&e.tagName&&e.tagName.toLowerCase()===t.toLowerCase()}function c(e){return e&&3===e.nodeType}var i=["a","button","form","input","select","textarea","label"];function u(e,t){if(!e||o(e,"html")||!s(e))return!1;for(var r=!1,n=[e],c=e;c.parentNode&&!o(c,"body");)i.indexOf(c.parentNode.tagName.toLowerCase())>-1&&(r=!0),n.push(c.parentNode),c=c.parentNode;var u=e.tagName.toLowerCase();switch(u){case"html":return!1;case"form":return"submit"===t.type;case"input":return"change"===t.type||"click"===t.type;case"select":case"textarea":return"change"===t.type||"click"===t.type;default:return r?"click"==t.type:"click"===t.type&&(i.indexOf(u)>-1||"true"===e.getAttribute("contenteditable"))}}function a(t){for(var n=t;n.parentNode&&!o(n,"body");n=n.parentNode){var s=r(n).split(" ");if(e._.includes(s,"ph-sensitive")||e._.includes(s,"ph-no-capture"))return!1}if(e._.includes(r(t).split(" "),"ph-include"))return!0;if(o(t,"input")&&"button"!=t.type||o(t,"select")||o(t,"textarea")||"true"===t.getAttribute("contenteditable"))return!1;var c=t.type||"";if("string"==typeof c)switch(c.toLowerCase()){case"hidden":case"password":return!1}var i=t.name||t.id||"";if("string"==typeof i){if(/^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i.test(i.replace(/[^a-zA-Z0-9]/g,"")))return!1}return!0}function p(t){if(null===t||e._.isUndefined(t))return!1;if("string"==typeof t){t=e._.trim(t);if(/^(?:(4[0-9]{12}(?:[0-9]{3})?)|(5[1-5][0-9]{14})|(6(?:011|5[0-9]{2})[0-9]{12})|(3[47][0-9]{13})|(3(?:0[0-5]|[68][0-9])[0-9]{11})|((?:2131|1800|35[0-9]{3})[0-9]{11}))$/.test((t||"").replace(/[- ]/g,"")))return!1;if(/(^\d{3}-?\d{2}-?\d{4}$)/.test(t))return!1}return!0}exports.usefulElements=i; },{"./utils":"FOZT"}],"gR3r":[function(require,module,exports) { -"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.autocapture=void 0;var e=require("./utils"),t=require("./autocapture-utils"),o={_initializedTokens:[],_previousElementSibling:function(e){if(e.previousElementSibling)return e.previousElementSibling;do{e=e.previousSibling}while(e&&!(0,t.isElementNode)(e));return e},_loadScript:function(e,t){var o=document.createElement("script");o.type="text/javascript",o.src=e,o.onload=t;var n=document.getElementsByTagName("script");n.length>0?n[0].parentNode.insertBefore(o,n[0]):document.body.appendChild(o)},_getPropertiesFromElement:function(o){var n=o.tagName.toLowerCase(),r={tag_name:n};t.usefulElements.indexOf(n)>-1&&(r.$el_text=(0,t.getSafeText)(o));var a=(0,t.getClassName)(o);a.length>0&&(r.classes=a.split(" ")),(0,t.shouldCaptureElement)(o)&&e._.each(o.attributes,function(e){(0,t.shouldCaptureValue)(e.value)&&(r["attr__"+e.name]=e.value)});for(var i=1,s=1,c=o;c=this._previousElementSibling(c);)i++,c.tagName===o.tagName&&s++;return r.nth_child=i,r.nth_of_type=s,r},_getDefaultProperties:function(e){return{$event_type:e,$ce_version:1,$host:window.location.host,$pathname:window.location.pathname}},_extractCustomPropertyValue:function(o){var n=[];return e._.each(document.querySelectorAll(o.css_selector),function(e){var o;["input","select"].indexOf(e.tagName.toLowerCase())>-1?o=e.value:e.textContent&&(o=e.textContent),(0,t.shouldCaptureValue)(o)&&n.push(o)}),n.join(", ")},_getCustomProperties:function(o){var n={};return e._.each(this._customProperties,function(r){e._.each(r.event_selectors,function(a){var i=document.querySelectorAll(a);e._.each(i,function(a){e._.includes(o,a)&&(0,t.shouldCaptureElement)(a)&&(n[r.name]=this._extractCustomPropertyValue(r))},this)},this)},this),n},_getEventTarget:function(e){return void 0===e.target?e.srcElement:e.target},_captureEvent:function(o,n){var r=this._getEventTarget(o);if((0,t.isTextNode)(r)&&(r=r.parentNode),(0,t.shouldCaptureDomEvent)(r,o)){for(var a=[r],i=r;i.parentNode&&!(0,t.isTag)(i,"body");)a.push(i.parentNode),i=i.parentNode;var s,c=[],u=!1;if(e._.each(a,function(o){var n=(0,t.shouldCaptureElement)(o);"a"===o.tagName.toLowerCase()&&(s=o.getAttribute("href"),s=n&&(0,t.shouldCaptureValue)(s)&&s);var r=(0,t.getClassName)(o).split(" ");e._.includes(r,"ph-no-capture")&&(u=!0),c.push(this._getPropertiesFromElement(o))},this),c[0].$el_text=(0,t.getSafeText)(r),u)return!1;var d=(0,t.getSafeText)(r);d&&d.length&&d;var l=e._.extend(this._getDefaultProperties(o.type),{$elements:c},this._getCustomProperties(a));return n.capture("$autocapture",l),!0}},_navigate:function(e){window.location.href=e},_addDomEventHandlers:function(t){var o=e._.bind(function(e){e=e||window.event,this._captureEvent(e,t)},this);e._.register_event(document,"submit",o,!1,!0),e._.register_event(document,"change",o,!1,!0),e._.register_event(document,"click",o,!1,!0)},_customProperties:{},init:function(t){if(document&&document.body){var o=t.get_config("token");if(this._initializedTokens.indexOf(o)>-1)console.log('autocapture already initialized for token "'+o+'"');else if(this._initializedTokens.push(o),!this._maybeLoadEditor(t)){var n=e._.bind(function(e){e&&e.config&&!0===e.config.enable_collect_everything?(e.custom_properties&&(this._customProperties=e.custom_properties),this._addDomEventHandlers(t)):t.__autocapture_enabled=!1},this);t._send_request(t.get_config("api_host")+"/decide/",{verbose:!0,version:"1",lib:"web",token:o},{method:"GET"},t._prepare_callback(n))}}else{console.log("document not ready yet, trying again in 500 milliseconds...");var r=this;setTimeout(function(){r.init(t)},500)}},_editorParamsFromHash:function(t,o){var n;try{var r=e._.getHashParam(o,"state");r=JSON.parse(decodeURIComponent(r));var a=e._.getHashParam(o,"expires_in");n={accessToken:e._.getHashParam(o,"access_token"),accessTokenExpiresAt:(new Date).getTime()+1e3*Number(a),actionId:r.actionId,projectToken:r.token,apiURL:r.apiURL,temporaryToken:r.temporaryToken},window.sessionStorage.setItem("editorParams",JSON.stringify(n)),window.sessionStorage.setItem("editorActionId",n.actionId),r.desiredHash?window.location.hash=r.desiredHash:window.history?history.replaceState("",document.title,window.location.pathname+window.location.search):window.location.hash=""}catch(i){console.error("Unable to parse data from hash",i)}return n},_maybeLoadEditor:function(t){try{var o=!1;if(e._.getHashParam(window.location.hash,"state")){var n=e._.getHashParam(window.location.hash,"state");o="mpeditor"===(n=JSON.parse(decodeURIComponent(n))).action}var r,a=!!window.sessionStorage.getItem("_mpcehash");return o?r=this._editorParamsFromHash(t,window.location.hash):a?(r=this._editorParamsFromHash(t,window.sessionStorage.getItem("_mpcehash")),window.sessionStorage.removeItem("_mpcehash")):r=JSON.parse(window.sessionStorage.getItem("editorParams")||"{}"),!(!r.projectToken||t.get_config("token")!==r.projectToken)&&(this._loadEditor(t,r),!0)}catch(i){return!1}},_loadEditor:function(e,t){if(!window._mpEditorLoaded){window._mpEditorLoaded=!0;var o=e.get_config("app_host")+"/static/editor.js?_ts="+(new Date).getTime();return this._loadScript(o,function(){window.ph_load_editor(t)}),!0}return!1},enabledForProject:function(t,o,n){o=e._.isUndefined(o)?10:o,n=e._.isUndefined(n)?10:n;for(var r=0,a=0;a0?n[0].parentNode.insertBefore(o,n[0]):document.body.appendChild(o)},_getPropertiesFromElement:function(o){var n=o.tagName.toLowerCase(),r={tag_name:n};t.usefulElements.indexOf(n)>-1&&(r.$el_text=(0,t.getSafeText)(o));var a=(0,t.getClassName)(o);a.length>0&&(r.classes=a.split(" ")),(0,t.shouldCaptureElement)(o)&&e._.each(o.attributes,function(e){(0,t.shouldCaptureValue)(e.value)&&(r["attr__"+e.name]=e.value)});for(var i=1,s=1,c=o;c=this._previousElementSibling(c);)i++,c.tagName===o.tagName&&s++;return r.nth_child=i,r.nth_of_type=s,r},_getDefaultProperties:function(e){return{$event_type:e,$ce_version:1,$host:window.location.host,$pathname:window.location.pathname}},_extractCustomPropertyValue:function(o){var n=[];return e._.each(document.querySelectorAll(o.css_selector),function(e){var o;["input","select"].indexOf(e.tagName.toLowerCase())>-1?o=e.value:e.textContent&&(o=e.textContent),(0,t.shouldCaptureValue)(o)&&n.push(o)}),n.join(", ")},_getCustomProperties:function(o){var n={};return e._.each(this._customProperties,function(r){e._.each(r.event_selectors,function(a){var i=document.querySelectorAll(a);e._.each(i,function(a){e._.includes(o,a)&&(0,t.shouldCaptureElement)(a)&&(n[r.name]=this._extractCustomPropertyValue(r))},this)},this)},this),n},_getEventTarget:function(e){return void 0===e.target?e.srcElement:e.target},_captureEvent:function(o,n){var r=this._getEventTarget(o);if((0,t.isTextNode)(r)&&(r=r.parentNode),(0,t.shouldCaptureDomEvent)(r,o)){for(var a=[r],i=r;i.parentNode&&!(0,t.isTag)(i,"body");)a.push(i.parentNode),i=i.parentNode;var s,c=[],u=!1;if(e._.each(a,function(o){var n=(0,t.shouldCaptureElement)(o);"a"===o.tagName.toLowerCase()&&(s=o.getAttribute("href"),s=n&&(0,t.shouldCaptureValue)(s)&&s);var r=(0,t.getClassName)(o).split(" ");e._.includes(r,"ph-no-capture")&&(u=!0),c.push(this._getPropertiesFromElement(o))},this),c[0].$el_text=(0,t.getSafeText)(r),u)return!1;var d=(0,t.getSafeText)(r);d&&d.length&&d;var l=e._.extend(this._getDefaultProperties(o.type),{$elements:c},this._getCustomProperties(a));return n.capture("$autocapture",l),!0}},_navigate:function(e){window.location.href=e},_addDomEventHandlers:function(t){var o=e._.bind(function(e){e=e||window.event,this._captureEvent(e,t)},this);e._.register_event(document,"submit",o,!1,!0),e._.register_event(document,"change",o,!1,!0),e._.register_event(document,"click",o,!1,!0)},_customProperties:{},init:function(t){if(document&&document.body){var o=t.get_config("token");if(this._initializedTokens.indexOf(o)>-1)console.log('autocapture already initialized for token "'+o+'"');else if(this._initializedTokens.push(o),!this._maybeLoadEditor(t)){var n=e._.bind(function(e){e&&e.config&&!0===e.config.enable_collect_everything?(e.custom_properties&&(this._customProperties=e.custom_properties),this._addDomEventHandlers(t)):t.__autocapture_enabled=!1},this);t._send_request(t.get_config("api_host")+"/decide/",{verbose:!0,version:"1",lib:"web",token:o},{method:"GET"},t._prepare_callback(n))}}else{console.log("document not ready yet, trying again in 500 milliseconds...");var r=this;setTimeout(function(){r.init(t)},500)}},_editorParamsFromHash:function(t,o){var n;try{var r=e._.getHashParam(o,"state");r=JSON.parse(decodeURIComponent(r));var a=e._.getHashParam(o,"expires_in");n={accessToken:e._.getHashParam(o,"access_token"),accessTokenExpiresAt:(new Date).getTime()+1e3*Number(a),actionId:r.actionId,projectToken:r.token,apiURL:r.apiURL,temporaryToken:r.temporaryToken},window.sessionStorage.setItem("editorParams",JSON.stringify(n)),window.sessionStorage.setItem("editorActionId",n.actionId),r.desiredHash?window.location.hash=r.desiredHash:window.history?history.replaceState("",document.title,window.location.pathname+window.location.search):window.location.hash=""}catch(i){console.error("Unable to parse data from hash",i)}return n},_maybeLoadEditor:function(t){try{var o=!1;if(e._.getHashParam(window.location.hash,"state")){var n=e._.getHashParam(window.location.hash,"state");o="mpeditor"===(n=JSON.parse(decodeURIComponent(n))).action}var r,a=!!window.sessionStorage.getItem("_mpcehash");return o?r=this._editorParamsFromHash(t,window.location.hash):a?(r=this._editorParamsFromHash(t,window.sessionStorage.getItem("_mpcehash")),window.sessionStorage.removeItem("_mpcehash")):r=JSON.parse(window.sessionStorage.getItem("editorParams")||"{}"),!(!r.projectToken||t.get_config("token")!==r.projectToken)&&(this._loadEditor(t,r),!0)}catch(i){return!1}},_loadEditor:function(e,t){if(!window._mpEditorLoaded){window._mpEditorLoaded=!0;var o=e.get_config("api_host")+"/static/editor.js?_ts="+(new Date).getTime();return this._loadScript(o,function(){window.ph_load_editor(t)}),!0}return!1},enabledForProject:function(t,o,n){o=e._.isUndefined(o)?10:o,n=e._.isUndefined(n)?10:n;for(var r=0,a=0;as&&delete e[r];o._.isEmptyObject(e)&&delete this.props[E]}}),m.prototype.update_campaign_params=function(){this.campaign_params_saved||(this.register_once(o._.info.campaignParams()),this.campaign_params_saved=!0)},m.prototype.update_search_keyword=function(e){this.register(o._.info.searchInfo(e))},m.prototype.update_referrer_info=function(e){this.register_once({$initial_referrer:e||"$direct",$initial_referring_domain:o._.info.referringDomain(e)||"$direct"},"")},m.prototype.get_referrer_info=function(){return o._.strip_empty_properties({$initial_referrer:this.props.$initial_referrer,$initial_referring_domain:this.props.$initial_referring_domain})},m.prototype.safe_merge=function(e){return o._.each(this.props,function(t,o){o in e||(e[o]=t)}),e},m.prototype.update_config=function(e){this.default_expiry=this.expire_days=e.cookie_expiration,this.set_disabled(e.disable_persistence),this.set_cross_subdomain(e.cross_subdomain_cookie),this.set_secure(e.secure_cookie)},m.prototype.set_disabled=function(e){this.disabled=e,this.disabled?this.remove():this.save()},m.prototype.set_cross_subdomain=function(e){e!==this.cross_subdomain&&(this.cross_subdomain=e,this.remove(),this.save())},m.prototype.get_cross_subdomain=function(){return this.cross_subdomain},m.prototype.set_secure=function(e){e!==this.secure&&(this.secure=!!e,this.remove(),this.save())},m.prototype._add_to_people_queue=function(t,s){var h=this._get_queue_key(t),c=s[t],E=this._get_or_create_queue(e.SET_ACTION),f=this._get_or_create_queue(e.SET_ONCE_ACTION),d=this._get_or_create_queue(e.UNSET_ACTION),m=this._get_or_create_queue(e.ADD_ACTION),g=this._get_or_create_queue(e.UNION_ACTION),l=this._get_or_create_queue(e.REMOVE_ACTION,[]),N=this._get_or_create_queue(e.APPEND_ACTION,[]);h===r?(o._.extend(E,c),this._pop_from_people_queue(e.ADD_ACTION,c),this._pop_from_people_queue(e.UNION_ACTION,c),this._pop_from_people_queue(e.UNSET_ACTION,c)):h===i?(o._.each(c,function(e,t){t in f||(f[t]=e)}),this._pop_from_people_queue(e.UNSET_ACTION,c)):h===_?o._.each(c,function(e){o._.each([E,f,m,g],function(t){e in t&&delete t[e]}),o._.each(N,function(t){e in t&&delete t[e]}),d[e]=!0}):h===p?(o._.each(c,function(e,t){t in E?E[t]+=e:(t in m||(m[t]=0),m[t]+=e)},this),this._pop_from_people_queue(e.UNSET_ACTION,c)):h===u?(o._.each(c,function(e,t){o._.isArray(e)&&(t in g||(g[t]=[]),g[t]=g[t].concat(e))}),this._pop_from_people_queue(e.UNSET_ACTION,c)):h===a?(l.push(c),this._pop_from_people_queue(e.APPEND_ACTION,c)):h===n&&(N.push(c),this._pop_from_people_queue(e.UNSET_ACTION,c)),o.console.log("POSTHOG PEOPLE REQUEST (QUEUED, PENDING IDENTIFY):"),o.console.log(s),this.save()},m.prototype._pop_from_people_queue=function(t,s){var r=this._get_queue(t);o._.isUndefined(r)||(o._.each(s,function(s,i){t===e.APPEND_ACTION||t===e.REMOVE_ACTION?o._.each(r,function(e){e[i]===s&&delete e[i]}):delete r[i]},this),this.save())},m.prototype._get_queue_key=function(t){return t===e.SET_ACTION?r:t===e.SET_ONCE_ACTION?i:t===e.UNSET_ACTION?_:t===e.ADD_ACTION?p:t===e.APPEND_ACTION?n:t===e.REMOVE_ACTION?a:t===e.UNION_ACTION?u:void o.console.error("Invalid queue:",t)},m.prototype._get_queue=function(e){return this.props[this._get_queue_key(e)]},m.prototype._get_or_create_queue=function(e,t){var s=this._get_queue_key(e);return t=o._.isUndefined(t)?{}:t,this.props[s]||(this.props[s]=t)},m.prototype.set_event_timer=function(e,t){var o=this.props[f]||{};o[e]=t,this.props[f]=o,this.save()},m.prototype.remove_event_timer=function(e){var t=(this.props[f]||{})[e];return o._.isUndefined(t)||(delete this.props[f][e],this.save()),t}; },{"./api-actions":"os8r","./config":"itQ5","./utils":"FOZT"}],"ok3T":[function(require,module,exports) { -"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.init_from_snippet=O,exports.init_as_module=E;var e,t,o=a(require("./config")),i=require("./utils"),r=require("./autocapture"),n=require("./dom-capture"),s=require("./posthog-group"),p=require("./posthog-people"),_=require("./posthog-persistence"),c=require("./gdpr-utils");function a(e){return e&&e.__esModule?e:{default:e}}var u=0,d=1,g="posthog",l=i.window.XMLHttpRequest&&"withCredentials"in new XMLHttpRequest,h=!l&&-1===i.userAgent.indexOf("MSIE")&&-1===i.userAgent.indexOf("Mozilla"),f=i.navigator.sendBeacon;f&&(f=i._.bind(f,i.navigator));var y={api_host:"https://t.posthog.com",api_method:"POST",api_transport:"XHR",app_host:"https://app.posthog.com",autocapture:!0,cdn:"https://cdn.posthog.com",cross_subdomain_cookie:!0,persistence:"cookie",persistence_name:"",cookie_name:"",loaded:function(){},store_google:!0,save_referrer:!0,test:!1,verbose:!1,img:!1,capture_pageview:!0,debug:!1,capture_links_timeout:300,cookie_expiration:365,upgrade:!1,disable_persistence:!1,disable_cookie:!1,secure_cookie:!1,ip:!0,opt_out_captureing_by_default:!1,opt_out_persistence_by_default:!1,opt_out_captureing_persistence_type:"localStorage",opt_out_captureing_cookie_prefix:null,property_blacklist:[],xhr_headers:{},inapp_protocol:"//",inapp_link_new_window:!1},m=!1,v=function(){},b=function(n,s,_){var c,a=_===g?t:t[_];if(a&&e===u)c=a;else{if(a&&!i._.isArray(a))return void i.console.error("You have already initialized "+_);c=new v}if(c._cached_groups={},c._user_decide_check_complete=!1,c._events_captureed_before_user_decide_check_complete=[],c._init(n,s,_),c.people=new p.PostHogPeople,c.people._init(c),o.default.DEBUG=o.default.DEBUG||c.get_config("debug"),c.__autocapture_enabled=c.get_config("autocapture"),c.get_config("autocapture")){r.autocapture.enabledForProject(c.get_config("token"),100,100)?r.autocapture.isBrowserSupported()?r.autocapture.init(c):(c.__autocapture_enabled=!1,i.console.log("Disabling Automatic Event Collection because this browser is not supported")):(c.__autocapture_enabled=!1,i.console.log("Not in active bucket: disabling Automatic Event Collection."))}return!i._.isUndefined(a)&&i._.isArray(a)&&(c._execute_array.call(c.people,a.people),c._execute_array(a)),c};v.prototype.init=function(e,o,r){if(i._.isUndefined(r))i.console.error("You must name your new library: init(token, config, name)");else{if(r!==g){var n=b(e,o,r);return t[r]=n,n._loaded(),n}i.console.error("You must initialize the main posthog object right after you include the PostHog js snippet")}},v.prototype._init=function(e,t,o){this.__loaded=!0,this.config={},this._triggered_notifs=[],this.set_config(i._.extend({},y,t,{name:o,token:e,callback_fn:(o===g?o:g+"."+o)+"._jsc"})),this._jsc=function(){},this.__dom_loaded_queue=[],this.__request_queue=[],this.__disabled_events=[],this._flags={disable_all_events:!1,identify_called:!1},this.persistence=this.cookie=new _.PostHogPersistence(this.config),this._gdpr_init();var r=i._.UUID();this.get_distinct_id()||this.register_once({distinct_id:r,$device_id:r},"")},v.prototype._loaded=function(){this.get_config("loaded")(this),this.get_config("capture_pageview")&&this.capture_pageview()},v.prototype._dom_loaded=function(){i._.each(this.__dom_loaded_queue,function(e){this._capture_dom.apply(this,e)},this),this.has_opted_out_captureing()||i._.each(this.__request_queue,function(e){this._send_request.apply(this,e)},this),delete this.__dom_loaded_queue,delete this.__request_queue},v.prototype._capture_dom=function(e,t){if(this.get_config("img"))return i.console.error("You can't use DOM captureing functions with img = true."),!1;if(!m)return this.__dom_loaded_queue.push([e,t]),!1;var o=(new e).init(this);return o.capture.apply(o,t)},v.prototype._prepare_callback=function(e,t){if(i._.isUndefined(e))return null;if(l){return function(o){e(o,t)}}var o=this._jsc,r=""+Math.floor(1e8*Math.random()),n=this.get_config("callback_fn")+"["+r+"]";return o[r]=function(i){delete o[r],e(i,t)},n},v.prototype._send_request=function(e,t,o,r){if(h)this.__request_queue.push(arguments);else{var n={method:this.get_config("api_method"),transport:this.get_config("api_transport")},s=null;r||!i._.isFunction(o)&&"string"!=typeof o||(r=o,o=null),o=i._.extend(n,o||{}),l||(o.method="GET");var p=f&&"sendbeacon"===o.transport.toLowerCase(),_=p||"POST"===o.method,c=this.get_config("verbose");if(t.verbose&&(c=!0),this.get_config("test")&&(t.test=1),c&&(t.verbose=1),this.get_config("img")&&(t.img=1),l||(r?t.callback=r:(c||this.get_config("test"))&&(t.callback="(function(){})")),t.ip=this.get_config("ip")?1:0,t._=(new Date).getTime().toString(),_&&(s="data="+t.data,delete t.data),e+="?"+i._.HTTPBuildQuery(t),"img"in t){var a=i.document.createElement("img");a.src=e,i.document.body.appendChild(a)}else if(p)try{f(e,s)}catch(m){i.console.error(m)}else if(l)try{var u=new XMLHttpRequest;u.open(o.method,e,!0);var d=this.get_config("xhr_headers");_&&(d["Content-Type"]="application/x-www-form-urlencoded"),i._.each(d,function(e,t){u.setRequestHeader(t,e)}),u.withCredentials=!0,u.onreadystatechange=function(){if(4===u.readyState)if(200===u.status){if(r)if(c){var e;try{e=i._.JSONDecode(u.responseText)}catch(m){return void i.console.error(m)}r(e)}else r(Number(u.responseText))}else{var t="Bad HTTP status: "+u.status+" "+u.statusText;i.console.error(t),r&&r(c?{status:0,error:t}:0)}},u.send(s)}catch(m){i.console.error(m)}else{var g=i.document.createElement("script");g.type="text/javascript",g.async=!0,g.defer=!0,g.src=e;var y=i.document.getElementsByTagName("script")[0];y.parentNode.insertBefore(g,y)}}},v.prototype._execute_array=function(e){var t,o=[],r=[],n=[];i._.each(e,function(e){e&&(t=e[0],i._.isArray(t)?n.push(e):"function"==typeof e?e.call(this):i._.isArray(e)&&"alias"===t?o.push(e):i._.isArray(e)&&-1!==t.indexOf("capture")&&"function"==typeof this[t]?n.push(e):r.push(e))},this);var s=function(e,t){i._.each(e,function(e){if(i._.isArray(e[0])){var o=t;i._.each(e,function(e){o=o[e[0]].apply(o,e.slice(1))})}else this[e[0]].apply(this,e.slice(1))},t)};s(o,this),s(r,this),s(n,this)},v.prototype.push=function(e){this._execute_array([e])},v.prototype.disable=function(e){void 0===e?this._flags.disable_all_events=!0:this.__disabled_events=this.__disabled_events.concat(e)},v.prototype.capture=(0,c.addOptOutCheckPostHogLib)(function(e,t,o,r){r||"function"!=typeof o||(r=o,o=null);var n=(o=o||{}).transport;if(n&&(o.transport=n),"function"!=typeof r&&(r=function(){}),i._.isUndefined(e))i.console.error("No event name provided to posthog.capture");else{if(!this._event_is_disabled(e)){(t=t||{}).token=this.get_config("token");var s=this.persistence.remove_event_timer(e);if(!i._.isUndefined(s)){var p=(new Date).getTime()-s;t.$duration=parseFloat((p/1e3).toFixed(3))}this.persistence.update_search_keyword(i.document.referrer),this.get_config("store_google")&&this.persistence.update_campaign_params(),this.get_config("save_referrer")&&this.persistence.update_referrer_info(i.document.referrer),t=i._.extend({},i._.info.properties(),this.persistence.properties(),t);var _=this.get_config("property_blacklist");i._.isArray(_)?i._.each(_,function(e){delete t[e]}):i.console.error("Invalid value for property_blacklist config: "+_);var c={event:e,properties:t},a=i._.truncate(c,255),u=i._.JSONEncode(a),d=i._.base64Encode(u);return i.console.log("POSTHOG REQUEST:"),i.console.log(a),this._send_request(this.get_config("api_host")+"/e/",{data:d},o,this._prepare_callback(r,a)),a}r(0)}}),v.prototype.set_group=(0,c.addOptOutCheckPostHogLib)(function(e,t,o){i._.isArray(t)||(t=[t]);var r={};return r[e]=t,this.register(r),this.people.set(e,t,o)}),v.prototype.add_group=(0,c.addOptOutCheckPostHogLib)(function(e,t,o){var i=this.get_property(e);if(void 0===i){var r={};r[e]=[t],this.register(r)}else-1===i.indexOf(t)&&(i.push(t),this.register(r));return this.people.union(e,t,o)}),v.prototype.remove_group=(0,c.addOptOutCheckPostHogLib)(function(e,t,o){var i=this.get_property(e);if(void 0!==i){var r=i.indexOf(t);r>-1&&(i.splice(r,1),this.register({group_key:i})),0===i.length&&this.unregister(e)}return this.people.remove(e,t,o)}),v.prototype.capture_with_groups=(0,c.addOptOutCheckPostHogLib)(function(e,t,o,r){var n=i._.extend({},t||{});return i._.each(o,function(e,t){null!=e&&(n[t]=e)}),this.capture(e,n,r)}),v.prototype._create_map_key=function(e,t){return e+"_"+JSON.stringify(t)},v.prototype._remove_group_from_cache=function(e,t){delete this._cached_groups[this._create_map_key(e,t)]},v.prototype.get_group=function(e,t){var o=this._create_map_key(e,t),i=this._cached_groups[o];return void 0!==i&&i._group_key===e&&i._group_id===t||((i=new s.PostHogGroup)._init(this,e,t),this._cached_groups[o]=i),i},v.prototype.capture_pageview=function(e){i._.isUndefined(e)&&(e=i.document.location.href),this.capture("$pageview")},v.prototype.capture_links=function(){return this._capture_dom.call(this,n.LinkCapture,arguments)},v.prototype.capture_forms=function(){return this._capture_dom.call(this,FormCaptureer,arguments)},v.prototype.time_event=function(e){i._.isUndefined(e)?i.console.error("No event name provided to posthog.time_event"):this._event_is_disabled(e)||this.persistence.set_event_timer(e,(new Date).getTime())},v.prototype.register=function(e,t){this.persistence.register(e,t)},v.prototype.register_once=function(e,t,o){this.persistence.register_once(e,t,o)},v.prototype.unregister=function(e){this.persistence.unregister(e)},v.prototype._register_single=function(e,t){var o={};o[e]=t,this.register(o)},v.prototype.identify=function(e,t,o,i,r,n,s,p){var c=this.get_distinct_id();if(this.register({$user_id:e}),!this.get_property("$device_id")){var a=c;this.register_once({$had_persisted_distinct_id:!0,$device_id:a},"")}e!==c&&e!==this.get_property(_.ALIAS_ID_KEY)&&(this.unregister(_.ALIAS_ID_KEY),this.register({distinct_id:e})),this._flags.identify_called=!0,this.people._flush(t,o,i,r,n,s,p),e!==c&&this.capture("$identify",{distinct_id:e,$anon_distinct_id:c})},v.prototype.reset=function(){this.persistence.clear(),this._flags.identify_called=!1;var e=i._.UUID();this.register_once({distinct_id:e,$device_id:e},"")},v.prototype.get_distinct_id=function(){return this.get_property("distinct_id")},v.prototype.alias=function(e,t){if(e===this.get_property(_.PEOPLE_DISTINCT_ID_KEY))return i.console.critical("Attempting to create alias for existing People user - aborting."),-2;var o=this;return i._.isUndefined(t)&&(t=this.get_distinct_id()),e!==t?(this._register_single(_.ALIAS_ID_KEY,e),this.capture("$create_alias",{alias:e,distinct_id:t},function(){o.identify(e)})):(i.console.error("alias matches current distinct_id - skipping api call."),this.identify(e),-1)},v.prototype.name_tag=function(e){this._register_single("ph_name_tag",e)},v.prototype.set_config=function(e){i._.isObject(e)&&(i._.extend(this.config,e),this.get_config("persistence_name")||(this.config.persistence_name=this.config.cookie_name),this.get_config("disable_persistence")||(this.config.disable_persistence=this.config.disable_cookie),this.persistence&&this.persistence.update_config(this.config),o.default.DEBUG=o.default.DEBUG||this.get_config("debug"))},v.prototype.get_config=function(e){return this.config[e]},v.prototype.get_property=function(e){return this.persistence.props[e]},v.prototype.toString=function(){var e=this.get_config("name");return e!==g&&(e=g+"."+e),e},v.prototype._event_is_disabled=function(e){return i._.isBlockedUA(i.userAgent)||this._flags.disable_all_events||i._.include(this.__disabled_events,e)},v.prototype._handle_user_decide_check_complete=function(){this._user_decide_check_complete=!0},v.prototype._gdpr_init=function(){"localStorage"===this.get_config("opt_out_captureing_persistence_type")&&i._.localStorage.is_supported()&&(!this.has_opted_in_captureing()&&this.has_opted_in_captureing({persistence_type:"cookie"})&&this.opt_in_captureing({enable_persistence:!1}),!this.has_opted_out_captureing()&&this.has_opted_out_captureing({persistence_type:"cookie"})&&this.opt_out_captureing({clear_persistence:!1}),this.clear_opt_in_out_captureing({persistence_type:"cookie",enable_persistence:!1})),this.has_opted_out_captureing()?this._gdpr_update_persistence({clear_persistence:!0}):this.has_opted_in_captureing()||!this.get_config("opt_out_captureing_by_default")&&!i._.cookie.get("ph_optout")||(i._.cookie.remove("ph_optout"),this.opt_out_captureing({clear_persistence:this.get_config("opt_out_persistence_by_default")}))},v.prototype._gdpr_update_persistence=function(e){var t;if(e&&e.clear_persistence)t=!0;else{if(!e||!e.enable_persistence)return;t=!1}this.get_config("disable_persistence")||this.persistence.disabled===t||this.persistence.set_disabled(t)},v.prototype._gdpr_call_func=function(e,t){return t=i._.extend({capture:i._.bind(this.capture,this),persistence_type:this.get_config("opt_out_captureing_persistence_type"),cookie_prefix:this.get_config("opt_out_captureing_cookie_prefix"),cookie_expiration:this.get_config("cookie_expiration"),cross_subdomain_cookie:this.get_config("cross_subdomain_cookie"),secure_cookie:this.get_config("secure_cookie")},t),i._.localStorage.is_supported()||(t.persistence_type="cookie"),e(this.get_config("token"),{capture:t.capture,captureEventName:t.capture_event_name,captureProperties:t.capture_properties,persistenceType:t.persistence_type,persistencePrefix:t.cookie_prefix,cookieExpiration:t.cookie_expiration,crossSubdomainCookie:t.cross_subdomain_cookie,secureCookie:t.secure_cookie})},v.prototype.opt_in_captureing=function(e){e=i._.extend({enable_persistence:!0},e),this._gdpr_call_func(c.optIn,e),this._gdpr_update_persistence(e)},v.prototype.opt_out_captureing=function(e){(e=i._.extend({clear_persistence:!0,delete_user:!0},e)).delete_user&&this.people&&this.people._identify_called()&&(this.people.delete_user(),this.people.clear_charges()),this._gdpr_call_func(c.optOut,e),this._gdpr_update_persistence(e)},v.prototype.has_opted_in_captureing=function(e){return this._gdpr_call_func(c.hasOptedIn,e)},v.prototype.has_opted_out_captureing=function(e){return this._gdpr_call_func(c.hasOptedOut,e)},v.prototype.clear_opt_in_out_captureing=function(e){e=i._.extend({enable_persistence:!0},e),this._gdpr_call_func(c.clearOptInOut,e),this._gdpr_update_persistence(e)},v.prototype.init=v.prototype.init,v.prototype.reset=v.prototype.reset,v.prototype.disable=v.prototype.disable,v.prototype.time_event=v.prototype.time_event,v.prototype.capture=v.prototype.capture,v.prototype.capture_links=v.prototype.capture_links,v.prototype.capture_forms=v.prototype.capture_forms,v.prototype.capture_pageview=v.prototype.capture_pageview,v.prototype.register=v.prototype.register,v.prototype.register_once=v.prototype.register_once,v.prototype.unregister=v.prototype.unregister,v.prototype.identify=v.prototype.identify,v.prototype.alias=v.prototype.alias,v.prototype.name_tag=v.prototype.name_tag,v.prototype.set_config=v.prototype.set_config,v.prototype.get_config=v.prototype.get_config,v.prototype.get_property=v.prototype.get_property,v.prototype.get_distinct_id=v.prototype.get_distinct_id,v.prototype.toString=v.prototype.toString,v.prototype._check_and_handle_notifications=v.prototype._check_and_handle_notifications,v.prototype._handle_user_decide_check_complete=v.prototype._handle_user_decide_check_complete,v.prototype.opt_out_captureing=v.prototype.opt_out_captureing,v.prototype.opt_in_captureing=v.prototype.opt_in_captureing,v.prototype.has_opted_out_captureing=v.prototype.has_opted_out_captureing,v.prototype.has_opted_in_captureing=v.prototype.has_opted_in_captureing,v.prototype.clear_opt_in_out_captureing=v.prototype.clear_opt_in_out_captureing,v.prototype.get_group=v.prototype.get_group,v.prototype.set_group=v.prototype.set_group,v.prototype.add_group=v.prototype.add_group,v.prototype.remove_group=v.prototype.remove_group,v.prototype.capture_with_groups=v.prototype.capture_with_groups,_.PostHogPersistence.prototype.properties=_.PostHogPersistence.prototype.properties,_.PostHogPersistence.prototype.update_search_keyword=_.PostHogPersistence.prototype.update_search_keyword,_.PostHogPersistence.prototype.update_referrer_info=_.PostHogPersistence.prototype.update_referrer_info,_.PostHogPersistence.prototype.get_cross_subdomain=_.PostHogPersistence.prototype.get_cross_subdomain,_.PostHogPersistence.prototype.clear=_.PostHogPersistence.prototype.clear,i._.safewrap_class(v,["identify","_check_and_handle_notifications"]);var k={},w=function(){i._.each(k,function(e,o){o!==g&&(t[o]=e)}),t._=i._},P=function(){t.init=function(o,r,n){if(n)return t[n]||(t[n]=k[n]=b(o,r,n),t[n]._loaded()),t[n];var s=t;k[g]?s=k[g]:o&&((s=b(o,r,g))._loaded(),k[g]=s),t=s,e===d&&(i.window[g]=t),w()}},x=function(){function e(){e.done||(e.done=!0,m=!0,h=!1,i._.each(k,function(e){e._dom_loaded()}))}if(i.document.addEventListener)"complete"===i.document.readyState?e():i.document.addEventListener("DOMContentLoaded",e,!1);else if(i.document.attachEvent){i.document.attachEvent("onreadystatechange",e);var t=!1;try{t=null===i.window.frameElement}catch(o){}i.document.documentElement.doScroll&&t&&function t(){try{i.document.documentElement.doScroll("left")}catch(o){return void setTimeout(t,1)}e()}()}i._.register_event(i.window,"load",e,!0)};function O(){e=d,i._.isUndefined(i.window.posthog)&&(i.window.posthog=[]),(t=i.window.posthog).__loaded||t.config&&t.persistence?i.console.error("PostHog library has already been downloaded at least once."):(i._.each(t._i,function(e){e&&i._.isArray(e)&&(k[e[e.length-1]]=b.apply(this,e))}),P(),t.init(),i._.each(k,function(e){e._loaded()}),x())}function E(){return e=u,t=new v,P(),t.init(),x(),t} +"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.init_from_snippet=O,exports.init_as_module=E;var e,t,o=a(require("./config")),i=require("./utils"),r=require("./autocapture"),n=require("./dom-capture"),s=require("./posthog-group"),p=require("./posthog-people"),_=require("./posthog-persistence"),c=require("./gdpr-utils");function a(e){return e&&e.__esModule?e:{default:e}}var u=0,d=1,g="posthog",l=i.window.XMLHttpRequest&&"withCredentials"in new XMLHttpRequest,h=!l&&-1===i.userAgent.indexOf("MSIE")&&-1===i.userAgent.indexOf("Mozilla"),f=i.navigator.sendBeacon;f&&(f=i._.bind(f,i.navigator));var y={api_host:"https://t.posthog.com",api_method:"POST",api_transport:"XHR",autocapture:!0,cdn:"https://cdn.posthog.com",cross_subdomain_cookie:!0,persistence:"cookie",persistence_name:"",cookie_name:"",loaded:function(){},store_google:!0,save_referrer:!0,test:!1,verbose:!1,img:!1,capture_pageview:!0,debug:!1,capture_links_timeout:300,cookie_expiration:365,upgrade:!1,disable_persistence:!1,disable_cookie:!1,secure_cookie:!1,ip:!0,opt_out_captureing_by_default:!1,opt_out_persistence_by_default:!1,opt_out_captureing_persistence_type:"localStorage",opt_out_captureing_cookie_prefix:null,property_blacklist:[],xhr_headers:{},inapp_protocol:"//",inapp_link_new_window:!1},m=!1,v=function(){},b=function(n,s,_){var c,a=_===g?t:t[_];if(a&&e===u)c=a;else{if(a&&!i._.isArray(a))return void i.console.error("You have already initialized "+_);c=new v}if(c._cached_groups={},c._user_decide_check_complete=!1,c._events_captureed_before_user_decide_check_complete=[],c._init(n,s,_),c.people=new p.PostHogPeople,c.people._init(c),o.default.DEBUG=o.default.DEBUG||c.get_config("debug"),c.__autocapture_enabled=c.get_config("autocapture"),c.get_config("autocapture")){r.autocapture.enabledForProject(c.get_config("token"),100,100)?r.autocapture.isBrowserSupported()?r.autocapture.init(c):(c.__autocapture_enabled=!1,i.console.log("Disabling Automatic Event Collection because this browser is not supported")):(c.__autocapture_enabled=!1,i.console.log("Not in active bucket: disabling Automatic Event Collection."))}return!i._.isUndefined(a)&&i._.isArray(a)&&(c._execute_array.call(c.people,a.people),c._execute_array(a)),c};v.prototype.init=function(e,o,r){if(i._.isUndefined(r))i.console.error("You must name your new library: init(token, config, name)");else{if(r!==g){var n=b(e,o,r);return t[r]=n,n._loaded(),n}i.console.error("You must initialize the main posthog object right after you include the PostHog js snippet")}},v.prototype._init=function(e,t,o){this.__loaded=!0,this.config={},this._triggered_notifs=[],this.set_config(i._.extend({},y,t,{name:o,token:e,callback_fn:(o===g?o:g+"."+o)+"._jsc"})),this._jsc=function(){},this.__dom_loaded_queue=[],this.__request_queue=[],this.__disabled_events=[],this._flags={disable_all_events:!1,identify_called:!1},this.persistence=this.cookie=new _.PostHogPersistence(this.config),this._gdpr_init();var r=i._.UUID();this.get_distinct_id()||this.register_once({distinct_id:r,$device_id:r},"")},v.prototype._loaded=function(){this.get_config("loaded")(this),this.get_config("capture_pageview")&&this.capture_pageview()},v.prototype._dom_loaded=function(){i._.each(this.__dom_loaded_queue,function(e){this._capture_dom.apply(this,e)},this),this.has_opted_out_captureing()||i._.each(this.__request_queue,function(e){this._send_request.apply(this,e)},this),delete this.__dom_loaded_queue,delete this.__request_queue},v.prototype._capture_dom=function(e,t){if(this.get_config("img"))return i.console.error("You can't use DOM captureing functions with img = true."),!1;if(!m)return this.__dom_loaded_queue.push([e,t]),!1;var o=(new e).init(this);return o.capture.apply(o,t)},v.prototype._prepare_callback=function(e,t){if(i._.isUndefined(e))return null;if(l){return function(o){e(o,t)}}var o=this._jsc,r=""+Math.floor(1e8*Math.random()),n=this.get_config("callback_fn")+"["+r+"]";return o[r]=function(i){delete o[r],e(i,t)},n},v.prototype._send_request=function(e,t,o,r){if(h)this.__request_queue.push(arguments);else{var n={method:this.get_config("api_method"),transport:this.get_config("api_transport")},s=null;r||!i._.isFunction(o)&&"string"!=typeof o||(r=o,o=null),o=i._.extend(n,o||{}),l||(o.method="GET");var p=f&&"sendbeacon"===o.transport.toLowerCase(),_=p||"POST"===o.method,c=this.get_config("verbose");if(t.verbose&&(c=!0),this.get_config("test")&&(t.test=1),c&&(t.verbose=1),this.get_config("img")&&(t.img=1),l||(r?t.callback=r:(c||this.get_config("test"))&&(t.callback="(function(){})")),t.ip=this.get_config("ip")?1:0,t._=(new Date).getTime().toString(),_&&(s="data="+t.data,delete t.data),e+="?"+i._.HTTPBuildQuery(t),"img"in t){var a=i.document.createElement("img");a.src=e,i.document.body.appendChild(a)}else if(p)try{f(e,s)}catch(m){i.console.error(m)}else if(l)try{var u=new XMLHttpRequest;u.open(o.method,e,!0);var d=this.get_config("xhr_headers");_&&(d["Content-Type"]="application/x-www-form-urlencoded"),i._.each(d,function(e,t){u.setRequestHeader(t,e)}),u.withCredentials=!0,u.onreadystatechange=function(){if(4===u.readyState)if(200===u.status){if(r)if(c){var e;try{e=i._.JSONDecode(u.responseText)}catch(m){return void i.console.error(m)}r(e)}else r(Number(u.responseText))}else{var t="Bad HTTP status: "+u.status+" "+u.statusText;i.console.error(t),r&&r(c?{status:0,error:t}:0)}},u.send(s)}catch(m){i.console.error(m)}else{var g=i.document.createElement("script");g.type="text/javascript",g.async=!0,g.defer=!0,g.src=e;var y=i.document.getElementsByTagName("script")[0];y.parentNode.insertBefore(g,y)}}},v.prototype._execute_array=function(e){var t,o=[],r=[],n=[];i._.each(e,function(e){e&&(t=e[0],i._.isArray(t)?n.push(e):"function"==typeof e?e.call(this):i._.isArray(e)&&"alias"===t?o.push(e):i._.isArray(e)&&-1!==t.indexOf("capture")&&"function"==typeof this[t]?n.push(e):r.push(e))},this);var s=function(e,t){i._.each(e,function(e){if(i._.isArray(e[0])){var o=t;i._.each(e,function(e){o=o[e[0]].apply(o,e.slice(1))})}else this[e[0]].apply(this,e.slice(1))},t)};s(o,this),s(r,this),s(n,this)},v.prototype.push=function(e){this._execute_array([e])},v.prototype.disable=function(e){void 0===e?this._flags.disable_all_events=!0:this.__disabled_events=this.__disabled_events.concat(e)},v.prototype.capture=(0,c.addOptOutCheckPostHogLib)(function(e,t,o,r){r||"function"!=typeof o||(r=o,o=null);var n=(o=o||{}).transport;if(n&&(o.transport=n),"function"!=typeof r&&(r=function(){}),i._.isUndefined(e))i.console.error("No event name provided to posthog.capture");else{if(!this._event_is_disabled(e)){(t=t||{}).token=this.get_config("token");var s=this.persistence.remove_event_timer(e);if(!i._.isUndefined(s)){var p=(new Date).getTime()-s;t.$duration=parseFloat((p/1e3).toFixed(3))}this.persistence.update_search_keyword(i.document.referrer),this.get_config("store_google")&&this.persistence.update_campaign_params(),this.get_config("save_referrer")&&this.persistence.update_referrer_info(i.document.referrer),t=i._.extend({},i._.info.properties(),this.persistence.properties(),t);var _=this.get_config("property_blacklist");i._.isArray(_)?i._.each(_,function(e){delete t[e]}):i.console.error("Invalid value for property_blacklist config: "+_);var c={event:e,properties:t},a=i._.truncate(c,255),u=i._.JSONEncode(a),d=i._.base64Encode(u);return i.console.log("POSTHOG REQUEST:"),i.console.log(a),this._send_request(this.get_config("api_host")+"/e/",{data:d},o,this._prepare_callback(r,a)),a}r(0)}}),v.prototype.set_group=(0,c.addOptOutCheckPostHogLib)(function(e,t,o){i._.isArray(t)||(t=[t]);var r={};return r[e]=t,this.register(r),this.people.set(e,t,o)}),v.prototype.add_group=(0,c.addOptOutCheckPostHogLib)(function(e,t,o){var i=this.get_property(e);if(void 0===i){var r={};r[e]=[t],this.register(r)}else-1===i.indexOf(t)&&(i.push(t),this.register(r));return this.people.union(e,t,o)}),v.prototype.remove_group=(0,c.addOptOutCheckPostHogLib)(function(e,t,o){var i=this.get_property(e);if(void 0!==i){var r=i.indexOf(t);r>-1&&(i.splice(r,1),this.register({group_key:i})),0===i.length&&this.unregister(e)}return this.people.remove(e,t,o)}),v.prototype.capture_with_groups=(0,c.addOptOutCheckPostHogLib)(function(e,t,o,r){var n=i._.extend({},t||{});return i._.each(o,function(e,t){null!=e&&(n[t]=e)}),this.capture(e,n,r)}),v.prototype._create_map_key=function(e,t){return e+"_"+JSON.stringify(t)},v.prototype._remove_group_from_cache=function(e,t){delete this._cached_groups[this._create_map_key(e,t)]},v.prototype.get_group=function(e,t){var o=this._create_map_key(e,t),i=this._cached_groups[o];return void 0!==i&&i._group_key===e&&i._group_id===t||((i=new s.PostHogGroup)._init(this,e,t),this._cached_groups[o]=i),i},v.prototype.capture_pageview=function(e){i._.isUndefined(e)&&(e=i.document.location.href),this.capture("$pageview")},v.prototype.capture_links=function(){return this._capture_dom.call(this,n.LinkCapture,arguments)},v.prototype.capture_forms=function(){return this._capture_dom.call(this,FormCaptureer,arguments)},v.prototype.time_event=function(e){i._.isUndefined(e)?i.console.error("No event name provided to posthog.time_event"):this._event_is_disabled(e)||this.persistence.set_event_timer(e,(new Date).getTime())},v.prototype.register=function(e,t){this.persistence.register(e,t)},v.prototype.register_once=function(e,t,o){this.persistence.register_once(e,t,o)},v.prototype.unregister=function(e){this.persistence.unregister(e)},v.prototype._register_single=function(e,t){var o={};o[e]=t,this.register(o)},v.prototype.identify=function(e,t,o,i,r,n,s,p){var c=this.get_distinct_id();if(this.register({$user_id:e}),!this.get_property("$device_id")){var a=c;this.register_once({$had_persisted_distinct_id:!0,$device_id:a},"")}e!==c&&e!==this.get_property(_.ALIAS_ID_KEY)&&(this.unregister(_.ALIAS_ID_KEY),this.register({distinct_id:e})),this._flags.identify_called=!0,this.people._flush(t,o,i,r,n,s,p),e!==c&&this.capture("$identify",{distinct_id:e,$anon_distinct_id:c})},v.prototype.reset=function(){this.persistence.clear(),this._flags.identify_called=!1;var e=i._.UUID();this.register_once({distinct_id:e,$device_id:e},"")},v.prototype.get_distinct_id=function(){return this.get_property("distinct_id")},v.prototype.alias=function(e,t){if(e===this.get_property(_.PEOPLE_DISTINCT_ID_KEY))return i.console.critical("Attempting to create alias for existing People user - aborting."),-2;var o=this;return i._.isUndefined(t)&&(t=this.get_distinct_id()),e!==t?(this._register_single(_.ALIAS_ID_KEY,e),this.capture("$create_alias",{alias:e,distinct_id:t},function(){o.identify(e)})):(i.console.error("alias matches current distinct_id - skipping api call."),this.identify(e),-1)},v.prototype.name_tag=function(e){this._register_single("ph_name_tag",e)},v.prototype.set_config=function(e){i._.isObject(e)&&(i._.extend(this.config,e),this.get_config("persistence_name")||(this.config.persistence_name=this.config.cookie_name),this.get_config("disable_persistence")||(this.config.disable_persistence=this.config.disable_cookie),this.persistence&&this.persistence.update_config(this.config),o.default.DEBUG=o.default.DEBUG||this.get_config("debug"))},v.prototype.get_config=function(e){return this.config[e]},v.prototype.get_property=function(e){return this.persistence.props[e]},v.prototype.toString=function(){var e=this.get_config("name");return e!==g&&(e=g+"."+e),e},v.prototype._event_is_disabled=function(e){return i._.isBlockedUA(i.userAgent)||this._flags.disable_all_events||i._.include(this.__disabled_events,e)},v.prototype._handle_user_decide_check_complete=function(){this._user_decide_check_complete=!0},v.prototype._gdpr_init=function(){"localStorage"===this.get_config("opt_out_captureing_persistence_type")&&i._.localStorage.is_supported()&&(!this.has_opted_in_captureing()&&this.has_opted_in_captureing({persistence_type:"cookie"})&&this.opt_in_captureing({enable_persistence:!1}),!this.has_opted_out_captureing()&&this.has_opted_out_captureing({persistence_type:"cookie"})&&this.opt_out_captureing({clear_persistence:!1}),this.clear_opt_in_out_captureing({persistence_type:"cookie",enable_persistence:!1})),this.has_opted_out_captureing()?this._gdpr_update_persistence({clear_persistence:!0}):this.has_opted_in_captureing()||!this.get_config("opt_out_captureing_by_default")&&!i._.cookie.get("ph_optout")||(i._.cookie.remove("ph_optout"),this.opt_out_captureing({clear_persistence:this.get_config("opt_out_persistence_by_default")}))},v.prototype._gdpr_update_persistence=function(e){var t;if(e&&e.clear_persistence)t=!0;else{if(!e||!e.enable_persistence)return;t=!1}this.get_config("disable_persistence")||this.persistence.disabled===t||this.persistence.set_disabled(t)},v.prototype._gdpr_call_func=function(e,t){return t=i._.extend({capture:i._.bind(this.capture,this),persistence_type:this.get_config("opt_out_captureing_persistence_type"),cookie_prefix:this.get_config("opt_out_captureing_cookie_prefix"),cookie_expiration:this.get_config("cookie_expiration"),cross_subdomain_cookie:this.get_config("cross_subdomain_cookie"),secure_cookie:this.get_config("secure_cookie")},t),i._.localStorage.is_supported()||(t.persistence_type="cookie"),e(this.get_config("token"),{capture:t.capture,captureEventName:t.capture_event_name,captureProperties:t.capture_properties,persistenceType:t.persistence_type,persistencePrefix:t.cookie_prefix,cookieExpiration:t.cookie_expiration,crossSubdomainCookie:t.cross_subdomain_cookie,secureCookie:t.secure_cookie})},v.prototype.opt_in_captureing=function(e){e=i._.extend({enable_persistence:!0},e),this._gdpr_call_func(c.optIn,e),this._gdpr_update_persistence(e)},v.prototype.opt_out_captureing=function(e){(e=i._.extend({clear_persistence:!0,delete_user:!0},e)).delete_user&&this.people&&this.people._identify_called()&&(this.people.delete_user(),this.people.clear_charges()),this._gdpr_call_func(c.optOut,e),this._gdpr_update_persistence(e)},v.prototype.has_opted_in_captureing=function(e){return this._gdpr_call_func(c.hasOptedIn,e)},v.prototype.has_opted_out_captureing=function(e){return this._gdpr_call_func(c.hasOptedOut,e)},v.prototype.clear_opt_in_out_captureing=function(e){e=i._.extend({enable_persistence:!0},e),this._gdpr_call_func(c.clearOptInOut,e),this._gdpr_update_persistence(e)},v.prototype.init=v.prototype.init,v.prototype.reset=v.prototype.reset,v.prototype.disable=v.prototype.disable,v.prototype.time_event=v.prototype.time_event,v.prototype.capture=v.prototype.capture,v.prototype.capture_links=v.prototype.capture_links,v.prototype.capture_forms=v.prototype.capture_forms,v.prototype.capture_pageview=v.prototype.capture_pageview,v.prototype.register=v.prototype.register,v.prototype.register_once=v.prototype.register_once,v.prototype.unregister=v.prototype.unregister,v.prototype.identify=v.prototype.identify,v.prototype.alias=v.prototype.alias,v.prototype.name_tag=v.prototype.name_tag,v.prototype.set_config=v.prototype.set_config,v.prototype.get_config=v.prototype.get_config,v.prototype.get_property=v.prototype.get_property,v.prototype.get_distinct_id=v.prototype.get_distinct_id,v.prototype.toString=v.prototype.toString,v.prototype._check_and_handle_notifications=v.prototype._check_and_handle_notifications,v.prototype._handle_user_decide_check_complete=v.prototype._handle_user_decide_check_complete,v.prototype.opt_out_captureing=v.prototype.opt_out_captureing,v.prototype.opt_in_captureing=v.prototype.opt_in_captureing,v.prototype.has_opted_out_captureing=v.prototype.has_opted_out_captureing,v.prototype.has_opted_in_captureing=v.prototype.has_opted_in_captureing,v.prototype.clear_opt_in_out_captureing=v.prototype.clear_opt_in_out_captureing,v.prototype.get_group=v.prototype.get_group,v.prototype.set_group=v.prototype.set_group,v.prototype.add_group=v.prototype.add_group,v.prototype.remove_group=v.prototype.remove_group,v.prototype.capture_with_groups=v.prototype.capture_with_groups,_.PostHogPersistence.prototype.properties=_.PostHogPersistence.prototype.properties,_.PostHogPersistence.prototype.update_search_keyword=_.PostHogPersistence.prototype.update_search_keyword,_.PostHogPersistence.prototype.update_referrer_info=_.PostHogPersistence.prototype.update_referrer_info,_.PostHogPersistence.prototype.get_cross_subdomain=_.PostHogPersistence.prototype.get_cross_subdomain,_.PostHogPersistence.prototype.clear=_.PostHogPersistence.prototype.clear,i._.safewrap_class(v,["identify","_check_and_handle_notifications"]);var k={},w=function(){i._.each(k,function(e,o){o!==g&&(t[o]=e)}),t._=i._},P=function(){t.init=function(o,r,n){if(n)return t[n]||(t[n]=k[n]=b(o,r,n),t[n]._loaded()),t[n];var s=t;k[g]?s=k[g]:o&&((s=b(o,r,g))._loaded(),k[g]=s),t=s,e===d&&(i.window[g]=t),w()}},x=function(){function e(){e.done||(e.done=!0,m=!0,h=!1,i._.each(k,function(e){e._dom_loaded()}))}if(i.document.addEventListener)"complete"===i.document.readyState?e():i.document.addEventListener("DOMContentLoaded",e,!1);else if(i.document.attachEvent){i.document.attachEvent("onreadystatechange",e);var t=!1;try{t=null===i.window.frameElement}catch(o){}i.document.documentElement.doScroll&&t&&function t(){try{i.document.documentElement.doScroll("left")}catch(o){return void setTimeout(t,1)}e()}()}i._.register_event(i.window,"load",e,!0)};function O(){e=d,i._.isUndefined(i.window.posthog)&&(i.window.posthog=[]),(t=i.window.posthog).__loaded||t.config&&t.persistence?i.console.error("PostHog library has already been downloaded at least once."):(i._.each(t._i,function(e){e&&i._.isArray(e)&&(k[e[e.length-1]]=b.apply(this,e))}),P(),t.init(),i._.each(k,function(e){e._loaded()}),x())}function E(){return e=u,t=new v,P(),t.init(),x(),t} },{"./config":"itQ5","./utils":"FOZT","./autocapture":"gR3r","./dom-capture":"OjnC","./posthog-group":"St3J","./posthog-people":"ecEG","./posthog-persistence":"MAdm","./gdpr-utils":"rxSh"}],"e2xX":[function(require,module,exports) { "use strict";var r=require("./posthog-core");(0,r.init_from_snippet)(); },{"./posthog-core":"ok3T"}]},{},["e2xX"], null) -//# sourceMappingURL=/array.js.map \ No newline at end of file +//# sourceMappingURL=/array.min.js.map \ No newline at end of file