posthog-js 1.15.1 → 1.16.0
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 +16 -0
- package/dist/array.js +4 -4
- package/dist/es.js +30 -23
- package/dist/module.d.ts +12 -1
- package/dist/module.js +30 -23
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,19 @@
|
|
|
1
|
+
## 1.16.0 - 2021-10-28
|
|
2
|
+
|
|
3
|
+
- Group analytics support (#325)
|
|
4
|
+
|
|
5
|
+
## 1.15.4 - 2021-10-27
|
|
6
|
+
|
|
7
|
+
- pass toolbar to posthog (#327)
|
|
8
|
+
|
|
9
|
+
## 1.15.3 - 2021-10-19
|
|
10
|
+
|
|
11
|
+
- Add localStorage+cookie as persistence type (#324)
|
|
12
|
+
|
|
13
|
+
## 1.15.2 - 2021-10-18
|
|
14
|
+
|
|
15
|
+
- drop data uri filter limit from 20mb to 5mb (#322)
|
|
16
|
+
|
|
1
17
|
## 1.15.1 - 2021-10-18
|
|
2
18
|
|
|
3
19
|
- Take a full recording snapshot when session ids update (a fix for missing recordings) (#318)
|
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.
|
|
4
|
+
module.exports={name:"posthog-js",version:"1.16.0",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:"^6.1.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.3",sinon:"9.0.2",testcafe:"^1.10.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) {
|
|
@@ -27,13 +27,13 @@ module.exports={name:"posthog-js",version:"1.15.1",description:"Posthog-js allow
|
|
|
27
27
|
},{"./utils":"FOZT","./storage":"KZ7Y"}],"vjIe":[function(require,module,exports) {
|
|
28
28
|
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var r=require("../posthog-persistence"),e=require("../utils");function t(r,e,t){return e in r?Object.defineProperty(r,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):r[e]=t,r}function n(r,e){return l(r)||u(r,e)||i(r,e)||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 i(r,e){if(r){if("string"==typeof r)return a(r,e);var t=Object.prototype.toString.call(r).slice(8,-1);return"Object"===t&&r.constructor&&(t=r.constructor.name),"Map"===t||"Set"===t?Array.from(r):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?a(r,e):void 0}}function a(r,e){(null==e||e>r.length)&&(e=r.length);for(var t=0,n=new Array(e);t<e;t++)n[t]=r[t];return n}function u(r,e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(r)){var t=[],n=!0,o=!1,i=void 0;try{for(var a,u=r[Symbol.iterator]();!(n=(a=u.next()).done)&&(t.push(a.value),!e||t.length!==e);n=!0);}catch(l){o=!0,i=l}finally{try{n||null==u.return||u.return()}finally{if(o)throw i}}return t}}function l(r){if(Array.isArray(r))return r}var s=18e5,c=function(o,i){var a=n(o.props[r.SESSION_ID]||[0,null],2),u=a[0],l=a[1],c=!1;return Math.abs(i-u)>s&&(l=e._.UUID(),c=!0),o.register(t({},r.SESSION_ID,[i,l])),{isNewSessionId:c,sessionId:l}};exports.default=c;
|
|
29
29
|
},{"../posthog-persistence":"MAdm","../utils":"FOZT"}],"vmk3":[function(require,module,exports) {
|
|
30
|
-
"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>
|
|
30
|
+
"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;
|
|
31
31
|
},{}],"Z2N4":[function(require,module,exports) {
|
|
32
32
|
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.SessionRecording=void 0;var e=require("../autocapture-utils"),t=require("../utils"),r=require("../posthog-persistence"),n=o(require("./sessionid")),i=o(require("../config")),s=require("./sessionrecording-utils");function o(e){return e&&e.__esModule?e:{default:e}}function a(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 c(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?a(Object(r),!0).forEach(function(t){b(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):a(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function u(e,t){return h(e)||f(e,t)||l(e,t)||p()}function p(){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 l(e,t){if(e){if("string"==typeof e)return d(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)?d(e,t):void 0}}function d(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 f(e,t){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e)){var r=[],n=!0,i=!1,s=void 0;try{for(var o,a=e[Symbol.iterator]();!(n=(o=a.next()).done)&&(r.push(o.value),!t||r.length!==t);n=!0);}catch(c){i=!0,s=c}finally{try{n||null==a.return||a.return()}finally{if(i)throw s}}return r}}function h(e){if(Array.isArray(e))return e}function b(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function g(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function y(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 _(e,t,r){return t&&y(e.prototype,t),r&&y(e,r),e}var v="/e/",w=function(){function o(e){g(this,o),this.instance=e,this.captureStarted=!1,this.snapshots=[],this.emit=!1,this.endpoint=v,this.stopRrweb=null}return _(o,[{key:"startRecordingIfEnabled",value:function(){this.instance.get_property(r.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(b({},r.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="+i.default.LIB_VERSION,t._.bind(this._onScriptLoaded,this))))}},{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},r=this.instance.get_config("session_recording"),i=0,o=Object.entries(r||{});i<o.length;i++){var a=u(o[i],2),p=a[0],l=a[1];p in t&&(t[p]=l)}this.stopRrweb=window.rrweb.record(c({emit:function(t){t=(0,s.filterDataURLsFromLargeDataObjects)(t);var r=(0,n.default)(e.instance.persistence,t.timestamp);r.isNewSessionId&&-1===[2,4].indexOf(t.type)&&window.rrweb.record.takeFullSnapshot();var i={$snapshot_data:t,$session_id:r.sessionId};e.instance._captureMetrics.incr("rrweb-record"),e.instance._captureMetrics.incr("rrweb-record-".concat(t.type)),e.emit?e._captureSnapshot(i):e.snapshots.push(i)}},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:2===e.$snapshot_data.type}})}}]),o}();exports.SessionRecording=w;
|
|
33
33
|
},{"../autocapture-utils":"RYfg","../utils":"FOZT","../posthog-persistence":"MAdm","./sessionid":"vjIe","../config":"itQ5","./sessionrecording-utils":"vmk3"}],"auG7":[function(require,module,exports) {
|
|
34
34
|
"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=i(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,o=function(){};return{s:o,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},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 i(e,t){if(e){if("string"==typeof e)return o(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)?o(e,t):void 0}}function o(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 i(e){s(this,i),this.instance=e}return c(i,[{key:"call",value:function(){var e=this,n=JSON.stringify({token:this.instance.get_config("token"),distinct_id:this.instance.get_distinct_id()}),r=t._.base64Encode(n);this.instance._send_request("".concat(this.instance.get_config("api_host"),"/decide/?v=2"),{data:r},{method:"POST"},function(t){return e.parseDecideResponse(t)})}},{key:"parseDecideResponse",value:function(t){var i=this;if(!document||!document.body)return console.log("document not ready yet, trying again in 500 milliseconds..."),void setTimeout(function(){i.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 o,s={},a=r(t.supportedCompression);try{for(a.s();!(o=a.n()).done;){s[o.value]=!0}}catch(c){a.e(c)}finally{a.f()}this.instance.compression=s}else this.instance.compression={}}}]),i}();exports.Decide=u;
|
|
35
35
|
},{"./autocapture":"gR3r","./utils":"FOZT","./posthog-featureflags":"aVqC"}],"ZEpJ":[function(require,module,exports) {
|
|
36
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Toolbar=void 0;var e=require("../autocapture-utils"),t=require("../utils");function o(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 r(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?o(Object(r),!0).forEach(function(t){n(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):o(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function n(e,t,o){return t in e?Object.defineProperty(e,t,{value:o,enumerable:!0,configurable:!0,writable:!0}):e[t]=o,e}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){for(var o=0;o<t.length;o++){var r=t[o];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function s(e,t,o){return t&&a(e.prototype,t),o&&a(e,o),e}var c=function(){function o(e){i(this,o),this.instance=e}return s(o,[{key:"afterDecideResponse",value:function(e){var t=e.editorParams||(e.toolbarVersion?{toolbarVersion:e.toolbarVersion}:{});e.isAuthenticated&&t.toolbarVersion&&0===t.toolbarVersion.indexOf("toolbar")&&(this._loadEditor(r(r({},t),{},{apiURL:this.instance.get_config("api_host")})),this.instance.set_config({debug:!0}))}},{key:"maybeLoadEditor",value:function(){var e=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=t._.getHashParam(e.hash,"__posthog")||t._.getHashParam(e.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?e.hash=a.desiredHash:r?r.replaceState("",document.title,e.pathname+e.search):e.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 r=this;if(!window._postHogToolbarLoaded){window._postHogToolbarLoaded=!0;var n=o.jsURL||o.apiURL||this.instance.get_config("api_host"),i=n+(n.endsWith("/")?"":"/")+"static/toolbar.js?_ts="+(new Date).getTime();return(0,e.loadScript)(i,function(){window.ph_load_editor(o)}),t._.register_event(window,"turbolinks:load",function(){window._postHogToolbarLoaded=!1,r._loadEditor(o)}),!0}return!1}}]),o}();exports.Toolbar=c;
|
|
36
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Toolbar=void 0;var e=require("../autocapture-utils"),t=require("../utils");function o(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 r(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?o(Object(r),!0).forEach(function(t){n(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):o(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function n(e,t,o){return t in e?Object.defineProperty(e,t,{value:o,enumerable:!0,configurable:!0,writable:!0}):e[t]=o,e}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){for(var o=0;o<t.length;o++){var r=t[o];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function s(e,t,o){return t&&a(e.prototype,t),o&&a(e,o),e}var c=function(){function o(e){i(this,o),this.instance=e}return s(o,[{key:"afterDecideResponse",value:function(e){var t=e.editorParams||(e.toolbarVersion?{toolbarVersion:e.toolbarVersion}:{});e.isAuthenticated&&t.toolbarVersion&&0===t.toolbarVersion.indexOf("toolbar")&&(this._loadEditor(r(r({},t),{},{apiURL:this.instance.get_config("api_host")})),this.instance.set_config({debug:!0}))}},{key:"maybeLoadEditor",value:function(){var e=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=t._.getHashParam(e.hash,"__posthog")||t._.getHashParam(e.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?e.hash=a.desiredHash:r?r.replaceState("",document.title,e.pathname+e.search):e.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 r=this;if(!window._postHogToolbarLoaded){window._postHogToolbarLoaded=!0;var n=o.jsURL||o.apiURL||this.instance.get_config("api_host"),i=n+(n.endsWith("/")?"":"/")+"static/toolbar.js?_ts="+(new Date).getTime();return(0,e.loadScript)(i,function(){window.ph_load_editor(o,r.instance)}),t._.register_event(window,"turbolinks:load",function(){window._postHogToolbarLoaded=!1,r._loadEditor(o)}),!0}return!1}}]),o}();exports.Toolbar=c;
|
|
37
37
|
},{"../autocapture-utils":"RYfg","../utils":"FOZT"}],"ae0g":[function(require,module,exports) {
|
|
38
38
|
"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;
|
|
39
39
|
},{}],"Je4H":[function(require,module,exports) {
|
|
@@ -49,7 +49,7 @@ module.exports={name:"posthog-js",version:"1.15.1",description:"Posthog-js allow
|
|
|
49
49
|
},{"./utils":"FOZT"}],"ennf":[function(require,module,exports) {
|
|
50
50
|
"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=d();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?v(e):t}function v(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function d(){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;window.navigator.sendBeacon(i,(0,t.encodePostData)(a,o(o({},c),{},{sendBeacon:!0})))}}catch(l){r.e(l)}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;
|
|
51
51
|
},{"./base-request-queue":"ae0g","./send-request":"tOu2"}],"ok3T":[function(require,module,exports) {
|
|
52
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.init_from_snippet=Q,exports.init_as_module=N,exports.PostHogLib=void 0;var e,t,o=require("./lz-string"),r=m(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");function m(e){return e&&e.__esModule?e:{default:e}}function v(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 w(e){for(var t=1;t<arguments.length;t++){var o=null!=arguments[t]?arguments[t]:{};t%2?v(Object(o),!0).forEach(function(t){k(e,t,o[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(o)):v(Object(o)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(o,t))})}return e}function k(e,t,o){return t in e?Object.defineProperty(e,t,{value:o,enumerable:!0,configurable:!0,writable:!0}):e[t]=o,e}function q(e,t){return O(e)||F(e,t)||S(e,t)||P()}function P(){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 S(e,t){if(e){if("string"==typeof e)return x(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)?x(e,t):void 0}}function x(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 F(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 O(e){if(Array.isArray(e))return e}var E=0,H=1,$=function(){},j={},I="posthog",A=i.window.XMLHttpRequest&&"withCredentials"in new XMLHttpRequest,R=!A&&-1===i.userAgent.indexOf("MSIE")&&-1===i.userAgent.indexOf("Mozilla"),D=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,on_xhr_error:function(e){var t="Bad HTTP status: "+e.status+" "+e.statusText;i.console.error(t)},_onCapture:function(){},_capture_metrics:!1}},M=function(){};exports.PostHogLib=M;var L=function(o,a,d){var g,l=d===I?t:t[d];if(l&&e===E)g=l;else{if(l&&!i._.isArray(l))return void i.console.error("You have already initialized "+d);g=new M}if(g._init(o,a,d),g.people=new s.PostHogPeople,g.people._init(g),g.featureFlags=new p.PostHogFeatureFlags(g),g.feature_flags=g.featureFlags,g.toolbar=new u.Toolbar(g),g.toolbar.maybeLoadEditor(),g.sessionRecording=new c.SessionRecording(g),g.sessionRecording.startRecordingIfEnabled(),g.__autocapture_enabled=g.get_config("autocapture"),g.get_config("autocapture")){n.autocapture.enabledForProject(g.get_config("token"),100,100)?n.autocapture.isBrowserSupported()?n.autocapture.init(g):(g.__autocapture_enabled=!1,i.console.log("Disabling Automatic Event Collection because this browser is not supported")):(g.__autocapture_enabled=!1,i.console.log("Not in active bucket: disabling Automatic Event Collection."))}return g.get_config("advanced_disable_decide")||new _.Decide(g).call(),r.default.DEBUG=r.default.DEBUG||g.get_config("debug"),!i._.isUndefined(l)&&i._.isArray(l)&&(g._execute_array.call(g.people,l.people),g._execute_array(l)),g};M.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!==I){var n=L(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")}},M.prototype._init=function(e,t,o){this.__loaded=!0,this.config={},this._triggered_notifs=[],this.compression={},this.set_config(i._.extend({},D(),t,{name:o,token:e,callback_fn:(o===I?o:I+"."+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._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))},M.prototype._loaded=function(){this.get_config("loaded")(this),this._start_queue_if_opted_in(),this.get_config("capture_pageview")&&this.capture("$pageview",{},{send_instantly:!0})},M.prototype._start_queue_if_opted_in=function(){this.has_opted_out_capturing()||this.get_config("request_batching")&&this._requestQueue.poll()},M.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()},M.prototype._prepare_callback=function(e,t){if(i._.isUndefined(e))return null;if(A){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},M.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"})},M.prototype._handle_queued_event=function(e,t,o){var r=JSON.stringify(t);this.__compress_and_send_json_request(e,r,o||j,$)},M.prototype.__compress_and_send_json_request=function(e,t,o,r){var i=q((0,f.compressData)((0,f.decideCompression)(this.compression),t,o),2),n=i[0],s=i[1];this._send_request(e,n,s,r)},M.prototype._send_request=function(e,t,o,r){if(R)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||{}),A||(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)i.window.navigator.sendBeacon(e,(0,y.encodePostData)(t,w(w({},o),{},{sendBeacon:!0})));else if(A)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)}}},M.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)},M.prototype.push=function(e){this._execute_array([e])},M.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||j).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!==j;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}}}),M.prototype._addCaptureHook=function(e){this.__captureHooks.push(e)},M.prototype._invokeCaptureHooks=function(e){this.config._onCapture(e),i._.each(this.__captureHooks,function(t){return t(e)})},M.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))}r=i._.extend({},i._.info.properties(),this.persistence.properties(),r);var p=this.get_config("property_blacklist");i._.isArray(p)?i._.each(p,function(e){delete r[e]}):i.console.error("Invalid value for property_blacklist config: "+p);var a=this.get_config("sanitize_properties");return a&&(r=a(r,e)),r},M.prototype.register=function(e,t){this.persistence.register(e,t)},M.prototype.register_once=function(e,t,o){this.persistence.register_once(e,t,o)},M.prototype.unregister=function(e){this.persistence.unregister(e)},M.prototype._register_single=function(e,t){var o={};o[e]=t,this.register(o)},M.prototype.getFeatureFlag=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return this.featureFlags.getFeatureFlag(e,t)},M.prototype.isFeatureEnabled=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return this.featureFlags.isFeatureEnabled(e,t)},M.prototype.reloadFeatureFlags=function(){return this.featureFlags.reloadFeatureFlags()},M.prototype.onFeatureFlags=function(e){this.featureFlags.addFeatureFlagsHandler(e),e(this.featureFlags.getFlags(),this.featureFlags.getFlagVariants())},M.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||{}}),this.reloadFeatureFlags()}else i.console.error("Unique user id has not been set in posthog.identify")},M.prototype.__group=function(e,t,o){if(i.console.error("posthog.__group is still under development and should not be used in production!"),e&&t){this._captureMetrics.incr("group");var r=this.getGroups();this.register({$groups:w(w({},r),{},k({},e,t))}),this.capture("$group",{distinct_id:this.get_distinct_id(),$group:{type:e,key:t,$set:o}}),this.reloadFeatureFlags()}else i.console.error("posthog.group requires a group type and group key")},M.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},"")},M.prototype.get_distinct_id=function(){return this.get_property("distinct_id")},M.prototype.getGroups=function(){return this.get_property("groups")},M.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)},M.prototype.set_config=function(e){var t=w({},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()))},M.prototype.startSessionRecording=function(){this.set_config({disable_session_recording:!1})},M.prototype.stopSessionRecording=function(){this.set_config({disable_session_recording:!0})},M.prototype.sessionRecordingStarted=function(){return this.sessionRecording.started()},M.prototype.get_config=function(e){return this.config[e]},M.prototype.get_property=function(e){return this.persistence.props[e]},M.prototype.toString=function(){var e=this.get_config("name");return e!==I&&(e=I+"."+e),e},M.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")}))},M.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)},M.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})},M.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)},M.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)},M.prototype.has_opted_in_capturing=function(e){return this._gdpr_call_func(d.hasOptedIn,e)},M.prototype.has_opted_out_capturing=function(e){return this._gdpr_call_func(d.hasOptedOut,e)},M.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)},M.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})}},M.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}))},M.prototype.decodeLZ64=o.LZString.decompressFromBase64,M.prototype.init=M.prototype.init,M.prototype.reset=M.prototype.reset,M.prototype.capture=M.prototype.capture,M.prototype.register=M.prototype.register,M.prototype.register_once=M.prototype.register_once,M.prototype.unregister=M.prototype.unregister,M.prototype.identify=M.prototype.identify,M.prototype.__group=M.prototype.__group,M.prototype.alias=M.prototype.alias,M.prototype.set_config=M.prototype.set_config,M.prototype.get_config=M.prototype.get_config,M.prototype.get_property=M.prototype.get_property,M.prototype.get_distinct_id=M.prototype.get_distinct_id,M.prototype.toString=M.prototype.toString,M.prototype.opt_out_captureing=M.prototype.opt_out_captureing,M.prototype.opt_in_captureing=M.prototype.opt_in_captureing,M.prototype.has_opted_out_captureing=M.prototype.has_opted_out_captureing,M.prototype.has_opted_in_captureing=M.prototype.has_opted_in_captureing,M.prototype.clear_opt_in_out_captureing=M.prototype.clear_opt_in_out_captureing,M.prototype.opt_out_capturing=M.prototype.opt_out_capturing,M.prototype.opt_in_capturing=M.prototype.opt_in_capturing,M.prototype.has_opted_out_capturing=M.prototype.has_opted_out_capturing,M.prototype.has_opted_in_capturing=M.prototype.has_opted_in_capturing,M.prototype.clear_opt_in_out_capturing=M.prototype.clear_opt_in_out_capturing,M.prototype.getFeatureFlag=M.prototype.getFeatureFlag,M.prototype.isFeatureEnabled=M.prototype.isFeatureEnabled,M.prototype.reloadFeatureFlags=M.prototype.reloadFeatureFlags,M.prototype.onFeatureFlags=M.prototype.onFeatureFlags,M.prototype.decodeLZ64=M.prototype.decodeLZ64,M.prototype.SentryIntegration=M.prototype.sentry_integration,M.prototype.debug=M.prototype.debug,M.prototype.LIB_VERSION=r.default.LIB_VERSION,M.prototype.startSessionRecording=M.prototype.startSessionRecording,M.prototype.stopSessionRecording=M.prototype.stopSessionRecording,M.prototype.sessionRecordingStarted=M.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(M,["identify"]);var C={},U=function(){i._.each(C,function(e,o){o!==I&&(t[o]=e)}),t._=i._},T=function(){t.init=function(o,r,n){if(n)return t[n]||(t[n]=C[n]=L(o,r,n),t[n]._loaded()),t[n];var s=t;C[I]?s=C[I]:o&&((s=L(o,r,I))._loaded(),C[I]=s),t=s,e===H&&(i.window[I]=t),U()}},B=function(){function e(){e.done||(e.done=!0,R=!1,i._.each(C,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 Q(){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)&&(C[e[e.length-1]]=L.apply(this,e))}),T(),t.init(),i._.each(C,function(e){e._loaded()}),B())}function N(){return e=E,t=new M,T(),t.init(),B(),t}
|
|
52
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.init_from_snippet=Q,exports.init_as_module=N,exports.PostHogLib=void 0;var e,t,o=require("./lz-string"),r=m(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");function m(e){return e&&e.__esModule?e:{default:e}}function v(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 w(e){for(var t=1;t<arguments.length;t++){var o=null!=arguments[t]?arguments[t]:{};t%2?v(Object(o),!0).forEach(function(t){k(e,t,o[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(o)):v(Object(o)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(o,t))})}return e}function k(e,t,o){return t in e?Object.defineProperty(e,t,{value:o,enumerable:!0,configurable:!0,writable:!0}):e[t]=o,e}function q(e,t){return O(e)||F(e,t)||S(e,t)||P()}function P(){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 S(e,t){if(e){if("string"==typeof e)return x(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)?x(e,t):void 0}}function x(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 F(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 O(e){if(Array.isArray(e))return e}var E=0,$=1,H=function(){},j={},I="posthog",A=i.window.XMLHttpRequest&&"withCredentials"in new XMLHttpRequest,R=!A&&-1===i.userAgent.indexOf("MSIE")&&-1===i.userAgent.indexOf("Mozilla"),D=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,on_xhr_error:function(e){var t="Bad HTTP status: "+e.status+" "+e.statusText;i.console.error(t)},_onCapture:function(){},_capture_metrics:!1}},M=function(){};exports.PostHogLib=M;var L=function(o,a,d){var g,l=d===I?t:t[d];if(l&&e===E)g=l;else{if(l&&!i._.isArray(l))return void i.console.error("You have already initialized "+d);g=new M}if(g._init(o,a,d),g.people=new s.PostHogPeople,g.people._init(g),g.featureFlags=new p.PostHogFeatureFlags(g),g.feature_flags=g.featureFlags,g.toolbar=new u.Toolbar(g),g.toolbar.maybeLoadEditor(),g.sessionRecording=new c.SessionRecording(g),g.sessionRecording.startRecordingIfEnabled(),g.__autocapture_enabled=g.get_config("autocapture"),g.get_config("autocapture")){n.autocapture.enabledForProject(g.get_config("token"),100,100)?n.autocapture.isBrowserSupported()?n.autocapture.init(g):(g.__autocapture_enabled=!1,i.console.log("Disabling Automatic Event Collection because this browser is not supported")):(g.__autocapture_enabled=!1,i.console.log("Not in active bucket: disabling Automatic Event Collection."))}return g.get_config("advanced_disable_decide")||new _.Decide(g).call(),r.default.DEBUG=r.default.DEBUG||g.get_config("debug"),!i._.isUndefined(l)&&i._.isArray(l)&&(g._execute_array.call(g.people,l.people),g._execute_array(l)),g};M.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!==I){var n=L(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")}},M.prototype._init=function(e,t,o){this.__loaded=!0,this.config={},this._triggered_notifs=[],this.compression={},this.set_config(i._.extend({},D(),t,{name:o,token:e,callback_fn:(o===I?o:I+"."+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._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))},M.prototype._loaded=function(){this.get_config("loaded")(this),this._start_queue_if_opted_in(),this.get_config("capture_pageview")&&this.capture("$pageview",{},{send_instantly:!0})},M.prototype._start_queue_if_opted_in=function(){this.has_opted_out_capturing()||this.get_config("request_batching")&&this._requestQueue.poll()},M.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()},M.prototype._prepare_callback=function(e,t){if(i._.isUndefined(e))return null;if(A){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},M.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"})},M.prototype._handle_queued_event=function(e,t,o){var r=JSON.stringify(t);this.__compress_and_send_json_request(e,r,o||j,H)},M.prototype.__compress_and_send_json_request=function(e,t,o,r){var i=q((0,f.compressData)((0,f.decideCompression)(this.compression),t,o),2),n=i[0],s=i[1];this._send_request(e,n,s,r)},M.prototype._send_request=function(e,t,o,r){if(R)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||{}),A||(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)i.window.navigator.sendBeacon(e,(0,y.encodePostData)(t,w(w({},o),{},{sendBeacon:!0})));else if(A)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)}}},M.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)},M.prototype.push=function(e){this._execute_array([e])},M.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||j).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!==j;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}}}),M.prototype._addCaptureHook=function(e){this.__captureHooks.push(e)},M.prototype._invokeCaptureHooks=function(e,t){this.config._onCapture(e,t),i._.each(this.__captureHooks,function(t){return t(e)})},M.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))}r=i._.extend({},i._.info.properties(),this.persistence.properties(),r);var p=this.get_config("property_blacklist");i._.isArray(p)?i._.each(p,function(e){delete r[e]}):i.console.error("Invalid value for property_blacklist config: "+p);var a=this.get_config("sanitize_properties");return a&&(r=a(r,e)),r},M.prototype.register=function(e,t){this.persistence.register(e,t)},M.prototype.register_once=function(e,t,o){this.persistence.register_once(e,t,o)},M.prototype.unregister=function(e){this.persistence.unregister(e)},M.prototype._register_single=function(e,t){var o={};o[e]=t,this.register(o)},M.prototype.getFeatureFlag=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return this.featureFlags.getFeatureFlag(e,t)},M.prototype.isFeatureEnabled=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return this.featureFlags.isFeatureEnabled(e,t)},M.prototype.reloadFeatureFlags=function(){return this.featureFlags.reloadFeatureFlags()},M.prototype.onFeatureFlags=function(e){this.featureFlags.addFeatureFlagsHandler(e),e(this.featureFlags.getFlags(),this.featureFlags.getFlagVariants())},M.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||{}}),this.reloadFeatureFlags()}else i.console.error("Unique user id has not been set in posthog.identify")},M.prototype.group=function(e,t,o){if(e&&t){this._captureMetrics.incr("group");var r=this.getGroups();this.register({$groups:w(w({},r),{},k({},e,t))}),o&&this.capture("$groupidentify",{$group_type:e,$group_key:t,$group_set:o})}else i.console.error("posthog.group requires a group type and group key")},M.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},"")},M.prototype.get_distinct_id=function(){return this.get_property("distinct_id")},M.prototype.getGroups=function(){return this.get_property("$groups")||{}},M.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)},M.prototype.set_config=function(e){var t=w({},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()))},M.prototype.startSessionRecording=function(){this.set_config({disable_session_recording:!1})},M.prototype.stopSessionRecording=function(){this.set_config({disable_session_recording:!0})},M.prototype.sessionRecordingStarted=function(){return this.sessionRecording.started()},M.prototype.get_config=function(e){return this.config[e]},M.prototype.get_property=function(e){return this.persistence.props[e]},M.prototype.toString=function(){var e=this.get_config("name");return e!==I&&(e=I+"."+e),e},M.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")}))},M.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)},M.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})},M.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)},M.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)},M.prototype.has_opted_in_capturing=function(e){return this._gdpr_call_func(d.hasOptedIn,e)},M.prototype.has_opted_out_capturing=function(e){return this._gdpr_call_func(d.hasOptedOut,e)},M.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)},M.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})}},M.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}))},M.prototype.decodeLZ64=o.LZString.decompressFromBase64,M.prototype.init=M.prototype.init,M.prototype.reset=M.prototype.reset,M.prototype.capture=M.prototype.capture,M.prototype.register=M.prototype.register,M.prototype.register_once=M.prototype.register_once,M.prototype.unregister=M.prototype.unregister,M.prototype.identify=M.prototype.identify,M.prototype.group=M.prototype.group,M.prototype.alias=M.prototype.alias,M.prototype.set_config=M.prototype.set_config,M.prototype.get_config=M.prototype.get_config,M.prototype.get_property=M.prototype.get_property,M.prototype.get_distinct_id=M.prototype.get_distinct_id,M.prototype.toString=M.prototype.toString,M.prototype.opt_out_captureing=M.prototype.opt_out_captureing,M.prototype.opt_in_captureing=M.prototype.opt_in_captureing,M.prototype.has_opted_out_captureing=M.prototype.has_opted_out_captureing,M.prototype.has_opted_in_captureing=M.prototype.has_opted_in_captureing,M.prototype.clear_opt_in_out_captureing=M.prototype.clear_opt_in_out_captureing,M.prototype.opt_out_capturing=M.prototype.opt_out_capturing,M.prototype.opt_in_capturing=M.prototype.opt_in_capturing,M.prototype.has_opted_out_capturing=M.prototype.has_opted_out_capturing,M.prototype.has_opted_in_capturing=M.prototype.has_opted_in_capturing,M.prototype.clear_opt_in_out_capturing=M.prototype.clear_opt_in_out_capturing,M.prototype.getFeatureFlag=M.prototype.getFeatureFlag,M.prototype.isFeatureEnabled=M.prototype.isFeatureEnabled,M.prototype.reloadFeatureFlags=M.prototype.reloadFeatureFlags,M.prototype.onFeatureFlags=M.prototype.onFeatureFlags,M.prototype.decodeLZ64=M.prototype.decodeLZ64,M.prototype.SentryIntegration=M.prototype.sentry_integration,M.prototype.debug=M.prototype.debug,M.prototype.LIB_VERSION=r.default.LIB_VERSION,M.prototype.startSessionRecording=M.prototype.startSessionRecording,M.prototype.stopSessionRecording=M.prototype.stopSessionRecording,M.prototype.sessionRecordingStarted=M.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(M,["identify"]);var C={},U=function(){i._.each(C,function(e,o){o!==I&&(t[o]=e)}),t._=i._},T=function(){t.init=function(o,r,n){if(n)return t[n]||(t[n]=C[n]=L(o,r,n),t[n]._loaded()),t[n];var s=t;C[I]?s=C[I]:o&&((s=L(o,r,I))._loaded(),C[I]=s),t=s,e===$&&(i.window[I]=t),U()}},B=function(){function e(){e.done||(e.done=!0,R=!1,i._.each(C,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 Q(){e=$,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)&&(C[e[e.length-1]]=L.apply(this,e))}),T(),t.init(),i._.each(C,function(e){e._loaded()}),B())}function N(){return e=E,t=new M,T(),t.init(),B(),t}
|
|
53
53
|
},{"./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"}],"e2xX":[function(require,module,exports) {
|
|
54
54
|
"use strict";var r=require("./posthog-core");(0,r.init_from_snippet)();
|
|
55
55
|
},{"./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.
|
|
866
|
+
var version = "1.16.0";
|
|
867
867
|
|
|
868
868
|
var Config = {
|
|
869
869
|
DEBUG: false,
|
|
@@ -3536,7 +3536,7 @@ var sessionIdGenerator = (function (persistence, timestamp) {
|
|
|
3536
3536
|
|
|
3537
3537
|
var replacementImageURI = 'data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHZpZXdCb3g9IjAgMCAxNiAxNiIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHJlY3Qgd2lkdGg9IjE2IiBoZWlnaHQ9IjE2IiBmaWxsPSJibGFjayIvPgo8cGF0aCBkPSJNOCAwSDE2TDAgMTZWOEw4IDBaIiBmaWxsPSIjMkQyRDJEIi8+CjxwYXRoIGQ9Ik0xNiA4VjE2SDhMMTYgOFoiIGZpbGw9IiMyRDJEMkQiLz4KPC9zdmc+Cg==';
|
|
3538
3538
|
/*
|
|
3539
|
-
* Check whether a data payload is nearing
|
|
3539
|
+
* Check whether a data payload is nearing 5mb. If it is, it checks the data for
|
|
3540
3540
|
* data URIs (the likely culprit for large payloads). If it finds data URIs, it either replaces
|
|
3541
3541
|
* it with a generic image (if it's an image) or removes it.
|
|
3542
3542
|
* @data {object} the rr-web data object
|
|
@@ -3545,12 +3545,12 @@ var replacementImageURI = 'data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWd
|
|
|
3545
3545
|
|
|
3546
3546
|
function filterDataURLsFromLargeDataObjects(data) {
|
|
3547
3547
|
if (data && _typeof(data) === 'object') {
|
|
3548
|
-
var stringifiedData = JSON.stringify(data); // String length of
|
|
3548
|
+
var stringifiedData = JSON.stringify(data); // String length of 5000000 is an approximation of 5mb
|
|
3549
3549
|
// Note: with compression, this limit may be able to be increased
|
|
3550
3550
|
// but we're assuming most of the size is from a data uri which
|
|
3551
3551
|
// is unlikely to be compressed further
|
|
3552
3552
|
|
|
3553
|
-
if (stringifiedData.length >
|
|
3553
|
+
if (stringifiedData.length > 5000000) {
|
|
3554
3554
|
// Regex that matches the pattern for a dataURI with the shape 'data:{mime type};{encoding},{data}'. It:
|
|
3555
3555
|
// 1) Checks if the pattern starts with 'data:' (potentially, not at the start of the string)
|
|
3556
3556
|
// 2) Extracts the mime type of the data uri in the first group
|
|
@@ -3936,7 +3936,7 @@ var Toolbar = /*#__PURE__*/function () {
|
|
|
3936
3936
|
var toolbarScript = 'toolbar.js';
|
|
3937
3937
|
var editorUrl = host + (host.endsWith('/') ? '' : '/') + 'static/' + toolbarScript + '?_ts=' + new Date().getTime();
|
|
3938
3938
|
loadScript(editorUrl, function () {
|
|
3939
|
-
window['ph_load_editor'](editorParams);
|
|
3939
|
+
window['ph_load_editor'](editorParams, _this.instance);
|
|
3940
3940
|
}); // Turbolinks doesn't fire an onload event but does replace the entire page, including the toolbar
|
|
3941
3941
|
|
|
3942
3942
|
_.register_event(window, 'turbolinks:load', function () {
|
|
@@ -5915,7 +5915,7 @@ PostHogLib.prototype.capture = addOptOutCheckPostHogLib(function (event_name, pr
|
|
|
5915
5915
|
this.__compress_and_send_json_request(url, jsonData, options);
|
|
5916
5916
|
}
|
|
5917
5917
|
|
|
5918
|
-
this._invokeCaptureHooks(event_name);
|
|
5918
|
+
this._invokeCaptureHooks(event_name, data);
|
|
5919
5919
|
|
|
5920
5920
|
return data;
|
|
5921
5921
|
});
|
|
@@ -5924,8 +5924,8 @@ PostHogLib.prototype._addCaptureHook = function (callback) {
|
|
|
5924
5924
|
this.__captureHooks.push(callback);
|
|
5925
5925
|
};
|
|
5926
5926
|
|
|
5927
|
-
PostHogLib.prototype._invokeCaptureHooks = function (eventName) {
|
|
5928
|
-
this.config._onCapture(eventName);
|
|
5927
|
+
PostHogLib.prototype._invokeCaptureHooks = function (eventName, eventData) {
|
|
5928
|
+
this.config._onCapture(eventName, eventData);
|
|
5929
5929
|
|
|
5930
5930
|
_.each(this.__captureHooks, function (callback) {
|
|
5931
5931
|
return callback(eventName);
|
|
@@ -6185,12 +6185,20 @@ PostHogLib.prototype.identify = function (new_distinct_id, userPropertiesToSet,
|
|
|
6185
6185
|
}
|
|
6186
6186
|
|
|
6187
6187
|
this.reloadFeatureFlags();
|
|
6188
|
-
};
|
|
6189
|
-
|
|
6188
|
+
};
|
|
6189
|
+
/**
|
|
6190
|
+
* Alpha feature: don't use unless you know what you're doing!
|
|
6191
|
+
*
|
|
6192
|
+
* Sets group analytics information for subsequent events.
|
|
6193
|
+
*
|
|
6194
|
+
* @param {String} groupType Group type (example: 'organization')
|
|
6195
|
+
* @param {String} groupKey Group key (example: 'org::5')
|
|
6196
|
+
* @param {Object} groupPropertiesToSet Optional properties to set for group
|
|
6197
|
+
*/
|
|
6190
6198
|
|
|
6191
|
-
PostHogLib.prototype.__group = function (groupType, groupKey, groupPropertiesToSet) {
|
|
6192
|
-
console$1.error('posthog.__group is still under development and should not be used in production!');
|
|
6193
6199
|
|
|
6200
|
+
PostHogLib.prototype.group = function (groupType, groupKey, groupPropertiesToSet) {
|
|
6201
|
+
// console.error('posthog.group is still under development and should not be used in production!')
|
|
6194
6202
|
if (!groupType || !groupKey) {
|
|
6195
6203
|
console$1.error('posthog.group requires a group type and group key');
|
|
6196
6204
|
return;
|
|
@@ -6202,15 +6210,14 @@ PostHogLib.prototype.__group = function (groupType, groupKey, groupPropertiesToS
|
|
|
6202
6210
|
this.register({
|
|
6203
6211
|
$groups: _objectSpread2(_objectSpread2({}, existingGroups), {}, _defineProperty({}, groupType, groupKey))
|
|
6204
6212
|
});
|
|
6205
|
-
|
|
6206
|
-
|
|
6207
|
-
$
|
|
6208
|
-
|
|
6209
|
-
|
|
6210
|
-
$
|
|
6211
|
-
}
|
|
6212
|
-
}
|
|
6213
|
-
this.reloadFeatureFlags();
|
|
6213
|
+
|
|
6214
|
+
if (groupPropertiesToSet) {
|
|
6215
|
+
this.capture('$groupidentify', {
|
|
6216
|
+
$group_type: groupType,
|
|
6217
|
+
$group_key: groupKey,
|
|
6218
|
+
$group_set: groupPropertiesToSet
|
|
6219
|
+
});
|
|
6220
|
+
}
|
|
6214
6221
|
};
|
|
6215
6222
|
/**
|
|
6216
6223
|
* Clears super properties and generates a new random distinct_id for this instance.
|
|
@@ -6252,7 +6259,7 @@ PostHogLib.prototype.get_distinct_id = function () {
|
|
|
6252
6259
|
};
|
|
6253
6260
|
|
|
6254
6261
|
PostHogLib.prototype.getGroups = function () {
|
|
6255
|
-
return this.get_property('groups');
|
|
6262
|
+
return this.get_property('$groups') || {};
|
|
6256
6263
|
};
|
|
6257
6264
|
/**
|
|
6258
6265
|
* Create an alias, which PostHog will use to link two distinct_ids going forward (not retroactively).
|
|
@@ -6843,7 +6850,7 @@ PostHogLib.prototype['register'] = PostHogLib.prototype.register;
|
|
|
6843
6850
|
PostHogLib.prototype['register_once'] = PostHogLib.prototype.register_once;
|
|
6844
6851
|
PostHogLib.prototype['unregister'] = PostHogLib.prototype.unregister;
|
|
6845
6852
|
PostHogLib.prototype['identify'] = PostHogLib.prototype.identify;
|
|
6846
|
-
PostHogLib.prototype['
|
|
6853
|
+
PostHogLib.prototype['group'] = PostHogLib.prototype.group;
|
|
6847
6854
|
PostHogLib.prototype['alias'] = PostHogLib.prototype.alias;
|
|
6848
6855
|
PostHogLib.prototype['set_config'] = PostHogLib.prototype.set_config;
|
|
6849
6856
|
PostHogLib.prototype['get_config'] = PostHogLib.prototype.get_config;
|
package/dist/module.d.ts
CHANGED
|
@@ -166,6 +166,17 @@ declare class posthog {
|
|
|
166
166
|
*/
|
|
167
167
|
static alias(alias: string, original?: string): posthog.CaptureResult | number
|
|
168
168
|
|
|
169
|
+
/**
|
|
170
|
+
* Alpha feature: don't use unless you know what you're doing!
|
|
171
|
+
*
|
|
172
|
+
* Sets group analytics information for subsequent events.
|
|
173
|
+
*
|
|
174
|
+
* @param {String} groupType Group type (example: 'organization')
|
|
175
|
+
* @param {String} groupKey Group key (example: 'org::5')
|
|
176
|
+
* @param {Object} groupPropertiesToSet Optional properties to set for group
|
|
177
|
+
*/
|
|
178
|
+
static group(groupType: string, groupKey: string, groupPropertiesToSet?: posthog.Properties): void
|
|
179
|
+
|
|
169
180
|
/**
|
|
170
181
|
* Update the configuration of a posthog library instance.
|
|
171
182
|
*
|
|
@@ -559,7 +570,7 @@ declare namespace posthog {
|
|
|
559
570
|
rageclick?: boolean
|
|
560
571
|
cdn?: string
|
|
561
572
|
cross_subdomain_cookie?: boolean
|
|
562
|
-
persistence?: 'localStorage' | 'cookie' | 'memory'
|
|
573
|
+
persistence?: 'localStorage' | 'cookie' | 'memory' | 'localStorage+cookie'
|
|
563
574
|
persistence_name?: string
|
|
564
575
|
cookie_name?: string
|
|
565
576
|
loaded?: (posthog_instance: typeof posthog) => void
|
package/dist/module.js
CHANGED
|
@@ -865,7 +865,7 @@ var LZString = {
|
|
|
865
865
|
}
|
|
866
866
|
};
|
|
867
867
|
|
|
868
|
-
var version = "1.
|
|
868
|
+
var version = "1.16.0";
|
|
869
869
|
|
|
870
870
|
var Config = {
|
|
871
871
|
DEBUG: false,
|
|
@@ -3538,7 +3538,7 @@ var sessionIdGenerator = (function (persistence, timestamp) {
|
|
|
3538
3538
|
|
|
3539
3539
|
var replacementImageURI = 'data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHZpZXdCb3g9IjAgMCAxNiAxNiIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHJlY3Qgd2lkdGg9IjE2IiBoZWlnaHQ9IjE2IiBmaWxsPSJibGFjayIvPgo8cGF0aCBkPSJNOCAwSDE2TDAgMTZWOEw4IDBaIiBmaWxsPSIjMkQyRDJEIi8+CjxwYXRoIGQ9Ik0xNiA4VjE2SDhMMTYgOFoiIGZpbGw9IiMyRDJEMkQiLz4KPC9zdmc+Cg==';
|
|
3540
3540
|
/*
|
|
3541
|
-
* Check whether a data payload is nearing
|
|
3541
|
+
* Check whether a data payload is nearing 5mb. If it is, it checks the data for
|
|
3542
3542
|
* data URIs (the likely culprit for large payloads). If it finds data URIs, it either replaces
|
|
3543
3543
|
* it with a generic image (if it's an image) or removes it.
|
|
3544
3544
|
* @data {object} the rr-web data object
|
|
@@ -3547,12 +3547,12 @@ var replacementImageURI = 'data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWd
|
|
|
3547
3547
|
|
|
3548
3548
|
function filterDataURLsFromLargeDataObjects(data) {
|
|
3549
3549
|
if (data && _typeof(data) === 'object') {
|
|
3550
|
-
var stringifiedData = JSON.stringify(data); // String length of
|
|
3550
|
+
var stringifiedData = JSON.stringify(data); // String length of 5000000 is an approximation of 5mb
|
|
3551
3551
|
// Note: with compression, this limit may be able to be increased
|
|
3552
3552
|
// but we're assuming most of the size is from a data uri which
|
|
3553
3553
|
// is unlikely to be compressed further
|
|
3554
3554
|
|
|
3555
|
-
if (stringifiedData.length >
|
|
3555
|
+
if (stringifiedData.length > 5000000) {
|
|
3556
3556
|
// Regex that matches the pattern for a dataURI with the shape 'data:{mime type};{encoding},{data}'. It:
|
|
3557
3557
|
// 1) Checks if the pattern starts with 'data:' (potentially, not at the start of the string)
|
|
3558
3558
|
// 2) Extracts the mime type of the data uri in the first group
|
|
@@ -3938,7 +3938,7 @@ var Toolbar = /*#__PURE__*/function () {
|
|
|
3938
3938
|
var toolbarScript = 'toolbar.js';
|
|
3939
3939
|
var editorUrl = host + (host.endsWith('/') ? '' : '/') + 'static/' + toolbarScript + '?_ts=' + new Date().getTime();
|
|
3940
3940
|
loadScript(editorUrl, function () {
|
|
3941
|
-
window['ph_load_editor'](editorParams);
|
|
3941
|
+
window['ph_load_editor'](editorParams, _this.instance);
|
|
3942
3942
|
}); // Turbolinks doesn't fire an onload event but does replace the entire page, including the toolbar
|
|
3943
3943
|
|
|
3944
3944
|
_.register_event(window, 'turbolinks:load', function () {
|
|
@@ -5917,7 +5917,7 @@ PostHogLib.prototype.capture = addOptOutCheckPostHogLib(function (event_name, pr
|
|
|
5917
5917
|
this.__compress_and_send_json_request(url, jsonData, options);
|
|
5918
5918
|
}
|
|
5919
5919
|
|
|
5920
|
-
this._invokeCaptureHooks(event_name);
|
|
5920
|
+
this._invokeCaptureHooks(event_name, data);
|
|
5921
5921
|
|
|
5922
5922
|
return data;
|
|
5923
5923
|
});
|
|
@@ -5926,8 +5926,8 @@ PostHogLib.prototype._addCaptureHook = function (callback) {
|
|
|
5926
5926
|
this.__captureHooks.push(callback);
|
|
5927
5927
|
};
|
|
5928
5928
|
|
|
5929
|
-
PostHogLib.prototype._invokeCaptureHooks = function (eventName) {
|
|
5930
|
-
this.config._onCapture(eventName);
|
|
5929
|
+
PostHogLib.prototype._invokeCaptureHooks = function (eventName, eventData) {
|
|
5930
|
+
this.config._onCapture(eventName, eventData);
|
|
5931
5931
|
|
|
5932
5932
|
_.each(this.__captureHooks, function (callback) {
|
|
5933
5933
|
return callback(eventName);
|
|
@@ -6187,12 +6187,20 @@ PostHogLib.prototype.identify = function (new_distinct_id, userPropertiesToSet,
|
|
|
6187
6187
|
}
|
|
6188
6188
|
|
|
6189
6189
|
this.reloadFeatureFlags();
|
|
6190
|
-
};
|
|
6191
|
-
|
|
6190
|
+
};
|
|
6191
|
+
/**
|
|
6192
|
+
* Alpha feature: don't use unless you know what you're doing!
|
|
6193
|
+
*
|
|
6194
|
+
* Sets group analytics information for subsequent events.
|
|
6195
|
+
*
|
|
6196
|
+
* @param {String} groupType Group type (example: 'organization')
|
|
6197
|
+
* @param {String} groupKey Group key (example: 'org::5')
|
|
6198
|
+
* @param {Object} groupPropertiesToSet Optional properties to set for group
|
|
6199
|
+
*/
|
|
6192
6200
|
|
|
6193
|
-
PostHogLib.prototype.__group = function (groupType, groupKey, groupPropertiesToSet) {
|
|
6194
|
-
console$1.error('posthog.__group is still under development and should not be used in production!');
|
|
6195
6201
|
|
|
6202
|
+
PostHogLib.prototype.group = function (groupType, groupKey, groupPropertiesToSet) {
|
|
6203
|
+
// console.error('posthog.group is still under development and should not be used in production!')
|
|
6196
6204
|
if (!groupType || !groupKey) {
|
|
6197
6205
|
console$1.error('posthog.group requires a group type and group key');
|
|
6198
6206
|
return;
|
|
@@ -6204,15 +6212,14 @@ PostHogLib.prototype.__group = function (groupType, groupKey, groupPropertiesToS
|
|
|
6204
6212
|
this.register({
|
|
6205
6213
|
$groups: _objectSpread2(_objectSpread2({}, existingGroups), {}, _defineProperty({}, groupType, groupKey))
|
|
6206
6214
|
});
|
|
6207
|
-
|
|
6208
|
-
|
|
6209
|
-
$
|
|
6210
|
-
|
|
6211
|
-
|
|
6212
|
-
$
|
|
6213
|
-
}
|
|
6214
|
-
}
|
|
6215
|
-
this.reloadFeatureFlags();
|
|
6215
|
+
|
|
6216
|
+
if (groupPropertiesToSet) {
|
|
6217
|
+
this.capture('$groupidentify', {
|
|
6218
|
+
$group_type: groupType,
|
|
6219
|
+
$group_key: groupKey,
|
|
6220
|
+
$group_set: groupPropertiesToSet
|
|
6221
|
+
});
|
|
6222
|
+
}
|
|
6216
6223
|
};
|
|
6217
6224
|
/**
|
|
6218
6225
|
* Clears super properties and generates a new random distinct_id for this instance.
|
|
@@ -6254,7 +6261,7 @@ PostHogLib.prototype.get_distinct_id = function () {
|
|
|
6254
6261
|
};
|
|
6255
6262
|
|
|
6256
6263
|
PostHogLib.prototype.getGroups = function () {
|
|
6257
|
-
return this.get_property('groups');
|
|
6264
|
+
return this.get_property('$groups') || {};
|
|
6258
6265
|
};
|
|
6259
6266
|
/**
|
|
6260
6267
|
* Create an alias, which PostHog will use to link two distinct_ids going forward (not retroactively).
|
|
@@ -6845,7 +6852,7 @@ PostHogLib.prototype['register'] = PostHogLib.prototype.register;
|
|
|
6845
6852
|
PostHogLib.prototype['register_once'] = PostHogLib.prototype.register_once;
|
|
6846
6853
|
PostHogLib.prototype['unregister'] = PostHogLib.prototype.unregister;
|
|
6847
6854
|
PostHogLib.prototype['identify'] = PostHogLib.prototype.identify;
|
|
6848
|
-
PostHogLib.prototype['
|
|
6855
|
+
PostHogLib.prototype['group'] = PostHogLib.prototype.group;
|
|
6849
6856
|
PostHogLib.prototype['alias'] = PostHogLib.prototype.alias;
|
|
6850
6857
|
PostHogLib.prototype['set_config'] = PostHogLib.prototype.set_config;
|
|
6851
6858
|
PostHogLib.prototype['get_config'] = PostHogLib.prototype.get_config;
|
package/package.json
CHANGED