posthog-js 1.17.4 → 1.17.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,19 @@
1
+ ## 1.17.8 - 2022-02-02
2
+
3
+ - Fix for enabling a disabled session recording (#364)
4
+
5
+ ## 1.17.7 - 2022-02-01
6
+
7
+ - fix onFeatureFlag (#363)
8
+
9
+ ## 1.17.6 - 2022-01-28
10
+
11
+ - Remove capture failed request (#362)
12
+
13
+ ## 1.17.5 - 2022-01-27
14
+
15
+ - Only hit onFeatureFlags callback after decide (#360)
16
+
1
17
  ## 1.17.4 - 2022-01-27
2
18
 
3
19
  - Fix featureflags not working when /decide is down (#359)
package/dist/array.js CHANGED
@@ -1,7 +1,7 @@
1
1
  parcelRequire=function(e,r,t,n){var i,o="function"==typeof parcelRequire&&parcelRequire,u="function"==typeof require&&require;function f(t,n){if(!r[t]){if(!e[t]){var i="function"==typeof parcelRequire&&parcelRequire;if(!n&&i)return i(t,!0);if(o)return o(t,!0);if(u&&"string"==typeof t)return u(t);var c=new Error("Cannot find module '"+t+"'");throw c.code="MODULE_NOT_FOUND",c}p.resolve=function(r){return e[t][1][r]||r},p.cache={};var l=r[t]=new f.Module(t);e[t][0].call(l.exports,p,l,l.exports,this)}return r[t].exports;function p(e){return f(p.resolve(e))}}f.isParcelRequire=!0,f.Module=function(e){this.id=e,this.bundle=f,this.exports={}},f.modules=e,f.cache=r,f.parent=o,f.register=function(r,t){e[r]=[function(e,r){r.exports=t},{}]};for(var c=0;c<t.length;c++)try{f(t[c])}catch(e){i||(i=e)}if(t.length){var l=f(t[t.length-1]);"object"==typeof exports&&"undefined"!=typeof module?module.exports=l:"function"==typeof define&&define.amd?define(function(){return l}):n&&(this[n]=l)}if(parcelRequire=f,i)throw i;return f}({"zdbk":[function(require,module,exports) {
2
2
  "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.LZString=void 0;var o=String.fromCharCode,r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-$",n={};function t(o,r){if(!n[o]){n[o]={};for(var e=0;e<o.length;e++)n[o][o.charAt(e)]=e}return n[o][r]}var s={compressToBase64:function(o){if(null==o)return"";var e=s._compress(o,6,function(o){return r.charAt(o)});switch(e.length%4){default:case 0:return e;case 1:return e+"===";case 2:return e+"==";case 3:return e+"="}},decompressFromBase64:function(o){return null==o?"":""==o?null:s._decompress(o.length,32,function(e){return t(r,o.charAt(e))})},compressToUTF16:function(r){return null==r?"":s._compress(r,15,function(r){return o(r+32)})+" "},decompressFromUTF16:function(o){return null==o?"":""==o?null:s._decompress(o.length,16384,function(r){return o.charCodeAt(r)-32})},compressToUint8Array:function(o){for(var r=s.compress(o),e=new Uint8Array(2*r.length),n=0,t=r.length;n<t;n++){var i=r.charCodeAt(n);e[2*n]=i>>>8,e[2*n+1]=i%256}return e},decompressFromUint8Array:function(r){if(null==r)return s.decompress(r);for(var e=new Array(r.length/2),n=0,t=e.length;n<t;n++)e[n]=256*r[2*n]+r[2*n+1];var i=[];return e.forEach(function(r){i.push(o(r))}),s.decompress(i.join(""))},compressToEncodedURIComponent:function(o){return null==o?"":s._compress(o,6,function(o){return e.charAt(o)})},decompressFromEncodedURIComponent:function(o){return null==o?"":""==o?null:(o=o.replace(/ /g,"+"),s._decompress(o.length,32,function(r){return t(e,o.charAt(r))}))},compress:function(r){return s._compress(r,16,function(r){return o(r)})},_compress:function(o,r,e){if(null==o)return"";var n,t,s,i={},p={},c="",a="",u="",l=2,f=3,h=2,d=[],m=0,v=0;for(s=0;s<o.length;s+=1)if(c=o.charAt(s),Object.prototype.hasOwnProperty.call(i,c)||(i[c]=f++,p[c]=!0),a=u+c,Object.prototype.hasOwnProperty.call(i,a))u=a;else{if(Object.prototype.hasOwnProperty.call(p,u)){if(u.charCodeAt(0)<256){for(n=0;n<h;n++)m<<=1,v==r-1?(v=0,d.push(e(m)),m=0):v++;for(t=u.charCodeAt(0),n=0;n<8;n++)m=m<<1|1&t,v==r-1?(v=0,d.push(e(m)),m=0):v++,t>>=1}else{for(t=1,n=0;n<h;n++)m=m<<1|t,v==r-1?(v=0,d.push(e(m)),m=0):v++,t=0;for(t=u.charCodeAt(0),n=0;n<16;n++)m=m<<1|1&t,v==r-1?(v=0,d.push(e(m)),m=0):v++,t>>=1}0==--l&&(l=Math.pow(2,h),h++),delete p[u]}else for(t=i[u],n=0;n<h;n++)m=m<<1|1&t,v==r-1?(v=0,d.push(e(m)),m=0):v++,t>>=1;0==--l&&(l=Math.pow(2,h),h++),i[a]=f++,u=String(c)}if(""!==u){if(Object.prototype.hasOwnProperty.call(p,u)){if(u.charCodeAt(0)<256){for(n=0;n<h;n++)m<<=1,v==r-1?(v=0,d.push(e(m)),m=0):v++;for(t=u.charCodeAt(0),n=0;n<8;n++)m=m<<1|1&t,v==r-1?(v=0,d.push(e(m)),m=0):v++,t>>=1}else{for(t=1,n=0;n<h;n++)m=m<<1|t,v==r-1?(v=0,d.push(e(m)),m=0):v++,t=0;for(t=u.charCodeAt(0),n=0;n<16;n++)m=m<<1|1&t,v==r-1?(v=0,d.push(e(m)),m=0):v++,t>>=1}0==--l&&(l=Math.pow(2,h),h++),delete p[u]}else for(t=i[u],n=0;n<h;n++)m=m<<1|1&t,v==r-1?(v=0,d.push(e(m)),m=0):v++,t>>=1;0==--l&&(l=Math.pow(2,h),h++)}for(t=2,n=0;n<h;n++)m=m<<1|1&t,v==r-1?(v=0,d.push(e(m)),m=0):v++,t>>=1;for(;;){if(m<<=1,v==r-1){d.push(e(m));break}v++}return d.join("")},decompress:function(o){return null==o?"":""==o?null:s._decompress(o.length,32768,function(r){return o.charCodeAt(r)})},_decompress:function(r,e,n){var t,s,i,p,c,a,u,l=[],f=4,h=4,d=3,m="",v=[],w={val:n(0),position:e,index:1};for(t=0;t<3;t+=1)l[t]=t;for(i=0,c=Math.pow(2,2),a=1;a!=c;)p=w.val&w.position,w.position>>=1,0==w.position&&(w.position=e,w.val=n(w.index++)),i|=(p>0?1:0)*a,a<<=1;switch(i){case 0:for(i=0,c=Math.pow(2,8),a=1;a!=c;)p=w.val&w.position,w.position>>=1,0==w.position&&(w.position=e,w.val=n(w.index++)),i|=(p>0?1:0)*a,a<<=1;u=o(i);break;case 1:for(i=0,c=Math.pow(2,16),a=1;a!=c;)p=w.val&w.position,w.position>>=1,0==w.position&&(w.position=e,w.val=n(w.index++)),i|=(p>0?1:0)*a,a<<=1;u=o(i);break;case 2:return""}for(l[3]=u,s=u,v.push(u);;){if(w.index>r)return"";for(i=0,c=Math.pow(2,d),a=1;a!=c;)p=w.val&w.position,w.position>>=1,0==w.position&&(w.position=e,w.val=n(w.index++)),i|=(p>0?1:0)*a,a<<=1;switch(u=i){case 0:for(i=0,c=Math.pow(2,8),a=1;a!=c;)p=w.val&w.position,w.position>>=1,0==w.position&&(w.position=e,w.val=n(w.index++)),i|=(p>0?1:0)*a,a<<=1;l[h++]=o(i),u=h-1,f--;break;case 1:for(i=0,c=Math.pow(2,16),a=1;a!=c;)p=w.val&w.position,w.position>>=1,0==w.position&&(w.position=e,w.val=n(w.index++)),i|=(p>0?1:0)*a,a<<=1;l[h++]=o(i),u=h-1,f--;break;case 2:return v.join("")}if(0==f&&(f=Math.pow(2,d),d++),l[u])m=l[u];else{if(u!==h)return null;m=s+s.charAt(0)}v.push(m),l[h++]=s+m.charAt(0),s=m,0==--f&&(f=Math.pow(2,d),d++)}}};exports.LZString=s;
3
3
  },{}],"EHrm":[function(require,module,exports) {
4
- module.exports={name:"posthog-js",version:"1.17.4",description:"Posthog-js allows you to automatically capture usage and send events to PostHog.",repository:"https://github.com/PostHog/posthog-js",author:"hey@posthog.com",license:"MIT",scripts:{start:"parcel watch src/loader-globals.js --out-file dist/array.js",serve:"parcel serve src/loader-globals.js --port 3001 --out-file dist/array.js",build:"yarn build-array && yarn build-module && yarn build-es-module && yarn process-types && yarn build-react","build-array":"parcel build src/loader-globals.js --out-file dist/array.js --no-source-maps","build-module":"rollup -i src/loader-module.js -f cjs -o dist/module.js -c rollup.config.js","build-es-module":"rollup -i src/loader-module.js -f es -o dist/es.js -c rollup.config.js","build-react":"cd react; yarn; yarn build;","process-types":"mkdir -p dist; eslint src --ext .ts -c .eslintrc.ts.js --fix && tsc && cp -f src/*.d.ts dist/",lint:"eslint src --fix",prepublishOnly:"yarn lint && yarn test && yarn build && yarn test-react",test:"jest src","test-react":"cd react; yarn test","test-watch":"jest --watch src",cypress:"cypress open"},main:"dist/module.js",module:"dist/es.js",files:["dist/*","react/dist/*"],dependencies:{"@sentry/types":"^6.11.0",fflate:"^0.4.1","rrweb-snapshot":"^1.1.7"},devDependencies:{"@babel/core":"7.12.10","@babel/preset-env":"7.12.11","@rollup/plugin-babel":"^5.2.1","@rollup/plugin-json":"^4.1.0","@rollup/plugin-node-resolve":"^8.1.0","@typescript-eslint/eslint-plugin":"^3.5.0","@typescript-eslint/parser":"^3.5.0","babel-eslint":"10.1.0","babel-jest":"^26.6.3",cypress:"^9.2.0",eslint:"7.3.1","eslint-plugin-prettier":"^3.1.4","eslint-plugin-react":"^7.21.5","eslint-plugin-react-hooks":"^4.2.0","fast-check":"^2.17.0",given2:"^2.1.7",husky:"^4.2.5",jest:"^26.1.0",jsdom:"16.2.2","jsdom-global":"3.0.2","lint-staged":"^10.2.11",localStorage:"1.0.4","node-fetch":"^2.6.1",parcel:"^1.12.4","posthog-js":"link:.",prettier:"^2.0.5",rollup:"^2.18.2",rrweb:"^1.0.6",sinon:"9.0.2",testcafe:"^1.17.1","testcafe-browser-provider-browserstack":"^1.13.2-alpha.1",typescript:"^3.9.6"},husky:{hooks:{"pre-commit":"lint-staged"}},"lint-staged":{"*.{ts,tsx,js,json}":"prettier --write","*.{ts,tsx}":["eslint -c .eslintrc.ts.js --fix","tsc --noEmit --esModuleInterop --jsx react"]},jest:{testPathIgnorePatterns:["/node_modules/","/cypress/","/react/","/test_data/"],moduleFileExtensions:["js","json"],setupFilesAfterEnv:["given2/setup"],clearMocks:!0}};
4
+ module.exports={name:"posthog-js",version:"1.17.8",description:"Posthog-js allows you to automatically capture usage and send events to PostHog.",repository:"https://github.com/PostHog/posthog-js",author:"hey@posthog.com",license:"MIT",scripts:{start:"parcel watch src/loader-globals.js --out-file dist/array.js",serve:"parcel serve src/loader-globals.js --port 3001 --out-file dist/array.js",build:"yarn build-array && yarn build-module && yarn build-es-module && yarn process-types && yarn build-react","build-array":"parcel build src/loader-globals.js --out-file dist/array.js --no-source-maps","build-module":"rollup -i src/loader-module.js -f cjs -o dist/module.js -c rollup.config.js","build-es-module":"rollup -i src/loader-module.js -f es -o dist/es.js -c rollup.config.js","build-react":"cd react; yarn; yarn build;","process-types":"mkdir -p dist; eslint src --ext .ts -c .eslintrc.ts.js --fix && tsc && cp -f src/*.d.ts dist/",lint:"eslint src --fix",prepublishOnly:"yarn lint && yarn test && yarn build && yarn test-react",test:"jest src","test-react":"cd react; yarn test","test-watch":"jest --watch src",cypress:"cypress open"},main:"dist/module.js",module:"dist/es.js",files:["dist/*","react/dist/*"],dependencies:{"@sentry/types":"^6.11.0",fflate:"^0.4.1","rrweb-snapshot":"^1.1.7"},devDependencies:{"@babel/core":"7.12.10","@babel/preset-env":"7.12.11","@rollup/plugin-babel":"^5.2.1","@rollup/plugin-json":"^4.1.0","@rollup/plugin-node-resolve":"^8.1.0","@typescript-eslint/eslint-plugin":"^3.5.0","@typescript-eslint/parser":"^3.5.0","babel-eslint":"10.1.0","babel-jest":"^26.6.3",cypress:"^9.2.0",eslint:"7.3.1","eslint-plugin-prettier":"^3.1.4","eslint-plugin-react":"^7.21.5","eslint-plugin-react-hooks":"^4.2.0","fast-check":"^2.17.0",given2:"^2.1.7",husky:"^4.2.5",jest:"^26.1.0",jsdom:"16.2.2","jsdom-global":"3.0.2","lint-staged":"^10.2.11",localStorage:"1.0.4","node-fetch":"^2.6.1",parcel:"^1.12.4","posthog-js":"link:.",prettier:"^2.0.5",rollup:"^2.18.2",rrweb:"^1.0.6",sinon:"9.0.2",testcafe:"^1.17.1","testcafe-browser-provider-browserstack":"^1.13.2-alpha.1",typescript:"^3.9.6"},husky:{hooks:{"pre-commit":"lint-staged"}},"lint-staged":{"*.{ts,tsx,js,json}":"prettier --write","*.{ts,tsx}":["eslint -c .eslintrc.ts.js --fix","tsc --noEmit --esModuleInterop --jsx react"]},jest:{testPathIgnorePatterns:["/node_modules/","/cypress/","/react/","/test_data/"],moduleFileExtensions:["js","json"],setupFilesAfterEnv:["given2/setup"],clearMocks:!0}};
5
5
  },{}],"itQ5":[function(require,module,exports) {
6
6
  "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var e=require("../package.json"),r={DEBUG:!1,LIB_VERSION:e.version},t=r;exports.default=t;
7
7
  },{"../package.json":"EHrm"}],"FOZT":[function(require,module,exports) {
@@ -21,29 +21,29 @@ module.exports={name:"posthog-js",version:"1.17.4",description:"Posthog-js allow
21
21
  },{"./utils":"FOZT"}],"ecEG":[function(require,module,exports) {
22
22
  "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.PostHogPeople=void 0;var t=require("./gdpr-utils"),e=require("./api-actions"),o=require("./utils"),i=function(){};exports.PostHogPeople=i,o._.extend(i.prototype,e.apiActions),i.prototype._init=function(t){this._posthog=t},i.prototype.set=(0,t.addOptOutCheckPostHogPeople)(function(t,i,r){var s=this.set_action(t,i);return o._.isObject(t)&&(r=i),this._get_config("save_referrer")&&this._posthog.persistence.update_referrer_info(document.referrer),s[e.SET_ACTION]=o._.extend({},o._.info.people_properties(),this._posthog.persistence.get_referrer_info(),s[e.SET_ACTION]),this._send_request(s,r)}),i.prototype.set_once=(0,t.addOptOutCheckPostHogPeople)(function(t,e,i){var r=this.set_once_action(t,e);return o._.isObject(t)&&(i=e),this._send_request(r,i)}),i.prototype.toString=function(){return this._posthog.toString()+".people"},i.prototype._send_request=function(t,e){t.$token=this._get_config("token"),t.$distinct_id=this._posthog.get_distinct_id();var i=this._posthog.get_property("$device_id"),r=this._posthog.get_property("$user_id"),s=this._posthog.get_property("$had_persisted_distinct_id");i&&(t.$device_id=i),r&&(t.$user_id=r),s&&(t.$had_persisted_distinct_id=s);var _=o._.encodeDates(t),p=o._.copyAndTruncateStrings(_,this._get_config("properties_string_max_length")),n=JSON.stringify(_),d=o._.base64Encode(n);return this._posthog._send_request(this._get_config("api_host")+"/engage/",{data:d},{},this._posthog._prepare_callback(e,p)),p},i.prototype._get_config=function(t){return this._posthog.get_config(t)},i.prototype._is_reserved_property=function(t){return"$distinct_id"===t||"$token"===t||"$device_id"===t||"$user_id"===t||"$had_persisted_distinct_id"===t},i.prototype.set=i.prototype.set,i.prototype.set_once=i.prototype.set_once,i.prototype.toString=i.prototype.toString;
23
23
  },{"./gdpr-utils":"rxSh","./api-actions":"os8r","./utils":"FOZT"}],"aVqC":[function(require,module,exports) {
24
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.PostHogFeatureFlags=exports.parseFeatureFlagDecideResponse=void 0;var e=require("./utils");function t(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){for(var a=0;a<t.length;a++){var r=t[a];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function r(e,t,r){return t&&a(e.prototype,t),r&&a(e,r),e}var s=function(e,t){var a=e.featureFlags;if(a)if(Array.isArray(a)){var r={};if(a)for(var s=0;s<a.length;s++)r[a[s]]=!0;t&&t.register({$active_feature_flags:a,$enabled_feature_flags:r})}else t&&t.register({$active_feature_flags:Object.keys(a||{}),$enabled_feature_flags:a||{}});else t&&(t.unregister("$active_feature_flags"),t.unregister("$enabled_feature_flags"))};exports.parseFeatureFlagDecideResponse=s;var i=function(){function a(e){t(this,a),this.instance=e,this._override_warning=!1,this.flagCallReported={},this.featureFlagEventHandlers=[],this.reloadFeatureFlagsQueued=!1,this.reloadFeatureFlagsInAction=!1}return r(a,[{key:"getFlags",value:function(){return Object.keys(this.getFlagVariants())}},{key:"getFlagVariants",value:function(){var t=this.instance.get_property("$enabled_feature_flags"),a=this.instance.get_property("$override_feature_flags");if(!a)return t||{};for(var r=e._.extend({},t),s=Object.keys(a),i=0;i<s.length;i++)!1===a[s[i]]?delete r[s[i]]:r[s[i]]=a[s[i]];return this._override_warning||(console.warn("[PostHog] Overriding feature flags!",{enabledFlags:t,overriddenFlags:a,finalFlags:r}),this._override_warning=!0),r}},{key:"reloadFeatureFlags",value:function(){this.reloadFeatureFlagsQueued||(this.reloadFeatureFlagsQueued=!0,this._startReloadTimer())}},{key:"setReloadingPaused",value:function(e){this.reloadFeatureFlagsInAction=e}},{key:"resetRequestQueue",value:function(){this.reloadFeatureFlagsQueued=!1}},{key:"_startReloadTimer",value:function(){var e=this;this.reloadFeatureFlagsQueued&&!this.reloadFeatureFlagsInAction&&setTimeout(function(){!e.reloadFeatureFlagsInAction&&e.reloadFeatureFlagsQueued&&(e.reloadFeatureFlagsQueued=!1,e._reloadFeatureFlagsRequest())},5)}},{key:"_reloadFeatureFlagsRequest",value:function(){var t=this;this.setReloadingPaused(!0);var a=this.instance.get_config("token"),r=JSON.stringify({token:a,distinct_id:this.instance.get_distinct_id(),groups:this.instance.getGroups()}),i=e._.base64Encode(r);this.instance._send_request(this.instance.get_config("api_host")+"/decide/?v=2",{data:i},{method:"POST"},this.instance._prepare_callback(function(e){s(e,t.instance.persistence),t.receivedFeatureFlags(),t.setReloadingPaused(!1),t._startReloadTimer()}))}},{key:"getFeatureFlag",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!this.getFlags())return console.warn('getFeatureFlag for key "'+e+"\" failed. Feature flags didn't load in time."),!1;var a=this.getFlagVariants()[e];return!t.send_event&&"send_event"in t||this.flagCallReported[e]||(this.flagCallReported[e]=!0,this.instance.capture("$feature_flag_called",{$feature_flag:e,$feature_flag_response:a})),a}},{key:"isFeatureEnabled",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return this.getFlags()?!!this.getFeatureFlag(e,t):(console.warn('isFeatureEnabled for key "'+e+"\" failed. Feature flags didn't load in time."),!1)}},{key:"addFeatureFlagsHandler",value:function(e){this.featureFlagEventHandlers.push(e)}},{key:"receivedFeatureFlags",value:function(){var e=this.getFlags(),t=this.getFlagVariants();this.featureFlagEventHandlers.forEach(function(a){return a(e,t)})}},{key:"override",value:function(e){if(this._override_warning=!1,!1===e)this.instance.persistence.unregister("$override_feature_flags");else if(Array.isArray(e)){for(var t={},a=0;a<e.length;a++)t[e[a]]=!0;this.instance.persistence.register({$override_feature_flags:t})}else this.instance.persistence.register({$override_feature_flags:e})}}]),a}();exports.PostHogFeatureFlags=i;
24
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.PostHogFeatureFlags=exports.parseFeatureFlagDecideResponse=void 0;var e=require("./utils");function t(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){for(var a=0;a<t.length;a++){var r=t[a];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function r(e,t,r){return t&&a(e.prototype,t),r&&a(e,r),e}var s=function(e,t){var a=e.featureFlags;if(a)if(Array.isArray(a)){var r={};if(a)for(var s=0;s<a.length;s++)r[a[s]]=!0;t&&t.register({$active_feature_flags:a,$enabled_feature_flags:r})}else t&&t.register({$active_feature_flags:Object.keys(a||{}),$enabled_feature_flags:a||{}});else t&&(t.unregister("$active_feature_flags"),t.unregister("$enabled_feature_flags"))};exports.parseFeatureFlagDecideResponse=s;var i=function(){function a(e){t(this,a),this.instance=e,this._override_warning=!1,this.flagCallReported={},this.featureFlagEventHandlers=[],this.reloadFeatureFlagsQueued=!1,this.reloadFeatureFlagsInAction=!1}return r(a,[{key:"getFlags",value:function(){return Object.keys(this.getFlagVariants())}},{key:"getFlagVariants",value:function(){var t=this.instance.get_property("$enabled_feature_flags"),a=this.instance.get_property("$override_feature_flags");if(!a)return t||{};for(var r=e._.extend({},t),s=Object.keys(a),i=0;i<s.length;i++)!1===a[s[i]]?delete r[s[i]]:r[s[i]]=a[s[i]];return this._override_warning||(console.warn("[PostHog] Overriding feature flags!",{enabledFlags:t,overriddenFlags:a,finalFlags:r}),this._override_warning=!0),r}},{key:"reloadFeatureFlags",value:function(){this.reloadFeatureFlagsQueued||(this.reloadFeatureFlagsQueued=!0,this._startReloadTimer())}},{key:"setReloadingPaused",value:function(e){this.reloadFeatureFlagsInAction=e}},{key:"resetRequestQueue",value:function(){this.reloadFeatureFlagsQueued=!1}},{key:"_startReloadTimer",value:function(){var e=this;this.reloadFeatureFlagsQueued&&!this.reloadFeatureFlagsInAction&&setTimeout(function(){!e.reloadFeatureFlagsInAction&&e.reloadFeatureFlagsQueued&&(e.reloadFeatureFlagsQueued=!1,e._reloadFeatureFlagsRequest())},5)}},{key:"_reloadFeatureFlagsRequest",value:function(){var t=this;this.setReloadingPaused(!0);var a=this.instance.get_config("token"),r=JSON.stringify({token:a,distinct_id:this.instance.get_distinct_id(),groups:this.instance.getGroups()}),s=e._.base64Encode(r);this.instance._send_request(this.instance.get_config("api_host")+"/decide/?v=2",{data:s},{method:"POST"},this.instance._prepare_callback(function(e){t.receivedFeatureFlags(e),t.setReloadingPaused(!1),t._startReloadTimer()}))}},{key:"getFeatureFlag",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!this.getFlags())return console.warn('getFeatureFlag for key "'+e+"\" failed. Feature flags didn't load in time."),!1;var a=this.getFlagVariants()[e];return!t.send_event&&"send_event"in t||this.flagCallReported[e]||(this.flagCallReported[e]=!0,this.instance.capture("$feature_flag_called",{$feature_flag:e,$feature_flag_response:a})),a}},{key:"isFeatureEnabled",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return this.getFlags()?!!this.getFeatureFlag(e,t):(console.warn('isFeatureEnabled for key "'+e+"\" failed. Feature flags didn't load in time."),!1)}},{key:"addFeatureFlagsHandler",value:function(e){this.featureFlagEventHandlers.push(e)}},{key:"receivedFeatureFlags",value:function(e){s(e,this.instance.persistence);var t=this.getFlags(),a=this.getFlagVariants();this.featureFlagEventHandlers.forEach(function(e){return e(t,a)})}},{key:"override",value:function(e){if(this._override_warning=!1,!1===e)this.instance.persistence.unregister("$override_feature_flags");else if(Array.isArray(e)){for(var t={},a=0;a<e.length;a++)t[e[a]]=!0;this.instance.persistence.register({$override_feature_flags:t})}else this.instance.persistence.register({$override_feature_flags:e})}},{key:"onFeatureFlags",value:function(e){(this.addFeatureFlagsHandler(e),this.instance.decideEndpointWasHit)&&e(this.getFlags(),this.getFlagVariants())}}]),a}();exports.PostHogFeatureFlags=i;
25
25
  },{"./utils":"FOZT"}],"MAdm":[function(require,module,exports) {
26
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.SESSION_ID=exports.SESSION_RECORDING_ENABLED=exports.EVENT_TIMERS_KEY=exports.CAMPAIGN_IDS_KEY=exports.ALIAS_ID_KEY=exports.PEOPLE_DISTINCT_ID_KEY=exports.SET_ONCE_QUEUE_KEY=exports.SET_QUEUE_KEY=exports.PostHogPersistence=void 0;var e=require("./utils"),t=require("./storage");function r(e){return(r="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)}var s="__mps";exports.SET_QUEUE_KEY=s;var o="__mpso";exports.SET_ONCE_QUEUE_KEY=o;var i="__mpus",p="__mpa",n="__mpap",a="__mpr",_="__mpu",c="$people_distinct_id";exports.PEOPLE_DISTINCT_ID_KEY=c;var h="__alias";exports.ALIAS_ID_KEY=h;var u="__cmpns";exports.CAMPAIGN_IDS_KEY=u;var f="__timers";exports.EVENT_TIMERS_KEY=f;var d="$session_recording_enabled";exports.SESSION_RECORDING_ENABLED=d;var m="$sesid";exports.SESSION_ID=m;var l="$enabled_feature_flags",y=[s,o,i,p,n,a,_,c,h,u,f,d,m,l],E=function(r){var s="";r.token&&(s=r.token.replace(/\+/g,"PL").replace(/\//g,"SL").replace(/=/g,"EQ")),this.props={},this.campaign_params_saved=!1,r.persistence_name?this.name="ph_"+r.persistence_name:this.name="ph_"+s+"_posthog";var o=r.persistence;"cookie"!==o&&-1===o.indexOf("localStorage")&&"memory"!==o&&(e.console.critical("Unknown persistence type "+o+"; falling back to cookie"),o=r.persistence="cookie"),"localStorage"===o&&t.localStore.is_supported()?this.storage=t.localStore:"localStorage+cookie"===o&&t.localPlusCookieStore.is_supported()?this.storage=t.localPlusCookieStore:this.storage="memory"===o?t.memoryStore:t.cookieStore,this.load(),this.update_config(r),this.save()};exports.PostHogPersistence=E,E.prototype.properties=function(){var t={};return e._.each(this.props,function(s,o){if(o===l&&"object"===r(s))for(var i=Object.keys(s),p=0;p<i.length;p++)t["$feature/".concat(i[p])]=s[i[p]];else e._.include(y,o)||(t[o]=s)}),t},E.prototype.load=function(){if(!this.disabled){var t=this.storage.parse(this.name);t&&(this.props=e._.extend({},t))}},E.prototype.save=function(){this.disabled||this.storage.set(this.name,this.props,this.expire_days,this.cross_subdomain,this.secure)},E.prototype.remove=function(){this.storage.remove(this.name,!1),this.storage.remove(this.name,!0)},E.prototype.clear=function(){this.remove(),this.props={}},E.prototype.register_once=function(t,r,s){return!!e._.isObject(t)&&(void 0===r&&(r="None"),this.expire_days=void 0===s?this.default_expiry:s,e._.each(t,function(e,t){this.props.hasOwnProperty(t)&&this.props[t]!==r||(this.props[t]=e)},this),this.save(),!0)},E.prototype.register=function(t,r){return!!e._.isObject(t)&&(this.expire_days=void 0===r?this.default_expiry:r,e._.extend(this.props,t),this.save(),!0)},E.prototype.unregister=function(e){e in this.props&&(delete this.props[e],this.save())},E.prototype.update_campaign_params=function(){this.campaign_params_saved||(this.register(e._.info.campaignParams()),this.campaign_params_saved=!0)},E.prototype.update_search_keyword=function(t){this.register(e._.info.searchInfo(t))},E.prototype.update_referrer_info=function(t){this.register_once({$initial_referrer:t||"$direct",$initial_referring_domain:e._.info.referringDomain(t)||"$direct"},""),this.register({$referrer:t||this.props.$referrer||"$direct",$referring_domain:e._.info.referringDomain(t)||this.props.$referring_domain||"$direct"})},E.prototype.get_referrer_info=function(){return e._.strip_empty_properties({$initial_referrer:this.props.$initial_referrer,$initial_referring_domain:this.props.$initial_referring_domain})},E.prototype.safe_merge=function(t){return e._.each(this.props,function(e,r){r in t||(t[r]=e)}),t},E.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)},E.prototype.set_disabled=function(e){this.disabled=e,this.disabled?this.remove():this.save()},E.prototype.set_cross_subdomain=function(e){e!==this.cross_subdomain&&(this.cross_subdomain=e,this.remove(),this.save())},E.prototype.get_cross_subdomain=function(){return this.cross_subdomain},E.prototype.set_secure=function(e){e!==this.secure&&(this.secure=!!e,this.remove(),this.save())},E.prototype.set_event_timer=function(e,t){var r=this.props[f]||{};r[e]=t,this.props[f]=r,this.save()},E.prototype.remove_event_timer=function(t){var r=(this.props[f]||{})[t];return e._.isUndefined(r)||(delete this.props[f][t],this.save()),r};
26
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.SESSION_ID=exports.SESSION_RECORDING_ENABLED_SERVER_SIDE=exports.EVENT_TIMERS_KEY=exports.CAMPAIGN_IDS_KEY=exports.ALIAS_ID_KEY=exports.PEOPLE_DISTINCT_ID_KEY=exports.SET_ONCE_QUEUE_KEY=exports.SET_QUEUE_KEY=exports.PostHogPersistence=void 0;var e=require("./utils"),t=require("./storage");function r(e){return(r="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)}var s="__mps";exports.SET_QUEUE_KEY=s;var o="__mpso";exports.SET_ONCE_QUEUE_KEY=o;var i="__mpus",p="__mpa",n="__mpap",_="__mpr",a="__mpu",c="$people_distinct_id";exports.PEOPLE_DISTINCT_ID_KEY=c;var h="__alias";exports.ALIAS_ID_KEY=h;var u="__cmpns";exports.CAMPAIGN_IDS_KEY=u;var d="__timers";exports.EVENT_TIMERS_KEY=d;var f="$session_recording_enabled_server_side";exports.SESSION_RECORDING_ENABLED_SERVER_SIDE=f;var m="$sesid";exports.SESSION_ID=m;var l="$enabled_feature_flags",E=[s,o,i,p,n,_,a,c,h,u,d,f,m,l],y=function(r){var s="";r.token&&(s=r.token.replace(/\+/g,"PL").replace(/\//g,"SL").replace(/=/g,"EQ")),this.props={},this.campaign_params_saved=!1,r.persistence_name?this.name="ph_"+r.persistence_name:this.name="ph_"+s+"_posthog";var o=r.persistence;"cookie"!==o&&-1===o.indexOf("localStorage")&&"memory"!==o&&(e.console.critical("Unknown persistence type "+o+"; falling back to cookie"),o=r.persistence="cookie"),"localStorage"===o&&t.localStore.is_supported()?this.storage=t.localStore:"localStorage+cookie"===o&&t.localPlusCookieStore.is_supported()?this.storage=t.localPlusCookieStore:this.storage="memory"===o?t.memoryStore:t.cookieStore,this.load(),this.update_config(r),this.save()};exports.PostHogPersistence=y,y.prototype.properties=function(){var t={};return e._.each(this.props,function(s,o){if(o===l&&"object"===r(s))for(var i=Object.keys(s),p=0;p<i.length;p++)t["$feature/".concat(i[p])]=s[i[p]];else e._.include(E,o)||(t[o]=s)}),t},y.prototype.load=function(){if(!this.disabled){var t=this.storage.parse(this.name);t&&(this.props=e._.extend({},t))}},y.prototype.save=function(){this.disabled||this.storage.set(this.name,this.props,this.expire_days,this.cross_subdomain,this.secure)},y.prototype.remove=function(){this.storage.remove(this.name,!1),this.storage.remove(this.name,!0)},y.prototype.clear=function(){this.remove(),this.props={}},y.prototype.register_once=function(t,r,s){return!!e._.isObject(t)&&(void 0===r&&(r="None"),this.expire_days=void 0===s?this.default_expiry:s,e._.each(t,function(e,t){this.props.hasOwnProperty(t)&&this.props[t]!==r||(this.props[t]=e)},this),this.save(),!0)},y.prototype.register=function(t,r){return!!e._.isObject(t)&&(this.expire_days=void 0===r?this.default_expiry:r,e._.extend(this.props,t),this.save(),!0)},y.prototype.unregister=function(e){e in this.props&&(delete this.props[e],this.save())},y.prototype.update_campaign_params=function(){this.campaign_params_saved||(this.register(e._.info.campaignParams()),this.campaign_params_saved=!0)},y.prototype.update_search_keyword=function(t){this.register(e._.info.searchInfo(t))},y.prototype.update_referrer_info=function(t){this.register_once({$initial_referrer:t||"$direct",$initial_referring_domain:e._.info.referringDomain(t)||"$direct"},""),this.register({$referrer:t||this.props.$referrer||"$direct",$referring_domain:e._.info.referringDomain(t)||this.props.$referring_domain||"$direct"})},y.prototype.get_referrer_info=function(){return e._.strip_empty_properties({$initial_referrer:this.props.$initial_referrer,$initial_referring_domain:this.props.$initial_referring_domain})},y.prototype.safe_merge=function(t){return e._.each(this.props,function(e,r){r in t||(t[r]=e)}),t},y.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)},y.prototype.set_disabled=function(e){this.disabled=e,this.disabled?this.remove():this.save()},y.prototype.set_cross_subdomain=function(e){e!==this.cross_subdomain&&(this.cross_subdomain=e,this.remove(),this.save())},y.prototype.get_cross_subdomain=function(){return this.cross_subdomain},y.prototype.set_secure=function(e){e!==this.secure&&(this.secure=!!e,this.remove(),this.save())},y.prototype.set_event_timer=function(e,t){var r=this.props[d]||{};r[e]=t,this.props[d]=r,this.save()},y.prototype.remove_event_timer=function(t){var r=(this.props[d]||{})[t];return e._.isUndefined(r)||(delete this.props[d][t],this.save()),r};
27
27
  },{"./utils":"FOZT","./storage":"KZ7Y"}],"vmk3":[function(require,module,exports) {
28
28
  "use strict";function t(t,r){var n;if("undefined"==typeof Symbol||null==t[Symbol.iterator]){if(Array.isArray(t)||(n=e(t))||r&&t&&"number"==typeof t.length){n&&(t=n);var o=0,a=function(){};return{s:a,n:function(){return o>=t.length?{done:!0}:{done:!1,value:t[o++]}},e:function(t){throw t},f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,l=!0,u=!1;return{s:function(){n=t[Symbol.iterator]()},n:function(){var t=n.next();return l=t.done,t},e:function(t){u=!0,i=t},f:function(){try{l||null==n.return||n.return()}finally{if(u)throw i}}}}function e(t,e){if(t){if("string"==typeof t)return r(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?r(t,e):void 0}}function r(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function n(t){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}Object.defineProperty(exports,"__esModule",{value:!0}),exports.filterDataURLsFromLargeDataObjects=a,exports.replacementImageURI=void 0;var o="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHZpZXdCb3g9IjAgMCAxNiAxNiIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHJlY3Qgd2lkdGg9IjE2IiBoZWlnaHQ9IjE2IiBmaWxsPSJibGFjayIvPgo8cGF0aCBkPSJNOCAwSDE2TDAgMTZWOEw4IDBaIiBmaWxsPSIjMkQyRDJEIi8+CjxwYXRoIGQ9Ik0xNiA4VjE2SDhMMTYgOFoiIGZpbGw9IiMyRDJEMkQiLz4KPC9zdmc+Cg==";function a(e){if(e&&"object"===n(e)){var r=JSON.stringify(e);if(r.length>5e6){var a,i=t(r.matchAll(/data:([\w\/\-\.]+);(\w+),([^)"]*)/gim));try{for(i.s();!(a=i.n()).done;){var l=a.value;r="image/"===l[1].toLocaleLowerCase().slice(0,6)?r.replace(l[0],o):r.replace(l[0],"")}}catch(u){i.e(u)}finally{i.f()}}return JSON.parse(r)}return e}exports.replacementImageURI=o;
29
29
  },{}],"Z2N4":[function(require,module,exports) {
30
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.SessionRecording=exports.MUTATION_SOURCE_TYPE=exports.INCREMENTAL_SNAPSHOT_EVENT_TYPE=exports.META_EVENT_TYPE=exports.FULL_SNAPSHOT_EVENT_TYPE=void 0;var e=require("../autocapture-utils"),t=require("../utils"),n=require("../posthog-persistence"),r=s(require("../config")),i=require("./sessionrecording-utils");function s(e){return e&&e.__esModule?e:{default:e}}function o(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function a(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?o(Object(n),!0).forEach(function(t){f(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):o(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function c(e,t){return h(e)||l(e,t)||p(e,t)||u()}function u(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function p(e,t){if(e){if("string"==typeof e)return d(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?d(e,t):void 0}}function d(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function l(e,t){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e)){var n=[],r=!0,i=!1,s=void 0;try{for(var o,a=e[Symbol.iterator]();!(r=(o=a.next()).done)&&(n.push(o.value),!t||n.length!==t);r=!0);}catch(c){i=!0,s=c}finally{try{r||null==a.return||a.return()}finally{if(i)throw s}}return n}}function h(e){if(Array.isArray(e))return e}function f(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function _(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function b(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function g(e,t,n){return t&&b(e.prototype,t),n&&b(e,n),e}var w="/e/",y=2;exports.FULL_SNAPSHOT_EVENT_TYPE=y;var v=4;exports.META_EVENT_TYPE=v;var S=3;exports.INCREMENTAL_SNAPSHOT_EVENT_TYPE=S;var E=3;exports.MUTATION_SOURCE_TYPE=E;var O=function(){function s(e){_(this,s),this.instance=e,this.captureStarted=!1,this.snapshots=[],this.emit=!1,this.endpoint=w,this.stopRrweb=null,this.windowId=null,this.sessionId=null}return g(s,[{key:"startRecordingIfEnabled",value:function(){this.instance.get_property(n.SESSION_RECORDING_ENABLED)&&!this.instance.get_config("disable_session_recording")&&this._startCapture()}},{key:"started",value:function(){return this.captureStarted}},{key:"stopRecording",value:function(){this.captureStarted&&this.stopRrweb&&(this.stopRrweb(),this.stopRrweb=null,this.captureStarted=!1)}},{key:"afterDecideResponse",value:function(e){var t=!this.instance.get_config("disable_session_recording")&&!!e.sessionRecording;this.instance.persistence&&this.instance.persistence.register(f({},n.SESSION_RECORDING_ENABLED,t)),t&&(e.sessionRecording.endpoint&&(this.endpoint=e.sessionRecording.endpoint),this.submitRecordings())}},{key:"submitRecordings",value:function(){var e=this;this.emit=!0,this._startCapture(),this.snapshots.forEach(function(t){return e._captureSnapshot(t)})}},{key:"_startCapture",value:function(){void 0!==Object.assign&&(this.captureStarted||this.instance.get_config("disable_session_recording")||(this.captureStarted=!0,(0,e.loadScript)(this.instance.get_config("api_host")+"/static/recorder.js?v="+r.default.LIB_VERSION,t._.bind(this._onScriptLoaded,this))))}},{key:"_updateWindowAndSessionIds",value:function(e){var t=this.instance.sessionManager.getSessionAndWindowId(e.timestamp||(new Date).getTime(),e),n=t.windowId,r=t.sessionId;this.windowId===n&&this.sessionId===r||-1!==[y,v].indexOf(e.type)||window.rrweb.record.takeFullSnapshot(),this.windowId=n,this.sessionId=r}},{key:"_onScriptLoaded",value:function(){for(var e=this,t={blockClass:"ph-no-capture",blockSelector:null,ignoreClass:"ph-ignore-input",maskAllInputs:!1,maskInputOptions:{},maskInputFn:null,slimDOMOptions:{},collectFonts:!1},n=this.instance.get_config("session_recording"),r=0,s=Object.entries(n||{});r<s.length;r++){var o=c(s[r],2),u=o[0],p=o[1];u in t&&(t[u]=p)}this.stopRrweb=window.rrweb.record(a({emit:function(t){t=(0,i.filterDataURLsFromLargeDataObjects)(t),e._updateWindowAndSessionIds(t);var n={$snapshot_data:t,$session_id:e.sessionId,$window_id:e.windowId};e.instance._captureMetrics.incr("rrweb-record"),e.instance._captureMetrics.incr("rrweb-record-".concat(t.type)),e.emit?e._captureSnapshot(n):e.snapshots.push(n)}},t)),this.instance._addCaptureHook(function(e){"$pageview"===e&&window.rrweb.record.addCustomEvent("$pageview",{href:window.location.href})})}},{key:"_captureSnapshot",value:function(e){this.instance.capture("$snapshot",e,{transport:"XHR",method:"POST",endpoint:this.endpoint,_forceCompression:!0,_noTruncate:!0,_batchKey:"sessionRecording",_metrics:{rrweb_full_snapshot:e.$snapshot_data.type===y}})}}]),s}();exports.SessionRecording=O;
30
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.SessionRecording=exports.MUTATION_SOURCE_TYPE=exports.INCREMENTAL_SNAPSHOT_EVENT_TYPE=exports.META_EVENT_TYPE=exports.FULL_SNAPSHOT_EVENT_TYPE=void 0;var e=require("../autocapture-utils"),t=require("../utils"),n=require("../posthog-persistence"),r=s(require("../config")),i=require("./sessionrecording-utils");function s(e){return e&&e.__esModule?e:{default:e}}function o(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function a(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?o(Object(n),!0).forEach(function(t){f(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):o(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function c(e,t){return h(e)||l(e,t)||d(e,t)||u()}function u(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function d(e,t){if(e){if("string"==typeof e)return p(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?p(e,t):void 0}}function p(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function l(e,t){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e)){var n=[],r=!0,i=!1,s=void 0;try{for(var o,a=e[Symbol.iterator]();!(r=(o=a.next()).done)&&(n.push(o.value),!t||n.length!==t);r=!0);}catch(c){i=!0,s=c}finally{try{r||null==a.return||a.return()}finally{if(i)throw s}}return n}}function h(e){if(Array.isArray(e))return e}function f(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function _(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function b(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function g(e,t,n){return t&&b(e.prototype,t),n&&b(e,n),e}var v="/e/",E=2;exports.FULL_SNAPSHOT_EVENT_TYPE=E;var S=4;exports.META_EVENT_TYPE=S;var y=3;exports.INCREMENTAL_SNAPSHOT_EVENT_TYPE=y;var w=3;exports.MUTATION_SOURCE_TYPE=w;var O=function(){function s(e){_(this,s),this.instance=e,this.captureStarted=!1,this.snapshots=[],this.emit=!1,this.endpoint=v,this.stopRrweb=null,this.windowId=null,this.sessionId=null,this.receivedDecide=!1}return g(s,[{key:"startRecordingIfEnabled",value:function(){this.isRecordingEnabled()?this.startCaptureAndTrySendingQueuedSnapshots():this.stopRecording()}},{key:"started",value:function(){return this.captureStarted}},{key:"stopRecording",value:function(){this.captureStarted&&this.stopRrweb&&(this.stopRrweb(),this.stopRrweb=null,this.captureStarted=!1)}},{key:"isRecordingEnabled",value:function(){var e=!!this.instance.get_property(n.SESSION_RECORDING_ENABLED_SERVER_SIDE),t=!this.instance.get_config("disable_session_recording");return e&&t}},{key:"afterDecideResponse",value:function(e){var t,r;(this.receivedDecide=!0,this.instance.persistence&&this.instance.persistence.register(f({},n.SESSION_RECORDING_ENABLED_SERVER_SIDE,!!e.sessionRecording)),null===(t=e.sessionRecording)||void 0===t?void 0:t.endpoint)&&(this.endpoint=null===(r=e.sessionRecording)||void 0===r?void 0:r.endpoint);this.startRecordingIfEnabled()}},{key:"startCaptureAndTrySendingQueuedSnapshots",value:function(){var e=this;this.receivedDecide&&(this.emit=!0,this.snapshots.forEach(function(t){return e._captureSnapshot(t)})),this._startCapture()}},{key:"_startCapture",value:function(){void 0!==Object.assign&&(this.captureStarted||this.instance.get_config("disable_session_recording")||(this.captureStarted=!0,(0,e.loadScript)(this.instance.get_config("api_host")+"/static/recorder.js?v="+r.default.LIB_VERSION,t._.bind(this._onScriptLoaded,this))))}},{key:"_updateWindowAndSessionIds",value:function(e){var t=this.instance.sessionManager.getSessionAndWindowId(e.timestamp||(new Date).getTime(),e),n=t.windowId,r=t.sessionId;this.windowId===n&&this.sessionId===r||-1!==[E,S].indexOf(e.type)||window.rrweb.record.takeFullSnapshot(),this.windowId=n,this.sessionId=r}},{key:"_onScriptLoaded",value:function(){for(var e=this,t={blockClass:"ph-no-capture",blockSelector:null,ignoreClass:"ph-ignore-input",maskAllInputs:!1,maskInputOptions:{},maskInputFn:null,slimDOMOptions:{},collectFonts:!1},n=this.instance.get_config("session_recording"),r=0,s=Object.entries(n||{});r<s.length;r++){var o=c(s[r],2),u=o[0],d=o[1];u in t&&(t[u]=d)}this.stopRrweb=window.rrweb.record(a({emit:function(t){t=(0,i.filterDataURLsFromLargeDataObjects)(t),e._updateWindowAndSessionIds(t);var n={$snapshot_data:t,$session_id:e.sessionId,$window_id:e.windowId};e.instance._captureMetrics.incr("rrweb-record"),e.instance._captureMetrics.incr("rrweb-record-".concat(t.type)),e.emit?e._captureSnapshot(n):e.snapshots.push(n)}},t)),this.instance._addCaptureHook(function(e){"$pageview"===e&&window.rrweb.record.addCustomEvent("$pageview",{href:window.location.href})})}},{key:"_captureSnapshot",value:function(e){this.instance.capture("$snapshot",e,{transport:"XHR",method:"POST",endpoint:this.endpoint,_forceCompression:!0,_noTruncate:!0,_batchKey:"sessionRecording",_metrics:{rrweb_full_snapshot:e.$snapshot_data.type===E}})}}]),s}();exports.SessionRecording=O;
31
31
  },{"../autocapture-utils":"RYfg","../utils":"FOZT","../posthog-persistence":"MAdm","../config":"itQ5","./sessionrecording-utils":"vmk3"}],"auG7":[function(require,module,exports) {
32
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Decide=void 0;var e=require("./autocapture"),t=require("./utils"),n=require("./posthog-featureflags");function r(e,t){var n;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(n=o(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var s,a=!0,c=!1;return{s:function(){n=e[Symbol.iterator]()},n:function(){var e=n.next();return a=e.done,e},e:function(e){c=!0,s=e},f:function(){try{a||null==n.return||n.return()}finally{if(c)throw s}}}}function o(e,t){if(e){if("string"==typeof e)return i(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?i(e,t):void 0}}function i(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function s(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function c(e,t,n){return t&&a(e.prototype,t),n&&a(e,n),e}var u=function(){function o(e){s(this,o),this.instance=e}return c(o,[{key:"call",value:function(){var e=this,n=JSON.stringify({token:this.instance.get_config("token"),distinct_id:this.instance.get_distinct_id(),groups:this.instance.getGroups()}),r=t._.base64Encode(n);this.instance._send_request("".concat(this.instance.get_config("api_host"),"/decide/?v=2"),{data:r,verbose:!0},{method:"POST"},function(t){return e.parseDecideResponse(t)})}},{key:"parseDecideResponse",value:function(t){var o=this;if(0!==(null==t?void 0:t.status)){if(!document||!document.body)return console.log("document not ready yet, trying again in 500 milliseconds..."),void setTimeout(function(){o.parseDecideResponse(t)},500);if(this.instance.toolbar.afterDecideResponse(t),this.instance.sessionRecording.afterDecideResponse(t),e.autocapture.afterDecideResponse(t,this.instance),(0,n.parseFeatureFlagDecideResponse)(t,this.instance.persistence),t.supportedCompression){var i,s={},a=r(t.supportedCompression);try{for(a.s();!(i=a.n()).done;){s[i.value]=!0}}catch(c){a.e(c)}finally{a.f()}this.instance.compression=s}else this.instance.compression={}}else console.error("Failed to fetch feature flags from PostHog.")}}]),o}();exports.Decide=u;
33
- },{"./autocapture":"gR3r","./utils":"FOZT","./posthog-featureflags":"aVqC"}],"ZEpJ":[function(require,module,exports) {
32
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Decide=void 0;var e=require("./autocapture"),t=require("./utils");function n(e,t){var n;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(n=r(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var i=0,o=function(){};return{s:o,n:function(){return i>=e.length?{done:!0}:{done:!1,value:e[i++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var s,a=!0,c=!1;return{s:function(){n=e[Symbol.iterator]()},n:function(){var e=n.next();return a=e.done,e},e:function(e){c=!0,s=e},f:function(){try{a||null==n.return||n.return()}finally{if(c)throw s}}}}function r(e,t){if(e){if("string"==typeof e)return i(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?i(e,t):void 0}}function i(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function s(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function a(e,t,n){return t&&s(e.prototype,t),n&&s(e,n),e}var c=function(){function r(e){o(this,r),this.instance=e,this.instance.decideEndpointWasHit=!1}return a(r,[{key:"call",value:function(){var e=this,n=JSON.stringify({token:this.instance.get_config("token"),distinct_id:this.instance.get_distinct_id(),groups:this.instance.getGroups()}),r=t._.base64Encode(n);this.instance._send_request("".concat(this.instance.get_config("api_host"),"/decide/?v=2"),{data:r,verbose:!0},{method:"POST"},function(t){return e.parseDecideResponse(t)})}},{key:"parseDecideResponse",value:function(t){var r=this;if(0!==(null==t?void 0:t.status)){if(this.instance.decideEndpointWasHit=!0,!document||!document.body)return console.log("document not ready yet, trying again in 500 milliseconds..."),void setTimeout(function(){r.parseDecideResponse(t)},500);if(this.instance.toolbar.afterDecideResponse(t),this.instance.sessionRecording.afterDecideResponse(t),e.autocapture.afterDecideResponse(t,this.instance),this.instance.featureFlags.receivedFeatureFlags(t),t.supportedCompression){var i,o={},s=n(t.supportedCompression);try{for(s.s();!(i=s.n()).done;){o[i.value]=!0}}catch(a){s.e(a)}finally{s.f()}this.instance.compression=o}else this.instance.compression={}}else console.error("Failed to fetch feature flags from PostHog.")}}]),r}();exports.Decide=c;
33
+ },{"./autocapture":"gR3r","./utils":"FOZT"}],"ZEpJ":[function(require,module,exports) {
34
34
  "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Toolbar=void 0;var t=require("../autocapture-utils"),e=require("../utils");function o(t,e){var o=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),o.push.apply(o,r)}return o}function r(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?o(Object(r),!0).forEach(function(e){n(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):o(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}function n(t,e,o){return e in t?Object.defineProperty(t,e,{value:o,enumerable:!0,configurable:!0,writable:!0}):t[e]=o,t}function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function a(t,e){for(var o=0;o<e.length;o++){var r=e[o];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function s(t,e,o){return e&&a(t.prototype,e),o&&a(t,o),t}var c=function(){function o(t){i(this,o),this.instance=t}return s(o,[{key:"afterDecideResponse",value:function(t){var e=t.editorParams||(t.toolbarVersion?{toolbarVersion:t.toolbarVersion}:{});t.isAuthenticated&&e.toolbarVersion&&0===e.toolbarVersion.indexOf("toolbar")&&this._loadEditor(r(r({},e),{},{apiURL:this.instance.get_config("api_host")}))}},{key:"maybeLoadEditor",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:window.location,o=arguments.length>1?arguments[1]:void 0,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:window.history;try{if(!o){try{window.localStorage.setItem("test","test"),window.localStorage.removeItem("test")}catch(s){return!1}o=window.localStorage}var n,i=e._.getHashParam(t.hash,"__posthog")||e._.getHashParam(t.hash,"state"),a=i?JSON.parse(decodeURIComponent(i)):null;return a&&("mpeditor"===a.action||"ph_authorize"===a.action)?(n=a)&&Object.keys(n).length>0&&(o.setItem("_postHogEditorParams",JSON.stringify(n)),a.desiredHash?t.hash=a.desiredHash:r?r.replaceState("",document.title,t.pathname+t.search):t.hash=""):delete(n=JSON.parse(o.getItem("_postHogEditorParams")||"{}")).userIntent,n.apiURL=this.instance.get_config("api_host"),!(!n.token||this.instance.get_config("token")!==n.token)&&(this._loadEditor(n),!0)}catch(c){return!1}}},{key:"_loadEditor",value:function(o){var n=this;if(!window._postHogToolbarLoaded){window._postHogToolbarLoaded=!0;var i=o.jsURL||o.apiURL||this.instance.get_config("api_host"),a=i+(i.endsWith("/")?"":"/")+"static/toolbar.js?_ts="+(new Date).getTime(),s="https://app.posthog.com"!==this.instance.get_config("api_host")&&this.instance.get_config("advanced_disable_toolbar_metrics");return o=r(r({},o),s?{instrument:!1}:{}),(0,t.loadScript)(a,function(){window.ph_load_editor(o,n.instance)}),e._.register_event(window,"turbolinks:load",function(){window._postHogToolbarLoaded=!1,n._loadEditor(o)}),!0}return!1}}]),o}();exports.Toolbar=c;
35
35
  },{"../autocapture-utils":"RYfg","../utils":"FOZT"}],"ae0g":[function(require,module,exports) {
36
36
  "use strict";function e(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function t(e,t){for(var n=0;n<t.length;n++){var u=t[n];u.enumerable=u.enumerable||!1,u.configurable=!0,"value"in u&&(u.writable=!0),Object.defineProperty(e,u.key,u)}}function n(e,n,u){return n&&t(e.prototype,n),u&&t(e,u),e}Object.defineProperty(exports,"__esModule",{value:!0}),exports.RequestQueueScaffold=void 0;var u=function(){function t(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:3e3;e(this,t),this.isPolling=!0,this._event_queue=[],this._empty_queue_count=0,this._poller=function(){},this._pollInterval=n}return n(t,[{key:"setPollInterval",value:function(e){this._pollInterval=e,this.isPolling&&this.poll()}},{key:"enqueue",value:function(){}},{key:"poll",value:function(){}},{key:"unload",value:function(){}},{key:"getTime",value:function(){return(new Date).getTime()}}]),t}();exports.RequestQueueScaffold=u;
37
37
  },{}],"Je4H":[function(require,module,exports) {
38
38
  "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.RequestQueue=void 0;var e=require("./base-request-queue"),t=require("./utils");function r(e){return(r="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 n(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function o(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?n(Object(r),!0).forEach(function(t){u(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):n(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function u(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function c(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function a(e,t,r){return t&&c(e.prototype,t),r&&c(e,r),e}function l(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&s(e,t)}function s(e,t){return(s=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function f(e){var t=b();return function(){var r,n=y(e);if(t){var o=y(this).constructor;r=Reflect.construct(n,arguments,o)}else r=n.apply(this,arguments);return p(this,r)}}function p(e,t){return!t||"object"!==r(t)&&"function"!=typeof t?h(e):t}function h(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function b(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch(e){return!1}}function y(e){return(y=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var _=function(r){l(u,e.RequestQueueScaffold);var n=f(u);function u(e,t){var r,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:3e3;return i(this,u),(r=n.call(this,o)).handlePollRequest=t,r.captureMetrics=e,r}return a(u,[{key:"enqueue",value:function(e,t,r){this.captureMetrics.incr("batch-enqueue"),this._event_queue.push({url:e,data:t,options:r}),this.isPolling||(this.isPolling=!0,this.poll())}},{key:"poll",value:function(){var e=this;clearTimeout(this._poller),this._poller=setTimeout(function(){if(e._event_queue.length>0){var r=e.formatQueue(),n=function(n){var o=r[n],u=o.url,i=o.data,c=o.options;t._.each(i,function(t,r){i[r].offset=Math.abs(i[r].timestamp-e.getTime()),delete i[r].timestamp}),e.handlePollRequest(u,i,c),e.captureMetrics.incr("batch-requests"),e.captureMetrics.incr("batch-requests-".concat(u.slice(u.length-2))),e.captureMetrics.incr("batch-handle",i.length),e.captureMetrics.incr("batch-handle-".concat(u.slice(u.length-2)),i.length)};for(var o in r)n(o);e._event_queue.length=0,e._empty_queue_count=0}else e._empty_queue_count++;e._empty_queue_count>4&&(e.isPolling=!1,e._empty_queue_count=0),e.isPolling&&e.poll()},this._pollInterval)}},{key:"updateUnloadMetrics",value:function(){var e=this.formatQueue();for(var t in e){var r=e[t],n=r.url,o=r.data;this.captureMetrics.incr("batch-unload-requests"),this.captureMetrics.incr("batch-unload-requests-".concat(n.slice(n.length-2))),this.captureMetrics.incr("batch-unload",o.length),this.captureMetrics.incr("batch-unload-".concat(n.slice(n.length-2)),o.length)}}},{key:"unload",value:function(){clearTimeout(this._poller);var e=this._event_queue.length>0?this.formatQueue():{};for(var t in this._event_queue.length=0,e){var r=e[t],n=r.url,u=r.data,i=r.options;this.handlePollRequest(n,u,o(o({},i),{},{transport:"sendbeacon"}))}}},{key:"formatQueue",value:function(){var e={};return t._.each(this._event_queue,function(t){var r=t.url,n=t.data,o=t.options,u=(o?o._batchKey:null)||r;void 0===e[u]&&(e[u]={data:[],url:r,options:o}),o&&e[u].options&&e[u].options._metrics&&!e[u].options._metrics.rrweb_full_snapshot&&(e[u].options._metrics.rrweb_full_snapshot=o._metrics.rrweb_full_snapshot),e[u].data.push(n)}),e}}]),u}();exports.RequestQueue=_;
39
39
  },{"./base-request-queue":"ae0g","./utils":"FOZT"}],"TeHW":[function(require,module,exports) {
40
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.CaptureMetrics=void 0;var e=require("./utils");function t(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function r(e){for(var r=1;r<arguments.length;r++){var i=null!=arguments[r]?arguments[r]:{};r%2?t(Object(i),!0).forEach(function(t){n(e,t,i[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):t(Object(i)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))})}return e}function n(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function i(e,t){return c(e)||s(e,t)||a(e,t)||o()}function o(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function a(e,t){if(e){if("string"==typeof e)return u(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?u(e,t):void 0}}function u(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function s(e,t){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e)){var r=[],n=!0,i=!1,o=void 0;try{for(var a,u=e[Symbol.iterator]();!(n=(a=u.next()).done)&&(r.push(a.value),!t||r.length!==t);n=!0);}catch(s){i=!0,o=s}finally{try{n||null==u.return||u.return()}finally{if(i)throw o}}return r}}function c(e){if(Array.isArray(e))return e}function l(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function f(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function h(e,t,r){return t&&f(e.prototype,t),r&&f(e,r),e}var b=function(){function t(e,r){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:function(){return(new Date).getTime()};l(this,t),this.enabled=e,this.capture=r,this.getTime=n,this.metrics={},this.requests={}}return h(t,[{key:"incr",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;this.enabled&&(e="phjs-".concat(e),this.metrics[e]=(this.metrics[e]||0)+t)}},{key:"decr",value:function(e){this.enabled&&(e="phjs-".concat(e),this.metrics[e]=(this.metrics[e]||0)-1)}},{key:"startRequest",value:function(t){if(this.enabled){var r=e._.UUID();return this.requests[r]=[this.getTime(),t],r}}},{key:"finishRequest",value:function(e){if(this.enabled&&this.requests[e]){var t=i(this.requests[e],2),r=t[0],n=t[1];return n.duration=this.getTime()-r,delete this.requests[e],n}}},{key:"markRequestFailed",value:function(e){this.enabled&&this.capture("$capture_failed_request",e)}},{key:"captureInProgressRequests",value:function(){var e=this;this.enabled&&Object.keys(this.requests).forEach(function(t){var n=e.finishRequest(t);e.markRequestFailed(r(r({},n),{},{type:"inflight_at_unload"}))})}}]),t}();exports.CaptureMetrics=b;
40
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.CaptureMetrics=void 0;var e=require("./utils");function t(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function r(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function i(e,t,i){return t&&r(e.prototype,t),i&&r(e,i),e}var n=function(){function e(r){t(this,e),this.enabled=r,this.metrics={}}return i(e,[{key:"incr",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;this.enabled&&(e="phjs-".concat(e),this.metrics[e]=(this.metrics[e]||0)+t)}},{key:"decr",value:function(e){this.enabled&&(e="phjs-".concat(e),this.metrics[e]=(this.metrics[e]||0)-1)}}]),e}();exports.CaptureMetrics=n;
41
41
  },{"./utils":"FOZT"}],"UJm1":[function(require,module,exports) {
42
42
  "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.deflate=xt,exports.deflateSync=bt,exports.inflate=Mt,exports.inflateSync=kt,exports.compress=exports.gzip=Dt,exports.compressSync=exports.gzipSync=Ot,exports.gunzip=It,exports.gunzipSync=Zt,exports.zlib=Tt,exports.zlibSync=jt,exports.unzlib=_t,exports.unzlibSync=Bt,exports.decompress=Wt,exports.decompressSync=Yt,exports.strToU8=Jt,exports.strFromU8=Kt,exports.zip=tn,exports.zipSync=nn,exports.unzip=rn,exports.unzipSync=en,exports.AsyncDecompress=exports.Decompress=exports.AsyncUnzlib=exports.Unzlib=exports.AsyncZlib=exports.Zlib=exports.AsyncGunzip=exports.Gunzip=exports.AsyncCompress=exports.AsyncGzip=exports.Compress=exports.Gzip=exports.AsyncInflate=exports.Inflate=exports.AsyncDeflate=exports.Deflate=void 0;var t={},n=function(n,r,e,i,o){var a=t[r]||(t[r]=URL.createObjectURL(new Blob([n],{type:"text/javascript"}))),f=new Worker(a);return f.onerror=function(t){return o(t.error,null)},f.onmessage=function(t){return o(null,t.data)},f.postMessage(e,i),f},r=Uint8Array,e=Uint16Array,i=Uint32Array,o=new r([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),a=new r([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),f=new r([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),s=function(t,n){for(var r=new e(31),o=0;o<31;++o)r[o]=n+=1<<t[o-1];var a=new i(r[30]);for(o=1;o<30;++o)for(var f=r[o];f<r[o+1];++f)a[f]=f-r[o]<<5|o;return[r,a]},u=s(o,2),l=u[0],c=u[1];l[28]=258,c[258]=28;for(var h=s(a,0),p=h[0],v=h[1],d=new e(32768),g=0;g<32768;++g){var w=(43690&g)>>>1|(21845&g)<<1;w=(61680&(w=(52428&w)>>>2|(13107&w)<<2))>>>4|(3855&w)<<4,d[g]=((65280&w)>>>8|(255&w)<<8)>>>1}var y=function(t,n,r){for(var i=t.length,o=0,a=new e(n);o<i;++o)++a[t[o]-1];var f,s=new e(n);for(o=0;o<n;++o)s[o]=s[o-1]+a[o-1]<<1;if(r){f=new e(1<<n);var u=15-n;for(o=0;o<i;++o)if(t[o])for(var l=o<<4|t[o],c=n-t[o],h=s[t[o]-1]++<<c,p=h|(1<<c)-1;h<=p;++h)f[d[h]>>>u]=l}else for(f=new e(i),o=0;o<i;++o)f[o]=d[s[t[o]-1]++]>>>15-t[o];return f},m=new r(288);for(g=0;g<144;++g)m[g]=8;for(g=144;g<256;++g)m[g]=9;for(g=256;g<280;++g)m[g]=7;for(g=280;g<288;++g)m[g]=8;var x=new r(32);for(g=0;g<32;++g)x[g]=5;var b=y(m,9,0),z=y(m,9,1),A=y(x,5,0),M=y(x,5,1),k=function(t){for(var n=t[0],r=1;r<t.length;++r)t[r]>n&&(n=t[r]);return n},S=function(t,n,r){var e=n/8>>0;return(t[e]|t[e+1]<<8)>>>(7&n)&r},C=function(t,n){var r=n/8>>0;return(t[r]|t[r+1]<<8|t[r+2]<<16)>>>(7&n)},D=function(t){return(t/8>>0)+(7&t&&1)},O=function(t,n,o){(null==n||n<0)&&(n=0),(null==o||o>t.length)&&(o=t.length);var a=new(t instanceof e?e:t instanceof i?i:r)(o-n);return a.set(t.subarray(n,o)),a},G=function(t,n,e){var i=t.length,s=!n||e,u=!e||e.i;e||(e={}),n||(n=new r(3*i));var c=function(t){var e=n.length;if(t>e){var i=new r(Math.max(2*e,t));i.set(n),n=i}},h=e.f||0,v=e.p||0,d=e.b||0,g=e.l,w=e.d,m=e.m,x=e.n,b=8*i;do{if(!g){e.f=h=S(t,v,1);var A=S(t,v+1,3);if(v+=3,!A){var G=t[(B=D(v)+4)-4]|t[B-3]<<8,U=B+G;if(U>i){if(u)throw"unexpected EOF";break}s&&c(d+G),n.set(t.subarray(B,U),d),e.b=d+=G,e.p=v=8*U;continue}if(1==A)g=z,w=M,m=9,x=5;else{if(2!=A)throw"invalid block type";var I=S(t,v,31)+257,Z=S(t,v+10,15)+4,E=I+S(t,v+5,31)+1;v+=14;for(var F=new r(E),T=new r(19),j=0;j<Z;++j)T[f[j]]=S(t,v+3*j,7);v+=3*Z;var L=k(T),R=(1<<L)-1;if(!u&&v+E*(L+7)>b)break;var _=y(T,L,1);for(j=0;j<E;){var B,H=_[S(t,v,R)];if(v+=15&H,(B=H>>>4)<16)F[j++]=B;else{var P=0,W=0;for(16==B?(W=3+S(t,v,3),v+=2,P=F[j-1]):17==B?(W=3+S(t,v,7),v+=3):18==B&&(W=11+S(t,v,127),v+=7);W--;)F[j++]=P}}var Y=F.subarray(0,I),q=F.subarray(I);m=k(Y),x=k(q),g=y(Y,m,1),w=y(q,x,1)}if(v>b)throw"unexpected EOF"}s&&c(d+131072);for(var J=(1<<m)-1,K=(1<<x)-1,N=m+x+18;u||v+N<b;){var Q=(P=g[C(t,v)&J])>>>4;if((v+=15&P)>b)throw"unexpected EOF";if(!P)throw"invalid length/literal";if(Q<256)n[d++]=Q;else{if(256==Q){g=null;break}var V=Q-254;if(Q>264){var X=o[j=Q-257];V=S(t,v,(1<<X)-1)+l[j],v+=X}var $=w[C(t,v)&K],tt=$>>>4;if(!$)throw"invalid distance";v+=15&$;q=p[tt];if(tt>3){X=a[tt];q+=C(t,v)&(1<<X)-1,v+=X}if(v>b)throw"unexpected EOF";s&&c(d+131072);for(var nt=d+V;d<nt;d+=4)n[d]=n[d-q],n[d+1]=n[d+1-q],n[d+2]=n[d+2-q],n[d+3]=n[d+3-q];d=nt}}e.l=g,e.p=v,e.b=d,g&&(h=1,e.m=m,e.d=w,e.n=x)}while(!h);return d==n.length?n:O(n,0,d)},U=function(t,n,r){r<<=7&n;var e=n/8>>0;t[e]|=r,t[e+1]|=r>>>8},I=function(t,n,r){r<<=7&n;var e=n/8>>0;t[e]|=r,t[e+1]|=r>>>8,t[e+2]|=r>>>16},Z=function(t,n){for(var i=[],o=0;o<t.length;++o)t[o]&&i.push({s:o,f:t[o]});var a=i.length,f=i.slice();if(!a)return[new r(0),0];if(1==a){var s=new r(i[0].s+1);return s[i[0].s]=1,[s,1]}i.sort(function(t,n){return t.f-n.f}),i.push({s:-1,f:25001});var u=i[0],l=i[1],c=0,h=1,p=2;for(i[0]={s:-1,f:u.f+l.f,l:u,r:l};h!=a-1;)u=i[i[c].f<i[p].f?c++:p++],l=i[c!=h&&i[c].f<i[p].f?c++:p++],i[h++]={s:-1,f:u.f+l.f,l:u,r:l};var v=f[0].s;for(o=1;o<a;++o)f[o].s>v&&(v=f[o].s);var d=new e(v+1),g=E(i[h-1],d,0);if(g>n){o=0;var w=0,y=g-n,m=1<<y;for(f.sort(function(t,n){return d[n.s]-d[t.s]||t.f-n.f});o<a;++o){var x=f[o].s;if(!(d[x]>n))break;w+=m-(1<<g-d[x]),d[x]=n}for(w>>>=y;w>0;){var b=f[o].s;d[b]<n?w-=1<<n-d[b]++-1:++o}for(;o>=0&&w;--o){var z=f[o].s;d[z]==n&&(--d[z],++w)}g=n}return[new r(d),g]},E=function(t,n,r){return-1==t.s?Math.max(E(t.l,n,r+1),E(t.r,n,r+1)):n[t.s]=r},F=function(t){for(var n=t.length;n&&!t[--n];);for(var r=new e(++n),i=0,o=t[0],a=1,f=function(t){r[i++]=t},s=1;s<=n;++s)if(t[s]==o&&s!=n)++a;else{if(!o&&a>2){for(;a>138;a-=138)f(32754);a>2&&(f(a>10?a-11<<5|28690:a-3<<5|12305),a=0)}else if(a>3){for(f(o),--a;a>6;a-=6)f(8304);a>2&&(f(a-3<<5|8208),a=0)}for(;a--;)f(o);a=1,o=t[s]}return[r.subarray(0,i),n]},T=function(t,n){for(var r=0,e=0;e<n.length;++e)r+=t[e]*n[e];return r},j=function(t,n,r){var e=r.length,i=D(n+2);t[i]=255&e,t[i+1]=e>>>8,t[i+2]=255^t[i],t[i+3]=255^t[i+1];for(var o=0;o<e;++o)t[i+o+4]=r[o];return 8*(i+4+e)},L=function(t,n,r,i,s,u,l,c,h,p,v){U(n,v++,r),++s[256];for(var d=Z(s,15),g=d[0],w=d[1],z=Z(u,15),M=z[0],k=z[1],S=F(g),C=S[0],D=S[1],O=F(M),G=O[0],E=O[1],L=new e(19),R=0;R<C.length;++R)L[31&C[R]]++;for(R=0;R<G.length;++R)L[31&G[R]]++;for(var _=Z(L,7),B=_[0],H=_[1],P=19;P>4&&!B[f[P-1]];--P);var W,Y,q,J,K=p+5<<3,N=T(s,m)+T(u,x)+l,Q=T(s,g)+T(u,M)+l+14+3*P+T(L,B)+(2*L[16]+3*L[17]+7*L[18]);if(K<=N&&K<=Q)return j(n,v,t.subarray(h,h+p));if(U(n,v,1+(Q<N)),v+=2,Q<N){W=y(g,w,0),Y=g,q=y(M,k,0),J=M;var V=y(B,H,0);U(n,v,D-257),U(n,v+5,E-1),U(n,v+10,P-4),v+=14;for(R=0;R<P;++R)U(n,v+3*R,B[f[R]]);v+=3*P;for(var X=[C,G],$=0;$<2;++$){var tt=X[$];for(R=0;R<tt.length;++R){var nt=31&tt[R];U(n,v,V[nt]),v+=B[nt],nt>15&&(U(n,v,tt[R]>>>5&127),v+=tt[R]>>>12)}}}else W=b,Y=m,q=A,J=x;for(R=0;R<c;++R)if(i[R]>255){nt=i[R]>>>18&31;I(n,v,W[nt+257]),v+=Y[nt+257],nt>7&&(U(n,v,i[R]>>>23&31),v+=o[nt]);var rt=31&i[R];I(n,v,q[rt]),v+=J[rt],rt>3&&(I(n,v,i[R]>>>5&8191),v+=a[rt])}else I(n,v,W[i[R]]),v+=Y[i[R]];return I(n,v,W[256]),v+Y[256]},R=new i([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),_=new r(0),B=function(t,n,f,s,u,l){var h=t.length,p=new r(s+h+5*(1+Math.floor(h/7e3))+u),d=p.subarray(s,p.length-u),g=0;if(!n||h<8)for(var w=0;w<=h;w+=65535){var y=w+65535;y<h?g=j(d,g,t.subarray(w,y)):(d[w]=l,g=j(d,g,t.subarray(w,h)))}else{for(var m=R[n-1],x=m>>>13,b=8191&m,z=(1<<f)-1,A=new e(32768),M=new e(z+1),k=Math.ceil(f/3),S=2*k,C=function(n){return(t[n]^t[n+1]<<k^t[n+2]<<S)&z},G=new i(25e3),U=new e(288),I=new e(32),Z=0,E=0,F=(w=0,0),T=0,B=0;w<h;++w){var H=C(w),P=32767&w,W=M[H];if(A[P]=W,M[H]=P,T<=w){var Y=h-w;if((Z>7e3||F>24576)&&Y>423){g=L(t,d,0,G,U,I,E,F,B,w-B,g),F=Z=E=0,B=w;for(var q=0;q<286;++q)U[q]=0;for(q=0;q<30;++q)I[q]=0}var J=2,K=0,N=b,Q=P-W&32767;if(Y>2&&H==C(w-Q))for(var V=Math.min(x,Y)-1,X=Math.min(32767,w),$=Math.min(258,Y);Q<=X&&--N&&P!=W;){if(t[w+J]==t[w+J-Q]){for(var tt=0;tt<$&&t[w+tt]==t[w+tt-Q];++tt);if(tt>J){if(J=tt,K=Q,tt>V)break;var nt=Math.min(Q,tt-2),rt=0;for(q=0;q<nt;++q){var et=w-Q+q+32768&32767,it=et-A[et]+32768&32767;it>rt&&(rt=it,W=et)}}}Q+=(P=W)-(W=A[P])+32768&32767}if(K){G[F++]=268435456|c[J]<<18|v[K];var ot=31&c[J],at=31&v[K];E+=o[ot]+a[at],++U[257+ot],++I[at],T=w+J,++Z}else G[F++]=t[w],++U[t[w]]}}g=L(t,d,l,G,U,I,E,F,B,w-B,g),l||(g=j(d,g,_))}return O(p,0,s+D(g)+u)},H=function(){for(var t=new i(256),n=0;n<256;++n){for(var r=n,e=9;--e;)r=(1&r&&3988292384)^r>>>1;t[n]=r}return t}(),P=function(){var t=4294967295;return{p:function(n){for(var r=t,e=0;e<n.length;++e)r=H[255&r^n[e]]^r>>>8;t=r},d:function(){return 4294967295^t}}},W=function(){var t=1,n=0;return{p:function(r){for(var e=t,i=n,o=r.length,a=0;a!=o;){for(var f=Math.min(a+5552,o);a<f;++a)i+=e+=r[a];e%=65521,i%=65521}t=e,n=i},d:function(){return(t>>>8<<16|(255&n)<<8|n>>>8)+2*((255&t)<<23)}}},Y=function(t,n,r,e,i){return B(t,null==n.level?6:n.level,null==n.mem?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(t.length)))):12+n.mem,r,e,!i)},q=function(t,n){var r={};for(var e in t)r[e]=t[e];for(var e in n)r[e]=n[e];return r},J=function(t,n,r){for(var e=t(),i=t.toString(),o=i.slice(i.indexOf("[")+1,i.lastIndexOf("]")).replace(/ /g,"").split(","),a=0;a<e.length;++a){var f=e[a],s=o[a];if("function"==typeof f){n+=";"+s+"=";var u=f.toString();if(f.prototype)if(-1!=u.indexOf("[native code]")){var l=u.indexOf(" ",8)+1;n+=u.slice(l,u.indexOf("(",l))}else for(var c in n+=u,f.prototype)n+=";"+s+".prototype."+c+"="+f.prototype[c].toString();else n+=u}else r[s]=f}return[n,r]},K=[],N=function(t){var n=[];for(var o in t)(t[o]instanceof r||t[o]instanceof e||t[o]instanceof i)&&n.push((t[o]=new t[o].constructor(t[o])).buffer);return n},Q=function(t,r,e,i){var o;if(!K[e]){for(var a="",f={},s=t.length-1,u=0;u<s;++u)a=(o=J(t[u],a,f))[0],f=o[1];K[e]=J(t[s],a,f)}var l=q({},K[e][1]);return n(K[e][0]+";onmessage=function(e){for(var k in e.data)self[k]=e.data[k];onmessage="+r.toString()+"}",e,l,N(l),i)},V=function(){return[r,e,i,o,a,f,l,p,z,M,d,y,k,S,C,D,O,G,kt,et,it]},X=function(){return[r,e,i,o,a,f,c,v,b,m,A,x,d,R,_,y,U,I,Z,E,F,T,j,L,D,O,B,Y,bt,et]},$=function(){return[ct,vt,lt,P,H]},tt=function(){return[ht,pt]},nt=function(){return[dt,lt,W]},rt=function(){return[gt]},et=function(t){return postMessage(t,[t.buffer])},it=function(t){return t&&t.size&&new r(t.size)},ot=function(t,n,e,i,o,a){var f=Q(e,i,o,function(t,n){f.terminate(),a(t,n)});return n.consume||(t=new r(t)),f.postMessage([t,n],[t.buffer]),function(){f.terminate()}},at=function(t){return t.ondata=function(t,n){return postMessage([t,n],[t.buffer])},function(n){return t.push(n.data[0],n.data[1])}},ft=function(t,n,r,e,i){var o,a=Q(t,e,i,function(t,r){t?(a.terminate(),n.ondata.call(n,t)):(r[1]&&a.terminate(),n.ondata.call(n,t,r[0],r[1]))});a.postMessage(r),n.push=function(t,r){if(o)throw"stream finished";if(!n.ondata)throw"no stream handler";a.postMessage([t,o=r],[t.buffer])},n.terminate=function(){a.terminate()}},st=function(t,n){return t[n]|t[n+1]<<8},ut=function(t,n){return(t[n]|t[n+1]<<8|t[n+2]<<16)+2*(t[n+3]<<23)},lt=function(t,n,r){for(;r;++n)t[n]=r,r>>>=8},ct=function(t,n){var r=n.filename;if(t[0]=31,t[1]=139,t[2]=8,t[8]=n.level<2?4:9==n.level?2:0,t[9]=3,0!=n.mtime&&lt(t,4,Math.floor(new Date(n.mtime||Date.now())/1e3)),r){t[3]=8;for(var e=0;e<=r.length;++e)t[e+10]=r.charCodeAt(e)}},ht=function(t){if(31!=t[0]||139!=t[1]||8!=t[2])throw"invalid gzip data";var n=t[3],r=10;4&n&&(r+=t[10]|2+(t[11]<<8));for(var e=(n>>3&1)+(n>>4&1);e>0;e-=!t[r++]);return r+(2&n)},pt=function(t){var n=t.length;return(t[n-4]|t[n-3]<<8|t[n-2]<<16)+2*(t[n-1]<<23)},vt=function(t){return 10+(t.filename&&t.filename.length+1||0)},dt=function(t,n){var r=n.level,e=0==r?0:r<6?1:9==r?3:2;t[0]=120,t[1]=e<<6|(e?32-2*e:1)},gt=function(t){if(8!=(15&t[0])||t[0]>>>4>7||(t[0]<<8|t[1])%31)throw"invalid zlib data";if(32&t[1])throw"invalid zlib data: preset dictionaries not supported"};function wt(t,n){return n||"function"!=typeof t||(n=t,t={}),this.ondata=n,t}var yt=function(){function t(t,n){n||"function"!=typeof t||(n=t,t={}),this.ondata=n,this.o=t||{}}return t.prototype.p=function(t,n){this.ondata(Y(t,this.o,0,0,!n),n)},t.prototype.push=function(t,n){if(this.d)throw"stream finished";if(!this.ondata)throw"no stream handler";this.d=n,this.p(t,n||!1)},t}();exports.Deflate=yt;var mt=function(){return function(t,n){ft([X,function(){return[at,yt]}],this,wt.call(this,t,n),function(t){var n=new yt(t.data);onmessage=at(n)},6)}}();function xt(t,n,r){if(r||(r=n,n={}),"function"!=typeof r)throw"no callback";return ot(t,n,[X],function(t){return et(bt(t.data[0],t.data[1]))},0,r)}function bt(t,n){return void 0===n&&(n={}),Y(t,n,0,0)}exports.AsyncDeflate=mt;var zt=function(){function t(t){this.s={},this.p=new r(0),this.ondata=t}return t.prototype.e=function(t){if(this.d)throw"stream finished";if(!this.ondata)throw"no stream handler";var n=this.p.length,e=new r(n+t.length);e.set(this.p),e.set(t,n),this.p=e},t.prototype.c=function(t){this.d=this.s.i=t||!1;var n=this.s.b,r=G(this.p,this.o,this.s);this.ondata(O(r,n,this.s.b),this.d),this.o=O(r,this.s.b-32768),this.s.b=this.o.length,this.p=O(this.p,this.s.p/8>>0),this.s.p&=7},t.prototype.push=function(t,n){this.e(t),this.c(n)},t}();exports.Inflate=zt;var At=function(){return function(t){this.ondata=t,ft([V,function(){return[at,zt]}],this,0,function(){var t=new zt;onmessage=at(t)},7)}}();function Mt(t,n,r){if(r||(r=n,n={}),"function"!=typeof r)throw"no callback";return ot(t,n,[V],function(t){return et(kt(t.data[0],it(t.data[1])))},1,r)}function kt(t,n){return G(t,n)}exports.AsyncInflate=At;var St=function(){function t(t,n){this.c=P(),this.l=0,this.v=1,yt.call(this,t,n)}return t.prototype.push=function(t,n){yt.prototype.push.call(this,t,n)},t.prototype.p=function(t,n){this.c.p(t),this.l+=t.length;var r=Y(t,this.o,this.v&&vt(this.o),n&&8,!n);this.v&&(ct(r,this.o),this.v=0),n&&(lt(r,r.length-8,this.c.d()),lt(r,r.length-4,this.l)),this.ondata(r,n)},t}();exports.Compress=exports.Gzip=St;var Ct=function(){return function(t,n){ft([X,$,function(){return[at,yt,St]}],this,wt.call(this,t,n),function(t){var n=new St(t.data);onmessage=at(n)},8)}}();function Dt(t,n,r){if(r||(r=n,n={}),"function"!=typeof r)throw"no callback";return ot(t,n,[X,$,function(){return[Ot]}],function(t){return et(Ot(t.data[0],t.data[1]))},2,r)}function Ot(t,n){void 0===n&&(n={});var r=P(),e=t.length;r.p(t);var i=Y(t,n,vt(n),8),o=i.length;return ct(i,n),lt(i,o-8,r.d()),lt(i,o-4,e),i}exports.AsyncCompress=exports.AsyncGzip=Ct;var Gt=function(){function t(t){this.v=1,zt.call(this,t)}return t.prototype.push=function(t,n){if(zt.prototype.e.call(this,t),this.v){var r=ht(this.p);if(r>=this.p.length&&!n)return;this.p=this.p.subarray(r),this.v=0}if(n){if(this.p.length<8)throw"invalid gzip stream";this.p=this.p.subarray(0,-8)}zt.prototype.c.call(this,n)},t}();exports.Gunzip=Gt;var Ut=function(){return function(t){this.ondata=t,ft([V,tt,function(){return[at,zt,Gt]}],this,0,function(){var t=new Gt;onmessage=at(t)},9)}}();function It(t,n,r){if(r||(r=n,n={}),"function"!=typeof r)throw"no callback";return ot(t,n,[V,tt,function(){return[Zt]}],function(t){return et(Zt(t.data[0]))},3,r)}function Zt(t,n){return G(t.subarray(ht(t),-8),n||new r(pt(t)))}exports.AsyncGunzip=Ut;var Et=function(){function t(t,n){this.c=W(),this.v=1,yt.call(this,t,n)}return t.prototype.push=function(t,n){yt.prototype.push.call(this,t,n)},t.prototype.p=function(t,n){this.c.p(t);var r=Y(t,this.o,this.v&&2,n&&4,!n);this.v&&(dt(r,this.o),this.v=0),n&&lt(r,r.length-4,this.c.d()),this.ondata(r,n)},t}();exports.Zlib=Et;var Ft=function(){return function(t,n){ft([X,nt,function(){return[at,yt,Et]}],this,wt.call(this,t,n),function(t){var n=new Et(t.data);onmessage=at(n)},10)}}();function Tt(t,n,r){if(r||(r=n,n={}),"function"!=typeof r)throw"no callback";return ot(t,n,[X,nt,function(){return[jt]}],function(t){return et(jt(t.data[0],t.data[1]))},4,r)}function jt(t,n){void 0===n&&(n={});var r=W();r.p(t);var e=Y(t,n,2,4);return dt(e,n),lt(e,e.length-4,r.d()),e}exports.AsyncZlib=Ft;var Lt=function(){function t(t){this.v=1,zt.call(this,t)}return t.prototype.push=function(t,n){if(zt.prototype.e.call(this,t),this.v){if(this.p.length<2&&!n)return;this.p=this.p.subarray(2),this.v=0}if(n){if(this.p.length<4)throw"invalid zlib stream";this.p=this.p.subarray(0,-4)}zt.prototype.c.call(this,n)},t}();exports.Unzlib=Lt;var Rt=function(){return function(t){this.ondata=t,ft([V,rt,function(){return[at,zt,Lt]}],this,0,function(){var t=new Lt;onmessage=at(t)},11)}}();function _t(t,n,r){if(r||(r=n,n={}),"function"!=typeof r)throw"no callback";return ot(t,n,[V,rt,function(){return[Bt]}],function(t){return et(Bt(t.data[0],it(t.data[1])))},5,r)}function Bt(t,n){return G((gt(t),t.subarray(2,-4)),n)}exports.AsyncUnzlib=Rt;var Ht=function(){function t(t){this.G=Gt,this.I=zt,this.Z=Lt,this.ondata=t}return t.prototype.push=function(t,n){if(!this.ondata)throw"no stream handler";if(this.s)this.s.push(t,n);else{if(this.p&&this.p.length){var e=new r(this.p.length+t.length);e.set(this.p),e.set(t,this.p.length)}else this.p=t;if(this.p.length>2){var i=this,o=function(){i.ondata.apply(i,arguments)};this.s=31==this.p[0]&&139==this.p[1]&&8==this.p[2]?new this.G(o):8!=(15&this.p[0])||this.p[0]>>4>7||(this.p[0]<<8|this.p[1])%31?new this.I(o):new this.Z(o),this.s.push(this.p,n),this.p=null}}},t}();exports.Decompress=Ht;var Pt=function(){function t(t){this.G=Ut,this.I=At,this.Z=Rt,this.ondata=t}return t.prototype.push=function(t,n){Ht.prototype.push.call(this,t,n)},t}();function Wt(t,n,r){if(r||(r=n,n={}),"function"!=typeof r)throw"no callback";return 31==t[0]&&139==t[1]&&8==t[2]?It(t,n,r):8!=(15&t[0])||t[0]>>4>7||(t[0]<<8|t[1])%31?Mt(t,n,r):_t(t,n,r)}function Yt(t,n){return 31==t[0]&&139==t[1]&&8==t[2]?Zt(t,n):8!=(15&t[0])||t[0]>>4>7||(t[0]<<8|t[1])%31?kt(t,n):Bt(t,n)}exports.AsyncDecompress=Pt;var qt=function(t,n,e,i){for(var o in t){var a=t[o],f=n+o;a instanceof r?e[f]=[a,i]:Array.isArray(a)?e[f]=[a[0],q(i,a[1])]:qt(a,f+"/",e,i)}};function Jt(t,n){var e=t.length;if(!n&&"undefined"!=typeof TextEncoder)return(new TextEncoder).encode(t);for(var i=new r(t.length+(t.length>>>1)),o=0,a=function(t){i[o++]=t},f=0;f<e;++f){if(o+5>i.length){var s=new r(o+8+(e-f<<1));s.set(i),i=s}var u=t.charCodeAt(f);u<128||n?a(u):u<2048?(a(192|u>>>6),a(128|63&u)):u>55295&&u<57344?(a(240|(u=65536+(1047552&u)|1023&t.charCodeAt(++f))>>>18),a(128|u>>>12&63),a(128|u>>>6&63),a(128|63&u)):(a(224|u>>>12),a(128|u>>>6&63),a(128|63&u))}return O(i,0,o)}function Kt(t,n){var r="";if(!n&&"undefined"!=typeof TextDecoder)return(new TextDecoder).decode(t);for(var e=0;e<t.length;){var i=t[e++];i<128||n?r+=String.fromCharCode(i):i<224?r+=String.fromCharCode((31&i)<<6|63&t[e++]):i<240?r+=String.fromCharCode((15&i)<<12|(63&t[e++])<<6|63&t[e++]):(i=((15&i)<<18|(63&t[e++])<<12|(63&t[e++])<<6|63&t[e++])-65536,r+=String.fromCharCode(55296|i>>10,56320|1023&i))}return r}var Nt=function(t,n){return n+30+st(t,n+26)+st(t,n+28)},Qt=function(t,n,r){var e=st(t,n+28),i=Kt(t.subarray(n+46,n+46+e),!(2048&st(t,n+8))),o=n+46+e,a=r?Vt(t,o):[ut(t,n+20),ut(t,n+24),ut(t,n+42)],f=a[0],s=a[1],u=a[2];return[st(t,n+10),f,s,i,o+st(t,n+30)+st(t,n+32),u]},Vt=function(t,n){for(;1!=st(t,n);n+=4+st(t,n+2));return[ut(t,n+12),ut(t,n+4),ut(t,n+20)]},Xt=function(t,n,r,e,i,o,a,f,s,u){var l=o.length,c=e.length;lt(t,n,null!=s?33639248:67324752),n+=4,null!=s&&(t[n]=20,n+=2),t[n]=20,n+=2,t[n++]=8==u&&(1==f.level?6:f.level<6?4:9==f.level?2:0),t[n++]=a&&8,t[n]=u,n+=2;var h=new Date(f.mtime||Date.now()),p=h.getFullYear()-1980;if(p<0||p>119)throw"date not in range 1980-2099";lt(t,n,2*(p<<24)|h.getMonth()+1<<21|h.getDate()<<16|h.getHours()<<11|h.getMinutes()<<5|h.getSeconds()>>>1),lt(t,n+=4,r),lt(t,n+4,c),lt(t,n+8,i),lt(t,n+12,l),n+=16,null!=s&&(lt(t,n+=10,s),n+=4),t.set(o,n),n+=l,null==s&&t.set(e,n)},$t=function(t,n,r,e,i){lt(t,n,101010256),lt(t,n+8,r),lt(t,n+10,r),lt(t,n+12,e),lt(t,n+16,i)};function tn(t,n,e){if(e||(e=n,n={}),"function"!=typeof e)throw"no callback";var i={};qt(t,"",i,n);var o=Object.keys(i),a=o.length,f=0,s=0,u=a,l=new Array(a),c=[],h=function(){for(var t=0;t<c.length;++t)c[t]()},p=function(){var t=new r(s+22),n=f,i=s-f;s=0;for(var o=0;o<u;++o){var a=l[o];try{Xt(t,s,a.c,a.d,a.m,a.n,a.u,a.p,null,a.t),Xt(t,f,a.c,a.d,a.m,a.n,a.u,a.p,s,a.t),f+=46+a.n.length,s+=30+a.n.length+a.d.length}catch(c){return e(c,null)}}$t(t,f,l.length,i,n),e(null,t)};a||p();for(var v=function(t){var n=o[t],r=i[n],u=r[0],v=r[1],d=P(),g=u.length;d.p(u);var w=Jt(n),y=w.length,m=0==v.level?0:8,x=function(r,i){if(r)h(),e(r,null);else{var o=i.length;l[t]={t:m,d:i,m:g,c:d.d(),u:n.length!=o,n:w,p:v},f+=30+y+o,s+=76+2*y+o,--a||p()}};if(w.length>65535&&x("filename too long",null),m)if(g<16e4)try{x(null,bt(u,v))}catch(b){x(b,null)}else c.push(xt(u,v,x));else x(null,u)},d=0;d<u;++d)v(d);return h}function nn(t,n){void 0===n&&(n={});var e={},i=[];qt(t,"",e,n);var o=0,a=0;for(var f in e){var s=e[f],u=s[0],l=s[1],c=0==l.level?0:8,h=Jt(f),p=h.length;if(h.length>65535)throw"filename too long";var v=c?bt(u,l):u,d=v.length,g=P();g.p(u),i.push({t:c,d:v,m:u.length,c:g.d(),u:f.length!=p,n:h,o:o,p:l}),o+=30+p+d,a+=76+2*p+d}for(var w=new r(a+22),y=o,m=a-o,x=0;x<i.length;++x){var b=i[x];Xt(w,b.o,b.c,b.d,b.m,b.n,b.u,b.p,null,b.t),Xt(w,o,b.c,b.d,b.m,b.n,b.u,b.p,b.o,b.t),o+=46+b.n.length}return $t(w,o,i.length,m,y),w}function rn(t,n){if("function"!=typeof n)throw"no callback";for(var e=[],i=function(){for(var t=0;t<e.length;++t)e[t]()},o={},a=t.length-22;101010256!=ut(t,a);--a)if(!a||t.length-a>65558)return void n("invalid zip file",null);var f=st(t,a+8);f||n(null,{});var s=f,u=ut(t,a+16),l=4294967295==u;if(l){if(a=ut(t,a-12),101075792!=ut(t,a))throw"invalid zip file";s=f=ut(t,a+32),u=ut(t,a+48)}for(var c=function(s){var c=Qt(t,u,l),h=c[0],p=c[1],v=c[2],d=c[3],g=c[4],w=c[5],y=Nt(t,w);u=g;var m=function(t,r){t?(i(),n(t,null)):(o[d]=r,--f||n(null,o))};if(h)if(8==h){var x=t.subarray(y,y+p);if(p<32e4)try{m(null,kt(x,new r(v)))}catch(a){m(a,null)}else e.push(Mt(x,{size:v},m))}else m("unknown compression type "+h,null);else m(null,O(t,y,y+p))},h=0;h<s;++h)c();return i}function en(t){for(var n={},e=t.length-22;101010256!=ut(t,e);--e)if(!e||t.length-e>65558)throw"invalid zip file";var i=st(t,e+8);if(!i)return{};var o=ut(t,e+16),a=4294967295==o;if(a){if(e=ut(t,e-12),101075792!=ut(t,e))throw"invalid zip file";i=ut(t,e+32),o=ut(t,e+48)}for(var f=0;f<i;++f){var s=Qt(t,o,a),u=s[0],l=s[1],c=s[2],h=s[3],p=s[4],v=s[5],d=Nt(t,v);if(o=p,u){if(8!=u)throw"unknown compression type "+u;n[h]=kt(t.subarray(d,d+l),new r(c))}else n[h]=O(t,d,d+l)}return n}
43
43
  },{}],"Ie9M":[function(require,module,exports) {
44
44
  "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.decideCompression=s,exports.compressData=c;var e=require("./lz-string"),r=require("fflate"),t=require("./utils");function n(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable})),t.push.apply(t,n)}return t}function o(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?n(Object(t),!0).forEach(function(r){i(e,r,t[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):n(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))})}return e}function i(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function s(e){return e["gzip-js"]?"gzip-js":e.lz64?"lz64":"base64"}function c(n,i,s){return"lz64"===n?[{data:e.LZString.compressToBase64(i),compression:"lz64"},s]:"gzip-js"===n?[(0,r.gzipSync)((0,r.strToU8)(i),{mtime:0}),o(o({},s),{},{blob:!0,urlQueryArgs:{compression:"gzip-js"}})]:[{data:t._.base64Encode(i)},s]}
45
45
  },{"./lz-string":"zdbk","fflate":"UJm1","./utils":"FOZT"}],"tOu2":[function(require,module,exports) {
46
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.xhr=exports.encodePostData=void 0;var e=require("./utils");function t(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function r(e){for(var r=1;r<arguments.length;r++){var o=null!=arguments[r]?arguments[r]:{};r%2?t(Object(o),!0).forEach(function(t){n(e,t,o[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(o)):t(Object(o)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(o,t))})}return e}function n(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var o=function e(t,r){if(r.blob&&t.buffer)return new Blob([t.buffer],{type:"text/plain"});if(r.sendBeacon||r.blob){var n=e(t,{method:"POST"});return new Blob([n],{type:"application/x-www-form-urlencoded"})}if("POST"!==r.method)return null;var o,s;return o=Array.isArray(t)||(s=t,"[object Uint8Array]"===Object.prototype.toString.call(s))?"data="+encodeURIComponent(t):"data="+encodeURIComponent(t.data),t.compression&&(o+="&compression="+t.compression),o};exports.encodePostData=o;var s=function(t){var n=t.url,s=t.data,a=t.headers,i=t.options,c=t.captureMetrics,u=t.callback,p=t.retriesPerformedSoFar,l=t.retryQueue,d=t.onXHRError,f=new XMLHttpRequest;f.open(i.method,n,!0);var b=o(s,i);c.incr("_send_request"),c.incr("_send_request_inflight");var y=c.startRequest(r({data_size:e._.isString(s)?s.length:b.length,endpoint:n.slice(n.length-2)},i._metrics));e._.each(a,function(e,t){f.setRequestHeader(t,e)}),"POST"!==i.method||i.blob||f.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),f.withCredentials=!0,f.onreadystatechange=function(){if(4===f.readyState){c.incr("xhr-response"),c.incr("xhr-response-".concat(f.status)),c.decr("_send_request_inflight");var t=c.finishRequest(y);if(200===f.status){if(u){var o;try{o=JSON.parse(f.responseText)}catch(b){return void e.console.error(b)}u(o)}}else"function"==typeof d&&d(f),[401,403,404,500].indexOf(f.status)<0&&l.enqueue({url:n,data:s,options:i,headers:a,retriesPerformedSoFar:(p||0)+1,callback:u}),c.markRequestFailed(r(r({},t),{},{type:"non_200",status:f.status,statusText:f.statusText})),u&&(i.verbose?u({status:0,error:error}):u(0))}},f.send(b)};exports.xhr=s;
46
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.xhr=exports.encodePostData=void 0;var e=require("./utils"),r=function e(r,t){if(t.blob&&r.buffer)return new Blob([r.buffer],{type:"text/plain"});if(t.sendBeacon||t.blob){var o=e(r,{method:"POST"});return new Blob([o],{type:"application/x-www-form-urlencoded"})}if("POST"!==t.method)return null;var n,s;return n=Array.isArray(r)||(s=r,"[object Uint8Array]"===Object.prototype.toString.call(s))?"data="+encodeURIComponent(r):"data="+encodeURIComponent(r.data),r.compression&&(n+="&compression="+r.compression),n};exports.encodePostData=r;var t=function(t){var o=t.url,n=t.data,s=t.headers,a=t.options,i=t.captureMetrics,c=t.callback,d=t.retriesPerformedSoFar,u=t.retryQueue,p=t.onXHRError,l=new XMLHttpRequest;l.open(a.method,o,!0);var f=r(n,a);i.incr("_send_request"),i.incr("_send_request_inflight"),e._.each(s,function(e,r){l.setRequestHeader(r,e)}),"POST"!==a.method||a.blob||l.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),l.withCredentials=!0,l.onreadystatechange=function(){if(4===l.readyState)if(i.incr("xhr-response"),i.incr("xhr-response-".concat(l.status)),i.decr("_send_request_inflight"),200===l.status){if(c){var r;try{r=JSON.parse(l.responseText)}catch(t){return void e.console.error(t)}c(r)}}else"function"==typeof p&&p(l),[401,403,404,500].indexOf(l.status)<0&&u.enqueue({url:o,data:n,options:a,headers:s,retriesPerformedSoFar:(d||0)+1,callback:c}),c&&(a.verbose?c({status:0,error:error}):c(0))},l.send(f)};exports.xhr=t;
47
47
  },{"./utils":"FOZT"}],"ennf":[function(require,module,exports) {
48
48
  "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.RetryQueue=void 0;var e=require("./base-request-queue"),t=require("./send-request");function r(e){return(r="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 n(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function o(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?n(Object(r),!0).forEach(function(t){i(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):n(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function i(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function u(e,t){var r;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(r=a(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,o=function(){};return{s:o,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,u=!0,c=!1;return{s:function(){r=e[Symbol.iterator]()},n:function(){var e=r.next();return u=e.done,e},e:function(e){c=!0,i=e},f:function(){try{u||null==r.return||r.return()}finally{if(c)throw i}}}}function a(e,t){if(e){if("string"==typeof e)return c(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?c(e,t):void 0}}function c(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function l(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function f(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function s(e,t,r){return t&&f(e.prototype,t),r&&f(e,r),e}function y(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&p(e,t)}function p(e,t){return(p=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function h(e){var t=v();return function(){var r,n=w(e);if(t){var o=w(this).constructor;r=Reflect.construct(n,arguments,o)}else r=n.apply(this,arguments);return b(this,r)}}function b(e,t){return!t||"object"!==r(t)&&"function"!=typeof t?d(e):t}function d(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function v(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch(e){return!1}}function w(e){return(w=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var O=function(r){y(i,e.RequestQueueScaffold);var n=h(i);function i(e,t){var r;return l(this,i),(r=n.call(this)).captureMetrics=e,r.isPolling=!1,r.queue=[],r.areWeOnline=!0,r.onXHRError=t,"onLine"in window.navigator&&(r.areWeOnline=window.navigator.onLine,window.addEventListener("online",function(){r._handleWeAreNowOnline()}),window.addEventListener("offline",function(){r.areWeOnline=!1})),r}return s(i,[{key:"enqueue",value:function(e){var t=e.retriesPerformedSoFar||0;if(!(t>=10)){var r=3e3*Math.pow(2,t),n=new Date(Date.now()+r);console.warn("Enqueued failed request for retry in ".concat(r)),this.queue.push({retryAt:n,requestData:e}),this.isPolling||(this.isPolling=!0,this.poll())}}},{key:"poll",value:function(){var e=this;clearTimeout(this._poller),this._poller=setTimeout(function(){e.areWeOnline&&e.queue.length>0&&e.flush(),e.poll()},this._pollInterval)}},{key:"flush",value:function(){var e=new Date(Date.now()),t=this.queue.filter(function(t){return t.retryAt<e});if(t.length>0){this.queue=this.queue.filter(function(t){return t.retryAt>=e});var r,n=u(t);try{for(n.s();!(r=n.n()).done;){var o=r.value.requestData;this._executeXhrRequest(o)}}catch(i){n.e(i)}finally{n.f()}}}},{key:"unload",value:function(){clearTimeout(this._poller);var e,r=u(this.queue);try{for(r.s();!(e=r.n()).done;){var n=e.value.requestData,i=n.url,a=n.data,c=n.options;try{window.navigator.sendBeacon(i,(0,t.encodePostData)(a,o(o({},c),{},{sendBeacon:!0})))}catch(l){this.get_config("debug")&&console.error(l)}}}catch(f){r.e(f)}finally{r.f()}this.queue=[]}},{key:"_executeXhrRequest",value:function(e){var r=e.url,n=e.data,o=e.options,i=e.headers,u=e.callback,a=e.retriesPerformedSoFar;(0,t.xhr)({url:r,data:n||{},options:o||{},headers:i||{},retriesPerformedSoFar:a||0,callback:u,captureMetrics:this.captureMetrics,retryQueue:this,onXHRError:this.onXHRError})}},{key:"_handleWeAreNowOnline",value:function(){this.areWeOnline=!0,this.flush()}}]),i}();exports.RetryQueue=O;
49
49
  },{"./base-request-queue":"ae0g","./send-request":"tOu2"}],"tci7":[function(require,module,exports) {
@@ -51,7 +51,7 @@ module.exports={name:"posthog-js",version:"1.17.4",description:"Posthog-js allow
51
51
  },{"./extensions/sessionrecording":"Z2N4","./posthog-persistence":"MAdm","./storage":"KZ7Y","./utils":"FOZT"}],"eWVp":[function(require,module,exports) {
52
52
  "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.optimisePerformanceData=o,exports.getPerformanceEntriesByType=a,exports.deduplicateKeys=i,exports.pageLoadFrom=u,exports.getPerformanceData=c;var e=require("./utils"),r=n(require("./config"));function n(e){return e&&e.__esModule?e:{default:e}}function t(e){return Number(e)===e&&e%1!=0}function o(e){return e.forEach(function(r,n){for(var o in r)t(r[o])&&r[o].toString().match(/^\d+\.\d{4,}$/)&&(e[n][o]=Number(r[o].toFixed(3))),["serverTiming","workerTiming"].includes(o)&&0===r[o].length&&delete e[n][o],"entryType"===o&&"resource"===r[o]&&delete e[n][o],"nextHopProtocol"===o&&delete e[n][o],0===r[o]&&delete e[n][o]}),i(e)}function a(n){try{return o(JSON.parse(JSON.stringify(e.window.performance.getEntriesByType(n))))}catch(t){return r.default.DEBUG&&console.warn("not able to capture performance data ("+n+") - "+t),[]}}function i(e){if(0===e.length)return[];var r=Object.keys(e[0]);return[r,e.map(function(e){return r.map(function(r){return e[r]})})]}function u(e){var r=e.navigation&&e.navigation[0]&&e.navigation[0].indexOf("duration");return e.navigation[1]&&e.navigation[1][0][r]}function c(){var e={navigation:a("navigation"),paint:a("paint"),resource:a("resource")},r={},n=u(e);return n&&(r.$performance_page_loaded=n),r.$performance_raw=JSON.stringify(e),r}
53
53
  },{"./utils":"FOZT","./config":"itQ5"}],"ok3T":[function(require,module,exports) {
54
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.init_from_snippet=Y,exports.init_as_module=G,exports.PostHogLib=void 0;var e,t,o=require("./lz-string"),r=w(require("./config")),i=require("./utils"),n=require("./autocapture"),s=require("./posthog-people"),p=require("./posthog-featureflags"),a=require("./posthog-persistence"),c=require("./extensions/sessionrecording"),_=require("./decide"),u=require("./extensions/toolbar"),d=require("./gdpr-utils"),g=require("./storage"),l=require("./request-queue"),h=require("./capture-metrics"),f=require("./compression"),y=require("./send-request"),b=require("./retry-queue"),m=require("./sessionid"),v=require("./apm");function w(e){return e&&e.__esModule?e:{default:e}}function k(e,t){var o=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),o.push.apply(o,r)}return o}function q(e){for(var t=1;t<arguments.length;t++){var o=null!=arguments[t]?arguments[t]:{};t%2?k(Object(o),!0).forEach(function(t){P(e,t,o[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(o)):k(Object(o)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(o,t))})}return e}function P(e,t,o){return t in e?Object.defineProperty(e,t,{value:o,enumerable:!0,configurable:!0,writable:!0}):e[t]=o,e}function S(e,t){return $(e)||E(e,t)||x(e,t)||F()}function F(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function x(e,t){if(e){if("string"==typeof e)return O(e,t);var o=Object.prototype.toString.call(e).slice(8,-1);return"Object"===o&&e.constructor&&(o=e.constructor.name),"Map"===o||"Set"===o?Array.from(e):"Arguments"===o||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(o)?O(e,t):void 0}}function O(e,t){(null==t||t>e.length)&&(t=e.length);for(var o=0,r=new Array(t);o<t;o++)r[o]=e[o];return r}function E(e,t){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e)){var o=[],r=!0,i=!1,n=void 0;try{for(var s,p=e[Symbol.iterator]();!(r=(s=p.next()).done)&&(o.push(s.value),!t||o.length!==t);r=!0);}catch(a){i=!0,n=a}finally{try{r||null==p.return||p.return()}finally{if(i)throw n}}return o}}function $(e){if(Array.isArray(e))return e}var I=0,H=1,j=function(){},A={},R="posthog",M=i.window.XMLHttpRequest&&"withCredentials"in new XMLHttpRequest,D=!M&&-1===i.userAgent.indexOf("MSIE")&&-1===i.userAgent.indexOf("Mozilla"),L=function(){return{api_host:"https://app.posthog.com",api_method:"POST",api_transport:"XHR",autocapture:!0,rageclick:!1,cross_subdomain_cookie:-1===i.document.location.hostname.indexOf("herokuapp.com"),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,cookie_expiration:365,upgrade:!1,disable_session_recording:!1,disable_persistence:!1,disable_cookie:!1,secure_cookie:"https:"===i.window.location.protocol,ip:!0,opt_out_capturing_by_default:!1,opt_out_persistence_by_default:!1,opt_out_capturing_persistence_type:"localStorage",opt_out_capturing_cookie_prefix:null,property_blacklist:[],sanitize_properties:null,xhr_headers:{},inapp_protocol:"//",inapp_link_new_window:!1,request_batching:!0,properties_string_max_length:65535,session_recording:{blockClass:"ph-no-capture",blockSelector:null,ignoreClass:"ph-ignore-input",maskAllInputs:!1,maskInputOptions:{},maskInputFn:null,slimDOMOptions:{},collectFonts:!1},mask_all_element_attributes:!1,mask_all_text:!1,advanced_disable_decide:!1,advanced_disable_toolbar_metrics:!1,on_xhr_error:function(e){var t="Bad HTTP status: "+e.status+" "+e.statusText;i.console.error(t)},_onCapture:function(){},_capture_metrics:!1,_capture_performance:!1}},C=function(){};exports.PostHogLib=C;var U=function(o,a,_){var d,g=_===R?t:t[_];if(g&&e===I)d=g;else{if(g&&!i._.isArray(g))return void i.console.error("You have already initialized "+_);d=new C}if(d._init(o,a,_),d.people=new s.PostHogPeople,d.people._init(d),d.featureFlags=new p.PostHogFeatureFlags(d),d.feature_flags=d.featureFlags,d.toolbar=new u.Toolbar(d),d.toolbar.maybeLoadEditor(),d.sessionRecording=new c.SessionRecording(d),d.sessionRecording.startRecordingIfEnabled(),d.__autocapture_enabled=d.get_config("autocapture"),d.get_config("autocapture")){n.autocapture.enabledForProject(d.get_config("token"),100,100)?n.autocapture.isBrowserSupported()?n.autocapture.init(d):(d.__autocapture_enabled=!1,i.console.log("Disabling Automatic Event Collection because this browser is not supported")):(d.__autocapture_enabled=!1,i.console.log("Not in active bucket: disabling Automatic Event Collection."))}return r.default.DEBUG=r.default.DEBUG||d.get_config("debug"),!i._.isUndefined(g)&&i._.isArray(g)&&(d._execute_array.call(d.people,g.people),d._execute_array(g)),d};C.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!==R){var n=U(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")}},C.prototype._init=function(e,t,o){this.__loaded=!0,this.config={},this._triggered_notifs=[],this.compression={},this.set_config(i._.extend({},L(),t,{name:o,token:e,callback_fn:(o===R?o:R+"."+o)+"._jsc"})),this._jsc=function(){},this._captureMetrics=new h.CaptureMetrics(this.get_config("_capture_metrics"),i._.bind(this.capture,this)),this._requestQueue=new l.RequestQueue(this._captureMetrics,i._.bind(this._handle_queued_event,this)),this._retryQueue=new b.RetryQueue(this._captureMetrics,this.get_config("on_xhr_error")),this.__captureHooks=[],this.__request_queue=[],this.persistence=new a.PostHogPersistence(this.config),this.sessionManager=new m.SessionIdManager(this.config,this.persistence),this._gdpr_init();var r=i._.UUID();this.get_distinct_id()||this.register_once({distinct_id:r,$device_id:r},""),i.window.addEventListener&&i.window.addEventListener("unload",this._handle_unload.bind(this))},C.prototype._loaded=function(){this.featureFlags.setReloadingPaused(!0);try{this.get_config("loaded")(this)}catch(e){i.console.error("`loaded` function failed",e)}this._start_queue_if_opted_in(),this.get_config("capture_pageview")&&this.capture("$pageview",{},{send_instantly:!0}),this.get_config("advanced_disable_decide")||new _.Decide(this).call(),this.featureFlags.resetRequestQueue(),this.featureFlags.setReloadingPaused(!1)},C.prototype._start_queue_if_opted_in=function(){this.has_opted_out_capturing()||this.get_config("request_batching")&&this._requestQueue.poll()},C.prototype._dom_loaded=function(){this.has_opted_out_capturing()||i._.each(this.__request_queue,function(e){this._send_request.apply(this,e)},this),delete this.__request_queue,this._start_queue_if_opted_in()},C.prototype._prepare_callback=function(e,t){if(i._.isUndefined(e))return null;if(M){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},C.prototype._handle_unload=function(){this.get_config("request_batching")?(this.get_config("capture_pageview")&&this.capture("$pageleave"),this.get_config("_capture_metrics")&&(this._requestQueue.updateUnloadMetrics(),this.capture("$capture_metrics",this._captureMetrics.metrics),this._captureMetrics.captureInProgressRequests()),this._requestQueue.unload(),this._retryQueue.unload()):this.get_config("capture_pageview")&&this.capture("$pageleave",null,{transport:"sendbeacon"})},C.prototype._handle_queued_event=function(e,t,o){var r=JSON.stringify(t);this.__compress_and_send_json_request(e,r,o||A,j)},C.prototype.__compress_and_send_json_request=function(e,t,o,r){var i=S((0,f.compressData)((0,f.decideCompression)(this.compression),t,o),2),n=i[0],s=i[1];this._send_request(e,n,s,r)},C.prototype._send_request=function(e,t,o,r){if(D)this.__request_queue.push(arguments);else{var n={method:this.get_config("api_method"),transport:this.get_config("api_transport"),verbose:this.get_config("verbose")};o=i._.extend(n,o||{}),M||(o.method="GET");var s=i.window.navigator.sendBeacon&&"sendbeacon"===o.transport.toLowerCase(),p=o.urlQueryArgs||{};p.ip=this.get_config("ip")?1:0,p._=(new Date).getTime().toString();var a=e.indexOf("?")>-1?"&":"?";if(e+=a+i._.HTTPBuildQuery(p),i._.isObject(t)&&this.get_config("img")){var c=i.document.createElement("img");c.src=e,i.document.body.appendChild(c)}else if(s)try{i.window.navigator.sendBeacon(e,(0,y.encodePostData)(t,q(q({},o),{},{sendBeacon:!0})))}catch(d){this.get_config("debug")&&i.console.error(d)}else if(M)try{(0,y.xhr)({url:e,data:t,headers:this.get_config("xhr_headers"),options:o,captureMetrics:this._captureMetrics,callback:r,retriesPerformedSoFar:0,retryQueue:this._retryQueue,onXHRError:this.get_config("on_xhr_error")})}catch(d){i.console.error(d)}else{var _=i.document.createElement("script");_.type="text/javascript",_.async=!0,_.defer=!0,_.src=e;var u=i.document.getElementsByTagName("script")[0];u.parentNode.insertBefore(_,u)}}},C.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)},C.prototype.push=function(e){this._execute_array([e])},C.prototype.capture=(0,d.addOptOutCheckPostHogLib)(function(e,t,o){if(this.__loaded){this._captureMetrics.incr("capture"),"$snapshot"===e&&this._captureMetrics.incr("snapshot");var r=(o=o||A).transport;if(r&&(o.transport=r),i._.isUndefined(e)||"string"!=typeof e)i.console.error("No event name provided to posthog.capture");else if(!i._.isBlockedUA(i.userAgent)){var n=this.persistence.remove_event_timer(e);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);var s={event:e,properties:this._calculate_event_properties(e,t,n)};"$identify"===e&&o.$set&&(s.$set=o.$set),s=i._.copyAndTruncateStrings(s,o._noTruncate?null:this.get_config("properties_string_max_length")),this.get_config("debug")&&i.console.log("PostHog.js send",s);var p=JSON.stringify(s),a=this.get_config("api_host")+(o.endpoint||"/e/"),c=o!==A;return!this.get_config("request_batching")||c&&!o._batchKey||o.send_instantly?this.__compress_and_send_json_request(a,p,o):(s.timestamp=new Date,this._requestQueue.enqueue(a,s,o)),this._invokeCaptureHooks(e,s),s}}}),C.prototype._addCaptureHook=function(e){this.__captureHooks.push(e)},C.prototype._invokeCaptureHooks=function(e,t){this.config._onCapture(e,t),i._.each(this.__captureHooks,function(t){return t(e)})},C.prototype._calculate_event_properties=function(e,t,o){var r=t||{};if(r.token=this.get_config("token"),"$snapshot"===e){var n=this.persistence.properties();return r.distinct_id=n.distinct_id,r}if(!i._.isUndefined(o)){var s=(new Date).getTime()-o;r.$duration=parseFloat((s/1e3).toFixed(3))}if(this.sessionManager){var p=this.sessionManager.getSessionAndWindowId(),a=p.sessionId,c=p.windowId;r.$session_id=a,r.$window_id=c}r=i._.extend({},i._.info.properties(),this.persistence.properties(),r),"$pageview"===e&&this.get_config("_capture_performance")&&(r=i._.extend(r,(0,v.getPerformanceData)()));var _=this.get_config("property_blacklist");i._.isArray(_)?i._.each(_,function(e){delete r[e]}):i.console.error("Invalid value for property_blacklist config: "+_);var u=this.get_config("sanitize_properties");return u&&(r=u(r,e)),r},C.prototype.register=function(e,t){this.persistence.register(e,t)},C.prototype.register_once=function(e,t,o){this.persistence.register_once(e,t,o)},C.prototype.unregister=function(e){this.persistence.unregister(e)},C.prototype._register_single=function(e,t){var o={};o[e]=t,this.register(o)},C.prototype.getFeatureFlag=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return this.featureFlags.getFeatureFlag(e,t)},C.prototype.isFeatureEnabled=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return this.featureFlags.isFeatureEnabled(e,t)},C.prototype.reloadFeatureFlags=function(){return this.featureFlags.reloadFeatureFlags()},C.prototype.onFeatureFlags=function(e){this.featureFlags.addFeatureFlagsHandler(e),e(this.featureFlags.getFlags(),this.featureFlags.getFlagVariants())},C.prototype.identify=function(e,t,o){if(e){this._captureMetrics.incr("identify");var r=this.get_distinct_id();if(this.register({$user_id:e}),!this.get_property("$device_id")){var n=r;this.register_once({$had_persisted_distinct_id:!0,$device_id:n},"")}e!==r&&e!==this.get_property(a.ALIAS_ID_KEY)&&(this.unregister(a.ALIAS_ID_KEY),this.register({distinct_id:e})),e===r||this.get_property("$device_id")&&r!==this.get_property("$device_id")?(t&&this.people.set(t),o&&this.people.set_once(o)):this.capture("$identify",{distinct_id:e,$anon_distinct_id:r},{$set:t||{}},{$set_once:o||{}}),e!==r&&this.reloadFeatureFlags()}else i.console.error("Unique user id has not been set in posthog.identify")},C.prototype.group=function(e,t,o){if(e&&t){this._captureMetrics.incr("group");var r=this.getGroups();this.register({$groups:q(q({},r),{},P({},e,t))}),o&&this.capture("$groupidentify",{$group_type:e,$group_key:t,$group_set:o}),r[e]!==t&&this.reloadFeatureFlags()}else i.console.error("posthog.group requires a group type and group key")},C.prototype.reset=function(e){var t=this.get_property("$device_id");this.persistence.clear();var o=i._.UUID();this.register_once({distinct_id:o,$device_id:e?o:t},"")},C.prototype.get_distinct_id=function(){return this.get_property("distinct_id")},C.prototype.getGroups=function(){return this.get_property("$groups")||{}},C.prototype.alias=function(e,t){if(e===this.get_property(a.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(a.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)},C.prototype.set_config=function(e){var t=q({},this.config);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),g.localStore.is_supported()&&"true"===g.localStore.get("ph_debug")&&(this.config.debug=!0),r.default.DEBUG=r.default.DEBUG||this.get_config("debug"),this.sessionRecording&&void 0!==e.disable_session_recording&&t.disable_session_recording!==e.disable_session_recording&&(e.disable_session_recording?this.sessionRecording.stopRecording():this.sessionRecording.startRecordingIfEnabled()))},C.prototype.startSessionRecording=function(){this.set_config({disable_session_recording:!1})},C.prototype.stopSessionRecording=function(){this.set_config({disable_session_recording:!0})},C.prototype.sessionRecordingStarted=function(){return this.sessionRecording.started()},C.prototype.get_config=function(e){return this.config[e]},C.prototype.get_property=function(e){return this.persistence.props[e]},C.prototype.toString=function(){var e=this.get_config("name");return e!==R&&(e=R+"."+e),e},C.prototype._gdpr_init=function(){"localStorage"===this.get_config("opt_out_capturing_persistence_type")&&g.localStore.is_supported()&&(!this.has_opted_in_capturing()&&this.has_opted_in_capturing({persistence_type:"cookie"})&&this.opt_in_capturing({enable_persistence:!1}),!this.has_opted_out_capturing()&&this.has_opted_out_capturing({persistence_type:"cookie"})&&this.opt_out_capturing({clear_persistence:!1}),this.clear_opt_in_out_capturing({persistence_type:"cookie",enable_persistence:!1})),this.has_opted_out_capturing()?this._gdpr_update_persistence({clear_persistence:!0}):this.has_opted_in_capturing()||!this.get_config("opt_out_capturing_by_default")&&!g.cookieStore.get("ph_optout")||(g.cookieStore.remove("ph_optout"),this.opt_out_capturing({clear_persistence:this.get_config("opt_out_persistence_by_default")}))},C.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)},C.prototype._gdpr_call_func=function(e,t){return t=i._.extend({capture:i._.bind(this.capture,this),persistence_type:this.get_config("opt_out_capturing_persistence_type"),cookie_prefix:this.get_config("opt_out_capturing_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),g.localStore.is_supported()||"localStorage"!==t.persistence_type||(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})},C.prototype.opt_in_capturing=function(e){e=i._.extend({enable_persistence:!0},e),this._gdpr_call_func(d.optIn,e),this._gdpr_update_persistence(e)},C.prototype.opt_out_capturing=function(e){e=i._.extend({clear_persistence:!0},e),this._gdpr_call_func(d.optOut,e),this._gdpr_update_persistence(e)},C.prototype.has_opted_in_capturing=function(e){return this._gdpr_call_func(d.hasOptedIn,e)},C.prototype.has_opted_out_capturing=function(e){return this._gdpr_call_func(d.hasOptedOut,e)},C.prototype.clear_opt_in_out_capturing=function(e){e=i._.extend({enable_persistence:!0},e),this._gdpr_call_func(d.clearOptInOut,e),this._gdpr_update_persistence(e)},C.prototype.sentry_integration=function(e,t,o,r){this.name="posthog-js",this.setupOnce=function(i){i(function(i){if("error"!==i.level||!e.__loaded)return i;i.tags||(i.tags={}),i.tags["PostHog URL"]=e.config.api_host+"/person/"+e.get_distinct_id();var n={$sentry_event_id:i.event_id,$sentry_exception:i.exception};return t&&o&&(n.$sentry_url=(r||"https://sentry.io/organizations/")+t+"/issues/?project="+o+"&query="+i.event_id),e.capture("$exception",n),i})}},C.prototype.debug=function(e){!1===e?(i.window.console.log("You've disabled debug mode."),localStorage&&localStorage.setItem("ph_debug",void 0),this.set_config({debug:!1})):(i.window.console.log("You're now in debug mode. All calls to PostHog will be logged in your console.\nYou can disable this with `posthog.debug(false)`."),localStorage&&localStorage.setItem("ph_debug","true"),this.set_config({debug:!0}))},C.prototype.decodeLZ64=o.LZString.decompressFromBase64,C.prototype.init=C.prototype.init,C.prototype.reset=C.prototype.reset,C.prototype.capture=C.prototype.capture,C.prototype.register=C.prototype.register,C.prototype.register_once=C.prototype.register_once,C.prototype.unregister=C.prototype.unregister,C.prototype.identify=C.prototype.identify,C.prototype.getGroups=C.prototype.getGroups,C.prototype.group=C.prototype.group,C.prototype.alias=C.prototype.alias,C.prototype.set_config=C.prototype.set_config,C.prototype.get_config=C.prototype.get_config,C.prototype.get_property=C.prototype.get_property,C.prototype.get_distinct_id=C.prototype.get_distinct_id,C.prototype.toString=C.prototype.toString,C.prototype.opt_out_captureing=C.prototype.opt_out_captureing,C.prototype.opt_in_captureing=C.prototype.opt_in_captureing,C.prototype.has_opted_out_captureing=C.prototype.has_opted_out_captureing,C.prototype.has_opted_in_captureing=C.prototype.has_opted_in_captureing,C.prototype.clear_opt_in_out_captureing=C.prototype.clear_opt_in_out_captureing,C.prototype.opt_out_capturing=C.prototype.opt_out_capturing,C.prototype.opt_in_capturing=C.prototype.opt_in_capturing,C.prototype.has_opted_out_capturing=C.prototype.has_opted_out_capturing,C.prototype.has_opted_in_capturing=C.prototype.has_opted_in_capturing,C.prototype.clear_opt_in_out_capturing=C.prototype.clear_opt_in_out_capturing,C.prototype.getFeatureFlag=C.prototype.getFeatureFlag,C.prototype.isFeatureEnabled=C.prototype.isFeatureEnabled,C.prototype.reloadFeatureFlags=C.prototype.reloadFeatureFlags,C.prototype.onFeatureFlags=C.prototype.onFeatureFlags,C.prototype.decodeLZ64=C.prototype.decodeLZ64,C.prototype.SentryIntegration=C.prototype.sentry_integration,C.prototype.debug=C.prototype.debug,C.prototype.LIB_VERSION=r.default.LIB_VERSION,C.prototype.startSessionRecording=C.prototype.startSessionRecording,C.prototype.stopSessionRecording=C.prototype.stopSessionRecording,C.prototype.sessionRecordingStarted=C.prototype.sessionRecordingStarted,a.PostHogPersistence.prototype.properties=a.PostHogPersistence.prototype.properties,a.PostHogPersistence.prototype.update_search_keyword=a.PostHogPersistence.prototype.update_search_keyword,a.PostHogPersistence.prototype.update_referrer_info=a.PostHogPersistence.prototype.update_referrer_info,a.PostHogPersistence.prototype.get_cross_subdomain=a.PostHogPersistence.prototype.get_cross_subdomain,a.PostHogPersistence.prototype.clear=a.PostHogPersistence.prototype.clear,i._.safewrap_class(C,["identify"]);var T={},B=function(){i._.each(T,function(e,o){o!==R&&(t[o]=e)}),t._=i._},Q=function(){t.init=function(o,r,n){if(n)return t[n]||(t[n]=T[n]=U(o,r,n),t[n]._loaded()),t[n];var s=t;T[R]?s=T[R]:o&&((s=U(o,r,R))._loaded(),T[R]=s),t=s,e===H&&(i.window[R]=t),B()}},N=function(){function e(){e.done||(e.done=!0,D=!1,i._.each(T,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 Y(){e=H,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)&&(T[e[e.length-1]]=U.apply(this,e))}),Q(),t.init(),i._.each(T,function(e){e._loaded()}),N())}function G(){return e=I,t=new C,Q(),t.init(),N(),t}
54
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.init_from_snippet=Y,exports.init_as_module=G,exports.PostHogLib=void 0;var e,t,o=require("./lz-string"),r=w(require("./config")),i=require("./utils"),n=require("./autocapture"),s=require("./posthog-people"),p=require("./posthog-featureflags"),a=require("./posthog-persistence"),c=require("./extensions/sessionrecording"),_=require("./decide"),u=require("./extensions/toolbar"),d=require("./gdpr-utils"),g=require("./storage"),l=require("./request-queue"),h=require("./capture-metrics"),f=require("./compression"),y=require("./send-request"),b=require("./retry-queue"),m=require("./sessionid"),v=require("./apm");function w(e){return e&&e.__esModule?e:{default:e}}function k(e,t){var o=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),o.push.apply(o,r)}return o}function q(e){for(var t=1;t<arguments.length;t++){var o=null!=arguments[t]?arguments[t]:{};t%2?k(Object(o),!0).forEach(function(t){P(e,t,o[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(o)):k(Object(o)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(o,t))})}return e}function P(e,t,o){return t in e?Object.defineProperty(e,t,{value:o,enumerable:!0,configurable:!0,writable:!0}):e[t]=o,e}function S(e,t){return $(e)||E(e,t)||F(e,t)||x()}function x(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function F(e,t){if(e){if("string"==typeof e)return O(e,t);var o=Object.prototype.toString.call(e).slice(8,-1);return"Object"===o&&e.constructor&&(o=e.constructor.name),"Map"===o||"Set"===o?Array.from(e):"Arguments"===o||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(o)?O(e,t):void 0}}function O(e,t){(null==t||t>e.length)&&(t=e.length);for(var o=0,r=new Array(t);o<t;o++)r[o]=e[o];return r}function E(e,t){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e)){var o=[],r=!0,i=!1,n=void 0;try{for(var s,p=e[Symbol.iterator]();!(r=(s=p.next()).done)&&(o.push(s.value),!t||o.length!==t);r=!0);}catch(a){i=!0,n=a}finally{try{r||null==p.return||p.return()}finally{if(i)throw n}}return o}}function $(e){if(Array.isArray(e))return e}var I=0,H=1,j=function(){},A={},R="posthog",M=i.window.XMLHttpRequest&&"withCredentials"in new XMLHttpRequest,D=!M&&-1===i.userAgent.indexOf("MSIE")&&-1===i.userAgent.indexOf("Mozilla"),L=function(){return{api_host:"https://app.posthog.com",api_method:"POST",api_transport:"XHR",autocapture:!0,rageclick:!1,cross_subdomain_cookie:-1===i.document.location.hostname.indexOf("herokuapp.com"),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,cookie_expiration:365,upgrade:!1,disable_session_recording:!1,disable_persistence:!1,disable_cookie:!1,secure_cookie:"https:"===i.window.location.protocol,ip:!0,opt_out_capturing_by_default:!1,opt_out_persistence_by_default:!1,opt_out_capturing_persistence_type:"localStorage",opt_out_capturing_cookie_prefix:null,property_blacklist:[],sanitize_properties:null,xhr_headers:{},inapp_protocol:"//",inapp_link_new_window:!1,request_batching:!0,properties_string_max_length:65535,session_recording:{blockClass:"ph-no-capture",blockSelector:null,ignoreClass:"ph-ignore-input",maskAllInputs:!1,maskInputOptions:{},maskInputFn:null,slimDOMOptions:{},collectFonts:!1},mask_all_element_attributes:!1,mask_all_text:!1,advanced_disable_decide:!1,advanced_disable_toolbar_metrics:!1,on_xhr_error:function(e){var t="Bad HTTP status: "+e.status+" "+e.statusText;i.console.error(t)},_onCapture:function(){},_capture_metrics:!1,_capture_performance:!1}},C=function(){};exports.PostHogLib=C;var U=function(o,a,_){var d,g=_===R?t:t[_];if(g&&e===I)d=g;else{if(g&&!i._.isArray(g))return void i.console.error("You have already initialized "+_);d=new C}if(d._init(o,a,_),d.people=new s.PostHogPeople,d.people._init(d),d.featureFlags=new p.PostHogFeatureFlags(d),d.feature_flags=d.featureFlags,d.toolbar=new u.Toolbar(d),d.toolbar.maybeLoadEditor(),d.sessionRecording=new c.SessionRecording(d),d.sessionRecording.startRecordingIfEnabled(),d.__autocapture_enabled=d.get_config("autocapture"),d.get_config("autocapture")){n.autocapture.enabledForProject(d.get_config("token"),100,100)?n.autocapture.isBrowserSupported()?n.autocapture.init(d):(d.__autocapture_enabled=!1,i.console.log("Disabling Automatic Event Collection because this browser is not supported")):(d.__autocapture_enabled=!1,i.console.log("Not in active bucket: disabling Automatic Event Collection."))}return r.default.DEBUG=r.default.DEBUG||d.get_config("debug"),!i._.isUndefined(g)&&i._.isArray(g)&&(d._execute_array.call(d.people,g.people),d._execute_array(g)),d};C.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!==R){var n=U(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")}},C.prototype._init=function(e,t,o){this.__loaded=!0,this.config={},this._triggered_notifs=[],this.compression={},this.set_config(i._.extend({},L(),t,{name:o,token:e,callback_fn:(o===R?o:R+"."+o)+"._jsc"})),this._jsc=function(){},this._captureMetrics=new h.CaptureMetrics(this.get_config("_capture_metrics")),this._requestQueue=new l.RequestQueue(this._captureMetrics,i._.bind(this._handle_queued_event,this)),this._retryQueue=new b.RetryQueue(this._captureMetrics,this.get_config("on_xhr_error")),this.__captureHooks=[],this.__request_queue=[],this.persistence=new a.PostHogPersistence(this.config),this.sessionManager=new m.SessionIdManager(this.config,this.persistence),this._gdpr_init();var r=i._.UUID();this.get_distinct_id()||this.register_once({distinct_id:r,$device_id:r},""),i.window.addEventListener&&i.window.addEventListener("unload",this._handle_unload.bind(this))},C.prototype._loaded=function(){this.featureFlags.setReloadingPaused(!0);try{this.get_config("loaded")(this)}catch(e){i.console.error("`loaded` function failed",e)}this._start_queue_if_opted_in(),this.get_config("capture_pageview")&&this.capture("$pageview",{},{send_instantly:!0}),this.get_config("advanced_disable_decide")||new _.Decide(this).call(),this.featureFlags.resetRequestQueue(),this.featureFlags.setReloadingPaused(!1)},C.prototype._start_queue_if_opted_in=function(){this.has_opted_out_capturing()||this.get_config("request_batching")&&this._requestQueue.poll()},C.prototype._dom_loaded=function(){this.has_opted_out_capturing()||i._.each(this.__request_queue,function(e){this._send_request.apply(this,e)},this),delete this.__request_queue,this._start_queue_if_opted_in()},C.prototype._prepare_callback=function(e,t){if(i._.isUndefined(e))return null;if(M){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},C.prototype._handle_unload=function(){this.get_config("request_batching")?(this.get_config("capture_pageview")&&this.capture("$pageleave"),this.get_config("_capture_metrics")&&(this._requestQueue.updateUnloadMetrics(),this.capture("$capture_metrics",this._captureMetrics.metrics)),this._requestQueue.unload(),this._retryQueue.unload()):this.get_config("capture_pageview")&&this.capture("$pageleave",null,{transport:"sendbeacon"})},C.prototype._handle_queued_event=function(e,t,o){var r=JSON.stringify(t);this.__compress_and_send_json_request(e,r,o||A,j)},C.prototype.__compress_and_send_json_request=function(e,t,o,r){var i=S((0,f.compressData)((0,f.decideCompression)(this.compression),t,o),2),n=i[0],s=i[1];this._send_request(e,n,s,r)},C.prototype._send_request=function(e,t,o,r){if(D)this.__request_queue.push(arguments);else{var n={method:this.get_config("api_method"),transport:this.get_config("api_transport"),verbose:this.get_config("verbose")};o=i._.extend(n,o||{}),M||(o.method="GET");var s=i.window.navigator.sendBeacon&&"sendbeacon"===o.transport.toLowerCase(),p=o.urlQueryArgs||{};p.ip=this.get_config("ip")?1:0,p._=(new Date).getTime().toString();var a=e.indexOf("?")>-1?"&":"?";if(e+=a+i._.HTTPBuildQuery(p),i._.isObject(t)&&this.get_config("img")){var c=i.document.createElement("img");c.src=e,i.document.body.appendChild(c)}else if(s)try{i.window.navigator.sendBeacon(e,(0,y.encodePostData)(t,q(q({},o),{},{sendBeacon:!0})))}catch(d){this.get_config("debug")&&i.console.error(d)}else if(M)try{(0,y.xhr)({url:e,data:t,headers:this.get_config("xhr_headers"),options:o,captureMetrics:this._captureMetrics,callback:r,retriesPerformedSoFar:0,retryQueue:this._retryQueue,onXHRError:this.get_config("on_xhr_error")})}catch(d){i.console.error(d)}else{var _=i.document.createElement("script");_.type="text/javascript",_.async=!0,_.defer=!0,_.src=e;var u=i.document.getElementsByTagName("script")[0];u.parentNode.insertBefore(_,u)}}},C.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)},C.prototype.push=function(e){this._execute_array([e])},C.prototype.capture=(0,d.addOptOutCheckPostHogLib)(function(e,t,o){if(this.__loaded){this._captureMetrics.incr("capture"),"$snapshot"===e&&this._captureMetrics.incr("snapshot");var r=(o=o||A).transport;if(r&&(o.transport=r),i._.isUndefined(e)||"string"!=typeof e)i.console.error("No event name provided to posthog.capture");else if(!i._.isBlockedUA(i.userAgent)){var n=this.persistence.remove_event_timer(e);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);var s={event:e,properties:this._calculate_event_properties(e,t,n)};"$identify"===e&&o.$set&&(s.$set=o.$set),s=i._.copyAndTruncateStrings(s,o._noTruncate?null:this.get_config("properties_string_max_length")),this.get_config("debug")&&i.console.log("PostHog.js send",s);var p=JSON.stringify(s),a=this.get_config("api_host")+(o.endpoint||"/e/"),c=o!==A;return!this.get_config("request_batching")||c&&!o._batchKey||o.send_instantly?this.__compress_and_send_json_request(a,p,o):(s.timestamp=new Date,this._requestQueue.enqueue(a,s,o)),this._invokeCaptureHooks(e,s),s}}}),C.prototype._addCaptureHook=function(e){this.__captureHooks.push(e)},C.prototype._invokeCaptureHooks=function(e,t){this.config._onCapture(e,t),i._.each(this.__captureHooks,function(t){return t(e)})},C.prototype._calculate_event_properties=function(e,t,o){var r=t||{};if(r.token=this.get_config("token"),"$snapshot"===e){var n=this.persistence.properties();return r.distinct_id=n.distinct_id,r}if(!i._.isUndefined(o)){var s=(new Date).getTime()-o;r.$duration=parseFloat((s/1e3).toFixed(3))}if(this.sessionManager){var p=this.sessionManager.getSessionAndWindowId(),a=p.sessionId,c=p.windowId;r.$session_id=a,r.$window_id=c}r=i._.extend({},i._.info.properties(),this.persistence.properties(),r),"$pageview"===e&&this.get_config("_capture_performance")&&(r=i._.extend(r,(0,v.getPerformanceData)()));var _=this.get_config("property_blacklist");i._.isArray(_)?i._.each(_,function(e){delete r[e]}):i.console.error("Invalid value for property_blacklist config: "+_);var u=this.get_config("sanitize_properties");return u&&(r=u(r,e)),r},C.prototype.register=function(e,t){this.persistence.register(e,t)},C.prototype.register_once=function(e,t,o){this.persistence.register_once(e,t,o)},C.prototype.unregister=function(e){this.persistence.unregister(e)},C.prototype._register_single=function(e,t){var o={};o[e]=t,this.register(o)},C.prototype.getFeatureFlag=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return this.featureFlags.getFeatureFlag(e,t)},C.prototype.isFeatureEnabled=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return this.featureFlags.isFeatureEnabled(e,t)},C.prototype.reloadFeatureFlags=function(){return this.featureFlags.reloadFeatureFlags()},C.prototype.onFeatureFlags=function(e){this.featureFlags.onFeatureFlags(e)},C.prototype.identify=function(e,t,o){if(e){this._captureMetrics.incr("identify");var r=this.get_distinct_id();if(this.register({$user_id:e}),!this.get_property("$device_id")){var n=r;this.register_once({$had_persisted_distinct_id:!0,$device_id:n},"")}e!==r&&e!==this.get_property(a.ALIAS_ID_KEY)&&(this.unregister(a.ALIAS_ID_KEY),this.register({distinct_id:e})),e===r||this.get_property("$device_id")&&r!==this.get_property("$device_id")?(t&&this.people.set(t),o&&this.people.set_once(o)):this.capture("$identify",{distinct_id:e,$anon_distinct_id:r},{$set:t||{}},{$set_once:o||{}}),e!==r&&this.reloadFeatureFlags()}else i.console.error("Unique user id has not been set in posthog.identify")},C.prototype.group=function(e,t,o){if(e&&t){this._captureMetrics.incr("group");var r=this.getGroups();this.register({$groups:q(q({},r),{},P({},e,t))}),o&&this.capture("$groupidentify",{$group_type:e,$group_key:t,$group_set:o}),r[e]!==t&&this.reloadFeatureFlags()}else i.console.error("posthog.group requires a group type and group key")},C.prototype.reset=function(e){var t=this.get_property("$device_id");this.persistence.clear();var o=i._.UUID();this.register_once({distinct_id:o,$device_id:e?o:t},"")},C.prototype.get_distinct_id=function(){return this.get_property("distinct_id")},C.prototype.getGroups=function(){return this.get_property("$groups")||{}},C.prototype.alias=function(e,t){if(e===this.get_property(a.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(a.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)},C.prototype.set_config=function(e){var t=q({},this.config);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),g.localStore.is_supported()&&"true"===g.localStore.get("ph_debug")&&(this.config.debug=!0),r.default.DEBUG=r.default.DEBUG||this.get_config("debug"),this.sessionRecording&&void 0!==e.disable_session_recording&&t.disable_session_recording!==e.disable_session_recording&&(e.disable_session_recording?this.sessionRecording.stopRecording():this.sessionRecording.startRecordingIfEnabled()))},C.prototype.startSessionRecording=function(){this.set_config({disable_session_recording:!1})},C.prototype.stopSessionRecording=function(){this.set_config({disable_session_recording:!0})},C.prototype.sessionRecordingStarted=function(){return this.sessionRecording.started()},C.prototype.get_config=function(e){return this.config[e]},C.prototype.get_property=function(e){return this.persistence.props[e]},C.prototype.toString=function(){var e=this.get_config("name");return e!==R&&(e=R+"."+e),e},C.prototype._gdpr_init=function(){"localStorage"===this.get_config("opt_out_capturing_persistence_type")&&g.localStore.is_supported()&&(!this.has_opted_in_capturing()&&this.has_opted_in_capturing({persistence_type:"cookie"})&&this.opt_in_capturing({enable_persistence:!1}),!this.has_opted_out_capturing()&&this.has_opted_out_capturing({persistence_type:"cookie"})&&this.opt_out_capturing({clear_persistence:!1}),this.clear_opt_in_out_capturing({persistence_type:"cookie",enable_persistence:!1})),this.has_opted_out_capturing()?this._gdpr_update_persistence({clear_persistence:!0}):this.has_opted_in_capturing()||!this.get_config("opt_out_capturing_by_default")&&!g.cookieStore.get("ph_optout")||(g.cookieStore.remove("ph_optout"),this.opt_out_capturing({clear_persistence:this.get_config("opt_out_persistence_by_default")}))},C.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)},C.prototype._gdpr_call_func=function(e,t){return t=i._.extend({capture:i._.bind(this.capture,this),persistence_type:this.get_config("opt_out_capturing_persistence_type"),cookie_prefix:this.get_config("opt_out_capturing_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),g.localStore.is_supported()||"localStorage"!==t.persistence_type||(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})},C.prototype.opt_in_capturing=function(e){e=i._.extend({enable_persistence:!0},e),this._gdpr_call_func(d.optIn,e),this._gdpr_update_persistence(e)},C.prototype.opt_out_capturing=function(e){e=i._.extend({clear_persistence:!0},e),this._gdpr_call_func(d.optOut,e),this._gdpr_update_persistence(e)},C.prototype.has_opted_in_capturing=function(e){return this._gdpr_call_func(d.hasOptedIn,e)},C.prototype.has_opted_out_capturing=function(e){return this._gdpr_call_func(d.hasOptedOut,e)},C.prototype.clear_opt_in_out_capturing=function(e){e=i._.extend({enable_persistence:!0},e),this._gdpr_call_func(d.clearOptInOut,e),this._gdpr_update_persistence(e)},C.prototype.sentry_integration=function(e,t,o,r){this.name="posthog-js",this.setupOnce=function(i){i(function(i){if("error"!==i.level||!e.__loaded)return i;i.tags||(i.tags={}),i.tags["PostHog URL"]=e.config.api_host+"/person/"+e.get_distinct_id();var n={$sentry_event_id:i.event_id,$sentry_exception:i.exception};return t&&o&&(n.$sentry_url=(r||"https://sentry.io/organizations/")+t+"/issues/?project="+o+"&query="+i.event_id),e.capture("$exception",n),i})}},C.prototype.debug=function(e){!1===e?(i.window.console.log("You've disabled debug mode."),localStorage&&localStorage.setItem("ph_debug",void 0),this.set_config({debug:!1})):(i.window.console.log("You're now in debug mode. All calls to PostHog will be logged in your console.\nYou can disable this with `posthog.debug(false)`."),localStorage&&localStorage.setItem("ph_debug","true"),this.set_config({debug:!0}))},C.prototype.decodeLZ64=o.LZString.decompressFromBase64,C.prototype.init=C.prototype.init,C.prototype.reset=C.prototype.reset,C.prototype.capture=C.prototype.capture,C.prototype.register=C.prototype.register,C.prototype.register_once=C.prototype.register_once,C.prototype.unregister=C.prototype.unregister,C.prototype.identify=C.prototype.identify,C.prototype.getGroups=C.prototype.getGroups,C.prototype.group=C.prototype.group,C.prototype.alias=C.prototype.alias,C.prototype.set_config=C.prototype.set_config,C.prototype.get_config=C.prototype.get_config,C.prototype.get_property=C.prototype.get_property,C.prototype.get_distinct_id=C.prototype.get_distinct_id,C.prototype.toString=C.prototype.toString,C.prototype.opt_out_captureing=C.prototype.opt_out_captureing,C.prototype.opt_in_captureing=C.prototype.opt_in_captureing,C.prototype.has_opted_out_captureing=C.prototype.has_opted_out_captureing,C.prototype.has_opted_in_captureing=C.prototype.has_opted_in_captureing,C.prototype.clear_opt_in_out_captureing=C.prototype.clear_opt_in_out_captureing,C.prototype.opt_out_capturing=C.prototype.opt_out_capturing,C.prototype.opt_in_capturing=C.prototype.opt_in_capturing,C.prototype.has_opted_out_capturing=C.prototype.has_opted_out_capturing,C.prototype.has_opted_in_capturing=C.prototype.has_opted_in_capturing,C.prototype.clear_opt_in_out_capturing=C.prototype.clear_opt_in_out_capturing,C.prototype.getFeatureFlag=C.prototype.getFeatureFlag,C.prototype.isFeatureEnabled=C.prototype.isFeatureEnabled,C.prototype.reloadFeatureFlags=C.prototype.reloadFeatureFlags,C.prototype.onFeatureFlags=C.prototype.onFeatureFlags,C.prototype.decodeLZ64=C.prototype.decodeLZ64,C.prototype.SentryIntegration=C.prototype.sentry_integration,C.prototype.debug=C.prototype.debug,C.prototype.LIB_VERSION=r.default.LIB_VERSION,C.prototype.startSessionRecording=C.prototype.startSessionRecording,C.prototype.stopSessionRecording=C.prototype.stopSessionRecording,C.prototype.sessionRecordingStarted=C.prototype.sessionRecordingStarted,a.PostHogPersistence.prototype.properties=a.PostHogPersistence.prototype.properties,a.PostHogPersistence.prototype.update_search_keyword=a.PostHogPersistence.prototype.update_search_keyword,a.PostHogPersistence.prototype.update_referrer_info=a.PostHogPersistence.prototype.update_referrer_info,a.PostHogPersistence.prototype.get_cross_subdomain=a.PostHogPersistence.prototype.get_cross_subdomain,a.PostHogPersistence.prototype.clear=a.PostHogPersistence.prototype.clear,i._.safewrap_class(C,["identify"]);var T={},B=function(){i._.each(T,function(e,o){o!==R&&(t[o]=e)}),t._=i._},Q=function(){t.init=function(o,r,n){if(n)return t[n]||(t[n]=T[n]=U(o,r,n),t[n]._loaded()),t[n];var s=t;T[R]?s=T[R]:o&&((s=U(o,r,R))._loaded(),T[R]=s),t=s,e===H&&(i.window[R]=t),B()}},N=function(){function e(){e.done||(e.done=!0,D=!1,i._.each(T,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 Y(){e=H,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)&&(T[e[e.length-1]]=U.apply(this,e))}),Q(),t.init(),i._.each(T,function(e){e._loaded()}),N())}function G(){return e=I,t=new C,Q(),t.init(),N(),t}
55
55
  },{"./lz-string":"zdbk","./config":"itQ5","./utils":"FOZT","./autocapture":"gR3r","./posthog-people":"ecEG","./posthog-featureflags":"aVqC","./posthog-persistence":"MAdm","./extensions/sessionrecording":"Z2N4","./decide":"auG7","./extensions/toolbar":"ZEpJ","./gdpr-utils":"rxSh","./storage":"KZ7Y","./request-queue":"Je4H","./capture-metrics":"TeHW","./compression":"Ie9M","./send-request":"tOu2","./retry-queue":"ennf","./sessionid":"tci7","./apm":"eWVp"}],"e2xX":[function(require,module,exports) {
56
56
  "use strict";var r=require("./posthog-core");(0,r.init_from_snippet)();
57
57
  },{"./posthog-core":"ok3T"}]},{},["e2xX"], null)
package/dist/es.js CHANGED
@@ -863,7 +863,7 @@ var LZString = {
863
863
  }
864
864
  };
865
865
 
866
- var version = "1.17.4";
866
+ var version = "1.17.8";
867
867
 
868
868
  var Config$1 = {
869
869
  DEBUG: false,
@@ -3225,9 +3225,7 @@ var PostHogFeatureFlags = /*#__PURE__*/function () {
3225
3225
  }, {
3226
3226
  method: 'POST'
3227
3227
  }, this.instance._prepare_callback(function (response) {
3228
- parseFeatureFlagDecideResponse(response, _this2.instance.persistence);
3229
-
3230
- _this2.receivedFeatureFlags(); // :TRICKY: Reload - start another request if queued!
3228
+ _this2.receivedFeatureFlags(response); // :TRICKY: Reload - start another request if queued!
3231
3229
 
3232
3230
 
3233
3231
  _this2.setReloadingPaused(false);
@@ -3298,7 +3296,8 @@ var PostHogFeatureFlags = /*#__PURE__*/function () {
3298
3296
  }
3299
3297
  }, {
3300
3298
  key: "receivedFeatureFlags",
3301
- value: function receivedFeatureFlags() {
3299
+ value: function receivedFeatureFlags(response) {
3300
+ parseFeatureFlagDecideResponse(response, this.instance.persistence);
3302
3301
  var flags = this.getFlags();
3303
3302
  var variants = this.getFlagVariants();
3304
3303
  this.featureFlagEventHandlers.forEach(function (handler) {
@@ -3340,6 +3339,29 @@ var PostHogFeatureFlags = /*#__PURE__*/function () {
3340
3339
  });
3341
3340
  }
3342
3341
  }
3342
+ /*
3343
+ * Register an event listener that runs when feature flags become available or when they change.
3344
+ * If there are flags, the listener is called immediately in addition to being called on future changes.
3345
+ *
3346
+ * ### Usage:
3347
+ *
3348
+ * posthog.onFeatureFlags(function(featureFlags) { // do something })
3349
+ *
3350
+ * @param {Function} [callback] The callback function will be called once the feature flags are ready or when they are updated.
3351
+ * It'll return a list of feature flags enabled for the user.
3352
+ */
3353
+
3354
+ }, {
3355
+ key: "onFeatureFlags",
3356
+ value: function onFeatureFlags(callback) {
3357
+ this.addFeatureFlagsHandler(callback);
3358
+
3359
+ if (this.instance.decideEndpointWasHit) {
3360
+ var flags = this.getFlags();
3361
+ var flagVariants = this.getFlagVariants();
3362
+ callback(flags, flagVariants);
3363
+ }
3364
+ }
3343
3365
  }]);
3344
3366
 
3345
3367
  return PostHogFeatureFlags;
@@ -3385,7 +3407,7 @@ var CAMPAIGN_IDS_KEY = '__cmpns';
3385
3407
  var EVENT_TIMERS_KEY = '__timers';
3386
3408
  /** @const */
3387
3409
 
3388
- var SESSION_RECORDING_ENABLED = '$session_recording_enabled';
3410
+ var SESSION_RECORDING_ENABLED_SERVER_SIDE = '$session_recording_enabled_server_side';
3389
3411
  /** @const */
3390
3412
 
3391
3413
  var SESSION_ID = '$sesid';
@@ -3394,7 +3416,7 @@ var SESSION_ID = '$sesid';
3394
3416
  var ENABLED_FEATURE_FLAGS = '$enabled_feature_flags';
3395
3417
  /** @const */
3396
3418
 
3397
- var RESERVED_PROPERTIES = [SET_QUEUE_KEY, SET_ONCE_QUEUE_KEY, UNSET_QUEUE_KEY, ADD_QUEUE_KEY, APPEND_QUEUE_KEY, REMOVE_QUEUE_KEY, UNION_QUEUE_KEY, PEOPLE_DISTINCT_ID_KEY, ALIAS_ID_KEY, CAMPAIGN_IDS_KEY, EVENT_TIMERS_KEY, SESSION_RECORDING_ENABLED, SESSION_ID, ENABLED_FEATURE_FLAGS];
3419
+ var RESERVED_PROPERTIES = [SET_QUEUE_KEY, SET_ONCE_QUEUE_KEY, UNSET_QUEUE_KEY, ADD_QUEUE_KEY, APPEND_QUEUE_KEY, REMOVE_QUEUE_KEY, UNION_QUEUE_KEY, PEOPLE_DISTINCT_ID_KEY, ALIAS_ID_KEY, CAMPAIGN_IDS_KEY, EVENT_TIMERS_KEY, SESSION_RECORDING_ENABLED_SERVER_SIDE, SESSION_ID, ENABLED_FEATURE_FLAGS];
3398
3420
  /**
3399
3421
  * PostHog Persistence Object
3400
3422
  * @constructor
@@ -3707,18 +3729,22 @@ var SessionRecording = /*#__PURE__*/function () {
3707
3729
  this.instance = instance;
3708
3730
  this.captureStarted = false;
3709
3731
  this.snapshots = [];
3710
- this.emit = false;
3732
+ this.emit = false; // Controls whether data is sent to the server or not
3733
+
3711
3734
  this.endpoint = BASE_ENDPOINT;
3712
3735
  this.stopRrweb = null;
3713
3736
  this.windowId = null;
3714
3737
  this.sessionId = null;
3738
+ this.receivedDecide = false;
3715
3739
  }
3716
3740
 
3717
3741
  _createClass(SessionRecording, [{
3718
3742
  key: "startRecordingIfEnabled",
3719
3743
  value: function startRecordingIfEnabled() {
3720
- if (this.instance.get_property(SESSION_RECORDING_ENABLED) && !this.instance.get_config('disable_session_recording')) {
3721
- this._startCapture();
3744
+ if (this.isRecordingEnabled()) {
3745
+ this.startCaptureAndTrySendingQueuedSnapshots();
3746
+ } else {
3747
+ this.stopRecording();
3722
3748
  }
3723
3749
  }
3724
3750
  }, {
@@ -3735,35 +3761,47 @@ var SessionRecording = /*#__PURE__*/function () {
3735
3761
  this.captureStarted = false;
3736
3762
  }
3737
3763
  }
3764
+ }, {
3765
+ key: "isRecordingEnabled",
3766
+ value: function isRecordingEnabled() {
3767
+ var enabled_server_side = !!this.instance.get_property(SESSION_RECORDING_ENABLED_SERVER_SIDE);
3768
+ var enabled_client_side = !this.instance.get_config('disable_session_recording');
3769
+ return enabled_server_side && enabled_client_side;
3770
+ }
3738
3771
  }, {
3739
3772
  key: "afterDecideResponse",
3740
3773
  value: function afterDecideResponse(response) {
3741
- var enableRecordings = !this.instance.get_config('disable_session_recording') && !!response['sessionRecording'];
3774
+ var _response$sessionReco;
3775
+
3776
+ this.receivedDecide = true;
3742
3777
 
3743
3778
  if (this.instance.persistence) {
3744
- this.instance.persistence.register(_defineProperty({}, SESSION_RECORDING_ENABLED, enableRecordings));
3779
+ this.instance.persistence.register(_defineProperty({}, SESSION_RECORDING_ENABLED_SERVER_SIDE, !!response['sessionRecording']));
3745
3780
  }
3746
3781
 
3747
- if (enableRecordings) {
3748
- if (response['sessionRecording'].endpoint) {
3749
- this.endpoint = response['sessionRecording'].endpoint;
3750
- }
3782
+ if ((_response$sessionReco = response.sessionRecording) !== null && _response$sessionReco !== void 0 && _response$sessionReco.endpoint) {
3783
+ var _response$sessionReco2;
3751
3784
 
3752
- this.submitRecordings();
3785
+ this.endpoint = (_response$sessionReco2 = response.sessionRecording) === null || _response$sessionReco2 === void 0 ? void 0 : _response$sessionReco2.endpoint;
3753
3786
  }
3787
+
3788
+ this.startRecordingIfEnabled();
3754
3789
  }
3755
3790
  }, {
3756
- key: "submitRecordings",
3757
- value: function submitRecordings() {
3791
+ key: "startCaptureAndTrySendingQueuedSnapshots",
3792
+ value: function startCaptureAndTrySendingQueuedSnapshots() {
3758
3793
  var _this = this;
3759
3794
 
3760
- this.emit = true;
3795
+ // Only submit data after we've received a decide response to account for
3796
+ // changing endpoints and the feature being disabled on the server side.
3797
+ if (this.receivedDecide) {
3798
+ this.emit = true;
3799
+ this.snapshots.forEach(function (properties) {
3800
+ return _this._captureSnapshot(properties);
3801
+ });
3802
+ }
3761
3803
 
3762
3804
  this._startCapture();
3763
-
3764
- this.snapshots.forEach(function (properties) {
3765
- return _this._captureSnapshot(properties);
3766
- });
3767
3805
  }
3768
3806
  }, {
3769
3807
  key: "_startCapture",
@@ -3889,6 +3927,7 @@ var Decide = /*#__PURE__*/function () {
3889
3927
  _classCallCheck(this, Decide);
3890
3928
 
3891
3929
  this.instance = instance;
3930
+ this.instance.decideEndpointWasHit = false;
3892
3931
  }
3893
3932
 
3894
3933
  _createClass(Decide, [{
@@ -3926,6 +3965,8 @@ var Decide = /*#__PURE__*/function () {
3926
3965
  return;
3927
3966
  }
3928
3967
 
3968
+ this.instance.decideEndpointWasHit = true;
3969
+
3929
3970
  if (!(document && document.body)) {
3930
3971
  console.log('document not ready yet, trying again in 500 milliseconds...');
3931
3972
  setTimeout(function () {
@@ -3937,7 +3978,7 @@ var Decide = /*#__PURE__*/function () {
3937
3978
  this.instance.toolbar.afterDecideResponse(response);
3938
3979
  this.instance.sessionRecording.afterDecideResponse(response);
3939
3980
  autocapture.afterDecideResponse(response, this.instance);
3940
- parseFeatureFlagDecideResponse(response, this.instance.persistence);
3981
+ this.instance.featureFlags.receivedFeatureFlags(response);
3941
3982
 
3942
3983
  if (response['supportedCompression']) {
3943
3984
  var compression = {};
@@ -4305,18 +4346,11 @@ var RequestQueue = /*#__PURE__*/function (_RequestQueueScaffold) {
4305
4346
  }(RequestQueueScaffold);
4306
4347
 
4307
4348
  var CaptureMetrics = /*#__PURE__*/function () {
4308
- function CaptureMetrics(enabled, capture) {
4309
- var getTime = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : function () {
4310
- return new Date().getTime();
4311
- };
4312
-
4349
+ function CaptureMetrics(enabled) {
4313
4350
  _classCallCheck(this, CaptureMetrics);
4314
4351
 
4315
4352
  this.enabled = enabled;
4316
- this.capture = capture;
4317
- this.getTime = getTime;
4318
4353
  this.metrics = {};
4319
- this.requests = {};
4320
4354
  }
4321
4355
 
4322
4356
  _createClass(CaptureMetrics, [{
@@ -4337,51 +4371,6 @@ var CaptureMetrics = /*#__PURE__*/function () {
4337
4371
  this.metrics[key] = (this.metrics[key] || 0) - 1;
4338
4372
  }
4339
4373
  }
4340
- }, {
4341
- key: "startRequest",
4342
- value: function startRequest(payload) {
4343
- if (this.enabled) {
4344
- var requestId = _.UUID();
4345
-
4346
- this.requests[requestId] = [this.getTime(), payload];
4347
- return requestId;
4348
- }
4349
- }
4350
- }, {
4351
- key: "finishRequest",
4352
- value: function finishRequest(requestId) {
4353
- if (this.enabled && this.requests[requestId]) {
4354
- var _this$requests$reques = _slicedToArray(this.requests[requestId], 2),
4355
- startTime = _this$requests$reques[0],
4356
- payload = _this$requests$reques[1];
4357
-
4358
- payload['duration'] = this.getTime() - startTime;
4359
- delete this.requests[requestId];
4360
- return payload;
4361
- }
4362
- }
4363
- }, {
4364
- key: "markRequestFailed",
4365
- value: function markRequestFailed(payload) {
4366
- if (this.enabled) {
4367
- this.capture('$capture_failed_request', payload);
4368
- }
4369
- }
4370
- }, {
4371
- key: "captureInProgressRequests",
4372
- value: function captureInProgressRequests() {
4373
- var _this = this;
4374
-
4375
- if (this.enabled) {
4376
- Object.keys(this.requests).forEach(function (requestId) {
4377
- var payload = _this.finishRequest(requestId);
4378
-
4379
- _this.markRequestFailed(_objectSpread2(_objectSpread2({}, payload), {}, {
4380
- type: 'inflight_at_unload'
4381
- }));
4382
- });
4383
- }
4384
- }
4385
4374
  }]);
4386
4375
 
4387
4376
  return CaptureMetrics;
@@ -5219,10 +5208,6 @@ var xhr = function xhr(_ref) {
5219
5208
  var body = encodePostData(data, options);
5220
5209
  captureMetrics.incr('_send_request');
5221
5210
  captureMetrics.incr('_send_request_inflight');
5222
- var requestId = captureMetrics.startRequest(_objectSpread2({
5223
- data_size: _.isString(data) ? data.length : body.length,
5224
- endpoint: url.slice(url.length - 2)
5225
- }, options._metrics));
5226
5211
 
5227
5212
  _.each(headers, function (headerValue, headerName) {
5228
5213
  req.setRequestHeader(headerName, headerValue);
@@ -5240,8 +5225,7 @@ var xhr = function xhr(_ref) {
5240
5225
  if (req.readyState === 4) {
5241
5226
  captureMetrics.incr("xhr-response");
5242
5227
  captureMetrics.incr("xhr-response-".concat(req.status));
5243
- captureMetrics.decr('_send_request_inflight');
5244
- var metricsData = captureMetrics.finishRequest(requestId); // XMLHttpRequest.DONE == 4, except in safari 4
5228
+ captureMetrics.decr('_send_request_inflight'); // XMLHttpRequest.DONE == 4, except in safari 4
5245
5229
 
5246
5230
  if (req.status === 200) {
5247
5231
  if (callback) {
@@ -5273,12 +5257,6 @@ var xhr = function xhr(_ref) {
5273
5257
  });
5274
5258
  }
5275
5259
 
5276
- captureMetrics.markRequestFailed(_objectSpread2(_objectSpread2({}, metricsData), {}, {
5277
- type: 'non_200',
5278
- status: req.status,
5279
- statusText: req.statusText
5280
- }));
5281
-
5282
5260
  if (callback) {
5283
5261
  if (options.verbose) {
5284
5262
  callback({
@@ -5890,7 +5868,7 @@ PostHogLib.prototype._init = function (token, config, name) {
5890
5868
 
5891
5869
  this['_jsc'] = function () {};
5892
5870
 
5893
- this._captureMetrics = new CaptureMetrics(this.get_config('_capture_metrics'), _.bind(this.capture, this));
5871
+ this._captureMetrics = new CaptureMetrics(this.get_config('_capture_metrics'));
5894
5872
  this._requestQueue = new RequestQueue(this._captureMetrics, _.bind(this._handle_queued_event, this));
5895
5873
  this._retryQueue = new RetryQueue(this._captureMetrics, this.get_config('on_xhr_error'));
5896
5874
  this.__captureHooks = [];
@@ -6026,8 +6004,6 @@ PostHogLib.prototype._handle_unload = function () {
6026
6004
  this._requestQueue.updateUnloadMetrics();
6027
6005
 
6028
6006
  this.capture('$capture_metrics', this._captureMetrics.metrics);
6029
-
6030
- this._captureMetrics.captureInProgressRequests();
6031
6007
  }
6032
6008
 
6033
6009
  this._requestQueue.unload();
@@ -6465,10 +6441,7 @@ PostHogLib.prototype.reloadFeatureFlags = function () {
6465
6441
 
6466
6442
 
6467
6443
  PostHogLib.prototype.onFeatureFlags = function (callback) {
6468
- this.featureFlags.addFeatureFlagsHandler(callback);
6469
- var flags = this.featureFlags.getFlags();
6470
- var flagVariants = this.featureFlags.getFlagVariants();
6471
- callback(flags, flagVariants);
6444
+ this.featureFlags.onFeatureFlags(callback);
6472
6445
  };
6473
6446
  /**
6474
6447
  * Identify a user with a unique ID instead of a PostHog
package/dist/module.js CHANGED
@@ -865,7 +865,7 @@ var LZString = {
865
865
  }
866
866
  };
867
867
 
868
- var version = "1.17.4";
868
+ var version = "1.17.8";
869
869
 
870
870
  var Config$1 = {
871
871
  DEBUG: false,
@@ -3227,9 +3227,7 @@ var PostHogFeatureFlags = /*#__PURE__*/function () {
3227
3227
  }, {
3228
3228
  method: 'POST'
3229
3229
  }, this.instance._prepare_callback(function (response) {
3230
- parseFeatureFlagDecideResponse(response, _this2.instance.persistence);
3231
-
3232
- _this2.receivedFeatureFlags(); // :TRICKY: Reload - start another request if queued!
3230
+ _this2.receivedFeatureFlags(response); // :TRICKY: Reload - start another request if queued!
3233
3231
 
3234
3232
 
3235
3233
  _this2.setReloadingPaused(false);
@@ -3300,7 +3298,8 @@ var PostHogFeatureFlags = /*#__PURE__*/function () {
3300
3298
  }
3301
3299
  }, {
3302
3300
  key: "receivedFeatureFlags",
3303
- value: function receivedFeatureFlags() {
3301
+ value: function receivedFeatureFlags(response) {
3302
+ parseFeatureFlagDecideResponse(response, this.instance.persistence);
3304
3303
  var flags = this.getFlags();
3305
3304
  var variants = this.getFlagVariants();
3306
3305
  this.featureFlagEventHandlers.forEach(function (handler) {
@@ -3342,6 +3341,29 @@ var PostHogFeatureFlags = /*#__PURE__*/function () {
3342
3341
  });
3343
3342
  }
3344
3343
  }
3344
+ /*
3345
+ * Register an event listener that runs when feature flags become available or when they change.
3346
+ * If there are flags, the listener is called immediately in addition to being called on future changes.
3347
+ *
3348
+ * ### Usage:
3349
+ *
3350
+ * posthog.onFeatureFlags(function(featureFlags) { // do something })
3351
+ *
3352
+ * @param {Function} [callback] The callback function will be called once the feature flags are ready or when they are updated.
3353
+ * It'll return a list of feature flags enabled for the user.
3354
+ */
3355
+
3356
+ }, {
3357
+ key: "onFeatureFlags",
3358
+ value: function onFeatureFlags(callback) {
3359
+ this.addFeatureFlagsHandler(callback);
3360
+
3361
+ if (this.instance.decideEndpointWasHit) {
3362
+ var flags = this.getFlags();
3363
+ var flagVariants = this.getFlagVariants();
3364
+ callback(flags, flagVariants);
3365
+ }
3366
+ }
3345
3367
  }]);
3346
3368
 
3347
3369
  return PostHogFeatureFlags;
@@ -3387,7 +3409,7 @@ var CAMPAIGN_IDS_KEY = '__cmpns';
3387
3409
  var EVENT_TIMERS_KEY = '__timers';
3388
3410
  /** @const */
3389
3411
 
3390
- var SESSION_RECORDING_ENABLED = '$session_recording_enabled';
3412
+ var SESSION_RECORDING_ENABLED_SERVER_SIDE = '$session_recording_enabled_server_side';
3391
3413
  /** @const */
3392
3414
 
3393
3415
  var SESSION_ID = '$sesid';
@@ -3396,7 +3418,7 @@ var SESSION_ID = '$sesid';
3396
3418
  var ENABLED_FEATURE_FLAGS = '$enabled_feature_flags';
3397
3419
  /** @const */
3398
3420
 
3399
- var RESERVED_PROPERTIES = [SET_QUEUE_KEY, SET_ONCE_QUEUE_KEY, UNSET_QUEUE_KEY, ADD_QUEUE_KEY, APPEND_QUEUE_KEY, REMOVE_QUEUE_KEY, UNION_QUEUE_KEY, PEOPLE_DISTINCT_ID_KEY, ALIAS_ID_KEY, CAMPAIGN_IDS_KEY, EVENT_TIMERS_KEY, SESSION_RECORDING_ENABLED, SESSION_ID, ENABLED_FEATURE_FLAGS];
3421
+ var RESERVED_PROPERTIES = [SET_QUEUE_KEY, SET_ONCE_QUEUE_KEY, UNSET_QUEUE_KEY, ADD_QUEUE_KEY, APPEND_QUEUE_KEY, REMOVE_QUEUE_KEY, UNION_QUEUE_KEY, PEOPLE_DISTINCT_ID_KEY, ALIAS_ID_KEY, CAMPAIGN_IDS_KEY, EVENT_TIMERS_KEY, SESSION_RECORDING_ENABLED_SERVER_SIDE, SESSION_ID, ENABLED_FEATURE_FLAGS];
3400
3422
  /**
3401
3423
  * PostHog Persistence Object
3402
3424
  * @constructor
@@ -3709,18 +3731,22 @@ var SessionRecording = /*#__PURE__*/function () {
3709
3731
  this.instance = instance;
3710
3732
  this.captureStarted = false;
3711
3733
  this.snapshots = [];
3712
- this.emit = false;
3734
+ this.emit = false; // Controls whether data is sent to the server or not
3735
+
3713
3736
  this.endpoint = BASE_ENDPOINT;
3714
3737
  this.stopRrweb = null;
3715
3738
  this.windowId = null;
3716
3739
  this.sessionId = null;
3740
+ this.receivedDecide = false;
3717
3741
  }
3718
3742
 
3719
3743
  _createClass(SessionRecording, [{
3720
3744
  key: "startRecordingIfEnabled",
3721
3745
  value: function startRecordingIfEnabled() {
3722
- if (this.instance.get_property(SESSION_RECORDING_ENABLED) && !this.instance.get_config('disable_session_recording')) {
3723
- this._startCapture();
3746
+ if (this.isRecordingEnabled()) {
3747
+ this.startCaptureAndTrySendingQueuedSnapshots();
3748
+ } else {
3749
+ this.stopRecording();
3724
3750
  }
3725
3751
  }
3726
3752
  }, {
@@ -3737,35 +3763,47 @@ var SessionRecording = /*#__PURE__*/function () {
3737
3763
  this.captureStarted = false;
3738
3764
  }
3739
3765
  }
3766
+ }, {
3767
+ key: "isRecordingEnabled",
3768
+ value: function isRecordingEnabled() {
3769
+ var enabled_server_side = !!this.instance.get_property(SESSION_RECORDING_ENABLED_SERVER_SIDE);
3770
+ var enabled_client_side = !this.instance.get_config('disable_session_recording');
3771
+ return enabled_server_side && enabled_client_side;
3772
+ }
3740
3773
  }, {
3741
3774
  key: "afterDecideResponse",
3742
3775
  value: function afterDecideResponse(response) {
3743
- var enableRecordings = !this.instance.get_config('disable_session_recording') && !!response['sessionRecording'];
3776
+ var _response$sessionReco;
3777
+
3778
+ this.receivedDecide = true;
3744
3779
 
3745
3780
  if (this.instance.persistence) {
3746
- this.instance.persistence.register(_defineProperty({}, SESSION_RECORDING_ENABLED, enableRecordings));
3781
+ this.instance.persistence.register(_defineProperty({}, SESSION_RECORDING_ENABLED_SERVER_SIDE, !!response['sessionRecording']));
3747
3782
  }
3748
3783
 
3749
- if (enableRecordings) {
3750
- if (response['sessionRecording'].endpoint) {
3751
- this.endpoint = response['sessionRecording'].endpoint;
3752
- }
3784
+ if ((_response$sessionReco = response.sessionRecording) !== null && _response$sessionReco !== void 0 && _response$sessionReco.endpoint) {
3785
+ var _response$sessionReco2;
3753
3786
 
3754
- this.submitRecordings();
3787
+ this.endpoint = (_response$sessionReco2 = response.sessionRecording) === null || _response$sessionReco2 === void 0 ? void 0 : _response$sessionReco2.endpoint;
3755
3788
  }
3789
+
3790
+ this.startRecordingIfEnabled();
3756
3791
  }
3757
3792
  }, {
3758
- key: "submitRecordings",
3759
- value: function submitRecordings() {
3793
+ key: "startCaptureAndTrySendingQueuedSnapshots",
3794
+ value: function startCaptureAndTrySendingQueuedSnapshots() {
3760
3795
  var _this = this;
3761
3796
 
3762
- this.emit = true;
3797
+ // Only submit data after we've received a decide response to account for
3798
+ // changing endpoints and the feature being disabled on the server side.
3799
+ if (this.receivedDecide) {
3800
+ this.emit = true;
3801
+ this.snapshots.forEach(function (properties) {
3802
+ return _this._captureSnapshot(properties);
3803
+ });
3804
+ }
3763
3805
 
3764
3806
  this._startCapture();
3765
-
3766
- this.snapshots.forEach(function (properties) {
3767
- return _this._captureSnapshot(properties);
3768
- });
3769
3807
  }
3770
3808
  }, {
3771
3809
  key: "_startCapture",
@@ -3891,6 +3929,7 @@ var Decide = /*#__PURE__*/function () {
3891
3929
  _classCallCheck(this, Decide);
3892
3930
 
3893
3931
  this.instance = instance;
3932
+ this.instance.decideEndpointWasHit = false;
3894
3933
  }
3895
3934
 
3896
3935
  _createClass(Decide, [{
@@ -3928,6 +3967,8 @@ var Decide = /*#__PURE__*/function () {
3928
3967
  return;
3929
3968
  }
3930
3969
 
3970
+ this.instance.decideEndpointWasHit = true;
3971
+
3931
3972
  if (!(document && document.body)) {
3932
3973
  console.log('document not ready yet, trying again in 500 milliseconds...');
3933
3974
  setTimeout(function () {
@@ -3939,7 +3980,7 @@ var Decide = /*#__PURE__*/function () {
3939
3980
  this.instance.toolbar.afterDecideResponse(response);
3940
3981
  this.instance.sessionRecording.afterDecideResponse(response);
3941
3982
  autocapture.afterDecideResponse(response, this.instance);
3942
- parseFeatureFlagDecideResponse(response, this.instance.persistence);
3983
+ this.instance.featureFlags.receivedFeatureFlags(response);
3943
3984
 
3944
3985
  if (response['supportedCompression']) {
3945
3986
  var compression = {};
@@ -4307,18 +4348,11 @@ var RequestQueue = /*#__PURE__*/function (_RequestQueueScaffold) {
4307
4348
  }(RequestQueueScaffold);
4308
4349
 
4309
4350
  var CaptureMetrics = /*#__PURE__*/function () {
4310
- function CaptureMetrics(enabled, capture) {
4311
- var getTime = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : function () {
4312
- return new Date().getTime();
4313
- };
4314
-
4351
+ function CaptureMetrics(enabled) {
4315
4352
  _classCallCheck(this, CaptureMetrics);
4316
4353
 
4317
4354
  this.enabled = enabled;
4318
- this.capture = capture;
4319
- this.getTime = getTime;
4320
4355
  this.metrics = {};
4321
- this.requests = {};
4322
4356
  }
4323
4357
 
4324
4358
  _createClass(CaptureMetrics, [{
@@ -4339,51 +4373,6 @@ var CaptureMetrics = /*#__PURE__*/function () {
4339
4373
  this.metrics[key] = (this.metrics[key] || 0) - 1;
4340
4374
  }
4341
4375
  }
4342
- }, {
4343
- key: "startRequest",
4344
- value: function startRequest(payload) {
4345
- if (this.enabled) {
4346
- var requestId = _.UUID();
4347
-
4348
- this.requests[requestId] = [this.getTime(), payload];
4349
- return requestId;
4350
- }
4351
- }
4352
- }, {
4353
- key: "finishRequest",
4354
- value: function finishRequest(requestId) {
4355
- if (this.enabled && this.requests[requestId]) {
4356
- var _this$requests$reques = _slicedToArray(this.requests[requestId], 2),
4357
- startTime = _this$requests$reques[0],
4358
- payload = _this$requests$reques[1];
4359
-
4360
- payload['duration'] = this.getTime() - startTime;
4361
- delete this.requests[requestId];
4362
- return payload;
4363
- }
4364
- }
4365
- }, {
4366
- key: "markRequestFailed",
4367
- value: function markRequestFailed(payload) {
4368
- if (this.enabled) {
4369
- this.capture('$capture_failed_request', payload);
4370
- }
4371
- }
4372
- }, {
4373
- key: "captureInProgressRequests",
4374
- value: function captureInProgressRequests() {
4375
- var _this = this;
4376
-
4377
- if (this.enabled) {
4378
- Object.keys(this.requests).forEach(function (requestId) {
4379
- var payload = _this.finishRequest(requestId);
4380
-
4381
- _this.markRequestFailed(_objectSpread2(_objectSpread2({}, payload), {}, {
4382
- type: 'inflight_at_unload'
4383
- }));
4384
- });
4385
- }
4386
- }
4387
4376
  }]);
4388
4377
 
4389
4378
  return CaptureMetrics;
@@ -5221,10 +5210,6 @@ var xhr = function xhr(_ref) {
5221
5210
  var body = encodePostData(data, options);
5222
5211
  captureMetrics.incr('_send_request');
5223
5212
  captureMetrics.incr('_send_request_inflight');
5224
- var requestId = captureMetrics.startRequest(_objectSpread2({
5225
- data_size: _.isString(data) ? data.length : body.length,
5226
- endpoint: url.slice(url.length - 2)
5227
- }, options._metrics));
5228
5213
 
5229
5214
  _.each(headers, function (headerValue, headerName) {
5230
5215
  req.setRequestHeader(headerName, headerValue);
@@ -5242,8 +5227,7 @@ var xhr = function xhr(_ref) {
5242
5227
  if (req.readyState === 4) {
5243
5228
  captureMetrics.incr("xhr-response");
5244
5229
  captureMetrics.incr("xhr-response-".concat(req.status));
5245
- captureMetrics.decr('_send_request_inflight');
5246
- var metricsData = captureMetrics.finishRequest(requestId); // XMLHttpRequest.DONE == 4, except in safari 4
5230
+ captureMetrics.decr('_send_request_inflight'); // XMLHttpRequest.DONE == 4, except in safari 4
5247
5231
 
5248
5232
  if (req.status === 200) {
5249
5233
  if (callback) {
@@ -5275,12 +5259,6 @@ var xhr = function xhr(_ref) {
5275
5259
  });
5276
5260
  }
5277
5261
 
5278
- captureMetrics.markRequestFailed(_objectSpread2(_objectSpread2({}, metricsData), {}, {
5279
- type: 'non_200',
5280
- status: req.status,
5281
- statusText: req.statusText
5282
- }));
5283
-
5284
5262
  if (callback) {
5285
5263
  if (options.verbose) {
5286
5264
  callback({
@@ -5892,7 +5870,7 @@ PostHogLib.prototype._init = function (token, config, name) {
5892
5870
 
5893
5871
  this['_jsc'] = function () {};
5894
5872
 
5895
- this._captureMetrics = new CaptureMetrics(this.get_config('_capture_metrics'), _.bind(this.capture, this));
5873
+ this._captureMetrics = new CaptureMetrics(this.get_config('_capture_metrics'));
5896
5874
  this._requestQueue = new RequestQueue(this._captureMetrics, _.bind(this._handle_queued_event, this));
5897
5875
  this._retryQueue = new RetryQueue(this._captureMetrics, this.get_config('on_xhr_error'));
5898
5876
  this.__captureHooks = [];
@@ -6028,8 +6006,6 @@ PostHogLib.prototype._handle_unload = function () {
6028
6006
  this._requestQueue.updateUnloadMetrics();
6029
6007
 
6030
6008
  this.capture('$capture_metrics', this._captureMetrics.metrics);
6031
-
6032
- this._captureMetrics.captureInProgressRequests();
6033
6009
  }
6034
6010
 
6035
6011
  this._requestQueue.unload();
@@ -6467,10 +6443,7 @@ PostHogLib.prototype.reloadFeatureFlags = function () {
6467
6443
 
6468
6444
 
6469
6445
  PostHogLib.prototype.onFeatureFlags = function (callback) {
6470
- this.featureFlags.addFeatureFlagsHandler(callback);
6471
- var flags = this.featureFlags.getFlags();
6472
- var flagVariants = this.featureFlags.getFlagVariants();
6473
- callback(flags, flagVariants);
6446
+ this.featureFlags.onFeatureFlags(callback);
6474
6447
  };
6475
6448
  /**
6476
6449
  * Identify a user with a unique ID instead of a PostHog
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "posthog-js",
3
- "version": "1.17.4",
3
+ "version": "1.17.8",
4
4
  "description": "Posthog-js allows you to automatically capture usage and send events to PostHog.",
5
5
  "repository": "https://github.com/PostHog/posthog-js",
6
6
  "author": "hey@posthog.com",