posthog-js 1.23.0 → 1.24.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/dist/array.js +2 -2
- package/dist/es.js +29 -14
- package/dist/module.js +29 -14
- package/package.json +8 -4
package/dist/array.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
parcelRequire=function(e,r,t,n){var i,o="function"==typeof parcelRequire&&parcelRequire,u="function"==typeof require&&require;function f(t,n){if(!r[t]){if(!e[t]){var i="function"==typeof parcelRequire&&parcelRequire;if(!n&&i)return i(t,!0);if(o)return o(t,!0);if(u&&"string"==typeof t)return u(t);var c=new Error("Cannot find module '"+t+"'");throw c.code="MODULE_NOT_FOUND",c}p.resolve=function(r){return e[t][1][r]||r},p.cache={};var l=r[t]=new f.Module(t);e[t][0].call(l.exports,p,l,l.exports,this)}return r[t].exports;function p(e){return f(p.resolve(e))}}f.isParcelRequire=!0,f.Module=function(e){this.id=e,this.bundle=f,this.exports={}},f.modules=e,f.cache=r,f.parent=o,f.register=function(r,t){e[r]=[function(e,r){r.exports=t},{}]};for(var c=0;c<t.length;c++)try{f(t[c])}catch(e){i||(i=e)}if(t.length){var l=f(t[t.length-1]);"object"==typeof exports&&"undefined"!=typeof module?module.exports=l:"function"==typeof define&&define.amd?define(function(){return l}):n&&(this[n]=l)}if(parcelRequire=f,i)throw i;return f}({"zdbk":[function(require,module,exports) {
|
|
2
2
|
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.LZString=void 0;var o=String.fromCharCode,r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-$",n={};function t(o,r){if(!n[o]){n[o]={};for(var e=0;e<o.length;e++)n[o][o.charAt(e)]=e}return n[o][r]}var s={compressToBase64:function(o){if(null==o)return"";var e=s._compress(o,6,function(o){return r.charAt(o)});switch(e.length%4){default:case 0:return e;case 1:return e+"===";case 2:return e+"==";case 3:return e+"="}},decompressFromBase64:function(o){return null==o?"":""==o?null:s._decompress(o.length,32,function(e){return t(r,o.charAt(e))})},compressToUTF16:function(r){return null==r?"":s._compress(r,15,function(r){return o(r+32)})+" "},decompressFromUTF16:function(o){return null==o?"":""==o?null:s._decompress(o.length,16384,function(r){return o.charCodeAt(r)-32})},compressToUint8Array:function(o){for(var r=s.compress(o),e=new Uint8Array(2*r.length),n=0,t=r.length;n<t;n++){var i=r.charCodeAt(n);e[2*n]=i>>>8,e[2*n+1]=i%256}return e},decompressFromUint8Array:function(r){if(null==r)return s.decompress(r);for(var e=new Array(r.length/2),n=0,t=e.length;n<t;n++)e[n]=256*r[2*n]+r[2*n+1];var i=[];return e.forEach(function(r){i.push(o(r))}),s.decompress(i.join(""))},compressToEncodedURIComponent:function(o){return null==o?"":s._compress(o,6,function(o){return e.charAt(o)})},decompressFromEncodedURIComponent:function(o){return null==o?"":""==o?null:(o=o.replace(/ /g,"+"),s._decompress(o.length,32,function(r){return t(e,o.charAt(r))}))},compress:function(r){return s._compress(r,16,function(r){return o(r)})},_compress:function(o,r,e){if(null==o)return"";var n,t,s,i={},p={},c="",a="",u="",l=2,f=3,h=2,d=[],m=0,v=0;for(s=0;s<o.length;s+=1)if(c=o.charAt(s),Object.prototype.hasOwnProperty.call(i,c)||(i[c]=f++,p[c]=!0),a=u+c,Object.prototype.hasOwnProperty.call(i,a))u=a;else{if(Object.prototype.hasOwnProperty.call(p,u)){if(u.charCodeAt(0)<256){for(n=0;n<h;n++)m<<=1,v==r-1?(v=0,d.push(e(m)),m=0):v++;for(t=u.charCodeAt(0),n=0;n<8;n++)m=m<<1|1&t,v==r-1?(v=0,d.push(e(m)),m=0):v++,t>>=1}else{for(t=1,n=0;n<h;n++)m=m<<1|t,v==r-1?(v=0,d.push(e(m)),m=0):v++,t=0;for(t=u.charCodeAt(0),n=0;n<16;n++)m=m<<1|1&t,v==r-1?(v=0,d.push(e(m)),m=0):v++,t>>=1}0==--l&&(l=Math.pow(2,h),h++),delete p[u]}else for(t=i[u],n=0;n<h;n++)m=m<<1|1&t,v==r-1?(v=0,d.push(e(m)),m=0):v++,t>>=1;0==--l&&(l=Math.pow(2,h),h++),i[a]=f++,u=String(c)}if(""!==u){if(Object.prototype.hasOwnProperty.call(p,u)){if(u.charCodeAt(0)<256){for(n=0;n<h;n++)m<<=1,v==r-1?(v=0,d.push(e(m)),m=0):v++;for(t=u.charCodeAt(0),n=0;n<8;n++)m=m<<1|1&t,v==r-1?(v=0,d.push(e(m)),m=0):v++,t>>=1}else{for(t=1,n=0;n<h;n++)m=m<<1|t,v==r-1?(v=0,d.push(e(m)),m=0):v++,t=0;for(t=u.charCodeAt(0),n=0;n<16;n++)m=m<<1|1&t,v==r-1?(v=0,d.push(e(m)),m=0):v++,t>>=1}0==--l&&(l=Math.pow(2,h),h++),delete p[u]}else for(t=i[u],n=0;n<h;n++)m=m<<1|1&t,v==r-1?(v=0,d.push(e(m)),m=0):v++,t>>=1;0==--l&&(l=Math.pow(2,h),h++)}for(t=2,n=0;n<h;n++)m=m<<1|1&t,v==r-1?(v=0,d.push(e(m)),m=0):v++,t>>=1;for(;;){if(m<<=1,v==r-1){d.push(e(m));break}v++}return d.join("")},decompress:function(o){return null==o?"":""==o?null:s._decompress(o.length,32768,function(r){return o.charCodeAt(r)})},_decompress:function(r,e,n){var t,s,i,p,c,a,u,l=[],f=4,h=4,d=3,m="",v=[],w={val:n(0),position:e,index:1};for(t=0;t<3;t+=1)l[t]=t;for(i=0,c=Math.pow(2,2),a=1;a!=c;)p=w.val&w.position,w.position>>=1,0==w.position&&(w.position=e,w.val=n(w.index++)),i|=(p>0?1:0)*a,a<<=1;switch(i){case 0:for(i=0,c=Math.pow(2,8),a=1;a!=c;)p=w.val&w.position,w.position>>=1,0==w.position&&(w.position=e,w.val=n(w.index++)),i|=(p>0?1:0)*a,a<<=1;u=o(i);break;case 1:for(i=0,c=Math.pow(2,16),a=1;a!=c;)p=w.val&w.position,w.position>>=1,0==w.position&&(w.position=e,w.val=n(w.index++)),i|=(p>0?1:0)*a,a<<=1;u=o(i);break;case 2:return""}for(l[3]=u,s=u,v.push(u);;){if(w.index>r)return"";for(i=0,c=Math.pow(2,d),a=1;a!=c;)p=w.val&w.position,w.position>>=1,0==w.position&&(w.position=e,w.val=n(w.index++)),i|=(p>0?1:0)*a,a<<=1;switch(u=i){case 0:for(i=0,c=Math.pow(2,8),a=1;a!=c;)p=w.val&w.position,w.position>>=1,0==w.position&&(w.position=e,w.val=n(w.index++)),i|=(p>0?1:0)*a,a<<=1;l[h++]=o(i),u=h-1,f--;break;case 1:for(i=0,c=Math.pow(2,16),a=1;a!=c;)p=w.val&w.position,w.position>>=1,0==w.position&&(w.position=e,w.val=n(w.index++)),i|=(p>0?1:0)*a,a<<=1;l[h++]=o(i),u=h-1,f--;break;case 2:return v.join("")}if(0==f&&(f=Math.pow(2,d),d++),l[u])m=l[u];else{if(u!==h)return null;m=s+s.charAt(0)}v.push(m),l[h++]=s+m.charAt(0),s=m,0==--f&&(f=Math.pow(2,d),d++)}}};exports.LZString=s;
|
|
3
3
|
},{}],"EHrm":[function(require,module,exports) {
|
|
4
|
-
module.exports={name:"posthog-js",version:"1.
|
|
4
|
+
module.exports={name:"posthog-js",version:"1.24.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.14"},devDependencies:{"@babel/core":"7.12.10","@babel/preset-env":"7.12.11","@rollup/plugin-babel":"^5.2.1","@rollup/plugin-json":"^4.1.0","@rollup/plugin-node-resolve":"^8.1.0","@typescript-eslint/eslint-plugin":"^3.5.0","@typescript-eslint/parser":"^3.5.0","babel-eslint":"10.1.0","babel-jest":"^26.6.3",cypress:"^9.2.0",eslint:"7.3.1","eslint-plugin-prettier":"^3.1.4","eslint-plugin-react":"^7.21.5","eslint-plugin-react-hooks":"^4.2.0","fast-check":"^2.17.0",given2:"^2.1.7",husky:"^4.2.5",jest:"^27.5.1",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.1.3",sinon:"9.0.2",testcafe:"^1.19.0","testcafe-browser-provider-browserstack":"^1.14.0",typescript:"^3.9.6"},husky:{hooks:{"pre-commit":"lint-staged"}},"lint-staged":{"*.{ts,tsx,js,json}":"prettier --write","*.{ts,tsx}":["eslint -c .eslintrc.ts.js --fix","tsc --noEmit --esModuleInterop --jsx react"]},jest:{testPathIgnorePatterns:["/node_modules/","/cypress/","/react/","/test_data/"],moduleFileExtensions:["js","json"],setupFilesAfterEnv:["given2/setup","./src/__tests__/setup.js"],modulePathIgnorePatterns:["src/__tests__/setup.js"],clearMocks:!0,testEnvironment:"jsdom"}};
|
|
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) {
|
|
@@ -47,7 +47,7 @@ module.exports={name:"posthog-js",version:"1.23.0",description:"Posthog-js allow
|
|
|
47
47
|
},{"./utils":"FOZT","./config":"itQ5"}],"ennf":[function(require,module,exports) {
|
|
48
48
|
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.RetryQueue=void 0;var e=require("./base-request-queue"),t=require("./send-request");function r(e){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function n(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function o(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?n(Object(r),!0).forEach(function(t){i(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):n(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function i(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function u(e,t){var r;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(r=a(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,o=function(){};return{s:o,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,u=!0,c=!1;return{s:function(){r=e[Symbol.iterator]()},n:function(){var e=r.next();return u=e.done,e},e:function(e){c=!0,i=e},f:function(){try{u||null==r.return||r.return()}finally{if(c)throw i}}}}function a(e,t){if(e){if("string"==typeof e)return c(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?c(e,t):void 0}}function c(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function l(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function f(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function s(e,t,r){return t&&f(e.prototype,t),r&&f(e,r),e}function y(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&p(e,t)}function p(e,t){return(p=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function h(e){var t=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;try{window.navigator.sendBeacon(i,(0,t.encodePostData)(a,o(o({},c),{},{sendBeacon:!0})))}catch(f){var l;(null===(l=this.get_config)||void 0===l?void 0:l.call(this,"debug"))&&console.error(f)}}}catch(s){r.e(s)}finally{r.f()}this.queue=[]}},{key:"_executeXhrRequest",value:function(e){var r=e.url,n=e.data,o=e.options,i=e.headers,u=e.callback,a=e.retriesPerformedSoFar;(0,t.xhr)({url:r,data:n||{},options:o||{},headers:i||{},retriesPerformedSoFar:a||0,callback:u,captureMetrics:this.captureMetrics,retryQueue:this,onXHRError:this.onXHRError})}},{key:"_handleWeAreNowOnline",value:function(){this.areWeOnline=!0,this.flush()}}]),i}();exports.RetryQueue=O;
|
|
49
49
|
},{"./base-request-queue":"ae0g","./send-request":"tOu2"}],"tci7":[function(require,module,exports) {
|
|
50
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.SessionIdManager=void 0;var e=require("./posthog-persistence"),t=require("./storage"),
|
|
50
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.SessionIdManager=void 0;var e=require("./posthog-persistence"),t=require("./storage"),i=require("./utils");function s(e,t){return u(e)||a(e,t)||r(e,t)||n()}function n(){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 r(e,t){if(e){if("string"==typeof e)return o(e,t);var i=Object.prototype.toString.call(e).slice(8,-1);return"Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i?Array.from(e):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?o(e,t):void 0}}function o(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,s=new Array(t);i<t;i++)s[i]=e[i];return s}function a(e,t){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e)){var i=[],s=!0,n=!1,r=void 0;try{for(var o,a=e[Symbol.iterator]();!(s=(o=a.next()).done)&&(i.push(o.value),!t||i.length!==t);s=!0);}catch(u){n=!0,r=u}finally{try{s||null==a.return||a.return()}finally{if(n)throw r}}return i}}function u(e){if(Array.isArray(e))return e}function d(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function l(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function c(e,t){for(var i=0;i<t.length;i++){var s=t[i];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(e,s.key,s)}}function _(e,t,i){return t&&c(e.prototype,t),i&&c(e,i),e}var h=18e5,p=864e5,f=function(){function n(e,t){l(this,n),this.persistence=t,e.persistence_name?this.window_id_storage_key="ph_"+e.persistence_name+"_window_id":this.window_id_storage_key="ph_"+e.token+"_window_id"}return _(n,[{key:"_setWindowId",value:function(e){e!==this._windowId&&(this._windowId=e,!this.persistence.disabled&&t.sessionStore.is_supported()&&t.sessionStore.set(this.window_id_storage_key,e))}},{key:"_getWindowId",value:function(){return this._windowId?this._windowId:!this.persistence.disabled&&t.sessionStore.is_supported()?t.sessionStore.parse(this.window_id_storage_key):null}},{key:"_setSessionId",value:function(t,i,s){t===this._sessionId&&i===this._sessionActivityTimestamp&&s===this._sessionStartTimestamp||(this._sessionStartTimestamp=s,this._sessionActivityTimestamp=i,this._sessionId=t,this.persistence.register(d({},e.SESSION_ID,[i,t,s])))}},{key:"_getSessionId",value:function(){if(this._sessionId&&this._sessionActivityTimestamp&&this._sessionStartTimestamp)return[this._sessionActivityTimestamp,this._sessionId,this._sessionStartTimestamp];var t=this.persistence.props[e.SESSION_ID];return Array.isArray(t)&&2===t.length&&t.push(t[0]),t||[0,null,0]}},{key:"resetSessionId",value:function(){this._setSessionId(null,null,null)}},{key:"checkAndGetSessionAndWindowId",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;t=t||(new Date).getTime();var n=s(this._getSessionId(),3),r=n[0],o=n[1],a=n[2],u=this._getWindowId(),d=a&&a>0&&Math.abs(t-a)>p;!o||!e&&Math.abs(t-r)>h||d?(o=i._.UUID(),u=i._.UUID(),a=t):u||(u=i._.UUID());var l=0===r||!e||d?t:r,c=0===a?(new Date).getTime():a;return this._setWindowId(u),this._setSessionId(o,l,c),{sessionId:o,windowId:u}}}]),n}();exports.SessionIdManager=f;
|
|
51
51
|
},{"./posthog-persistence":"MAdm","./storage":"KZ7Y","./utils":"FOZT"}],"eWVp":[function(require,module,exports) {
|
|
52
52
|
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.optimisePerformanceData=i,exports.getPerformanceEntriesByType=a,exports.deduplicateKeys=u,exports.pageLoadFrom=c,exports.getPerformanceData=f;var e=require("./utils"),r=n(require("./config"));function n(e){return e&&e.__esModule?e:{default:e}}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 o(e){return Number(e)===e&&e%1!=0}function i(e){return e.forEach(function(r,n){for(var t in r)o(r[t])&&r[t].toString().match(/^\d+\.\d{4,}$/)&&(e[n][t]=Number(r[t].toFixed(3))),["serverTiming","workerTiming"].includes(t)&&0===r[t].length&&delete e[n][t],"entryType"===t&&"resource"===r[t]&&delete e[n][t],"nextHopProtocol"===t&&delete e[n][t],0===r[t]&&delete e[n][t]}),u(e)}function a(n){try{return i(JSON.parse(JSON.stringify(e.window.performance.getEntriesByType(n))))}catch(t){return r.default.DEBUG&&console.warn("not able to capture performance data ("+n+") - "+t),[]}}function u(e){if(0===e.length)return[];var r=Object.keys(e[0]);return[r,e.map(function(e){return r.map(function(r){return e[r]})})]}function c(e){var r=e.navigation&&e.navigation[0],n=e.navigation&&e.navigation[1]&&e.navigation[1][0],t=r&&r.indexOf("duration");if(t>-1)return n[t];var o=r&&r.indexOf("loadEventEnd"),i=r&&r.indexOf("startTime");return o>-1?(n&&n[o])-(n&&n[i]||0):void 0}function f(){var r={navigation:a("navigation"),paint:a("paint"),resource:a("resource")};void 0!==t(e.window)&&e.window.performance&&e.window.performance.clearResourceTimings&&e.window.performance.clearResourceTimings();var n={},o=c(r);return o&&(n.$performance_page_loaded=o),n.$performance_raw=JSON.stringify(r),n}
|
|
53
53
|
},{"./utils":"FOZT","./config":"itQ5"}],"ok3T":[function(require,module,exports) {
|
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.24.0";
|
|
867
867
|
|
|
868
868
|
var Config$1 = {
|
|
869
869
|
DEBUG: false,
|
|
@@ -5529,6 +5529,8 @@ var RetryQueue = /*#__PURE__*/function (_RequestQueueScaffold) {
|
|
|
5529
5529
|
|
|
5530
5530
|
var SESSION_CHANGE_THRESHOLD = 30 * 60 * 1000; // 30 mins
|
|
5531
5531
|
|
|
5532
|
+
var SESSION_LENGTH_LIMIT = 24 * 3600 * 1000; // 24 hours
|
|
5533
|
+
|
|
5532
5534
|
var SessionIdManager = /*#__PURE__*/function () {
|
|
5533
5535
|
function SessionIdManager(config, persistence) {
|
|
5534
5536
|
_classCallCheck(this, SessionIdManager);
|
|
@@ -5574,28 +5576,36 @@ var SessionIdManager = /*#__PURE__*/function () {
|
|
|
5574
5576
|
|
|
5575
5577
|
}, {
|
|
5576
5578
|
key: "_setSessionId",
|
|
5577
|
-
value: function _setSessionId(sessionId,
|
|
5578
|
-
if (sessionId !== this._sessionId ||
|
|
5579
|
-
this.
|
|
5579
|
+
value: function _setSessionId(sessionId, sessionActivityTimestamp, sessionStartTimestamp) {
|
|
5580
|
+
if (sessionId !== this._sessionId || sessionActivityTimestamp !== this._sessionActivityTimestamp || sessionStartTimestamp !== this._sessionStartTimestamp) {
|
|
5581
|
+
this._sessionStartTimestamp = sessionStartTimestamp;
|
|
5582
|
+
this._sessionActivityTimestamp = sessionActivityTimestamp;
|
|
5580
5583
|
this._sessionId = sessionId;
|
|
5581
|
-
this.persistence.register(_defineProperty({}, SESSION_ID, [
|
|
5584
|
+
this.persistence.register(_defineProperty({}, SESSION_ID, [sessionActivityTimestamp, sessionId, sessionStartTimestamp]));
|
|
5582
5585
|
}
|
|
5583
5586
|
}
|
|
5584
5587
|
}, {
|
|
5585
5588
|
key: "_getSessionId",
|
|
5586
5589
|
value: function _getSessionId() {
|
|
5587
|
-
if (this._sessionId && this.
|
|
5588
|
-
return [this.
|
|
5590
|
+
if (this._sessionId && this._sessionActivityTimestamp && this._sessionStartTimestamp) {
|
|
5591
|
+
return [this._sessionActivityTimestamp, this._sessionId, this._sessionStartTimestamp];
|
|
5589
5592
|
}
|
|
5590
5593
|
|
|
5591
|
-
|
|
5594
|
+
var sessionId = this.persistence['props'][SESSION_ID];
|
|
5595
|
+
|
|
5596
|
+
if (Array.isArray(sessionId) && sessionId.length === 2) {
|
|
5597
|
+
// Storage does not yet have a session start time. Add the last activity timestamp as the start time
|
|
5598
|
+
sessionId.push(sessionId[0]);
|
|
5599
|
+
}
|
|
5600
|
+
|
|
5601
|
+
return sessionId || [0, null, 0];
|
|
5592
5602
|
} // Resets the session id by setting it to null. On the subsequent call to checkAndGetSessionAndWindowId,
|
|
5593
5603
|
// new ids will be generated.
|
|
5594
5604
|
|
|
5595
5605
|
}, {
|
|
5596
5606
|
key: "resetSessionId",
|
|
5597
5607
|
value: function resetSessionId() {
|
|
5598
|
-
this._setSessionId(null, null);
|
|
5608
|
+
this._setSessionId(null, null, null);
|
|
5599
5609
|
}
|
|
5600
5610
|
/*
|
|
5601
5611
|
* This function returns the current sessionId and windowId. It should be used to
|
|
@@ -5622,24 +5632,29 @@ var SessionIdManager = /*#__PURE__*/function () {
|
|
|
5622
5632
|
timestamp = timestamp || new Date().getTime();
|
|
5623
5633
|
|
|
5624
5634
|
var _this$_getSessionId = this._getSessionId(),
|
|
5625
|
-
_this$_getSessionId2 = _slicedToArray(_this$_getSessionId,
|
|
5635
|
+
_this$_getSessionId2 = _slicedToArray(_this$_getSessionId, 3),
|
|
5626
5636
|
lastTimestamp = _this$_getSessionId2[0],
|
|
5627
|
-
sessionId = _this$_getSessionId2[1]
|
|
5637
|
+
sessionId = _this$_getSessionId2[1],
|
|
5638
|
+
startTimestamp = _this$_getSessionId2[2];
|
|
5628
5639
|
|
|
5629
5640
|
var windowId = this._getWindowId();
|
|
5630
5641
|
|
|
5631
|
-
|
|
5642
|
+
var sessionPastMaximumLength = startTimestamp && startTimestamp > 0 && Math.abs(timestamp - startTimestamp) > SESSION_LENGTH_LIMIT;
|
|
5643
|
+
|
|
5644
|
+
if (!sessionId || !readOnly && Math.abs(timestamp - lastTimestamp) > SESSION_CHANGE_THRESHOLD || sessionPastMaximumLength) {
|
|
5632
5645
|
sessionId = _.UUID();
|
|
5633
5646
|
windowId = _.UUID();
|
|
5647
|
+
startTimestamp = timestamp;
|
|
5634
5648
|
} else if (!windowId) {
|
|
5635
5649
|
windowId = _.UUID();
|
|
5636
5650
|
}
|
|
5637
5651
|
|
|
5638
|
-
var newTimestamp = lastTimestamp === 0 || !readOnly ? timestamp : lastTimestamp;
|
|
5652
|
+
var newTimestamp = lastTimestamp === 0 || !readOnly || sessionPastMaximumLength ? timestamp : lastTimestamp;
|
|
5653
|
+
var sessionStartTimestamp = startTimestamp === 0 ? new Date().getTime() : startTimestamp;
|
|
5639
5654
|
|
|
5640
5655
|
this._setWindowId(windowId);
|
|
5641
5656
|
|
|
5642
|
-
this._setSessionId(sessionId, newTimestamp);
|
|
5657
|
+
this._setSessionId(sessionId, newTimestamp, sessionStartTimestamp);
|
|
5643
5658
|
|
|
5644
5659
|
return {
|
|
5645
5660
|
sessionId: sessionId,
|
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.24.0";
|
|
869
869
|
|
|
870
870
|
var Config$1 = {
|
|
871
871
|
DEBUG: false,
|
|
@@ -5531,6 +5531,8 @@ var RetryQueue = /*#__PURE__*/function (_RequestQueueScaffold) {
|
|
|
5531
5531
|
|
|
5532
5532
|
var SESSION_CHANGE_THRESHOLD = 30 * 60 * 1000; // 30 mins
|
|
5533
5533
|
|
|
5534
|
+
var SESSION_LENGTH_LIMIT = 24 * 3600 * 1000; // 24 hours
|
|
5535
|
+
|
|
5534
5536
|
var SessionIdManager = /*#__PURE__*/function () {
|
|
5535
5537
|
function SessionIdManager(config, persistence) {
|
|
5536
5538
|
_classCallCheck(this, SessionIdManager);
|
|
@@ -5576,28 +5578,36 @@ var SessionIdManager = /*#__PURE__*/function () {
|
|
|
5576
5578
|
|
|
5577
5579
|
}, {
|
|
5578
5580
|
key: "_setSessionId",
|
|
5579
|
-
value: function _setSessionId(sessionId,
|
|
5580
|
-
if (sessionId !== this._sessionId ||
|
|
5581
|
-
this.
|
|
5581
|
+
value: function _setSessionId(sessionId, sessionActivityTimestamp, sessionStartTimestamp) {
|
|
5582
|
+
if (sessionId !== this._sessionId || sessionActivityTimestamp !== this._sessionActivityTimestamp || sessionStartTimestamp !== this._sessionStartTimestamp) {
|
|
5583
|
+
this._sessionStartTimestamp = sessionStartTimestamp;
|
|
5584
|
+
this._sessionActivityTimestamp = sessionActivityTimestamp;
|
|
5582
5585
|
this._sessionId = sessionId;
|
|
5583
|
-
this.persistence.register(_defineProperty({}, SESSION_ID, [
|
|
5586
|
+
this.persistence.register(_defineProperty({}, SESSION_ID, [sessionActivityTimestamp, sessionId, sessionStartTimestamp]));
|
|
5584
5587
|
}
|
|
5585
5588
|
}
|
|
5586
5589
|
}, {
|
|
5587
5590
|
key: "_getSessionId",
|
|
5588
5591
|
value: function _getSessionId() {
|
|
5589
|
-
if (this._sessionId && this.
|
|
5590
|
-
return [this.
|
|
5592
|
+
if (this._sessionId && this._sessionActivityTimestamp && this._sessionStartTimestamp) {
|
|
5593
|
+
return [this._sessionActivityTimestamp, this._sessionId, this._sessionStartTimestamp];
|
|
5591
5594
|
}
|
|
5592
5595
|
|
|
5593
|
-
|
|
5596
|
+
var sessionId = this.persistence['props'][SESSION_ID];
|
|
5597
|
+
|
|
5598
|
+
if (Array.isArray(sessionId) && sessionId.length === 2) {
|
|
5599
|
+
// Storage does not yet have a session start time. Add the last activity timestamp as the start time
|
|
5600
|
+
sessionId.push(sessionId[0]);
|
|
5601
|
+
}
|
|
5602
|
+
|
|
5603
|
+
return sessionId || [0, null, 0];
|
|
5594
5604
|
} // Resets the session id by setting it to null. On the subsequent call to checkAndGetSessionAndWindowId,
|
|
5595
5605
|
// new ids will be generated.
|
|
5596
5606
|
|
|
5597
5607
|
}, {
|
|
5598
5608
|
key: "resetSessionId",
|
|
5599
5609
|
value: function resetSessionId() {
|
|
5600
|
-
this._setSessionId(null, null);
|
|
5610
|
+
this._setSessionId(null, null, null);
|
|
5601
5611
|
}
|
|
5602
5612
|
/*
|
|
5603
5613
|
* This function returns the current sessionId and windowId. It should be used to
|
|
@@ -5624,24 +5634,29 @@ var SessionIdManager = /*#__PURE__*/function () {
|
|
|
5624
5634
|
timestamp = timestamp || new Date().getTime();
|
|
5625
5635
|
|
|
5626
5636
|
var _this$_getSessionId = this._getSessionId(),
|
|
5627
|
-
_this$_getSessionId2 = _slicedToArray(_this$_getSessionId,
|
|
5637
|
+
_this$_getSessionId2 = _slicedToArray(_this$_getSessionId, 3),
|
|
5628
5638
|
lastTimestamp = _this$_getSessionId2[0],
|
|
5629
|
-
sessionId = _this$_getSessionId2[1]
|
|
5639
|
+
sessionId = _this$_getSessionId2[1],
|
|
5640
|
+
startTimestamp = _this$_getSessionId2[2];
|
|
5630
5641
|
|
|
5631
5642
|
var windowId = this._getWindowId();
|
|
5632
5643
|
|
|
5633
|
-
|
|
5644
|
+
var sessionPastMaximumLength = startTimestamp && startTimestamp > 0 && Math.abs(timestamp - startTimestamp) > SESSION_LENGTH_LIMIT;
|
|
5645
|
+
|
|
5646
|
+
if (!sessionId || !readOnly && Math.abs(timestamp - lastTimestamp) > SESSION_CHANGE_THRESHOLD || sessionPastMaximumLength) {
|
|
5634
5647
|
sessionId = _.UUID();
|
|
5635
5648
|
windowId = _.UUID();
|
|
5649
|
+
startTimestamp = timestamp;
|
|
5636
5650
|
} else if (!windowId) {
|
|
5637
5651
|
windowId = _.UUID();
|
|
5638
5652
|
}
|
|
5639
5653
|
|
|
5640
|
-
var newTimestamp = lastTimestamp === 0 || !readOnly ? timestamp : lastTimestamp;
|
|
5654
|
+
var newTimestamp = lastTimestamp === 0 || !readOnly || sessionPastMaximumLength ? timestamp : lastTimestamp;
|
|
5655
|
+
var sessionStartTimestamp = startTimestamp === 0 ? new Date().getTime() : startTimestamp;
|
|
5641
5656
|
|
|
5642
5657
|
this._setWindowId(windowId);
|
|
5643
5658
|
|
|
5644
|
-
this._setSessionId(sessionId, newTimestamp);
|
|
5659
|
+
this._setSessionId(sessionId, newTimestamp, sessionStartTimestamp);
|
|
5645
5660
|
|
|
5646
5661
|
return {
|
|
5647
5662
|
sessionId: sessionId,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "posthog-js",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.24.0",
|
|
4
4
|
"description": "Posthog-js allows you to automatically capture usage and send events to PostHog.",
|
|
5
5
|
"repository": "https://github.com/PostHog/posthog-js",
|
|
6
6
|
"author": "hey@posthog.com",
|
|
@@ -62,8 +62,8 @@
|
|
|
62
62
|
"rollup": "^2.18.2",
|
|
63
63
|
"rrweb": "^1.1.3",
|
|
64
64
|
"sinon": "9.0.2",
|
|
65
|
-
"testcafe": "^1.
|
|
66
|
-
"testcafe-browser-provider-browserstack": "^1.
|
|
65
|
+
"testcafe": "^1.19.0",
|
|
66
|
+
"testcafe-browser-provider-browserstack": "^1.14.0",
|
|
67
67
|
"typescript": "^3.9.6"
|
|
68
68
|
},
|
|
69
69
|
"husky": {
|
|
@@ -90,7 +90,11 @@
|
|
|
90
90
|
"json"
|
|
91
91
|
],
|
|
92
92
|
"setupFilesAfterEnv": [
|
|
93
|
-
"given2/setup"
|
|
93
|
+
"given2/setup",
|
|
94
|
+
"./src/__tests__/setup.js"
|
|
95
|
+
],
|
|
96
|
+
"modulePathIgnorePatterns": [
|
|
97
|
+
"src/__tests__/setup.js"
|
|
94
98
|
],
|
|
95
99
|
"clearMocks": true,
|
|
96
100
|
"testEnvironment": "jsdom"
|