posthog-js 1.13.14 → 1.14.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 +25 -0
- package/README.md +28 -3
- package/dist/array.js +8 -8
- package/dist/es.js +86 -49
- package/dist/module.d.ts +25 -10
- package/dist/module.js +86 -49
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,28 @@
|
|
|
1
|
+
## 1.14.0 - 2021-10-05
|
|
2
|
+
|
|
3
|
+
- Bump build and a readme change (#306)
|
|
4
|
+
- Add posthog.people.increment (#254)
|
|
5
|
+
- Send initial pageview immediately (#295)
|
|
6
|
+
- add a test for init-ing and reading the on xhr error handler (#308)
|
|
7
|
+
|
|
8
|
+
## 1.13.17 - 2021-10-04
|
|
9
|
+
|
|
10
|
+
- corrects exported type which got out of sync with core.js file (#307)
|
|
11
|
+
|
|
12
|
+
## 1.13.16 - 2021-10-04
|
|
13
|
+
|
|
14
|
+
- Allow injection from config of a function to call when xhr requests fail (#296)
|
|
15
|
+
- add instructions for developing with Yalc (#303)
|
|
16
|
+
- Revert "Speculative logging for PostHog/posthog#4816 (#293)" (#302)
|
|
17
|
+
- Filter out _ngcontent attributes in autocapture (#298)
|
|
18
|
+
- corrects a test where assertion and setup didn't match test name (#299)
|
|
19
|
+
|
|
20
|
+
## 1.13.15 - 2021-09-29
|
|
21
|
+
|
|
22
|
+
- Speculative logging for PostHog/posthog#4816 (#293)
|
|
23
|
+
- Bump tmpl from 1.0.4 to 1.0.5 in /react (#287)
|
|
24
|
+
- Bump ansi-regex from 5.0.0 to 5.0.1 in /react (#294)
|
|
25
|
+
|
|
1
26
|
## 1.13.14 - 2021-09-28
|
|
2
27
|
|
|
3
28
|
- Revert "Trigger onFeatureFlags on reset (#263)" (#292)
|
package/README.md
CHANGED
|
@@ -23,13 +23,12 @@ Testing on IE11 requires a bit more setup.
|
|
|
23
23
|
|
|
24
24
|
## Developing together with another repo
|
|
25
25
|
|
|
26
|
-
|
|
26
|
+
### Using Yarn link
|
|
27
27
|
Use [`yarn link`](https://classic.yarnpkg.com/en/docs/cli/link/). Run `yarn link` in `posthog-js`, and then `yarn link posthog-js` in `posthog`. Once you're done, remember to `yarn unlink posthog-js` in `posthog`, and `yarn unlink` in `posthog-js`.
|
|
28
28
|
|
|
29
29
|
An alternative is to update dependency in package.json to e.g. `"posthog-js": "link:../posthog-js"`, `yarn` and run `yarn build && yarn build-module`
|
|
30
30
|
|
|
31
|
-
|
|
32
|
-
### Developing with main PostHog repo
|
|
31
|
+
#### Developing with main PostHog repo
|
|
33
32
|
|
|
34
33
|
The `posthog-js` snippet for a website loads static js from the main `PostHog/posthog` repo. Which means, when testing the snippet with a website, there's a bit of extra setup required:
|
|
35
34
|
|
|
@@ -40,6 +39,32 @@ The `posthog-js` snippet for a website loads static js from the main `PostHog/po
|
|
|
40
39
|
|
|
41
40
|
Further, it's a good idea to modify `start-http` script to add development mode: `webpack serve --mode development`, which doesn't minify the resulting js (which you can then read in your browser).
|
|
42
41
|
|
|
42
|
+
### Using Yalc (Alternative to yarn link)
|
|
43
|
+
|
|
44
|
+
Run `npm install -g yalc`
|
|
45
|
+
|
|
46
|
+
* In the posthog-js repo
|
|
47
|
+
* run `yalc publish`
|
|
48
|
+
* In the posthog repo
|
|
49
|
+
* run `yalc add posthog-js`
|
|
50
|
+
* run `yarn`
|
|
51
|
+
* run `yarn copy-scripts`
|
|
52
|
+
|
|
53
|
+
#### When making changes
|
|
54
|
+
|
|
55
|
+
* In the posthog-js repo
|
|
56
|
+
* run `yalc publish`
|
|
57
|
+
* In the posthog repo
|
|
58
|
+
* run `yalc update`
|
|
59
|
+
* run `yarn`
|
|
60
|
+
* run `yarn copy-scripts`
|
|
61
|
+
|
|
62
|
+
#### To remove the local package
|
|
63
|
+
|
|
64
|
+
* In the posthog repo
|
|
65
|
+
* run `yalc remove posthog-js`
|
|
66
|
+
* run `yarn install`
|
|
67
|
+
|
|
43
68
|
|
|
44
69
|
## Releasing a new version
|
|
45
70
|
|
package/dist/array.js
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
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.14.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",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/"],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) {
|
|
8
8
|
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.COPY_IN_PROGRESS_ATTRIBUTE=exports.document=exports.console=exports.userAgent=exports._=exports.window=void 0;var e=n(require("./config"));function n(e){return e&&e.__esModule?e:{default:e}}var r=Array.prototype,o=Function.prototype,t=Object.prototype,i=r.slice,c=t.toString,a=t.hasOwnProperty,s="undefined"!=typeof window?window:{},u=s.navigator||{userAgent:""},d=s.document||{},l=u.userAgent;exports.userAgent=l,exports.document=d,exports.window=s;var f=o.bind,p=r.forEach,h=r.indexOf,w=Array.isArray,g={},v={trim:function(e){return e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"")}};exports._=v;var b={log:function(){if(e.default.DEBUG&&!v.isUndefined(window.console)&&window.console)try{window.console.log.apply(window.console,arguments)}catch(n){v.each(arguments,function(e){window.console.log(e)})}},error:function(){if(e.default.DEBUG&&!v.isUndefined(window.console)&&window.console){var n=["PostHog error:"].concat(Array.prototype.slice.call(arguments));try{window.console.error.apply(window.console,n)}catch(r){v.each(n,function(e){window.console.error(e)})}}},critical:function(){if(!v.isUndefined(window.console)&&window.console){var e=["PostHog error:"].concat(Array.prototype.slice.call(arguments));try{window.console.error.apply(window.console,e)}catch(n){v.each(e,function(e){window.console.error(e)})}}}};exports.console=b,v.bind=function(e,n){var r,o;if(f&&e.bind===f)return f.apply(e,i.call(arguments,1));if(!v.isFunction(e))throw new TypeError;return r=i.call(arguments,2),o=function(){if(!(this instanceof o))return e.apply(n,r.concat(i.call(arguments)));var t={};t.prototype=e.prototype;var c=new t;t.prototype=null;var a=e.apply(c,r.concat(i.call(arguments)));return Object(a)===a?a:c}},v.bind_instance_methods=function(e){for(var n in e)"function"==typeof e[n]&&(e[n]=v.bind(e[n],e))},v.each=function(e,n,r){if(null!=e)if(p&&e.forEach===p)e.forEach(n,r);else if(e.length===+e.length){for(var o=0,t=e.length;o<t;o++)if(o in e&&n.call(r,e[o],o,e)===g)return}else for(var i in e)if(a.call(e,i)&&n.call(r,e[i],i,e)===g)return},v.extend=function(e){return v.each(i.call(arguments,1),function(n){for(var r in n)void 0!==n[r]&&(e[r]=n[r])}),e},v.isArray=w||function(e){return"[object Array]"===c.call(e)},v.isFunction=function(e){try{return/^\s*\bfunction\b/.test(e)}catch(n){return!1}},v.include=function(e,n){var r=!1;return null===e?r:h&&e.indexOf===h?-1!=e.indexOf(n):(v.each(e,function(e){if(r||(r=e===n))return g}),r)},v.includes=function(e,n){return-1!==e.indexOf(n)},v.isObject=function(e){return e===Object(e)&&!v.isArray(e)},v.isEmptyObject=function(e){if(v.isObject(e)){for(var n in e)if(a.call(e,n))return!1;return!0}return!1},v.isUndefined=function(e){return void 0===e},v.isString=function(e){return"[object String]"==c.call(e)},v.isDate=function(e){return"[object Date]"==c.call(e)},v.isNumber=function(e){return"[object Number]"==c.call(e)},v.encodeDates=function(e){return v.each(e,function(n,r){v.isDate(n)?e[r]=v.formatDate(n):v.isObject(n)&&(e[r]=v.encodeDates(n))}),e},v.timestamp=function(){return Date.now=Date.now||function(){return+new Date},Date.now()},v.formatDate=function(e){function n(e){return e<10?"0"+e:e}return e.getUTCFullYear()+"-"+n(e.getUTCMonth()+1)+"-"+n(e.getUTCDate())+"T"+n(e.getUTCHours())+":"+n(e.getUTCMinutes())+":"+n(e.getUTCSeconds())},v.safewrap=function(n){return function(){try{return n.apply(this,arguments)}catch(r){b.critical("Implementation error. Please turn on debug and contact support@posthog.com."),e.default.DEBUG&&b.critical(r)}}},v.safewrap_class=function(e,n){for(var r=0;r<n.length;r++)e.prototype[n[r]]=v.safewrap(e.prototype[n[r]])},v.safewrap_instance_methods=function(e){for(var n in e)"function"==typeof e[n]&&(e[n]=v.safewrap(e[n]))},v.strip_empty_properties=function(e){var n={};return v.each(e,function(e,r){v.isString(e)&&e.length>0&&(n[r]=e)}),n};var y="undefined"!=typeof Symbol?Symbol("__deepCircularCopyInProgress__"):"__deepCircularCopyInProgress__";function m(e,n){return e!==Object(e)?n?n(e):e:e[y]?void 0:(e[y]=!0,v.isArray(e)?(r=[],v.each(e,function(e){r.push(m(e,n))})):(r={},v.each(e,function(e,o){o!==y&&(r[o]=m(e,n))})),delete e[y],r);var r}exports.COPY_IN_PROGRESS_ATTRIBUTE=y,v.copyAndTruncateStrings=function(e,n){return m(e,function(e){return"string"==typeof e&&null!==n&&(e=e.slice(0,n)),e},{})},v.base64Encode=function(e){var n,r,o,t,i,c="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",a=0,s=0,u="",d=[];if(!e)return e;e=v.utf8Encode(e);do{n=(i=e.charCodeAt(a++)<<16|e.charCodeAt(a++)<<8|e.charCodeAt(a++))>>18&63,r=i>>12&63,o=i>>6&63,t=63&i,d[s++]=c.charAt(n)+c.charAt(r)+c.charAt(o)+c.charAt(t)}while(a<e.length);switch(u=d.join(""),e.length%3){case 1:u=u.slice(0,-2)+"==";break;case 2:u=u.slice(0,-1)+"="}return u},v.utf8Encode=function(e){var n,r,o,t,i="";for(n=r=0,o=(e=(e+"").replace(/\r\n/g,"\n").replace(/\r/g,"\n")).length,t=0;t<o;t++){var c=e.charCodeAt(t),a=null;c<128?r++:a=c>127&&c<2048?String.fromCharCode(c>>6|192,63&c|128):String.fromCharCode(c>>12|224,c>>6&63|128,63&c|128),null!==a&&(r>n&&(i+=e.substring(n,r)),i+=a,n=r=t+1)}return r>n&&(i+=e.substring(n,e.length)),i},v.UUID=function(){var e=function(){for(var e=1*new Date,n=0;e==1*new Date;)n++;return e.toString(16)+n.toString(16)};return function(){var n=(window.screen.height*window.screen.width).toString(16);return e()+"-"+Math.random().toString(16).replace(".","")+"-"+function(){var e,n,r=l,o=[],t=0;function i(e,n){var r,t=0;for(r=0;r<n.length;r++)t|=o[r]<<8*r;return e^t}for(e=0;e<r.length;e++)n=r.charCodeAt(e),o.unshift(255&n),o.length>=4&&(t=i(t,o),o=[]);return o.length>0&&(t=i(t,o)),t.toString(16)}()+"-"+n+"-"+e()}}(),v.isBlockedUA=function(e){return!!/(google web preview|baiduspider|yandexbot|bingbot|googlebot|yahoo! slurp)/i.test(e)},v.HTTPBuildQuery=function(e,n){var r,o,t=[];return v.isUndefined(n)&&(n="&"),v.each(e,function(e,n){r=encodeURIComponent(e.toString()),o=encodeURIComponent(n),t[t.length]=o+"="+r}),t.join(n)},v.getQueryParam=function(e,n){n=n.replace(/[[]/,"\\[").replace(/[\]]/,"\\]");var r=new RegExp("[\\?&]"+n+"=([^&#]*)").exec(e);if(null===r||r&&"string"!=typeof r[1]&&r[1].length)return"";var o=r[1];try{o=decodeURIComponent(o)}catch(t){b.error("Skipping decoding for malformed query param: "+o)}return o.replace(/\+/g," ")},v.getHashParam=function(e,n){var r=e.match(new RegExp(n+"=([^&]*)"));return r?r[1]:null},v.register_event=function(){function e(n){return n&&(n.preventDefault=e.preventDefault,n.stopPropagation=e.stopPropagation),n}return e.preventDefault=function(){this.returnValue=!1},e.stopPropagation=function(){this.cancelBubble=!0},function(n,r,o,t,i){if(n)if(n.addEventListener&&!t)n.addEventListener(r,o,!!i);else{var c="on"+r,a=n[c];n[c]=function(n,r,o){return function(t){if(t=t||e(window.event)){var i,c,a=!0;return v.isFunction(o)&&(i=o(t)),c=r.call(n,t),!1!==i&&!1!==c||(a=!1),a}}}(n,o,a)}else b.error("No valid element provided to register_event")}}(),v.info={campaignParams:function(){var e="utm_source utm_medium utm_campaign utm_content utm_term gclid".split(" "),n="",r={};return v.each(e,function(e){(n=v.getQueryParam(d.URL,e)).length&&(r[e]=n)}),r},searchEngine:function(e){return 0===e.search("https?://(.*)google.([^/?]*)")?"google":0===e.search("https?://(.*)bing.com")?"bing":0===e.search("https?://(.*)yahoo.com")?"yahoo":0===e.search("https?://(.*)duckduckgo.com")?"duckduckgo":null},searchInfo:function(e){var n=v.info.searchEngine(e),r="yahoo"!=n?"q":"p",o={};if(null!==n){o.$search_engine=n;var t=v.getQueryParam(e,r);t.length&&(o.ph_keyword=t)}return o},browser:function(e,n,r){return n=n||"",r||v.includes(e," OPR/")?v.includes(e,"Mini")?"Opera Mini":"Opera":/(BlackBerry|PlayBook|BB10)/i.test(e)?"BlackBerry":v.includes(e,"IEMobile")||v.includes(e,"WPDesktop")?"Internet Explorer Mobile":v.includes(e,"SamsungBrowser/")?"Samsung Internet":v.includes(e,"Edge")||v.includes(e,"Edg/")?"Microsoft Edge":v.includes(e,"FBIOS")?"Facebook Mobile":v.includes(e,"Chrome")?"Chrome":v.includes(e,"CriOS")?"Chrome iOS":v.includes(e,"UCWEB")||v.includes(e,"UCBrowser")?"UC Browser":v.includes(e,"FxiOS")?"Firefox iOS":v.includes(n,"Apple")?v.includes(e,"Mobile")?"Mobile Safari":"Safari":v.includes(e,"Android")?"Android Mobile":v.includes(e,"Konqueror")?"Konqueror":v.includes(e,"Firefox")?"Firefox":v.includes(e,"MSIE")||v.includes(e,"Trident/")?"Internet Explorer":v.includes(e,"Gecko")?"Mozilla":""},browserVersion:function(e,n,r){var o={"Internet Explorer Mobile":/rv:(\d+(\.\d+)?)/,"Microsoft Edge":/Edge?\/(\d+(\.\d+)?)/,Chrome:/Chrome\/(\d+(\.\d+)?)/,"Chrome iOS":/CriOS\/(\d+(\.\d+)?)/,"UC Browser":/(UCBrowser|UCWEB)\/(\d+(\.\d+)?)/,Safari:/Version\/(\d+(\.\d+)?)/,"Mobile Safari":/Version\/(\d+(\.\d+)?)/,Opera:/(Opera|OPR)\/(\d+(\.\d+)?)/,Firefox:/Firefox\/(\d+(\.\d+)?)/,"Firefox iOS":/FxiOS\/(\d+(\.\d+)?)/,Konqueror:/Konqueror:(\d+(\.\d+)?)/,BlackBerry:/BlackBerry (\d+(\.\d+)?)/,"Android Mobile":/android\s(\d+(\.\d+)?)/,"Samsung Internet":/SamsungBrowser\/(\d+(\.\d+)?)/,"Internet Explorer":/(rv:|MSIE )(\d+(\.\d+)?)/,Mozilla:/rv:(\d+(\.\d+)?)/}[v.info.browser(e,n,r)];if(void 0===o)return null;var t=e.match(o);return t?parseFloat(t[t.length-2]):null},os:function(){var e=l;return/Windows/i.test(e)?/Phone/.test(e)||/WPDesktop/.test(e)?"Windows Phone":"Windows":/(iPhone|iPad|iPod)/.test(e)?"iOS":/Android/.test(e)?"Android":/(BlackBerry|PlayBook|BB10)/i.test(e)?"BlackBerry":/Mac/i.test(e)?"Mac OS X":/Linux/.test(e)?"Linux":/CrOS/.test(e)?"Chrome OS":""},device:function(e){return/Windows Phone/i.test(e)||/WPDesktop/.test(e)?"Windows Phone":/iPad/.test(e)?"iPad":/iPod/.test(e)?"iPod Touch":/iPhone/.test(e)?"iPhone":/(BlackBerry|PlayBook|BB10)/i.test(e)?"BlackBerry":/Android/.test(e)&&!/Mobile/.test(e)?"Android Tablet":/Android/.test(e)?"Android":""},deviceType:function(e){var n=this.device(e);return"iPad"===n||"Android Tablet"===n?"Tablet":n?"Mobile":"Desktop"},referringDomain:function(e){var n=e.split("/");return n.length>=3?n[2]:""},properties:function(){return v.extend(v.strip_empty_properties({$os:v.info.os(),$browser:v.info.browser(l,u.vendor,window.opera),$device:v.info.device(l),$device_type:v.info.deviceType(l)}),{$current_url:window.location.href,$host:window.location.host,$pathname:window.location.pathname,$browser_version:v.info.browserVersion(l,u.vendor,window.opera),$screen_height:window.screen.height,$screen_width:window.screen.width,$viewport_height:window.innerHeight,$viewport_width:window.innerWidth,$lib:"web",$lib_version:e.default.LIB_VERSION,$insert_id:Math.random().toString(36).substring(2,10)+Math.random().toString(36).substring(2,10),$time:v.timestamp()/1e3})},people_properties:function(){return v.extend(v.strip_empty_properties({$os:v.info.os(),$browser:v.info.browser(l,u.vendor,window.opera)}),{$browser_version:v.info.browserVersion(l,u.vendor,window.opera)})}},v.isObject=v.isObject,v.isBlockedUA=v.isBlockedUA,v.isEmptyObject=v.isEmptyObject,v.info=v.info,v.info.device=v.info.device,v.info.browser=v.info.browser,v.info.browserVersion=v.info.browserVersion,v.info.properties=v.info.properties;
|
|
9
9
|
},{"./config":"itQ5"}],"RYfg":[function(require,module,exports) {
|
|
10
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getClassName=r,exports.getSafeText=n,exports.isElementNode=o,exports.isTag=s,exports.isTextNode=i,exports.shouldCaptureDomEvent=c,exports.shouldCaptureElement=u,exports.isSensitiveElement=p,exports.shouldCaptureValue=l,exports.
|
|
10
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getClassName=r,exports.getSafeText=n,exports.isElementNode=o,exports.isTag=s,exports.isTextNode=i,exports.shouldCaptureDomEvent=c,exports.shouldCaptureElement=u,exports.isSensitiveElement=p,exports.shouldCaptureValue=l,exports.isAngularContentAttr=d,exports.loadScript=f,exports.usefulElements=void 0;var e=require("./utils");function t(e){return(t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function r(e){switch(t(e.className)){case"string":return e.className;case"object":return e.className.baseVal||e.getAttribute("class")||"";default:return""}}function n(t){var r="";return u(t)&&!p(t)&&t.childNodes&&t.childNodes.length&&e._.each(t.childNodes,function(t){i(t)&&t.textContent&&(r+=e._.trim(t.textContent).split(/(\s+)/).filter(l).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255))}),e._.trim(r)}function o(e){return e&&1===e.nodeType}function s(e,t){return e&&e.tagName&&e.tagName.toLowerCase()===t.toLowerCase()}function i(e){return e&&3===e.nodeType}var a=["a","button","form","input","select","textarea","label"];function c(e,t){if(!e||s(e,"html")||!o(e))return!1;for(var r=!1,n=[e],i=!0,c=e;c.parentNode&&!s(c,"body");)if(11!==c.parentNode.nodeType){if(!(i=c.parentNode))break;if(a.indexOf(i.tagName.toLowerCase())>-1)r=!0;else{var u=window.getComputedStyle(i);u&&"pointer"===u.getPropertyValue("cursor")&&(r=!0)}n.push(i),c=i}else n.push(c.parentNode.host),c=c.parentNode.host;var p=window.getComputedStyle(e);if(p&&"pointer"===p.getPropertyValue("cursor")&&"click"===t.type)return!0;var l=e.tagName.toLowerCase();switch(l){case"html":return!1;case"form":return"submit"===t.type;case"input":return"change"===t.type||"click"===t.type;case"select":case"textarea":return"change"===t.type||"click"===t.type;default:return r?"click"===t.type:"click"===t.type&&(a.indexOf(l)>-1||"true"===e.getAttribute("contenteditable"))}}function u(t){for(var n=t;n.parentNode&&!s(n,"body");n=n.parentNode){var o=r(n).split(" ");if(e._.includes(o,"ph-sensitive")||e._.includes(o,"ph-no-capture"))return!1}if(e._.includes(r(t).split(" "),"ph-include"))return!0;var i=t.type||"";if("string"==typeof i)switch(i.toLowerCase()){case"hidden":case"password":return!1}var a=t.name||t.id||"";if("string"==typeof a){if(/^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i.test(a.replace(/[^a-zA-Z0-9]/g,"")))return!1}return!0}function p(e){return!!(s(e,"input")&&"button"!=e.type||s(e,"select")||s(e,"textarea")||"true"===e.getAttribute("contenteditable"))}function l(t){if(null===t||e._.isUndefined(t))return!1;if("string"==typeof t){t=e._.trim(t);if(/^(?:(4[0-9]{12}(?:[0-9]{3})?)|(5[1-5][0-9]{14})|(6(?:011|5[0-9]{2})[0-9]{12})|(3[47][0-9]{13})|(3(?:0[0-5]|[68][0-9])[0-9]{11})|((?:2131|1800|35[0-9]{3})[0-9]{11}))$/.test((t||"").replace(/[- ]/g,"")))return!1;if(/(^\d{3}-?\d{2}-?\d{4}$)/.test(t))return!1}return!0}function d(e){return"string"==typeof e&&"_ngcontent"===e.substring(0,10)}function f(e,t){var r=document.createElement("script");r.type="text/javascript",r.src=e,r.onload=t;var n=document.getElementsByTagName("script");n.length>0?n[0].parentNode.insertBefore(r,n[0]):document.body.appendChild(r)}exports.usefulElements=a;
|
|
11
11
|
},{"./utils":"FOZT"}],"Oszc":[function(require,module,exports) {
|
|
12
12
|
"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 i=0;i<t.length;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function i(e,i,n){return i&&t(e.prototype,i),n&&t(e,n),e}Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var n=30,c=1e3,a=3,s=function(){function t(i){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:i.get_config("rageclick");e(this,t),this.clicks=[],this.instance=i,this.enabled=n}return i(t,[{key:"click",value:function(e,t,i){if(this.enabled){var s=this.clicks[this.clicks.length-1];s&&Math.abs(e-s.x)+Math.abs(t-s.y)<n&&i-s.timestamp<c?(this.clicks.push({x:e,y:t,timestamp:i}),this.clicks.length===a&&this.instance.capture("$rageclick")):this.clicks=[{x:e,y:t,timestamp:i}]}}}]),t}();exports.default=s;
|
|
13
13
|
},{}],"gR3r":[function(require,module,exports) {
|
|
14
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.autocapture=void 0;var e=require("./utils"),t=require("./autocapture-utils"),n=r(require("./extensions/rageclick"));function r(e){return e&&e.__esModule?e:{default:e}}var i={_initializedTokens:[],_previousElementSibling:function(e){if(e.previousElementSibling)return e.previousElementSibling;do{e=e.previousSibling}while(e&&!(0,t.isElementNode)(e));return e},_getPropertiesFromElement:function(n,r,i){var o=n.tagName.toLowerCase(),a={tag_name:o};t.usefulElements.indexOf(o)>-1&&!i&&(a.$el_text=(0,t.getSafeText)(n));var s=(0,t.getClassName)(n);s.length>0&&(a.classes=s.split(" ").filter(function(e){return""!==e})),e._.each(n.attributes,function(e){(0,t.isSensitiveElement)(n)&&-1===["name","id","class"].indexOf(e.name)||!
|
|
14
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.autocapture=void 0;var e=require("./utils"),t=require("./autocapture-utils"),n=r(require("./extensions/rageclick"));function r(e){return e&&e.__esModule?e:{default:e}}var i={_initializedTokens:[],_previousElementSibling:function(e){if(e.previousElementSibling)return e.previousElementSibling;do{e=e.previousSibling}while(e&&!(0,t.isElementNode)(e));return e},_getPropertiesFromElement:function(n,r,i){var o=n.tagName.toLowerCase(),a={tag_name:o};t.usefulElements.indexOf(o)>-1&&!i&&(a.$el_text=(0,t.getSafeText)(n));var s=(0,t.getClassName)(n);s.length>0&&(a.classes=s.split(" ").filter(function(e){return""!==e})),e._.each(n.attributes,function(e){(0,t.isSensitiveElement)(n)&&-1===["name","id","class"].indexOf(e.name)||r||!(0,t.shouldCaptureValue)(e.value)||(0,t.isAngularContentAttr)(e.name)||(a["attr__"+e.name]=e.value)});for(var u=1,c=1,l=n;l=this._previousElementSibling(l);)u++,l.tagName===n.tagName&&c++;return a.nth_child=u,a.nth_of_type=c,a},_getDefaultProperties:function(e){return{$event_type:e,$ce_version:1}},_extractCustomPropertyValue:function(n){var r=[];return e._.each(document.querySelectorAll(n.css_selector),function(e){var n;["input","select"].indexOf(e.tagName.toLowerCase())>-1?n=e.value:e.textContent&&(n=e.textContent),(0,t.shouldCaptureValue)(n)&&r.push(n)}),r.join(", ")},_getCustomProperties:function(n){var r={};return e._.each(this._customProperties,function(i){e._.each(i.event_selectors,function(o){var a=document.querySelectorAll(o);e._.each(a,function(o){e._.includes(n,o)&&(0,t.shouldCaptureElement)(o)&&(r[i.name]=this._extractCustomPropertyValue(i))},this)},this)},this),r},_getEventTarget:function(e){return void 0===e.target?e.srcElement:e.target.shadowRoot?e.composedPath()[0]:e.target},_captureEvent:function(n,r){var i=this._getEventTarget(n);if((0,t.isTextNode)(i)&&(i=i.parentNode),"click"===n.type&&this.rageclicks.click(n.clientX,n.clientY,(new Date).getTime()),(0,t.shouldCaptureDomEvent)(i,n)){for(var o=[i],a=i;a.parentNode&&!(0,t.isTag)(a,"body");)11!==a.parentNode.nodeType?(o.push(a.parentNode),a=a.parentNode):(o.push(a.parentNode.host),a=a.parentNode.host);var s,u=[],c=!1;if(e._.each(o,function(n){var i=(0,t.shouldCaptureElement)(n);"a"===n.tagName.toLowerCase()&&(s=n.getAttribute("href"),s=i&&(0,t.shouldCaptureValue)(s)&&s);var o=(0,t.getClassName)(n).split(" ");e._.includes(o,"ph-no-capture")&&(c=!0),u.push(this._getPropertiesFromElement(n,r.get_config("mask_all_element_attributes"),r.get_config("mask_all_text")))},this),r.get_config("mask_all_text")||(u[0].$el_text=(0,t.getSafeText)(i)),s&&(u[0].attr__href=s),c)return!1;var l=e._.extend(this._getDefaultProperties(n.type),{$elements:u},this._getCustomProperties(o));return r.capture("$autocapture",l),!0}},_navigate:function(e){window.location.href=e},_addDomEventHandlers:function(t){var n=e._.bind(function(e){e=e||window.event,this._captureEvent(e,t)},this);e._.register_event(document,"submit",n,!1,!0),e._.register_event(document,"change",n,!1,!0),e._.register_event(document,"click",n,!1,!0)},_customProperties:{},init:function(e){this.rageclicks=new n.default(e)},afterDecideResponse:function(e,t){var n=t.get_config("token");this._initializedTokens.indexOf(n)>-1?console.log('autocapture already initialized for token "'+n+'"'):(this._initializedTokens.push(n),e&&e.config&&!0===e.config.enable_collect_everything&&t.get_config("autocapture")?(e.custom_properties&&(this._customProperties=e.custom_properties),this._addDomEventHandlers(t)):t.__autocapture_enabled=!1)},enabledForProject:function(t,n,r){n=e._.isUndefined(n)?10:n,r=e._.isUndefined(r)?10:r;for(var i=0,o=0;o<t.length;o++)i+=t.charCodeAt(o);return i%n<r},isBrowserSupported:function(){return e._.isFunction(document.querySelectorAll)}};exports.autocapture=i,e._.bind_instance_methods(i),e._.safewrap_instance_methods(i);
|
|
15
15
|
},{"./utils":"FOZT","./autocapture-utils":"RYfg","./extensions/rageclick":"Oszc"}],"KZ7Y":[function(require,module,exports) {
|
|
16
16
|
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.memoryStore=exports.localStore=exports.cookieStore=void 0;var r=require("./utils"),e=/[a-z0-9][a-z0-9-]+\.[a-z.]{2,6}$/i,t={get:function(r){try{for(var e=r+"=",t=document.cookie.split(";"),o=0;o<t.length;o++){for(var n=t[o];" "==n.charAt(0);)n=n.substring(1,n.length);if(0===n.indexOf(e))return decodeURIComponent(n.substring(e.length,n.length))}}catch(c){}return null},parse:function(r){var e;try{e=JSON.parse(t.get(r))||{}}catch(o){}return e},set:function(r,t,o,n,c){try{var a="",u="",i="";if(n){var l=document.location.hostname.match(e),s=l?l[0]:"";a=s?"; domain=."+s:""}if(o){var p=new Date;p.setTime(p.getTime()+24*o*60*60*1e3),u="; expires="+p.toGMTString()}c&&(i="; secure");var m=r+"="+encodeURIComponent(t)+u+"; path=/"+a+i;return document.cookie=m,m}catch(f){return}},remove:function(r,e){try{t.set(r,"",-1,e)}catch(o){return}}};exports.cookieStore=t;var o=null,n={is_supported:function(){if(null!==o)return o;var e=!0;try{var t="__mplssupport__";n.set(t,"xyz"),"xyz"!==n.get(t)&&(e=!1),n.remove(t)}catch(c){e=!1}return e||r.console.error("localStorage unsupported; falling back to cookie store"),o=e,e},error:function(e){r.console.error("localStorage error: "+e)},get:function(r){try{return window.localStorage.getItem(r)}catch(e){n.error(e)}return null},parse:function(r){try{return JSON.parse(n.get(r))||{}}catch(e){}return null},set:function(r,e){try{window.localStorage.setItem(r,e)}catch(t){n.error(t)}},remove:function(r){try{window.localStorage.removeItem(r)}catch(e){n.error(e)}}};exports.localStore=n;var c={},a={is_supported:function(){return!0},error:function(e){r.console.error("memoryStorage error: "+e)},parse:function(r){return c[r]||null},set:function(r,e){c[r]=e},remove:function(r){delete c[r]}};exports.memoryStore=a;
|
|
17
17
|
},{"./utils":"FOZT"}],"rxSh":[function(require,module,exports) {
|
|
18
18
|
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.optIn=n,exports.optOut=r,exports.hasOptedIn=i,exports.hasOptedOut=c,exports.addOptOutCheckPostHogLib=u,exports.addOptOutCheckPostHogPeople=s,exports.clearOptInOut=p;var t=require("./utils"),e=require("./storage"),o="__ph_opt_in_out_";function n(t,e){d(!0,t,e)}function r(t,e){d(!1,t,e)}function i(t,e){return"1"===f(t,e)}function c(t,e){return!!_(e)||"0"===f(t,e)}function u(t,e){return h(t,function(t){return this.get_config(t)},e)}function s(t,e){return h(t,function(t){return this._get_config(t)},e)}function p(t,e){a(e=e||{}).remove(l(t,e),!!e.crossSubdomainCookie,e.cookieDomain)}function a(t){return"localStorage"===(t=t||{}).persistenceType?e.localStore:e.cookieStore}function l(t,e){return((e=e||{}).persistencePrefix||o)+t}function f(t,e){return a(e).get(l(t,e))}function _(e){if(e&&e.respectDnt){var o=e&&e.window||t.window,n=o.navigator||{},r=!1;return t._.each([n.doNotTrack,n.msDoNotTrack,o.doNotTrack],function(e){t._.includes([!0,1,"1","yes"],e)&&(r=!0)}),r}return!1}function d(e,o,n){t._.isString(o)&&o.length?(a(n=n||{}).set(l(o,n),e?1:0,t._.isNumber(n.cookieExpiration)?n.cookieExpiration:null,!!n.crossSubdomainCookie,!!n.secureCookie,!!n.crossSiteCookie,n.cookieDomain),n.capture&&e&&n.capture(n.captureEventName||"$opt_in",n.captureProperties,{send_immediately:!0})):console.error("gdpr."+(e?"optIn":"optOut")+" called with an invalid token")}function h(t,e,o){return function(){var n=!1;try{var r=e.call(this,"token"),i=e.call(this,"respect_dnt"),u=e.call(this,"opt_out_capturing_persistence_type"),s=e.call(this,"opt_out_capturing_cookie_prefix"),p=e.call(this,"window");r&&(n=c(r,{respectDnt:i,persistenceType:u,persistencePrefix:s,window:p}))}catch(l){o||console.error("Unexpected error when checking capturing opt-out status: "+l)}if(!n)return t.apply(this,arguments);var a=arguments[arguments.length-1];"function"==typeof a&&a(0)}}
|
|
19
19
|
},{"./utils":"FOZT","./storage":"KZ7Y"}],"os8r":[function(require,module,exports) {
|
|
20
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.apiActions=exports.SET_ACTION=void 0;var
|
|
20
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.apiActions=exports.SET_ACTION=void 0;var t=require("./utils"),e="$set";exports.SET_ACTION=e;var r="$set_once",i="$increment",n={set_action:function(t,r){return this.apiActionParser(e,t,r)},set_once_action:function(t,e){return this.apiActionParser(r,t,e)},increment_action:function(t,e){return this.apiActionParser(i,t,e)},apiActionParser:function(e,r,i){var n={},s={};return t._.isObject(r)?t._.each(r,function(t,e){this._is_reserved_property(e)||(s[e]=t)},this):s[r]=i,n[e]=s,n}};exports.apiActions=n;
|
|
21
21
|
},{"./utils":"FOZT"}],"ecEG":[function(require,module,exports) {
|
|
22
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.PostHogPeople=void 0;var t=require("./gdpr-utils"),e=require("./api-actions"),o=require("./utils"),i=function(){};exports.PostHogPeople=i,o._.extend(i.prototype,e.apiActions),i.prototype._init=function(t){this._posthog=t},i.prototype.set=(0,t.addOptOutCheckPostHogPeople)(function(t,i,r){var s=this.set_action(t,i);return o._.isObject(t)&&(r=i),this._get_config("save_referrer")&&this._posthog.persistence.update_referrer_info(document.referrer),s[e.SET_ACTION]=o._.extend({},o._.info.people_properties(),this._posthog.persistence.get_referrer_info(),s[e.SET_ACTION]),this._send_request(s,r)}),i.prototype.set_once=(0,t.addOptOutCheckPostHogPeople)(function(t,e,i){var r=this.set_once_action(t,e);return o._.isObject(t)&&(i=e),this._send_request(r,i)}),i.prototype.toString=function(){return this._posthog.toString()+".people"},i.prototype._send_request=function(t,e){t.$token=this._get_config("token"),t.$distinct_id=this._posthog.get_distinct_id();var i=this._posthog.get_property("$device_id"),r=this._posthog.get_property("$user_id"),s=this._posthog.get_property("$had_persisted_distinct_id");i&&(t.$device_id=i),r&&(t.$user_id=r),s&&(t.$had_persisted_distinct_id=s);var _=o._.encodeDates(t),
|
|
22
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.PostHogPeople=void 0;var t=require("./gdpr-utils"),e=require("./api-actions"),o=require("./utils"),i=function(){};exports.PostHogPeople=i,o._.extend(i.prototype,e.apiActions),i.prototype._init=function(t){this._posthog=t},i.prototype.set=(0,t.addOptOutCheckPostHogPeople)(function(t,i,r){var s=this.set_action(t,i);return o._.isObject(t)&&(r=i),this._get_config("save_referrer")&&this._posthog.persistence.update_referrer_info(document.referrer),s[e.SET_ACTION]=o._.extend({},o._.info.people_properties(),this._posthog.persistence.get_referrer_info(),s[e.SET_ACTION]),this._send_request(s,r)}),i.prototype.set_once=(0,t.addOptOutCheckPostHogPeople)(function(t,e,i){var r=this.set_once_action(t,e);return o._.isObject(t)&&(i=e),this._send_request(r,i)}),i.prototype.increment=(0,t.addOptOutCheckPostHogPeople)(function(t,e,i){var r=this.increment_action(t,e);return o._.isObject(t)&&(i=e),this._send_request({properties:{$increment:r.$increment}},i)}),i.prototype.toString=function(){return this._posthog.toString()+".people"},i.prototype._send_request=function(t,e){t.$token=this._get_config("token"),t.$distinct_id=this._posthog.get_distinct_id();var i=this._posthog.get_property("$device_id"),r=this._posthog.get_property("$user_id"),s=this._posthog.get_property("$had_persisted_distinct_id");i&&(t.$device_id=i),r&&(t.$user_id=r),s&&(t.$had_persisted_distinct_id=s);var _=o._.encodeDates(t),n=o._.copyAndTruncateStrings(_,this._get_config("properties_string_max_length")),p=JSON.stringify(_),c=o._.base64Encode(p);return this._posthog._send_request(this._get_config("api_host")+"/engage/",{data:c},{},this._posthog._prepare_callback(e,n)),n},i.prototype._get_config=function(t){return this._posthog.get_config(t)},i.prototype._is_reserved_property=function(t){return"$distinct_id"===t||"$token"===t||"$device_id"===t||"$user_id"===t||"$had_persisted_distinct_id"===t},i.prototype.set=i.prototype.set,i.prototype.set_once=i.prototype.set_once,i.prototype.toString=i.prototype.toString;
|
|
23
23
|
},{"./gdpr-utils":"rxSh","./api-actions":"os8r","./utils":"FOZT"}],"aVqC":[function(require,module,exports) {
|
|
24
24
|
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.PostHogFeatureFlags=exports.parseFeatureFlagDecideResponse=void 0;var e=require("./utils");function t(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){for(var a=0;a<t.length;a++){var r=t[a];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function r(e,t,r){return t&&a(e.prototype,t),r&&a(e,r),e}var n=function(e,t){var a=e.featureFlags;if(a)if(Array.isArray(a)){var r={};if(a)for(var n=0;n<a.length;n++)r[a[n]]=!0;t&&t.register({$active_feature_flags:a,$enabled_feature_flags:r})}else t&&t.register({$active_feature_flags:Object.keys(a||{}),$enabled_feature_flags:a||{}});else t&&(t.unregister("$active_feature_flags"),t.unregister("$enabled_feature_flags"))};exports.parseFeatureFlagDecideResponse=n;var i=function(){function a(e){t(this,a),this.instance=e,this._override_warning=!1,this.flagCallReported={},this.featureFlagEventHandlers=[]}return r(a,[{key:"getFlags",value:function(){return Object.keys(this.getFlagVariants())}},{key:"getFlagVariants",value:function(){var t=this.instance.get_property("$enabled_feature_flags"),a=this.instance.get_property("$override_feature_flags");if(!a)return t||{};for(var r=e._.extend({},t),n=Object.keys(a),i=0;i<n.length;i++)!1===a[n[i]]?delete r[n[i]]:r[n[i]]=a[n[i]];return this._override_warning||(console.warn("[PostHog] Overriding feature flags!",{enabledFlags:t,overriddenFlags:a,finalFlags:r}),this._override_warning=!0),r}},{key:"reloadFeatureFlags",value:function(){var t=this,a=this.instance.get_config("token"),r=JSON.stringify({token:a,distinct_id:this.instance.get_distinct_id()}),i=e._.base64Encode(r);this.instance._send_request(this.instance.get_config("api_host")+"/decide/?v=2",{data:i},{method:"POST"},this.instance._prepare_callback(function(e){n(e,t.instance.persistence),t.receivedFeatureFlags()}))}},{key:"getFeatureFlag",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!this.getFlags())return console.warn('getFeatureFlag for key "'+e+"\" failed. Feature flags didn't load in time."),!1;var a=this.getFlagVariants()[e];return!t.send_event&&"send_event"in t||this.flagCallReported[e]||(this.flagCallReported[e]=!0,this.instance.capture("$feature_flag_called",{$feature_flag:e,$feature_flag_response:a})),a}},{key:"isFeatureEnabled",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return this.getFlags()?!!this.getFeatureFlag(e,t):(console.warn('isFeatureEnabled for key "'+e+"\" failed. Feature flags didn't load in time."),!1)}},{key:"addFeatureFlagsHandler",value:function(e){this.featureFlagEventHandlers.push(e)}},{key:"receivedFeatureFlags",value:function(){var e=this.getFlags(),t=this.getFlagVariants();this.featureFlagEventHandlers.forEach(function(a){return a(e,t)})}},{key:"override",value:function(e){if(this._override_warning=!1,!1===e)this.instance.persistence.unregister("$override_feature_flags");else if(Array.isArray(e)){for(var t={},a=0;a<e.length;a++)t[e[a]]=!0;this.instance.persistence.register({$override_feature_flags:t})}else this.instance.persistence.register({$override_feature_flags:e})}}]),a}();exports.PostHogFeatureFlags=i;
|
|
25
25
|
},{"./utils":"FOZT"}],"MAdm":[function(require,module,exports) {
|
|
@@ -43,11 +43,11 @@ module.exports={name:"posthog-js",version:"1.13.14",description:"Posthog-js allo
|
|
|
43
43
|
},{}],"Ie9M":[function(require,module,exports) {
|
|
44
44
|
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.decideCompression=s,exports.compressData=c;var e=require("./lz-string"),r=require("fflate"),t=require("./utils");function n(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable})),t.push.apply(t,n)}return t}function o(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?n(Object(t),!0).forEach(function(r){i(e,r,t[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):n(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))})}return e}function i(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function s(e){return e["gzip-js"]?"gzip-js":e.lz64?"lz64":"base64"}function c(n,i,s){return"lz64"===n?[{data:e.LZString.compressToBase64(i),compression:"lz64"},s]:"gzip-js"===n?[(0,r.gzipSync)((0,r.strToU8)(i),{mtime:0}),o(o({},s),{},{blob:!0,urlQueryArgs:{compression:"gzip-js"}})]:[{data:t._.base64Encode(i)},s]}
|
|
45
45
|
},{"./lz-string":"zdbk","fflate":"UJm1","./utils":"FOZT"}],"tOu2":[function(require,module,exports) {
|
|
46
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.xhr=exports.encodePostData=void 0;var e=require("./utils");function t(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function r(e){for(var r=1;r<arguments.length;r++){var o=null!=arguments[r]?arguments[r]:{};r%2?t(Object(o),!0).forEach(function(t){n(e,t,o[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(o)):t(Object(o)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(o,t))})}return e}function n(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var o=function e(t,r){if(r.blob)return new Blob([t.buffer],{type:"text/plain"});if(r.sendBeacon){var n=e(t,{method:"POST"});return new Blob([n],{type:"application/x-www-form-urlencoded"})}return"POST"!==r.method?null:(o=Array.isArray(t)?"data="+encodeURIComponent(t):"data="+encodeURIComponent(t.data),t.compression&&(o+="&compression="+t.compression),o);var o};exports.encodePostData=o;var s=function(t){var n=t.url,s=t.data,a=t.headers,i=t.options,c=t.captureMetrics,u=t.callback,p=t.retriesPerformedSoFar,d=t.retryQueue,l=new XMLHttpRequest;
|
|
46
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.xhr=exports.encodePostData=void 0;var e=require("./utils");function t(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function r(e){for(var r=1;r<arguments.length;r++){var o=null!=arguments[r]?arguments[r]:{};r%2?t(Object(o),!0).forEach(function(t){n(e,t,o[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(o)):t(Object(o)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(o,t))})}return e}function n(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var o=function e(t,r){if(r.blob)return new Blob([t.buffer],{type:"text/plain"});if(r.sendBeacon){var n=e(t,{method:"POST"});return new Blob([n],{type:"application/x-www-form-urlencoded"})}return"POST"!==r.method?null:(o=Array.isArray(t)?"data="+encodeURIComponent(t):"data="+encodeURIComponent(t.data),t.compression&&(o+="&compression="+t.compression),o);var o};exports.encodePostData=o;var s=function(t){var n=t.url,s=t.data,a=t.headers,i=t.options,c=t.captureMetrics,u=t.callback,p=t.retriesPerformedSoFar,d=t.retryQueue,l=t.onXHRError,f=new XMLHttpRequest;f.open(i.method,n,!0);var b=o(s,i);c.incr("_send_request"),c.incr("_send_request_inflight");var h=c.startRequest(r({data_size:e._.isString(s)?s.length:b.length,endpoint:n.slice(n.length-2)},i._metrics));e._.each(a,function(e,t){f.setRequestHeader(t,e)}),"POST"!==i.method||i.blob||f.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),f.withCredentials=!0,f.onreadystatechange=function(){if(4===f.readyState){c.incr("xhr-response"),c.incr("xhr-response-".concat(f.status)),c.decr("_send_request_inflight");var t=c.finishRequest(h);if(200===f.status){if(u){var o;try{o=JSON.parse(f.responseText)}catch(b){return void e.console.error(b)}u(o)}}else"function"==typeof l&&l(f),[401,403,404,500].indexOf(f.status)<0&&d.enqueue({url:n,data:s,options:i,headers:a,retriesPerformedSoFar:(p||0)+1,callback:u}),c.markRequestFailed(r(r({},t),{},{type:"non_200",status:f.status,statusText:f.statusText})),u&&(i.verbose?u({status:0,error:error}):u(0))}},f.send(b)};exports.xhr=s;
|
|
47
47
|
},{"./utils":"FOZT"}],"ennf":[function(require,module,exports) {
|
|
48
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.RetryQueue=void 0;var e=require("./base-request-queue"),t=require("./send-request");function r(e){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function n(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function o(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?n(Object(r),!0).forEach(function(t){
|
|
48
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.RetryQueue=void 0;var e=require("./base-request-queue"),t=require("./send-request");function r(e){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function n(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function o(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?n(Object(r),!0).forEach(function(t){i(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):n(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function i(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function u(e,t){var r;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(r=a(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,o=function(){};return{s:o,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,u=!0,c=!1;return{s:function(){r=e[Symbol.iterator]()},n:function(){var e=r.next();return u=e.done,e},e:function(e){c=!0,i=e},f:function(){try{u||null==r.return||r.return()}finally{if(c)throw i}}}}function a(e,t){if(e){if("string"==typeof e)return c(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?c(e,t):void 0}}function c(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function l(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function f(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function s(e,t,r){return t&&f(e.prototype,t),r&&f(e,r),e}function y(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&p(e,t)}function p(e,t){return(p=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function h(e){var t=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;
|
|
49
49
|
},{"./base-request-queue":"ae0g","./send-request":"tOu2"}],"ok3T":[function(require,module,exports) {
|
|
50
|
-
"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=v(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 v(e){return e&&e.__esModule?e:{default:e}}function m(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?m(Object(o),!0).forEach(function(t){k(e,t,o[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(o)):m(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 x(e)||O(e,t)||P(e,t)||S()}function S(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function P(e,t){if(e){if("string"==typeof e)return F(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)?F(e,t):void 0}}function F(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 O(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 x(e){if(Array.isArray(e))return e}var E=0,$=1,j=function(){},H={},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,_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.__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()},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||H,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})}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||H).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!==H;return!this.get_config("request_batching")||c&&!o._batchKey?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.capture_pageview=function(e){i._.isUndefined(e)&&(e=i.document.location.href),this.capture("$pageview")},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.capture_pageview=M.prototype.capture_pageview,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 U={},C=function(){i._.each(U,function(e,o){o!==I&&(t[o]=e)}),t._=i._},B=function(){t.init=function(o,r,n){if(n)return t[n]||(t[n]=U[n]=L(o,r,n),t[n]._loaded()),t[n];var s=t;U[I]?s=U[I]:o&&((s=L(o,r,I))._loaded(),U[I]=s),t=s,e===$&&(i.window[I]=t),C()}},T=function(){function e(){e.done||(e.done=!0,R=!1,i._.each(U,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)&&(U[e[e.length-1]]=L.apply(this,e))}),B(),t.init(),i._.each(U,function(e){e._loaded()}),T())}function N(){return e=E,t=new M,B(),t.init(),T(),t}
|
|
50
|
+
"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}
|
|
51
51
|
},{"./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) {
|
|
52
52
|
"use strict";var r=require("./posthog-core");(0,r.init_from_snippet)();
|
|
53
53
|
},{"./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.14.0";
|
|
867
867
|
|
|
868
868
|
var Config = {
|
|
869
869
|
DEBUG: false,
|
|
@@ -2003,6 +2003,21 @@ function shouldCaptureValue(value) {
|
|
|
2003
2003
|
|
|
2004
2004
|
return true;
|
|
2005
2005
|
}
|
|
2006
|
+
/*
|
|
2007
|
+
* Check whether an attribute name is an Angular content attr
|
|
2008
|
+
* These update on each build and lead to noise in the element chain
|
|
2009
|
+
* https://stackoverflow.com/questions/45082129/what-does-ngcontent-c-mean-in-angular
|
|
2010
|
+
* @param {string} attributeName - string value to check
|
|
2011
|
+
* @returns {boolean} whether the element is an angular tag
|
|
2012
|
+
*/
|
|
2013
|
+
|
|
2014
|
+
function isAngularContentAttr(attributeName) {
|
|
2015
|
+
if (typeof attributeName === 'string') {
|
|
2016
|
+
return attributeName.substring(0, 10) === '_ngcontent';
|
|
2017
|
+
}
|
|
2018
|
+
|
|
2019
|
+
return false;
|
|
2020
|
+
}
|
|
2006
2021
|
function loadScript(scriptUrlToLoad, callback) {
|
|
2007
2022
|
var scriptTag = document.createElement('script');
|
|
2008
2023
|
scriptTag.type = 'text/javascript';
|
|
@@ -2099,7 +2114,7 @@ var autocapture = {
|
|
|
2099
2114
|
// Only capture attributes we know are safe
|
|
2100
2115
|
if (isSensitiveElement(elem) && ['name', 'id', 'class'].indexOf(attr.name) === -1) return;
|
|
2101
2116
|
|
|
2102
|
-
if (!maskInputs && shouldCaptureValue(attr.value)) {
|
|
2117
|
+
if (!maskInputs && shouldCaptureValue(attr.value) && !isAngularContentAttr(attr.name)) {
|
|
2103
2118
|
props['attr__' + attr.name] = attr.value;
|
|
2104
2119
|
}
|
|
2105
2120
|
});
|
|
@@ -2754,42 +2769,38 @@ function _addOptOutCheck(method, getConfigValue, silenceErrors) {
|
|
|
2754
2769
|
var SET_ACTION = '$set';
|
|
2755
2770
|
/** @const */
|
|
2756
2771
|
|
|
2757
|
-
var SET_ONCE_ACTION = '$set_once';
|
|
2772
|
+
var SET_ONCE_ACTION = '$set_once';
|
|
2773
|
+
/** @const */
|
|
2774
|
+
|
|
2775
|
+
var INCREMENT_ACTION = '$increment'; // Internal methods for posthog.people API.
|
|
2758
2776
|
// These methods shouldn't involve network I/O.
|
|
2759
2777
|
|
|
2760
2778
|
var apiActions = {
|
|
2761
2779
|
set_action: function set_action(prop, to) {
|
|
2762
|
-
|
|
2763
|
-
var $set = {};
|
|
2764
|
-
|
|
2765
|
-
if (_.isObject(prop)) {
|
|
2766
|
-
_.each(prop, function (v, k) {
|
|
2767
|
-
if (!this._is_reserved_property(k)) {
|
|
2768
|
-
$set[k] = v;
|
|
2769
|
-
}
|
|
2770
|
-
}, this);
|
|
2771
|
-
} else {
|
|
2772
|
-
$set[prop] = to;
|
|
2773
|
-
}
|
|
2774
|
-
|
|
2775
|
-
data[SET_ACTION] = $set;
|
|
2776
|
-
return data;
|
|
2780
|
+
return this.apiActionParser(SET_ACTION, prop, to);
|
|
2777
2781
|
},
|
|
2778
2782
|
set_once_action: function set_once_action(prop, to) {
|
|
2783
|
+
return this.apiActionParser(SET_ONCE_ACTION, prop, to);
|
|
2784
|
+
},
|
|
2785
|
+
increment_action: function increment_action(prop, to) {
|
|
2786
|
+
var a = this.apiActionParser(INCREMENT_ACTION, prop, to);
|
|
2787
|
+
return a;
|
|
2788
|
+
},
|
|
2789
|
+
apiActionParser: function apiActionParser(actionType, prop, to) {
|
|
2779
2790
|
var data = {};
|
|
2780
|
-
var
|
|
2791
|
+
var props = {};
|
|
2781
2792
|
|
|
2782
2793
|
if (_.isObject(prop)) {
|
|
2783
2794
|
_.each(prop, function (v, k) {
|
|
2784
2795
|
if (!this._is_reserved_property(k)) {
|
|
2785
|
-
|
|
2796
|
+
props[k] = v;
|
|
2786
2797
|
}
|
|
2787
2798
|
}, this);
|
|
2788
2799
|
} else {
|
|
2789
|
-
|
|
2800
|
+
props[prop] = to;
|
|
2790
2801
|
}
|
|
2791
2802
|
|
|
2792
|
-
data[
|
|
2803
|
+
data[actionType] = props;
|
|
2793
2804
|
return data;
|
|
2794
2805
|
}
|
|
2795
2806
|
};
|
|
@@ -2875,6 +2886,38 @@ PostHogPeople.prototype.set_once = addOptOutCheckPostHogPeople(function (prop, t
|
|
|
2875
2886
|
|
|
2876
2887
|
return this._send_request(data, callback);
|
|
2877
2888
|
});
|
|
2889
|
+
/*
|
|
2890
|
+
* Increment numerical properties on a user record
|
|
2891
|
+
*
|
|
2892
|
+
* ### Usage:
|
|
2893
|
+
*
|
|
2894
|
+
* posthog.people.increment('times visited platform', 1);
|
|
2895
|
+
*
|
|
2896
|
+
* // or set multiple properties at once
|
|
2897
|
+
* posthog.people.increment({
|
|
2898
|
+
* 'times visited platform': 1,
|
|
2899
|
+
* 'total amount spent': 100
|
|
2900
|
+
* });
|
|
2901
|
+
*
|
|
2902
|
+
*
|
|
2903
|
+
* @param {Object|String} prop If a string, this is the name of the property. If an object, this is an associative array of names and values.
|
|
2904
|
+
* @param {*} [to] A value to set on the given property name
|
|
2905
|
+
* @param {Function} [callback] If provided, the callback will be called after captureing the event.
|
|
2906
|
+
*/
|
|
2907
|
+
|
|
2908
|
+
PostHogPeople.prototype.increment = addOptOutCheckPostHogPeople(function (prop, to, callback) {
|
|
2909
|
+
var data = this.increment_action(prop, to);
|
|
2910
|
+
|
|
2911
|
+
if (_.isObject(prop)) {
|
|
2912
|
+
callback = to;
|
|
2913
|
+
}
|
|
2914
|
+
|
|
2915
|
+
return this._send_request({
|
|
2916
|
+
properties: {
|
|
2917
|
+
$increment: data['$increment']
|
|
2918
|
+
}
|
|
2919
|
+
}, callback);
|
|
2920
|
+
});
|
|
2878
2921
|
|
|
2879
2922
|
PostHogPeople.prototype.toString = function () {
|
|
2880
2923
|
return this._posthog.toString() + '.people';
|
|
@@ -4920,7 +4963,8 @@ var xhr = function xhr(_ref) {
|
|
|
4920
4963
|
captureMetrics = _ref.captureMetrics,
|
|
4921
4964
|
callback = _ref.callback,
|
|
4922
4965
|
retriesPerformedSoFar = _ref.retriesPerformedSoFar,
|
|
4923
|
-
retryQueue = _ref.retryQueue
|
|
4966
|
+
retryQueue = _ref.retryQueue,
|
|
4967
|
+
onXHRError = _ref.onXHRError;
|
|
4924
4968
|
var req = new XMLHttpRequest();
|
|
4925
4969
|
req.open(options.method, url, true);
|
|
4926
4970
|
var body = encodePostData(data, options);
|
|
@@ -4964,8 +5008,10 @@ var xhr = function xhr(_ref) {
|
|
|
4964
5008
|
callback(response);
|
|
4965
5009
|
}
|
|
4966
5010
|
} else {
|
|
4967
|
-
|
|
4968
|
-
|
|
5011
|
+
if (typeof onXHRError === 'function') {
|
|
5012
|
+
onXHRError(req);
|
|
5013
|
+
} // don't retry certain errors
|
|
5014
|
+
|
|
4969
5015
|
|
|
4970
5016
|
if ([401, 403, 404, 500].indexOf(req.status) < 0) {
|
|
4971
5017
|
retryQueue.enqueue({
|
|
@@ -5006,7 +5052,7 @@ var RetryQueue = /*#__PURE__*/function (_RequestQueueScaffold) {
|
|
|
5006
5052
|
|
|
5007
5053
|
var _super = _createSuper(RetryQueue);
|
|
5008
5054
|
|
|
5009
|
-
function RetryQueue(captureMetrics) {
|
|
5055
|
+
function RetryQueue(captureMetrics, onXHRError) {
|
|
5010
5056
|
var _this;
|
|
5011
5057
|
|
|
5012
5058
|
_classCallCheck(this, RetryQueue);
|
|
@@ -5016,6 +5062,7 @@ var RetryQueue = /*#__PURE__*/function (_RequestQueueScaffold) {
|
|
|
5016
5062
|
_this.isPolling = false;
|
|
5017
5063
|
_this.queue = [];
|
|
5018
5064
|
_this.areWeOnline = true;
|
|
5065
|
+
_this.onXHRError = onXHRError;
|
|
5019
5066
|
|
|
5020
5067
|
if ('onLine' in window.navigator) {
|
|
5021
5068
|
_this.areWeOnline = window.navigator.onLine;
|
|
@@ -5141,7 +5188,8 @@ var RetryQueue = /*#__PURE__*/function (_RequestQueueScaffold) {
|
|
|
5141
5188
|
retriesPerformedSoFar: retriesPerformedSoFar || 0,
|
|
5142
5189
|
callback: callback,
|
|
5143
5190
|
captureMetrics: this.captureMetrics,
|
|
5144
|
-
retryQueue: this
|
|
5191
|
+
retryQueue: this,
|
|
5192
|
+
onXHRError: this.onXHRError
|
|
5145
5193
|
});
|
|
5146
5194
|
}
|
|
5147
5195
|
}, {
|
|
@@ -5241,6 +5289,10 @@ var defaultConfig = function defaultConfig() {
|
|
|
5241
5289
|
mask_all_element_attributes: false,
|
|
5242
5290
|
mask_all_text: false,
|
|
5243
5291
|
advanced_disable_decide: false,
|
|
5292
|
+
on_xhr_error: function on_xhr_error(req) {
|
|
5293
|
+
var error = 'Bad HTTP status: ' + req.status + ' ' + req.statusText;
|
|
5294
|
+
console$1.error(error);
|
|
5295
|
+
},
|
|
5244
5296
|
// Used for internal testing
|
|
5245
5297
|
_onCapture: function _onCapture() {},
|
|
5246
5298
|
_capture_metrics: false
|
|
@@ -5387,7 +5439,7 @@ PostHogLib.prototype._init = function (token, config, name) {
|
|
|
5387
5439
|
|
|
5388
5440
|
this._captureMetrics = new CaptureMetrics(this.get_config('_capture_metrics'), _.bind(this.capture, this));
|
|
5389
5441
|
this._requestQueue = new RequestQueue(this._captureMetrics, _.bind(this._handle_queued_event, this));
|
|
5390
|
-
this._retryQueue = new RetryQueue(this._captureMetrics);
|
|
5442
|
+
this._retryQueue = new RetryQueue(this._captureMetrics, this.get_config('on_xhr_error'));
|
|
5391
5443
|
this.__captureHooks = [];
|
|
5392
5444
|
this.__request_queue = [];
|
|
5393
5445
|
this['persistence'] = new PostHogPersistence(this['config']);
|
|
@@ -5419,7 +5471,9 @@ PostHogLib.prototype._loaded = function () {
|
|
|
5419
5471
|
|
|
5420
5472
|
|
|
5421
5473
|
if (this.get_config('capture_pageview')) {
|
|
5422
|
-
this.
|
|
5474
|
+
this.capture('$pageview', {}, {
|
|
5475
|
+
send_instantly: true
|
|
5476
|
+
});
|
|
5423
5477
|
}
|
|
5424
5478
|
};
|
|
5425
5479
|
|
|
@@ -5571,7 +5625,8 @@ PostHogLib.prototype._send_request = function (url, data, options, callback) {
|
|
|
5571
5625
|
captureMetrics: this._captureMetrics,
|
|
5572
5626
|
callback: callback,
|
|
5573
5627
|
retriesPerformedSoFar: 0,
|
|
5574
|
-
retryQueue: this._retryQueue
|
|
5628
|
+
retryQueue: this._retryQueue,
|
|
5629
|
+
onXHRError: this.get_config('on_xhr_error')
|
|
5575
5630
|
});
|
|
5576
5631
|
} catch (e) {
|
|
5577
5632
|
console$1.error(e);
|
|
@@ -5739,7 +5794,7 @@ PostHogLib.prototype.capture = addOptOutCheckPostHogLib(function (event_name, pr
|
|
|
5739
5794
|
var url = this.get_config('api_host') + (options.endpoint || '/e/');
|
|
5740
5795
|
var has_unique_traits = options !== __NOOPTIONS;
|
|
5741
5796
|
|
|
5742
|
-
if (this.get_config('request_batching') && (!has_unique_traits || options._batchKey)) {
|
|
5797
|
+
if (this.get_config('request_batching') && (!has_unique_traits || options._batchKey) && !options.send_instantly) {
|
|
5743
5798
|
data['timestamp'] = new Date();
|
|
5744
5799
|
|
|
5745
5800
|
this._requestQueue.enqueue(url, data, options);
|
|
@@ -5804,23 +5859,6 @@ PostHogLib.prototype._calculate_event_properties = function (event_name, event_p
|
|
|
5804
5859
|
|
|
5805
5860
|
return properties;
|
|
5806
5861
|
};
|
|
5807
|
-
/**
|
|
5808
|
-
* Capture a page view event.
|
|
5809
|
-
* This function is called by default on page load unless the
|
|
5810
|
-
* capture_pageview configuration variable is false.
|
|
5811
|
-
*
|
|
5812
|
-
* @param {String} [page] The url of the page to record. If you don't include this, it defaults to the current url.
|
|
5813
|
-
* @api private
|
|
5814
|
-
*/
|
|
5815
|
-
|
|
5816
|
-
|
|
5817
|
-
PostHogLib.prototype.capture_pageview = function (page) {
|
|
5818
|
-
if (_.isUndefined(page)) {
|
|
5819
|
-
page = document$1.location.href;
|
|
5820
|
-
}
|
|
5821
|
-
|
|
5822
|
-
this.capture('$pageview');
|
|
5823
|
-
};
|
|
5824
5862
|
/**
|
|
5825
5863
|
* Register a set of super properties, which are included with all
|
|
5826
5864
|
* events. This will overwrite previous super property values.
|
|
@@ -6688,7 +6726,6 @@ PostHogLib.prototype.decodeLZ64 = LZString.decompressFromBase64; // EXPORTS (for
|
|
|
6688
6726
|
PostHogLib.prototype['init'] = PostHogLib.prototype.init;
|
|
6689
6727
|
PostHogLib.prototype['reset'] = PostHogLib.prototype.reset;
|
|
6690
6728
|
PostHogLib.prototype['capture'] = PostHogLib.prototype.capture;
|
|
6691
|
-
PostHogLib.prototype['capture_pageview'] = PostHogLib.prototype.capture_pageview;
|
|
6692
6729
|
PostHogLib.prototype['register'] = PostHogLib.prototype.register;
|
|
6693
6730
|
PostHogLib.prototype['register_once'] = PostHogLib.prototype.register_once;
|
|
6694
6731
|
PostHogLib.prototype['unregister'] = PostHogLib.prototype.unregister;
|
package/dist/module.d.ts
CHANGED
|
@@ -51,16 +51,6 @@ declare class posthog {
|
|
|
51
51
|
options?: { transport: 'XHR' | 'sendBeacon' }
|
|
52
52
|
): posthog.CaptureResult
|
|
53
53
|
|
|
54
|
-
/**
|
|
55
|
-
* Capture a page view event, which is currently ignored by the server.
|
|
56
|
-
* This function is called by default on page load unless the
|
|
57
|
-
* capture_pageview configuration variable is false.
|
|
58
|
-
*
|
|
59
|
-
* @param {String} [page] The url of the page to record. If you don't include this, it defaults to the current url.
|
|
60
|
-
* @api private
|
|
61
|
-
*/
|
|
62
|
-
static capture_pageview(page?: string): void
|
|
63
|
-
|
|
64
54
|
/**
|
|
65
55
|
* Register a set of super properties, which are included with all
|
|
66
56
|
* events. This will overwrite previous super property values.
|
|
@@ -594,6 +584,7 @@ declare namespace posthog {
|
|
|
594
584
|
respect_dnt?: boolean
|
|
595
585
|
property_blacklist?: string[]
|
|
596
586
|
xhr_headers?: { [header_name: string]: string }
|
|
587
|
+
on_xhr_error?: (failedRequest: XMLHttpRequest) => void
|
|
597
588
|
inapp_protocol?: string
|
|
598
589
|
inapp_link_new_window?: boolean
|
|
599
590
|
request_batching?: boolean
|
|
@@ -747,6 +738,30 @@ declare namespace posthog {
|
|
|
747
738
|
callback?: posthog.CaptureCallback
|
|
748
739
|
): posthog.Properties
|
|
749
740
|
|
|
741
|
+
/*
|
|
742
|
+
* Increment numerical properties on a user record
|
|
743
|
+
*
|
|
744
|
+
* ### Usage:
|
|
745
|
+
*
|
|
746
|
+
* posthog.people.increment('times visited platform', 1);
|
|
747
|
+
*
|
|
748
|
+
* // or set multiple properties at once
|
|
749
|
+
* posthog.people.increment({
|
|
750
|
+
* 'times visited platform': 1,
|
|
751
|
+
* 'total amount spent': 100
|
|
752
|
+
* });
|
|
753
|
+
*
|
|
754
|
+
*
|
|
755
|
+
* @param {Object|String} prop If a string, this is the name of the property. If an object, this is an associative array of names and values.
|
|
756
|
+
* @param {*} [to] A value to set on the given property name
|
|
757
|
+
* @param {Function} [callback] If provided, the callback will be called after captureing the event.
|
|
758
|
+
*/
|
|
759
|
+
static increment(
|
|
760
|
+
prop: posthog.Properties | string,
|
|
761
|
+
to?: posthog.Property,
|
|
762
|
+
callback?: posthog.CaptureCallback
|
|
763
|
+
): posthog.Properties
|
|
764
|
+
|
|
750
765
|
static toString(): string
|
|
751
766
|
}
|
|
752
767
|
|
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.14.0";
|
|
869
869
|
|
|
870
870
|
var Config = {
|
|
871
871
|
DEBUG: false,
|
|
@@ -2005,6 +2005,21 @@ function shouldCaptureValue(value) {
|
|
|
2005
2005
|
|
|
2006
2006
|
return true;
|
|
2007
2007
|
}
|
|
2008
|
+
/*
|
|
2009
|
+
* Check whether an attribute name is an Angular content attr
|
|
2010
|
+
* These update on each build and lead to noise in the element chain
|
|
2011
|
+
* https://stackoverflow.com/questions/45082129/what-does-ngcontent-c-mean-in-angular
|
|
2012
|
+
* @param {string} attributeName - string value to check
|
|
2013
|
+
* @returns {boolean} whether the element is an angular tag
|
|
2014
|
+
*/
|
|
2015
|
+
|
|
2016
|
+
function isAngularContentAttr(attributeName) {
|
|
2017
|
+
if (typeof attributeName === 'string') {
|
|
2018
|
+
return attributeName.substring(0, 10) === '_ngcontent';
|
|
2019
|
+
}
|
|
2020
|
+
|
|
2021
|
+
return false;
|
|
2022
|
+
}
|
|
2008
2023
|
function loadScript(scriptUrlToLoad, callback) {
|
|
2009
2024
|
var scriptTag = document.createElement('script');
|
|
2010
2025
|
scriptTag.type = 'text/javascript';
|
|
@@ -2101,7 +2116,7 @@ var autocapture = {
|
|
|
2101
2116
|
// Only capture attributes we know are safe
|
|
2102
2117
|
if (isSensitiveElement(elem) && ['name', 'id', 'class'].indexOf(attr.name) === -1) return;
|
|
2103
2118
|
|
|
2104
|
-
if (!maskInputs && shouldCaptureValue(attr.value)) {
|
|
2119
|
+
if (!maskInputs && shouldCaptureValue(attr.value) && !isAngularContentAttr(attr.name)) {
|
|
2105
2120
|
props['attr__' + attr.name] = attr.value;
|
|
2106
2121
|
}
|
|
2107
2122
|
});
|
|
@@ -2756,42 +2771,38 @@ function _addOptOutCheck(method, getConfigValue, silenceErrors) {
|
|
|
2756
2771
|
var SET_ACTION = '$set';
|
|
2757
2772
|
/** @const */
|
|
2758
2773
|
|
|
2759
|
-
var SET_ONCE_ACTION = '$set_once';
|
|
2774
|
+
var SET_ONCE_ACTION = '$set_once';
|
|
2775
|
+
/** @const */
|
|
2776
|
+
|
|
2777
|
+
var INCREMENT_ACTION = '$increment'; // Internal methods for posthog.people API.
|
|
2760
2778
|
// These methods shouldn't involve network I/O.
|
|
2761
2779
|
|
|
2762
2780
|
var apiActions = {
|
|
2763
2781
|
set_action: function set_action(prop, to) {
|
|
2764
|
-
|
|
2765
|
-
var $set = {};
|
|
2766
|
-
|
|
2767
|
-
if (_.isObject(prop)) {
|
|
2768
|
-
_.each(prop, function (v, k) {
|
|
2769
|
-
if (!this._is_reserved_property(k)) {
|
|
2770
|
-
$set[k] = v;
|
|
2771
|
-
}
|
|
2772
|
-
}, this);
|
|
2773
|
-
} else {
|
|
2774
|
-
$set[prop] = to;
|
|
2775
|
-
}
|
|
2776
|
-
|
|
2777
|
-
data[SET_ACTION] = $set;
|
|
2778
|
-
return data;
|
|
2782
|
+
return this.apiActionParser(SET_ACTION, prop, to);
|
|
2779
2783
|
},
|
|
2780
2784
|
set_once_action: function set_once_action(prop, to) {
|
|
2785
|
+
return this.apiActionParser(SET_ONCE_ACTION, prop, to);
|
|
2786
|
+
},
|
|
2787
|
+
increment_action: function increment_action(prop, to) {
|
|
2788
|
+
var a = this.apiActionParser(INCREMENT_ACTION, prop, to);
|
|
2789
|
+
return a;
|
|
2790
|
+
},
|
|
2791
|
+
apiActionParser: function apiActionParser(actionType, prop, to) {
|
|
2781
2792
|
var data = {};
|
|
2782
|
-
var
|
|
2793
|
+
var props = {};
|
|
2783
2794
|
|
|
2784
2795
|
if (_.isObject(prop)) {
|
|
2785
2796
|
_.each(prop, function (v, k) {
|
|
2786
2797
|
if (!this._is_reserved_property(k)) {
|
|
2787
|
-
|
|
2798
|
+
props[k] = v;
|
|
2788
2799
|
}
|
|
2789
2800
|
}, this);
|
|
2790
2801
|
} else {
|
|
2791
|
-
|
|
2802
|
+
props[prop] = to;
|
|
2792
2803
|
}
|
|
2793
2804
|
|
|
2794
|
-
data[
|
|
2805
|
+
data[actionType] = props;
|
|
2795
2806
|
return data;
|
|
2796
2807
|
}
|
|
2797
2808
|
};
|
|
@@ -2877,6 +2888,38 @@ PostHogPeople.prototype.set_once = addOptOutCheckPostHogPeople(function (prop, t
|
|
|
2877
2888
|
|
|
2878
2889
|
return this._send_request(data, callback);
|
|
2879
2890
|
});
|
|
2891
|
+
/*
|
|
2892
|
+
* Increment numerical properties on a user record
|
|
2893
|
+
*
|
|
2894
|
+
* ### Usage:
|
|
2895
|
+
*
|
|
2896
|
+
* posthog.people.increment('times visited platform', 1);
|
|
2897
|
+
*
|
|
2898
|
+
* // or set multiple properties at once
|
|
2899
|
+
* posthog.people.increment({
|
|
2900
|
+
* 'times visited platform': 1,
|
|
2901
|
+
* 'total amount spent': 100
|
|
2902
|
+
* });
|
|
2903
|
+
*
|
|
2904
|
+
*
|
|
2905
|
+
* @param {Object|String} prop If a string, this is the name of the property. If an object, this is an associative array of names and values.
|
|
2906
|
+
* @param {*} [to] A value to set on the given property name
|
|
2907
|
+
* @param {Function} [callback] If provided, the callback will be called after captureing the event.
|
|
2908
|
+
*/
|
|
2909
|
+
|
|
2910
|
+
PostHogPeople.prototype.increment = addOptOutCheckPostHogPeople(function (prop, to, callback) {
|
|
2911
|
+
var data = this.increment_action(prop, to);
|
|
2912
|
+
|
|
2913
|
+
if (_.isObject(prop)) {
|
|
2914
|
+
callback = to;
|
|
2915
|
+
}
|
|
2916
|
+
|
|
2917
|
+
return this._send_request({
|
|
2918
|
+
properties: {
|
|
2919
|
+
$increment: data['$increment']
|
|
2920
|
+
}
|
|
2921
|
+
}, callback);
|
|
2922
|
+
});
|
|
2880
2923
|
|
|
2881
2924
|
PostHogPeople.prototype.toString = function () {
|
|
2882
2925
|
return this._posthog.toString() + '.people';
|
|
@@ -4922,7 +4965,8 @@ var xhr = function xhr(_ref) {
|
|
|
4922
4965
|
captureMetrics = _ref.captureMetrics,
|
|
4923
4966
|
callback = _ref.callback,
|
|
4924
4967
|
retriesPerformedSoFar = _ref.retriesPerformedSoFar,
|
|
4925
|
-
retryQueue = _ref.retryQueue
|
|
4968
|
+
retryQueue = _ref.retryQueue,
|
|
4969
|
+
onXHRError = _ref.onXHRError;
|
|
4926
4970
|
var req = new XMLHttpRequest();
|
|
4927
4971
|
req.open(options.method, url, true);
|
|
4928
4972
|
var body = encodePostData(data, options);
|
|
@@ -4966,8 +5010,10 @@ var xhr = function xhr(_ref) {
|
|
|
4966
5010
|
callback(response);
|
|
4967
5011
|
}
|
|
4968
5012
|
} else {
|
|
4969
|
-
|
|
4970
|
-
|
|
5013
|
+
if (typeof onXHRError === 'function') {
|
|
5014
|
+
onXHRError(req);
|
|
5015
|
+
} // don't retry certain errors
|
|
5016
|
+
|
|
4971
5017
|
|
|
4972
5018
|
if ([401, 403, 404, 500].indexOf(req.status) < 0) {
|
|
4973
5019
|
retryQueue.enqueue({
|
|
@@ -5008,7 +5054,7 @@ var RetryQueue = /*#__PURE__*/function (_RequestQueueScaffold) {
|
|
|
5008
5054
|
|
|
5009
5055
|
var _super = _createSuper(RetryQueue);
|
|
5010
5056
|
|
|
5011
|
-
function RetryQueue(captureMetrics) {
|
|
5057
|
+
function RetryQueue(captureMetrics, onXHRError) {
|
|
5012
5058
|
var _this;
|
|
5013
5059
|
|
|
5014
5060
|
_classCallCheck(this, RetryQueue);
|
|
@@ -5018,6 +5064,7 @@ var RetryQueue = /*#__PURE__*/function (_RequestQueueScaffold) {
|
|
|
5018
5064
|
_this.isPolling = false;
|
|
5019
5065
|
_this.queue = [];
|
|
5020
5066
|
_this.areWeOnline = true;
|
|
5067
|
+
_this.onXHRError = onXHRError;
|
|
5021
5068
|
|
|
5022
5069
|
if ('onLine' in window.navigator) {
|
|
5023
5070
|
_this.areWeOnline = window.navigator.onLine;
|
|
@@ -5143,7 +5190,8 @@ var RetryQueue = /*#__PURE__*/function (_RequestQueueScaffold) {
|
|
|
5143
5190
|
retriesPerformedSoFar: retriesPerformedSoFar || 0,
|
|
5144
5191
|
callback: callback,
|
|
5145
5192
|
captureMetrics: this.captureMetrics,
|
|
5146
|
-
retryQueue: this
|
|
5193
|
+
retryQueue: this,
|
|
5194
|
+
onXHRError: this.onXHRError
|
|
5147
5195
|
});
|
|
5148
5196
|
}
|
|
5149
5197
|
}, {
|
|
@@ -5243,6 +5291,10 @@ var defaultConfig = function defaultConfig() {
|
|
|
5243
5291
|
mask_all_element_attributes: false,
|
|
5244
5292
|
mask_all_text: false,
|
|
5245
5293
|
advanced_disable_decide: false,
|
|
5294
|
+
on_xhr_error: function on_xhr_error(req) {
|
|
5295
|
+
var error = 'Bad HTTP status: ' + req.status + ' ' + req.statusText;
|
|
5296
|
+
console$1.error(error);
|
|
5297
|
+
},
|
|
5246
5298
|
// Used for internal testing
|
|
5247
5299
|
_onCapture: function _onCapture() {},
|
|
5248
5300
|
_capture_metrics: false
|
|
@@ -5389,7 +5441,7 @@ PostHogLib.prototype._init = function (token, config, name) {
|
|
|
5389
5441
|
|
|
5390
5442
|
this._captureMetrics = new CaptureMetrics(this.get_config('_capture_metrics'), _.bind(this.capture, this));
|
|
5391
5443
|
this._requestQueue = new RequestQueue(this._captureMetrics, _.bind(this._handle_queued_event, this));
|
|
5392
|
-
this._retryQueue = new RetryQueue(this._captureMetrics);
|
|
5444
|
+
this._retryQueue = new RetryQueue(this._captureMetrics, this.get_config('on_xhr_error'));
|
|
5393
5445
|
this.__captureHooks = [];
|
|
5394
5446
|
this.__request_queue = [];
|
|
5395
5447
|
this['persistence'] = new PostHogPersistence(this['config']);
|
|
@@ -5421,7 +5473,9 @@ PostHogLib.prototype._loaded = function () {
|
|
|
5421
5473
|
|
|
5422
5474
|
|
|
5423
5475
|
if (this.get_config('capture_pageview')) {
|
|
5424
|
-
this.
|
|
5476
|
+
this.capture('$pageview', {}, {
|
|
5477
|
+
send_instantly: true
|
|
5478
|
+
});
|
|
5425
5479
|
}
|
|
5426
5480
|
};
|
|
5427
5481
|
|
|
@@ -5573,7 +5627,8 @@ PostHogLib.prototype._send_request = function (url, data, options, callback) {
|
|
|
5573
5627
|
captureMetrics: this._captureMetrics,
|
|
5574
5628
|
callback: callback,
|
|
5575
5629
|
retriesPerformedSoFar: 0,
|
|
5576
|
-
retryQueue: this._retryQueue
|
|
5630
|
+
retryQueue: this._retryQueue,
|
|
5631
|
+
onXHRError: this.get_config('on_xhr_error')
|
|
5577
5632
|
});
|
|
5578
5633
|
} catch (e) {
|
|
5579
5634
|
console$1.error(e);
|
|
@@ -5741,7 +5796,7 @@ PostHogLib.prototype.capture = addOptOutCheckPostHogLib(function (event_name, pr
|
|
|
5741
5796
|
var url = this.get_config('api_host') + (options.endpoint || '/e/');
|
|
5742
5797
|
var has_unique_traits = options !== __NOOPTIONS;
|
|
5743
5798
|
|
|
5744
|
-
if (this.get_config('request_batching') && (!has_unique_traits || options._batchKey)) {
|
|
5799
|
+
if (this.get_config('request_batching') && (!has_unique_traits || options._batchKey) && !options.send_instantly) {
|
|
5745
5800
|
data['timestamp'] = new Date();
|
|
5746
5801
|
|
|
5747
5802
|
this._requestQueue.enqueue(url, data, options);
|
|
@@ -5806,23 +5861,6 @@ PostHogLib.prototype._calculate_event_properties = function (event_name, event_p
|
|
|
5806
5861
|
|
|
5807
5862
|
return properties;
|
|
5808
5863
|
};
|
|
5809
|
-
/**
|
|
5810
|
-
* Capture a page view event.
|
|
5811
|
-
* This function is called by default on page load unless the
|
|
5812
|
-
* capture_pageview configuration variable is false.
|
|
5813
|
-
*
|
|
5814
|
-
* @param {String} [page] The url of the page to record. If you don't include this, it defaults to the current url.
|
|
5815
|
-
* @api private
|
|
5816
|
-
*/
|
|
5817
|
-
|
|
5818
|
-
|
|
5819
|
-
PostHogLib.prototype.capture_pageview = function (page) {
|
|
5820
|
-
if (_.isUndefined(page)) {
|
|
5821
|
-
page = document$1.location.href;
|
|
5822
|
-
}
|
|
5823
|
-
|
|
5824
|
-
this.capture('$pageview');
|
|
5825
|
-
};
|
|
5826
5864
|
/**
|
|
5827
5865
|
* Register a set of super properties, which are included with all
|
|
5828
5866
|
* events. This will overwrite previous super property values.
|
|
@@ -6690,7 +6728,6 @@ PostHogLib.prototype.decodeLZ64 = LZString.decompressFromBase64; // EXPORTS (for
|
|
|
6690
6728
|
PostHogLib.prototype['init'] = PostHogLib.prototype.init;
|
|
6691
6729
|
PostHogLib.prototype['reset'] = PostHogLib.prototype.reset;
|
|
6692
6730
|
PostHogLib.prototype['capture'] = PostHogLib.prototype.capture;
|
|
6693
|
-
PostHogLib.prototype['capture_pageview'] = PostHogLib.prototype.capture_pageview;
|
|
6694
6731
|
PostHogLib.prototype['register'] = PostHogLib.prototype.register;
|
|
6695
6732
|
PostHogLib.prototype['register_once'] = PostHogLib.prototype.register_once;
|
|
6696
6733
|
PostHogLib.prototype['unregister'] = PostHogLib.prototype.unregister;
|
package/package.json
CHANGED