@dev-2-dev/websdk-plugin-session-tracker 0.9.4 → 0.9.5
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/README.md +11 -11
- package/dist/browser.js +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.esm.js +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -37,13 +37,13 @@ The plugin integrates automatically with the DevToDev WebSDK. Simply enable it i
|
|
|
37
37
|
|
|
38
38
|
```typescript
|
|
39
39
|
import DTDAnalytics from '@dev-2-dev/websdk';
|
|
40
|
-
import
|
|
40
|
+
import DTDWebSessionTracker from '@dev-2-dev/websdk-plugin-session-tracker';
|
|
41
41
|
|
|
42
|
-
const sessionTracker = new
|
|
43
|
-
const
|
|
42
|
+
const sessionTracker = new DTDWebSessionTracker();
|
|
43
|
+
const analytics = new DTDAnalytics();
|
|
44
44
|
|
|
45
|
-
|
|
46
|
-
|
|
45
|
+
analytics.initialize('your-app-id');
|
|
46
|
+
analytics.registerPlugin(sessionTracker);
|
|
47
47
|
```
|
|
48
48
|
|
|
49
49
|
That's it! Session recording will start automatically for eligible sessions based on your DevToDev dashboard configuration.
|
|
@@ -57,7 +57,7 @@ You can customize the session recording behavior in two ways:
|
|
|
57
57
|
Configure privacy and recording behavior when creating the tracker instance:
|
|
58
58
|
|
|
59
59
|
```typescript
|
|
60
|
-
import {
|
|
60
|
+
import { DTDWebSessionTracker } from '@dev-2-dev/websdk-plugin-session-tracker';
|
|
61
61
|
|
|
62
62
|
const sessionRecordingConfig = {
|
|
63
63
|
recordCanvas: true, // Record canvas elements
|
|
@@ -70,7 +70,7 @@ const sessionRecordingConfig = {
|
|
|
70
70
|
blockClass: 'sensitive-field', // Block elements with this class
|
|
71
71
|
};
|
|
72
72
|
|
|
73
|
-
const sessionTracker = new
|
|
73
|
+
const sessionTracker = new DTDWebSessionTracker(sessionRecordingConfig);
|
|
74
74
|
```
|
|
75
75
|
|
|
76
76
|
### 2. Disabling from SDK Config
|
|
@@ -80,7 +80,7 @@ You can disable session recording through the SDK's `webSessions` configuration:
|
|
|
80
80
|
```typescript
|
|
81
81
|
import { DTDAnalytics } from '@dev-2-dev/websdk';
|
|
82
82
|
|
|
83
|
-
const
|
|
83
|
+
const analytics = new DTDAnalytics({
|
|
84
84
|
appId: 'your-app-id',
|
|
85
85
|
webSessions: {
|
|
86
86
|
enabled: false, // Disable session recording
|
|
@@ -90,7 +90,7 @@ const sdk = new DTDAnalytics({
|
|
|
90
90
|
|
|
91
91
|
### Configuration Options
|
|
92
92
|
|
|
93
|
-
These options are passed to the `
|
|
93
|
+
These options are passed to the DTDWebSessionTracker` constructor:
|
|
94
94
|
|
|
95
95
|
| Option | Type | Default | Description |
|
|
96
96
|
|--------|------|---------|-------------|
|
|
@@ -111,12 +111,12 @@ These options are passed to the `D2DWebSessionTracker` constructor:
|
|
|
111
111
|
|
|
112
112
|
```typescript
|
|
113
113
|
// Option 1: Mask all inputs
|
|
114
|
-
const sessionTracker = new
|
|
114
|
+
const sessionTracker = new DTDWebSessionTracker({
|
|
115
115
|
maskAllInputs: true,
|
|
116
116
|
});
|
|
117
117
|
|
|
118
118
|
// Option 2: Selective masking
|
|
119
|
-
const sessionTracker = new
|
|
119
|
+
const sessionTracker = new DTDWebSessionTracker({
|
|
120
120
|
maskAllInputs: false,
|
|
121
121
|
maskInputOptions: {
|
|
122
122
|
password: true, // Mask passwords
|
package/dist/browser.js
CHANGED
|
@@ -12,4 +12,4 @@
|
|
|
12
12
|
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
13
13
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
14
14
|
PERFORMANCE OF THIS SOFTWARE.
|
|
15
|
-
***************************************************************************** */function Se(e,t,n,r){return new(n||(n=Promise))(function(t,s){function i(e){try{a(r.next(e))}catch(e){s(e)}}function o(e){try{a(r.throw(e))}catch(e){s(e)}}function a(e){var r;e.done?t(e.value):(r=e.value,r instanceof n?r:new n(function(e){e(r)})).then(i,o)}a((r=r.apply(e,[])).next())})}for(var be="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Ae="undefined"==typeof Uint8Array?[]:new Uint8Array(256),ke=0;ke<64;ke++)Ae[be.charCodeAt(ke)]=ke;const we=new Map;const Me=(e,t,n)=>{if(!e||!Ee(e,t)&&"object"!=typeof e)return;const r=function(e,t){let n=we.get(e);return n||(n=new Map,we.set(e,n)),n.has(t)||n.set(t,[]),n.get(t)}(n,e.constructor.name);let s=r.indexOf(e);return-1===s&&(s=r.length,r.push(e)),s};function Te(e,t,n){if(e instanceof Array)return e.map(e=>Te(e,t,n));if(null===e)return e;if(e instanceof Float32Array||e instanceof Float64Array||e instanceof Int32Array||e instanceof Uint32Array||e instanceof Uint8Array||e instanceof Uint16Array||e instanceof Int16Array||e instanceof Int8Array||e instanceof Uint8ClampedArray){return{rr_type:e.constructor.name,args:[Object.values(e)]}}if(e instanceof ArrayBuffer){const t=e.constructor.name,n=function(e){var t,n=new Uint8Array(e),r=n.length,s="";for(t=0;t<r;t+=3)s+=be[n[t]>>2],s+=be[(3&n[t])<<4|n[t+1]>>4],s+=be[(15&n[t+1])<<2|n[t+2]>>6],s+=be[63&n[t+2]];return r%3==2?s=s.substring(0,s.length-1)+"=":r%3==1&&(s=s.substring(0,s.length-2)+"=="),s}(e);return{rr_type:t,base64:n}}if(e instanceof DataView){return{rr_type:e.constructor.name,args:[Te(e.buffer,t,n),e.byteOffset,e.byteLength]}}if(e instanceof HTMLImageElement){const t=e.constructor.name,{src:n}=e;return{rr_type:t,src:n}}if(e instanceof HTMLCanvasElement){return{rr_type:"HTMLImageElement",src:e.toDataURL()}}if(e instanceof ImageData){return{rr_type:e.constructor.name,args:[Te(e.data,t,n),e.width,e.height]}}if(Ee(e,t)||"object"==typeof e){return{rr_type:e.constructor.name,index:Me(e,t,n)}}return e}const Re=(e,t,n)=>[...e].map(e=>Te(e,t,n)),Ee=(e,t)=>{const n=["WebGLActiveInfo","WebGLBuffer","WebGLFramebuffer","WebGLProgram","WebGLRenderbuffer","WebGLShader","WebGLShaderPrecisionFormat","WebGLTexture","WebGLUniformLocation","WebGLVertexArrayObject","WebGLVertexArrayObjectOES"].filter(e=>"function"==typeof t[e]);return Boolean(n.find(n=>e instanceof t[n]))};function Ne(e,t,n){const r=[];try{const s=F(e.HTMLCanvasElement.prototype,"getContext",function(e){return function(r,...s){return L(this,t,n,!0)||"__context"in this||(this.__context=r),e.apply(this,[r,...s])}});r.push(s)}catch(e){}return()=>{r.forEach(e=>e())}}function xe(e,t,n,r,s,i,o){const a=[],c=Object.getOwnPropertyNames(e);for(const i of c)if(!["isContextLost","canvas","drawingBufferWidth","drawingBufferHeight"].includes(i))try{if("function"!=typeof e[i])continue;const c=F(e,i,function(e){return function(...a){const c=e.apply(this,a);if(Me(c,o,this),!L(this.canvas,r,s,!0)){const e=Re([...a],o,this),r={type:t,property:i,args:e};n(this.canvas,r)}return c}});a.push(c)}catch(r){const s=x(e,i,{set(e){n(this.canvas,{type:t,property:i,args:[e],setter:!0})}});a.push(s)}return a}var Fe=null;try{var Oe="undefined"!=typeof module&&"function"==typeof module.require&&module.require("worker_threads")||"function"==typeof __non_webpack_require__&&__non_webpack_require__("worker_threads")||"function"==typeof require&&require("worker_threads");Fe=Oe.Worker}catch(e){}function De(e,t,n){var r=function(e){return Buffer.from(e,"base64").toString("utf8")}(e),s=r.indexOf("\n",10)+1,i=r.substring(s)+"";return function(e){return new Fe(i,Object.assign({},e,{eval:!0}))}}function Le(e,t,n){var r=function(e){return atob(e)}(e),s=r.indexOf("\n",10)+1,i=r.substring(s)+"",o=new Blob([i],{type:"application/javascript"});return URL.createObjectURL(o)}var Be="[object process]"===Object.prototype.toString.call("undefined"!=typeof process?process:0);var Ue,We=(Ue="Lyogcm9sbHVwLXBsdWdpbi13ZW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250ZXh0KCcyZCcpOw0KICAgICAgICAgICAgICAgIGN0eC5kcmF3SW1hZ2UoYml0bWFwLCAwLCAwKTsNCiAgICAgICAgICAgICAgICBiaXRtYXAuY2xvc2UoKTsNCiAgICAgICAgICAgICAgICBjb25zdCBibG9iID0geWllbGQgb2Zmc2NyZWVuLmNvbnZlcnRUb0Jsb2IoZGF0YVVSTE9wdGlvbnMpOw0KICAgICAgICAgICAgICAgIGNvbnN0IHR5cGUgPSBibG9iLnR5cGU7DQogICAgICAgICAgICAgICAgY29uc3QgYXJyYXlCdWZmZXIgPSB5aWVsZCBibG9iLmFycmF5QnVmZmVyKCk7DQogICAgICAgICAgICAgICAgY29uc3QgYmFzZTY0ID0gZW5jb2RlKGFycmF5QnVmZmVyKTsNCiAgICAgICAgICAgICAgICBpZiAoIWxhc3RCbG9iTWFwLmhhcyhpZCkgJiYgKHlpZWxkIHRyYW5zcGFyZW50QmFzZTY0KSA9PT0gYmFzZTY0KSB7DQogICAgICAgICAgICAgICAgICAgIGxhc3RCbG9iTWFwLnNldChpZCwgYmFzZTY0KTsNCiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHdvcmtlci5wb3N0TWVzc2FnZSh7IGlkIH0pOw0KICAgICAgICAgICAgICAgIH0NCiAgICAgICAgICAgICAgICBpZiAobGFzdEJsb2JNYXAuZ2V0KGlkKSA9PT0gYmFzZTY0KQ0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gd29ya2VyLnBvc3RNZXNzYWdlKHsgaWQgfSk7DQogICAgICAgICAgICAgICAgd29ya2VyLnBvc3RNZXNzYWdlKHsNCiAgICAgICAgICAgICAgICAgICAgaWQsDQogICAgICAgICAgICAgICAgICAgIHR5cGUsDQogICAgICAgICAgICAgICAgICAgIGJhc2U2NCwNCiAgICAgICAgICAgICAgICAgICAgd2lkdGgsDQogICAgICAgICAgICAgICAgICAgIGhlaWdodCwNCiAgICAgICAgICAgICAgICB9KTsNCiAgICAgICAgICAgICAgICBsYXN0QmxvYk1hcC5zZXQoaWQsIGJhc2U2NCk7DQogICAgICAgICAgICB9DQogICAgICAgICAgICBlbHNlIHsNCiAgICAgICAgICAgICAgICByZXR1cm4gd29ya2VyLnBvc3RNZXNzYWdlKHsgaWQ6IGUuZGF0YS5pZCB9KTsNCiAgICAgICAgICAgIH0NCiAgICAgICAgfSk7DQogICAgfTsKCn0pKCk7Cgo=",Be?De(Ue):function(e){var t;return function(n){return t=t||Le(e),new Worker(t,n)}}(Ue));class Ze{constructor(e){this.pendingCanvasMutations=new Map,this.rafStamps={latestId:0,invokeId:null},this.frozen=!1,this.locked=!1,this.processMutation=(e,t)=>{!(this.rafStamps.invokeId&&this.rafStamps.latestId!==this.rafStamps.invokeId)&&this.rafStamps.invokeId||(this.rafStamps.invokeId=this.rafStamps.latestId),this.pendingCanvasMutations.has(e)||this.pendingCanvasMutations.set(e,[]),this.pendingCanvasMutations.get(e).push(t)};const{sampling:t="all",win:n,blockClass:r,blockSelector:s,recordCanvas:i,dataURLOptions:o}=e;this.mutationCb=e.mutationCb,this.mirror=e.mirror,i&&"all"===t&&this.initCanvasMutationObserver(n,r,s),i&&"number"==typeof t&&this.initCanvasFPSObserver(t,n,r,s,{dataURLOptions:o})}reset(){this.pendingCanvasMutations.clear(),this.resetObservers&&this.resetObservers()}freeze(){this.frozen=!0}unfreeze(){this.frozen=!1}lock(){this.locked=!0}unlock(){this.locked=!1}initCanvasFPSObserver(e,t,n,r,s){const i=Ne(t,n,r),o=new Map,a=new We;a.onmessage=e=>{const{id:t}=e.data;if(o.set(t,!1),!("base64"in e.data))return;const{base64:n,type:r,width:s,height:i}=e.data;this.mutationCb({id:t,type:J["2D"],commands:[{property:"clearRect",args:[0,0,s,i]},{property:"drawImage",args:[{rr_type:"ImageBitmap",args:[{rr_type:"Blob",data:[{rr_type:"ArrayBuffer",base64:n}],type:r}]},0,0]}]})};const c=1e3/e;let l,d=0;const u=e=>{d&&e-d<c||(d=e,(()=>{const e=[];return t.document.querySelectorAll("canvas").forEach(t=>{L(t,n,r,!0)||e.push(t)}),e})().forEach(e=>Se(this,0,void 0,function*(){var t;const n=this.mirror.getId(e);if(o.get(n))return;if(o.set(n,!0),["webgl","webgl2"].includes(e.__context)){const n=e.getContext(e.__context);!1===(null===(t=null==n?void 0:n.getContextAttributes())||void 0===t?void 0:t.preserveDrawingBuffer)&&(null==n||n.clear(n.COLOR_BUFFER_BIT))}const r=yield createImageBitmap(e);a.postMessage({id:n,bitmap:r,width:e.width,height:e.height,dataURLOptions:s.dataURLOptions},[r])}))),l=requestAnimationFrame(u)};l=requestAnimationFrame(u),this.resetObservers=()=>{i(),cancelAnimationFrame(l)}}initCanvasMutationObserver(e,t,n){this.startRAFTimestamping(),this.startPendingCanvasMutationFlusher();const r=Ne(e,t,n),s=function(e,t,n,r){const s=[],i=Object.getOwnPropertyNames(t.CanvasRenderingContext2D.prototype);for(const o of i)try{if("function"!=typeof t.CanvasRenderingContext2D.prototype[o])continue;const i=F(t.CanvasRenderingContext2D.prototype,o,function(s){return function(...i){return L(this.canvas,n,r,!0)||setTimeout(()=>{const n=Re([...i],t,this);e(this.canvas,{type:J["2D"],property:o,args:n})},0),s.apply(this,i)}});s.push(i)}catch(n){const r=x(t.CanvasRenderingContext2D.prototype,o,{set(t){e(this.canvas,{type:J["2D"],property:o,args:[t],setter:!0})}});s.push(r)}return()=>{s.forEach(e=>e())}}(this.processMutation.bind(this),e,t,n),i=function(e,t,n,r){const s=[];return s.push(...xe(t.WebGLRenderingContext.prototype,J.WebGL,e,n,r,0,t)),void 0!==t.WebGL2RenderingContext&&s.push(...xe(t.WebGL2RenderingContext.prototype,J.WebGL2,e,n,r,0,t)),()=>{s.forEach(e=>e())}}(this.processMutation.bind(this),e,t,n,this.mirror);this.resetObservers=()=>{r(),s(),i()}}startPendingCanvasMutationFlusher(){requestAnimationFrame(()=>this.flushPendingCanvasMutations())}startRAFTimestamping(){const e=t=>{this.rafStamps.latestId=t,requestAnimationFrame(e)};requestAnimationFrame(e)}flushPendingCanvasMutations(){this.pendingCanvasMutations.forEach((e,t)=>{const n=this.mirror.getId(t);this.flushPendingCanvasMutationFor(t,n)}),requestAnimationFrame(()=>this.flushPendingCanvasMutations())}flushPendingCanvasMutationFor(e,t){if(this.frozen||this.locked)return;const n=this.pendingCanvasMutations.get(e);if(!n||-1===t)return;const r=n.map(e=>{const t=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var s=0;for(r=Object.getOwnPropertySymbols(e);s<r.length;s++)t.indexOf(r[s])<0&&Object.prototype.propertyIsEnumerable.call(e,r[s])&&(n[r[s]]=e[r[s]])}return n}(e,["type"]);return t}),{type:s}=n[0];this.mutationCb({id:t,type:s,commands:r}),this.pendingCanvasMutations.delete(e)}}class Ge{constructor(e){this.trackedLinkElements=new WeakSet,this.styleMirror=new K,this.mutationCb=e.mutationCb,this.adoptedStyleSheetCb=e.adoptedStyleSheetCb}attachLinkElement(e,t){"_cssText"in t.attributes&&this.mutationCb({adds:[],removes:[],texts:[],attributes:[{id:t.id,attributes:t.attributes}]}),this.trackLinkElement(e)}trackLinkElement(e){this.trackedLinkElements.has(e)||(this.trackedLinkElements.add(e),this.trackStylesheetInLinkElement(e))}adoptStyleSheets(e,t){if(0===e.length)return;const n={id:t,styleIds:[]},r=[];for(const t of e){let e;if(this.styleMirror.has(t))e=this.styleMirror.getId(t);else{e=this.styleMirror.add(t);const n=Array.from(t.rules||CSSRule);r.push({styleId:e,rules:n.map((e,t)=>({rule:s(e),index:t}))})}n.styleIds.push(e)}r.length>0&&(n.styles=r),this.adoptedStyleSheetCb(n)}reset(){this.styleMirror.reset(),this.trackedLinkElements=new WeakSet}trackStylesheetInLinkElement(e){}}function Ve(e){return Object.assign(Object.assign({},e),{timestamp:Date.now()})}let Ke,_e,ze,Ye=!1;const Je=new i;function Qe(e={}){const{emit:t,checkoutEveryNms:n,checkoutEveryNth:r,blockClass:s="rr-block",blockSelector:o=null,ignoreClass:a="rr-ignore",maskTextClass:c="rr-mask",maskTextSelector:l=null,inlineStylesheet:d=!0,maskAllInputs:u,maskInputOptions:h,slimDOMOptions:g,maskInputFn:p,maskTextFn:m,hooks:f,packFn:I,sampling:C={},dataURLOptions:y={},mousemoveWait:v,recordCanvas:S=!1,recordCrossOriginIframes:b=!1,userTriggeredOnInput:A=!1,collectFonts:k=!1,inlineImages:w=!1,plugins:M,keepIframeSrcFn:E=()=>!1,ignoreCSSAttributes:N=new Set([])}=e,x=!b||window.parent===window;let F=!1;if(!x)try{window.parent.document,F=!1}catch(e){F=!0}if(x&&!t)throw new Error("emit function is required");void 0!==v&&void 0===C.mousemove&&(C.mousemove=v),Je.reset();const L=!0===u?{color:!0,date:!0,"datetime-local":!0,email:!0,month:!0,number:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0,textarea:!0,select:!0,password:!0}:void 0!==h?h:{password:!0},B=!0===g||"all"===g?{script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaVerification:!0,headMetaAuthorship:"all"===g,headMetaDescKeywords:"all"===g}:g||{};let U;!function(e=window){"NodeList"in e&&!e.NodeList.prototype.forEach&&(e.NodeList.prototype.forEach=Array.prototype.forEach),"DOMTokenList"in e&&!e.DOMTokenList.prototype.forEach&&(e.DOMTokenList.prototype.forEach=Array.prototype.forEach),Node.prototype.contains||(Node.prototype.contains=(...e)=>{let t=e[0];if(!(0 in e))throw new TypeError("1 argument is required");do{if(this===t)return!0}while(t=t&&t.parentNode);return!1})}();let W=0;const K=e=>{for(const t of M||[])t.eventProcessor&&(e=t.eventProcessor(e));return I&&(e=I(e)),e};Ke=(e,s)=>{var i;if(!(null===(i=ne[0])||void 0===i?void 0:i.isFrozen())||e.type===_.FullSnapshot||e.type===_.IncrementalSnapshot&&e.data.source===z.Mutation||ne.forEach(e=>e.unfreeze()),x)null==t||t(K(e),s);else if(F){const t={type:"rrweb",event:K(e),isCheckout:s};window.parent.postMessage(t,"*")}if(e.type===_.FullSnapshot)U=e,W=0;else if(e.type===_.IncrementalSnapshot){if(e.data.source===z.Mutation&&e.data.isAttachIframe)return;W++;const t=r&&W>=r,s=n&&e.timestamp-U.timestamp>n;(t||s)&&_e(!0)}};const Y=e=>{Ke(Ve({type:_.IncrementalSnapshot,data:Object.assign({source:z.Mutation},e)}))},J=e=>Ke(Ve({type:_.IncrementalSnapshot,data:Object.assign({source:z.Scroll},e)})),Q=e=>Ke(Ve({type:_.IncrementalSnapshot,data:Object.assign({source:z.CanvasMutation},e)})),P=new Ge({mutationCb:Y,adoptedStyleSheetCb:e=>Ke(Ve({type:_.IncrementalSnapshot,data:Object.assign({source:z.AdoptedStyleSheet},e)}))}),H=new ye({mirror:Je,mutationCb:Y,stylesheetManager:P,recordCrossOriginIframes:b,wrappedEmit:Ke});for(const e of M||[])e.getMirror&&e.getMirror({nodeMirror:Je,crossOriginIframeMirror:H.crossOriginIframeMirror,crossOriginIframeStyleMirror:H.crossOriginIframeStyleMirror});ze=new Ze({recordCanvas:S,mutationCb:Q,win:window,blockClass:s,blockSelector:o,mirror:Je,sampling:C.canvas,dataURLOptions:y});const X=new ve({mutationCb:Y,scrollCb:J,bypassOptions:{blockClass:s,blockSelector:o,maskTextClass:c,maskTextSelector:l,inlineStylesheet:d,maskInputOptions:L,dataURLOptions:y,maskTextFn:m,maskInputFn:p,recordCanvas:S,inlineImages:w,sampling:C,slimDOMOptions:B,iframeManager:H,stylesheetManager:P,canvasManager:ze,keepIframeSrcFn:E},mirror:Je});_e=(e=!1)=>{var t,n,r,a,u,h;Ke(Ve({type:_.Meta,data:{href:window.location.href,width:D(),height:O()}}),e),P.reset(),ne.forEach(e=>e.lock());const g=function(e,t){var n=t||{},r=n.mirror,s=void 0===r?new i:r,o=n.blockClass,a=void 0===o?"rr-block":o,c=n.blockSelector,l=void 0===c?null:c,d=n.maskTextClass,u=void 0===d?"rr-mask":d,h=n.maskTextSelector,g=void 0===h?null:h,p=n.inlineStylesheet,m=void 0===p||p,f=n.inlineImages,I=void 0!==f&&f,C=n.recordCanvas,y=void 0!==C&&C,v=n.maskAllInputs,S=void 0!==v&&v,b=n.maskTextFn,A=n.maskInputFn,k=n.slimDOM,w=void 0!==k&&k,M=n.dataURLOptions,R=n.preserveWhiteSpace,E=n.onSerialize,N=n.onIframeLoad,x=n.iframeLoadTimeout,F=n.onStylesheetLoad,O=n.stylesheetLoadTimeout,D=n.keepIframeSrcFn;return T(e,{doc:e,mirror:s,blockClass:a,blockSelector:l,maskTextClass:u,maskTextSelector:g,skipChild:!1,inlineStylesheet:m,maskInputOptions:!0===S?{color:!0,date:!0,"datetime-local":!0,email:!0,month:!0,number:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0,textarea:!0,select:!0,password:!0}:!1===S?{password:!0}:S,maskTextFn:b,maskInputFn:A,slimDOMOptions:!0===w||"all"===w?{script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaDescKeywords:"all"===w,headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaAuthorship:!0,headMetaVerification:!0}:!1===w?{}:w,dataURLOptions:M,inlineImages:I,recordCanvas:y,preserveWhiteSpace:R,onSerialize:E,onIframeLoad:N,iframeLoadTimeout:x,onStylesheetLoad:F,stylesheetLoadTimeout:O,keepIframeSrcFn:void 0===D?function(){return!1}:D,newlyAddedElement:!1})}(document,{mirror:Je,blockClass:s,blockSelector:o,maskTextClass:c,maskTextSelector:l,inlineStylesheet:d,maskAllInputs:L,maskTextFn:m,slimDOM:B,dataURLOptions:y,recordCanvas:S,inlineImages:w,onSerialize:e=>{Z(e,Je)&&H.addIframe(e),G(e,Je)&&P.trackLinkElement(e),V(e)&&X.addShadowRoot(e.shadowRoot,document)},onIframeLoad:(e,t)=>{H.attachIframe(e,t),X.observeAttachShadow(e)},onStylesheetLoad:(e,t)=>{P.attachLinkElement(e,t)},keepIframeSrcFn:E});g&&(Ke(Ve({type:_.FullSnapshot,data:{node:g,initialOffset:{left:void 0!==window.pageXOffset?window.pageXOffset:(null===document||void 0===document?void 0:document.documentElement.scrollLeft)||(null===(n=null===(t=null===document||void 0===document?void 0:document.body)||void 0===t?void 0:t.parentElement)||void 0===n?void 0:n.scrollLeft)||(null===(r=null===document||void 0===document?void 0:document.body)||void 0===r?void 0:r.scrollLeft)||0,top:void 0!==window.pageYOffset?window.pageYOffset:(null===document||void 0===document?void 0:document.documentElement.scrollTop)||(null===(u=null===(a=null===document||void 0===document?void 0:document.body)||void 0===a?void 0:a.parentElement)||void 0===u?void 0:u.scrollTop)||(null===(h=null===document||void 0===document?void 0:document.body)||void 0===h?void 0:h.scrollTop)||0}}})),ne.forEach(e=>e.unlock()),document.adoptedStyleSheets&&document.adoptedStyleSheets.length>0&&P.adoptStyleSheets(document.adoptedStyleSheets,Je.getId(document)))};try{const e=[];e.push(R("DOMContentLoaded",()=>{Ke(Ve({type:_.DomContentLoaded,data:{}}))}));const t=e=>{var t;return Ie({mutationCb:Y,mousemoveCb:(e,t)=>Ke(Ve({type:_.IncrementalSnapshot,data:{source:t,positions:e}})),mouseInteractionCb:e=>Ke(Ve({type:_.IncrementalSnapshot,data:Object.assign({source:z.MouseInteraction},e)})),scrollCb:J,viewportResizeCb:e=>Ke(Ve({type:_.IncrementalSnapshot,data:Object.assign({source:z.ViewportResize},e)})),inputCb:e=>Ke(Ve({type:_.IncrementalSnapshot,data:Object.assign({source:z.Input},e)})),mediaInteractionCb:e=>Ke(Ve({type:_.IncrementalSnapshot,data:Object.assign({source:z.MediaInteraction},e)})),styleSheetRuleCb:e=>Ke(Ve({type:_.IncrementalSnapshot,data:Object.assign({source:z.StyleSheetRule},e)})),styleDeclarationCb:e=>Ke(Ve({type:_.IncrementalSnapshot,data:Object.assign({source:z.StyleDeclaration},e)})),canvasMutationCb:Q,fontCb:e=>Ke(Ve({type:_.IncrementalSnapshot,data:Object.assign({source:z.Font},e)})),selectionCb:e=>{Ke(Ve({type:_.IncrementalSnapshot,data:Object.assign({source:z.Selection},e)}))},blockClass:s,ignoreClass:a,maskTextClass:c,maskTextSelector:l,maskInputOptions:L,inlineStylesheet:d,sampling:C,recordCanvas:S,inlineImages:w,userTriggeredOnInput:A,collectFonts:k,doc:e,maskInputFn:p,maskTextFn:m,keepIframeSrcFn:E,blockSelector:o,slimDOMOptions:B,dataURLOptions:y,mirror:Je,iframeManager:H,stylesheetManager:P,shadowDomManager:X,canvasManager:ze,ignoreCSSAttributes:N,plugins:(null===(t=null==M?void 0:M.filter(e=>e.observer))||void 0===t?void 0:t.map(e=>({observer:e.observer,options:e.options,callback:t=>Ke(Ve({type:_.Plugin,data:{plugin:e.name,payload:t}}))})))||[]},f)};H.addLoadListener(n=>{e.push(t(n.contentDocument))});const n=()=>{_e(),e.push(t(document)),Ye=!0};return"interactive"===document.readyState||"complete"===document.readyState?n():e.push(R("load",()=>{Ke(Ve({type:_.Load,data:{}})),n()},window)),()=>{e.forEach(e=>e()),Ye=!1}}catch(e){}}Qe.addCustomEvent=(e,t)=>{if(!Ye)throw new Error("please add custom event after start recording");Ke(Ve({type:_.Custom,data:{tag:e,payload:t}}))},Qe.freezePage=()=>{ne.forEach(e=>e.freeze())},Qe.takeFullSnapshot=e=>{if(!Ye)throw new Error("please take full snapshot after start recording");_e(e)},Qe.mirror=Je;var Pe=Uint8Array,He=Uint16Array,Xe=Uint32Array,je=new Pe([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),qe=new Pe([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),$e=new Pe([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),et=function(e,t){for(var n=new He(31),r=0;r<31;++r)n[r]=t+=1<<e[r-1];var s=new Xe(n[30]);for(r=1;r<30;++r)for(var i=n[r];i<n[r+1];++i)s[i]=i-n[r]<<5|r;return[n,s]},tt=et(je,2),nt=tt[0],rt=tt[1];nt[28]=258,rt[258]=28;for(var st=et(qe,0)[1],it=new He(32768),ot=0;ot<32768;++ot){var at=(43690&ot)>>>1|(21845&ot)<<1;at=(61680&(at=(52428&at)>>>2|(13107&at)<<2))>>>4|(3855&at)<<4,it[ot]=((65280&at)>>>8|(255&at)<<8)>>>1}var ct=function(e,t,n){for(var r=e.length,s=0,i=new He(t);s<r;++s)++i[e[s]-1];var o,a=new He(t);for(s=0;s<t;++s)a[s]=a[s-1]+i[s-1]<<1;if(n){o=new He(1<<t);var c=15-t;for(s=0;s<r;++s)if(e[s])for(var l=s<<4|e[s],d=t-e[s],u=a[e[s]-1]++<<d,h=u|(1<<d)-1;u<=h;++u)o[it[u]>>>c]=l}else for(o=new He(r),s=0;s<r;++s)o[s]=it[a[e[s]-1]++]>>>15-e[s];return o},lt=new Pe(288);for(ot=0;ot<144;++ot)lt[ot]=8;for(ot=144;ot<256;++ot)lt[ot]=9;for(ot=256;ot<280;++ot)lt[ot]=7;for(ot=280;ot<288;++ot)lt[ot]=8;var dt=new Pe(32);for(ot=0;ot<32;++ot)dt[ot]=5;var ut=ct(lt,9,0),ht=ct(dt,5,0),gt=function(e){return(e/8|0)+(7&e&&1)},pt=function(e,t,n){(null==n||n>e.length)&&(n=e.length);var r=new(e instanceof He?He:e instanceof Xe?Xe:Pe)(n-t);return r.set(e.subarray(t,n)),r},mt=function(e,t,n){n<<=7&t;var r=t/8|0;e[r]|=n,e[r+1]|=n>>>8},ft=function(e,t,n){n<<=7&t;var r=t/8|0;e[r]|=n,e[r+1]|=n>>>8,e[r+2]|=n>>>16},It=function(e,t){for(var n=[],r=0;r<e.length;++r)e[r]&&n.push({s:r,f:e[r]});var s=n.length,i=n.slice();if(!s)return[new Pe(0),0];if(1==s){var o=new Pe(n[0].s+1);return o[n[0].s]=1,[o,1]}n.sort(function(e,t){return e.f-t.f}),n.push({s:-1,f:25001});var a=n[0],c=n[1],l=0,d=1,u=2;for(n[0]={s:-1,f:a.f+c.f,l:a,r:c};d!=s-1;)a=n[n[l].f<n[u].f?l++:u++],c=n[l!=d&&n[l].f<n[u].f?l++:u++],n[d++]={s:-1,f:a.f+c.f,l:a,r:c};var h=i[0].s;for(r=1;r<s;++r)i[r].s>h&&(h=i[r].s);var g=new He(h+1),p=Ct(n[d-1],g,0);if(p>t){r=0;var m=0,f=p-t,I=1<<f;for(i.sort(function(e,t){return g[t.s]-g[e.s]||e.f-t.f});r<s;++r){var C=i[r].s;if(!(g[C]>t))break;m+=I-(1<<p-g[C]),g[C]=t}for(m>>>=f;m>0;){var y=i[r].s;g[y]<t?m-=1<<t-g[y]++-1:++r}for(;r>=0&&m;--r){var v=i[r].s;g[v]==t&&(--g[v],++m)}p=t}return[new Pe(g),p]},Ct=function(e,t,n){return-1==e.s?Math.max(Ct(e.l,t,n+1),Ct(e.r,t,n+1)):t[e.s]=n},yt=function(e){for(var t=e.length;t&&!e[--t];);for(var n=new He(++t),r=0,s=e[0],i=1,o=function(e){n[r++]=e},a=1;a<=t;++a)if(e[a]==s&&a!=t)++i;else{if(!s&&i>2){for(;i>138;i-=138)o(32754);i>2&&(o(i>10?i-11<<5|28690:i-3<<5|12305),i=0)}else if(i>3){for(o(s),--i;i>6;i-=6)o(8304);i>2&&(o(i-3<<5|8208),i=0)}for(;i--;)o(s);i=1,s=e[a]}return[n.subarray(0,r),t]},vt=function(e,t){for(var n=0,r=0;r<t.length;++r)n+=e[r]*t[r];return n},St=function(e,t,n){var r=n.length,s=gt(t+2);e[s]=255&r,e[s+1]=r>>>8,e[s+2]=255^e[s],e[s+3]=255^e[s+1];for(var i=0;i<r;++i)e[s+i+4]=n[i];return 8*(s+4+r)},bt=function(e,t,n,r,s,i,o,a,c,l,d){mt(t,d++,n),++s[256];for(var u=It(s,15),h=u[0],g=u[1],p=It(i,15),m=p[0],f=p[1],I=yt(h),C=I[0],y=I[1],v=yt(m),S=v[0],b=v[1],A=new He(19),k=0;k<C.length;++k)A[31&C[k]]++;for(k=0;k<S.length;++k)A[31&S[k]]++;for(var w=It(A,7),M=w[0],T=w[1],R=19;R>4&&!M[$e[R-1]];--R);var E,N,x,F,O=l+5<<3,D=vt(s,lt)+vt(i,dt)+o,L=vt(s,h)+vt(i,m)+o+14+3*R+vt(A,M)+(2*A[16]+3*A[17]+7*A[18]);if(O<=D&&O<=L)return St(t,d,e.subarray(c,c+l));if(mt(t,d,1+(L<D)),d+=2,L<D){E=ct(h,g,0),N=h,x=ct(m,f,0),F=m;var B=ct(M,T,0);mt(t,d,y-257),mt(t,d+5,b-1),mt(t,d+10,R-4),d+=14;for(k=0;k<R;++k)mt(t,d+3*k,M[$e[k]]);d+=3*R;for(var U=[C,S],W=0;W<2;++W){var Z=U[W];for(k=0;k<Z.length;++k){var G=31&Z[k];mt(t,d,B[G]),d+=M[G],G>15&&(mt(t,d,Z[k]>>>5&127),d+=Z[k]>>>12)}}}else E=ut,N=lt,x=ht,F=dt;for(k=0;k<a;++k)if(r[k]>255){G=r[k]>>>18&31;ft(t,d,E[G+257]),d+=N[G+257],G>7&&(mt(t,d,r[k]>>>23&31),d+=je[G]);var V=31&r[k];ft(t,d,x[V]),d+=F[V],V>3&&(ft(t,d,r[k]>>>5&8191),d+=qe[V])}else ft(t,d,E[r[k]]),d+=N[r[k]];return ft(t,d,E[256]),d+N[256]},At=new Xe([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),kt=function(e,t,n,r,s){return function(e,t,n,r,s,i){var o=e.length,a=new Pe(r+o+5*(1+Math.floor(o/7e3))+s),c=a.subarray(r,a.length-s),l=0;if(!t||o<8)for(var d=0;d<=o;d+=65535){var u=d+65535;u<o?l=St(c,l,e.subarray(d,u)):(c[d]=i,l=St(c,l,e.subarray(d,o)))}else{for(var h=At[t-1],g=h>>>13,p=8191&h,m=(1<<n)-1,f=new He(32768),I=new He(m+1),C=Math.ceil(n/3),y=2*C,v=function(t){return(e[t]^e[t+1]<<C^e[t+2]<<y)&m},S=new Xe(25e3),b=new He(288),A=new He(32),k=0,w=0,M=(d=0,0),T=0,R=0;d<o;++d){var E=v(d),N=32767&d,x=I[E];if(f[N]=x,I[E]=N,T<=d){var F=o-d;if((k>7e3||M>24576)&&F>423){l=bt(e,c,0,S,b,A,w,M,R,d-R,l),M=k=w=0,R=d;for(var O=0;O<286;++O)b[O]=0;for(O=0;O<30;++O)A[O]=0}var D=2,L=0,B=p,U=N-x&32767;if(F>2&&E==v(d-U))for(var W=Math.min(g,F)-1,Z=Math.min(32767,d),G=Math.min(258,F);U<=Z&&--B&&N!=x;){if(e[d+D]==e[d+D-U]){for(var V=0;V<G&&e[d+V]==e[d+V-U];++V);if(V>D){if(D=V,L=U,V>W)break;var K=Math.min(U,V-2),_=0;for(O=0;O<K;++O){var z=d-U+O+32768&32767,Y=z-f[z]+32768&32767;Y>_&&(_=Y,x=z)}}}U+=(N=x)-(x=f[N])+32768&32767}if(L){S[M++]=268435456|rt[D]<<18|st[L];var J=31&rt[D],Q=31&st[L];w+=je[J]+qe[Q],++b[257+J],++A[Q],T=d+D,++k}else S[M++]=e[d],++b[e[d]]}}l=bt(e,c,i,S,b,A,w,M,R,d-R,l)}return pt(a,0,r+gt(l)+s)}(e,null==t.level?6:t.level,null==t.mem?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(e.length)))):12+t.mem,n,r,!0)};function wt(e,t){void 0===t&&(t={});var n=function(){var e=1,t=0;return{p:function(n){for(var r=e,s=t,i=n.length,o=0;o!=i;){for(var a=Math.min(o+5552,i);o<a;++o)s+=r+=n[o];r%=65521,s%=65521}e=r,t=s},d:function(){return(e>>>8<<16|(255&t)<<8|t>>>8)+2*((255&e)<<23)}}}();n.p(e);var r,s,i,o=kt(e,t,2,4);return r=o,s=t.level,i=0==s?0:s<6?1:9==s?3:2,r[0]=120,r[1]=i<<6|(i?32-2*i:1),function(e,t,n){for(;n;++t)e[t]=n,n>>>=8}(o,o.length-4,n.d()),o}const Mt=e=>{const t={...e,v:"v1"};return function(e){for(var t="",n=0;n<e.length;){var r=e[n++];t+=String.fromCharCode(r)}return t}(wt(function(e,t){var n=e.length;if("undefined"!=typeof TextEncoder)return(new TextEncoder).encode(e);for(var r=new Pe(e.length+(e.length>>>1)),s=0,i=function(e){r[s++]=e},o=0;o<n;++o){if(s+5>r.length){var a=new Pe(s+8+(n-o<<1));a.set(r),r=a}var c=e.charCodeAt(o);c<128||t?i(c):c<2048?(i(192|c>>>6),i(128|63&c)):c>55295&&c<57344?(i(240|(c=65536+(1047552&c)|1023&e.charCodeAt(++o))>>>18),i(128|c>>>12&63),i(128|c>>>6&63),i(128|63&c)):(i(224|c>>>12),i(128|c>>>6&63),i(128|63&c))}return pt(r,0,s)}(JSON.stringify(t))))};class Tt{constructor(e){this.name="session-tracker",this.version='"0.9.4"',this.context=null,this.config={},this.userConfig=null,this.sessionStartTime=0,this.isActive=!1,this.stopRecordingFn=null,this.sessionEvents=[],this.sessionId="",this.currentSessionSize=0,this.lastBatchTime=0,this.activeBatchCount=0,this.userId="",this.appId="",this.pendingEvents=[],this.eventsInFlight=[],this.sentEventCount=0,this.isSendingBatch=!1,this.delayedS3Url=null,this.delayedUrlExpiry=0,this.delayedUrlRefreshTimer=null,this.userConfig=e||{}}init(e,t){this.context=e;const n="object"==typeof t?.webSessions?t?.webSessions:null,r={enableSessionRecording:!1!==t?.webSessions&&(!0===t?.webSessions||!1!==n?.enabled),maxBatchSize:1048576,maxSessionDuration:null,batchSize:150,batchInterval:3e4,minimumSessionDuration:5e3,compressionEnabled:!1,recordingOptions:{recordCanvas:!0,recordCrossOriginIframes:!1,recordAfter:"DOMContentLoaded",maskAllInputs:!1,maskInputOptions:{password:!0,email:!0,text:!1},blockClass:"sensitive-field",slimDOMOptions:{script:!1,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaDescKeywords:!0,headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaAuthorship:!0,headMetaVerification:!0},sampling:{scroll:150,mouseInteraction:!0,input:"last",mutation:!0},...this.userConfig?this.userConfig:{},...this.config.recordingOptions?this.config.recordingOptions:{}}};this.config={...r}}start(){if(!this.context)return;if(this.isActive)return;this.delayedUrlRefreshTimer&&(clearTimeout(this.delayedUrlRefreshTimer),this.delayedUrlRefreshTimer=null),this.isActive=!0,this.userId=this.context.userManager.getUserId(),this.appId=this.context.appManager.getAppId();const e=String(this.context.userManager.getSessionId());(!this.sessionId||this.sessionId!==e)&&(this.sessionEvents=[],this.pendingEvents=[],this.eventsInFlight=[],this.currentSessionSize=0,this.sentEventCount=0,this.sessionStartTime=Date.now(),this.delayedS3Url=null,this.delayedUrlExpiry=0),this.sessionId=e,this.config.enableSessionRecording&&this.startRecording()}stop(){this.isActive&&this.stopRecording()}destroy(){this.stopRecording(),this.pendingEvents=[],this.eventsInFlight=[],this.sessionEvents=[],this.currentSessionSize=0,this.sentEventCount=0,this.delayedS3Url=null,this.delayedUrlExpiry=0,this.context?.removePluginField("recordingSessionId"),this.context?.setPluginField("isRecordingActive",!1),this.context=null}onEvent(e,t){this.isActive&&"session_start"===e&&(this.sessionStartTime=Date.now())}async onUserChange(e){this.isActive&&(await this.sendBatchToBackend(),this.stopRecording(),this.isActive=!1,this.start())}async onFocus(){this.pendingEvents.length>0&&await this.sendBatchToBackend(),this.isActive||this.start()}onBlur(){this.isActive&&(this.sendFinalBatch().catch(e=>{this.context?.logger.error(e)}),this.stopRecording(!0))}async onBeforeUnload(){const e=this.pendingEvents.length>0||this.eventsInFlight.length>0;(this.isActive||e)&&this.sendFinalBatch().catch(e=>{this.context?.logger.error(e)})}async onTrackingChange(e){e?this.isActive||this.start():this.isActive&&(await this.sendBatchToBackend(),this.stopRecording())}async onSessionStart(){await this.sendBatchToBackend(),this.isActive||this.start()}stopRecording(e=!1){e||this.context?.setPluginField("isRecordingActive",!1),this.isActive=!1,this.delayedUrlRefreshTimer&&(clearTimeout(this.delayedUrlRefreshTimer),this.delayedUrlRefreshTimer=null),this.stopRecordingFn&&(this.stopRecordingFn(),this.stopRecordingFn=null)}async startRecording(){if(!this.context)return;this.lastBatchTime=Date.now(),this.isSendingBatch=!1;const e=Date.now();if(!this.delayedS3Url||this.delayedUrlExpiry>0&&e>this.delayedUrlExpiry)this.fetchDelayedUrl();else if(this.delayedS3Url){const t=Math.max(0,this.delayedUrlExpiry-e);this.scheduleDelayedUrlRefresh(t+1e4)}const t=this.context.getPluginField("recordingSessionId"),n=!!t&&t===this.context.userManager.getSessionId(),r=this.context.getPluginField("isRecordingActive");if(n&&r)this.startSessionRecording();else try{const e=this.context.api.buildUrl(["sessions","configurations","get"],{appId:this.appId}),t=await this.sendRequest(e,null,"GET");if(t&&t.data){const e=t.data;if(e.blocked||!e.active)return this.context.logger.debug("Session configuration is "+(e.blocked?"blocked":"inactive")),void this.context.setPluginField("isRecordingActive",!1);100*Math.random()<e.record_chance_percent?(this.context.setPluginField("isRecordingActive",!0),this.startSessionRecording()):this.context.setPluginField("isRecordingActive",!1)}}catch(e){this.context.logger.error("Failed to fetch session configuration",{error:e}),this.context.setPluginField("isRecordingActive",!1)}}startSessionRecording(){if(!this.config.enableSessionRecording)return;this.context?.setPluginField("recordingSessionId",this.context?.userManager.getSessionId()),this.lastBatchTime=Date.now();const e={emit:e=>{this.addEventToSession(e),this.pendingEvents.push(e),this.currentSessionSize+=JSON.stringify(e).length,e.type,this.checkBatchLimits()},...this.config.recordingOptions};this.config.compressionEnabled&&(e.packFn=Mt);const t=Qe(e);this.stopRecordingFn=t||null}addEventToSession(e){this.sessionEvents.push(e);this.sessionEvents.length>1e4&&(this.sessionEvents=this.sessionEvents.slice(-Math.floor(5e3)))}hasMinimumSessionDuration(){return Date.now()-this.sessionStartTime>=this.config.minimumSessionDuration}checkBatchLimits(){if(this.isSendingBatch)return;const e=Date.now()-this.sessionStartTime,t=this.pendingEvents.length>=this.config.batchSize,n=this.currentSessionSize>=this.config.maxBatchSize,r=this.config.maxSessionDuration&&e>=this.config.maxSessionDuration,s=Date.now()-this.lastBatchTime>=this.config.batchInterval;(t||n||r||s)&&this.sendBatchToBackend().catch(e=>{this.context?.logger.error("Error in checkBatchLimits sendBatchToBackend",{error:e instanceof Error?e.message:e,pendingEventsCount:this.pendingEvents.length})})}async sendBatchToBackend(){if(!this.pendingEvents.length||!this.context||this.isSendingBatch)return;if(!this.hasMinimumSessionDuration())return;this.isSendingBatch=!0,this.eventsInFlight=[...this.pendingEvents],this.pendingEvents=[];const e=this.eventsInFlight.reduce((e,t)=>e+JSON.stringify(t).length,0);this.currentSessionSize-=e,this.currentSessionSize=Math.max(0,this.currentSessionSize),this.activeBatchCount++;try{const e=this.eventsInFlight[0]?.timestamp||Date.now(),t=this.eventsInFlight[this.eventsInFlight.length-1]?.timestamp||Date.now(),n={appId:this.appId,session_id:this.sessionId,user_id:this.userId,start_time:e,end_time:t},r=this.context.api.buildUrl(["sessions","add"],n),s=await this.sendRequest(r,null,"GET",{},!0);if(204===s.status)return this.context.logger.warning("Session storage exceeded"),this.eventsInFlight=[],void this.stop();const i=s.data,o="string"==typeof i?i:i?.url;if(!o)throw new Error("No S3 URL returned");await this.uploadToS3(o,this.eventsInFlight),this.sentEventCount+=this.eventsInFlight.length,this.lastBatchTime=Date.now(),this.eventsInFlight=[]}catch(t){throw this.context?.logger.error("Error sending session batch to backend",{error:t instanceof Error?t.message:t,eventsCount:this.eventsInFlight.length}),this.pendingEvents.unshift(...this.eventsInFlight),this.eventsInFlight=[],this.currentSessionSize+=e,t}finally{this.activeBatchCount--,this.isSendingBatch=!1,this.pendingEvents.length>0&&this.checkBatchLimits()}}async fetchDelayedUrl(){if(this.context)try{const e=this.context.api.buildUrl(["sessions","addDelayed"],{session_id:this.sessionId,appId:this.appId,user_id:this.userId}),t=await this.sendRequest(e,null,"GET");if(t&&t.data){const e=t.data;this.delayedS3Url=e.url,this.delayedUrlExpiry=Date.now()+e.ttl,this.scheduleDelayedUrlRefresh(e.ttl)}}catch(e){this.context.logger.error("Failed to fetch delayed URL",{error:e})}}scheduleDelayedUrlRefresh(e){this.delayedUrlRefreshTimer&&clearTimeout(this.delayedUrlRefreshTimer);const t=Math.max(0,e-1e4);this.delayedUrlRefreshTimer=setTimeout(()=>{this.fetchDelayedUrl()},t)}async sendFinalBatch(){if(!this.context)return;if(!this.hasMinimumSessionDuration())return;const e=[...this.eventsInFlight,...this.pendingEvents];if(!e.length)return;if(!this.delayedS3Url)return void this.context.logger.error("No delayed URL available for final batch - cannot send.");const t=[...this.pendingEvents],n=[...this.eventsInFlight];this.pendingEvents=[],this.eventsInFlight=[],this.currentSessionSize=0;const r=JSON.stringify(e),s=new Blob([r],{type:"application/json"});try{const e=await fetch(this.delayedS3Url,{method:"PUT",body:s,keepalive:!0,credentials:"omit"});if(!e.ok)throw new Error(`S3 upload failed: ${e.statusText}`);this.lastBatchTime=Date.now()}catch(e){this.pendingEvents=t,this.eventsInFlight=n,this.context?.logger.error(`Failed to send final batch: ${e}`)}}async uploadToS3(e,t){const n=JSON.stringify(t),r=await fetch(e,{method:"PUT",body:n});if(!r.ok)throw new Error(`S3 upload failed: ${r.statusText}`)}sendRequest(e,t,n="POST",r={},s=!1){return new Promise((i,o)=>{if(!this.context)return o(new Error("No context"));const a=this.context.api.createRequestStructure(e,t,r,n);this.context.api.sendRequest(`req-${Date.now()}-${Math.random()}`,a,(e,t,n)=>{e>=200&&e<300?i({status:e,data:t}):o({status:e,data:t,error:n})},{gzip:!1,method:n,noContentType:s})})}}"undefined"!=typeof window&&(window.D2DWebSessionTracker=Tt)}();
|
|
15
|
+
***************************************************************************** */function Se(e,t,n,r){return new(n||(n=Promise))(function(t,s){function i(e){try{a(r.next(e))}catch(e){s(e)}}function o(e){try{a(r.throw(e))}catch(e){s(e)}}function a(e){var r;e.done?t(e.value):(r=e.value,r instanceof n?r:new n(function(e){e(r)})).then(i,o)}a((r=r.apply(e,[])).next())})}for(var be="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Ae="undefined"==typeof Uint8Array?[]:new Uint8Array(256),ke=0;ke<64;ke++)Ae[be.charCodeAt(ke)]=ke;const we=new Map;const Me=(e,t,n)=>{if(!e||!Ee(e,t)&&"object"!=typeof e)return;const r=function(e,t){let n=we.get(e);return n||(n=new Map,we.set(e,n)),n.has(t)||n.set(t,[]),n.get(t)}(n,e.constructor.name);let s=r.indexOf(e);return-1===s&&(s=r.length,r.push(e)),s};function Te(e,t,n){if(e instanceof Array)return e.map(e=>Te(e,t,n));if(null===e)return e;if(e instanceof Float32Array||e instanceof Float64Array||e instanceof Int32Array||e instanceof Uint32Array||e instanceof Uint8Array||e instanceof Uint16Array||e instanceof Int16Array||e instanceof Int8Array||e instanceof Uint8ClampedArray){return{rr_type:e.constructor.name,args:[Object.values(e)]}}if(e instanceof ArrayBuffer){const t=e.constructor.name,n=function(e){var t,n=new Uint8Array(e),r=n.length,s="";for(t=0;t<r;t+=3)s+=be[n[t]>>2],s+=be[(3&n[t])<<4|n[t+1]>>4],s+=be[(15&n[t+1])<<2|n[t+2]>>6],s+=be[63&n[t+2]];return r%3==2?s=s.substring(0,s.length-1)+"=":r%3==1&&(s=s.substring(0,s.length-2)+"=="),s}(e);return{rr_type:t,base64:n}}if(e instanceof DataView){return{rr_type:e.constructor.name,args:[Te(e.buffer,t,n),e.byteOffset,e.byteLength]}}if(e instanceof HTMLImageElement){const t=e.constructor.name,{src:n}=e;return{rr_type:t,src:n}}if(e instanceof HTMLCanvasElement){return{rr_type:"HTMLImageElement",src:e.toDataURL()}}if(e instanceof ImageData){return{rr_type:e.constructor.name,args:[Te(e.data,t,n),e.width,e.height]}}if(Ee(e,t)||"object"==typeof e){return{rr_type:e.constructor.name,index:Me(e,t,n)}}return e}const Re=(e,t,n)=>[...e].map(e=>Te(e,t,n)),Ee=(e,t)=>{const n=["WebGLActiveInfo","WebGLBuffer","WebGLFramebuffer","WebGLProgram","WebGLRenderbuffer","WebGLShader","WebGLShaderPrecisionFormat","WebGLTexture","WebGLUniformLocation","WebGLVertexArrayObject","WebGLVertexArrayObjectOES"].filter(e=>"function"==typeof t[e]);return Boolean(n.find(n=>e instanceof t[n]))};function Ne(e,t,n){const r=[];try{const s=F(e.HTMLCanvasElement.prototype,"getContext",function(e){return function(r,...s){return L(this,t,n,!0)||"__context"in this||(this.__context=r),e.apply(this,[r,...s])}});r.push(s)}catch(e){}return()=>{r.forEach(e=>e())}}function xe(e,t,n,r,s,i,o){const a=[],c=Object.getOwnPropertyNames(e);for(const i of c)if(!["isContextLost","canvas","drawingBufferWidth","drawingBufferHeight"].includes(i))try{if("function"!=typeof e[i])continue;const c=F(e,i,function(e){return function(...a){const c=e.apply(this,a);if(Me(c,o,this),!L(this.canvas,r,s,!0)){const e=Re([...a],o,this),r={type:t,property:i,args:e};n(this.canvas,r)}return c}});a.push(c)}catch(r){const s=x(e,i,{set(e){n(this.canvas,{type:t,property:i,args:[e],setter:!0})}});a.push(s)}return a}var Fe=null;try{var Oe="undefined"!=typeof module&&"function"==typeof module.require&&module.require("worker_threads")||"function"==typeof __non_webpack_require__&&__non_webpack_require__("worker_threads")||"function"==typeof require&&require("worker_threads");Fe=Oe.Worker}catch(e){}function De(e,t,n){var r=function(e){return Buffer.from(e,"base64").toString("utf8")}(e),s=r.indexOf("\n",10)+1,i=r.substring(s)+"";return function(e){return new Fe(i,Object.assign({},e,{eval:!0}))}}function Le(e,t,n){var r=function(e){return atob(e)}(e),s=r.indexOf("\n",10)+1,i=r.substring(s)+"",o=new Blob([i],{type:"application/javascript"});return URL.createObjectURL(o)}var Be="[object process]"===Object.prototype.toString.call("undefined"!=typeof process?process:0);var Ue,We=(Ue="Lyogcm9sbHVwLXBsdWdpbi13ZWItd29ya2VyLWxvYWRlciAqLwooZnVuY3Rpb24gKCkgewogICAgJ3VzZSBzdHJpY3QnOwoKICAgIC8qISAqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKg0KICAgIENvcHlyaWdodCA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ZlcnRUb0Jsb2IoZGF0YVVSTE9wdGlvbnMpOw0KICAgICAgICAgICAgICAgIGNvbnN0IHR5cGUgPSBibG9iLnR5cGU7DQogICAgICAgICAgICAgICAgY29uc3QgYXJyYXlCdWZmZXIgPSB5aWVsZCBibG9iLmFycmF5QnVmZmVyKCk7DQogICAgICAgICAgICAgICAgY29uc3QgYmFzZTY0ID0gZW5jb2RlKGFycmF5QnVmZmVyKTsNCiAgICAgICAgICAgICAgICBpZiAoIWxhc3RCbG9iTWFwLmhhcyhpZCkgJiYgKHlpZWxkIHRyYW5zcGFyZW50QmFzZTY0KSA9PT0gYmFzZTY0KSB7DQogICAgICAgICAgICAgICAgICAgIGxhc3RCbG9iTWFwLnNldChpZCwgYmFzZTY0KTsNCiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHdvcmtlci5wb3N0TWVzc2FnZSh7IGlkIH0pOw0KICAgICAgICAgICAgICAgIH0NCiAgICAgICAgICAgICAgICBpZiAobGFzdEJsb2JNYXAuZ2V0KGlkKSA9PT0gYmFzZTY0KQ0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gd29ya2VyLnBvc3RNZXNzYWdlKHsgaWQgfSk7DQogICAgICAgICAgICAgICAgd29ya2VyLnBvc3RNZXNzYWdlKHsNCiAgICAgICAgICAgICAgICAgICAgaWQsDQogICAgICAgICAgICAgICAgICAgIHR5cGUsDQogICAgICAgICAgICAgICAgICAgIGJhc2U2NCwNCiAgICAgICAgICAgICAgICAgICAgd2lkdGgsDQogICAgICAgICAgICAgICAgICAgIGhlaWdodCwNCiAgICAgICAgICAgICAgICB9KTsNCiAgICAgICAgICAgICAgICBsYXN0QmxvYk1hcC5zZXQoaWQsIGJhc2U2NCk7DQogICAgICAgICAgICB9DQogICAgICAgICAgICBlbHNlIHsNCiAgICAgICAgICAgICAgICByZXR1cm4gd29ya2VyLnBvc3RNZXNzYWdlKHsgaWQ6IGUuZGF0YS5pZCB9KTsNCiAgICAgICAgICAgIH0NCiAgICAgICAgfSk7DQogICAgfTsKCn0pKCk7Cgo=",Be?De(Ue):function(e){var t;return function(n){return t=t||Le(e),new Worker(t,n)}}(Ue));class Ze{constructor(e){this.pendingCanvasMutations=new Map,this.rafStamps={latestId:0,invokeId:null},this.frozen=!1,this.locked=!1,this.processMutation=(e,t)=>{!(this.rafStamps.invokeId&&this.rafStamps.latestId!==this.rafStamps.invokeId)&&this.rafStamps.invokeId||(this.rafStamps.invokeId=this.rafStamps.latestId),this.pendingCanvasMutations.has(e)||this.pendingCanvasMutations.set(e,[]),this.pendingCanvasMutations.get(e).push(t)};const{sampling:t="all",win:n,blockClass:r,blockSelector:s,recordCanvas:i,dataURLOptions:o}=e;this.mutationCb=e.mutationCb,this.mirror=e.mirror,i&&"all"===t&&this.initCanvasMutationObserver(n,r,s),i&&"number"==typeof t&&this.initCanvasFPSObserver(t,n,r,s,{dataURLOptions:o})}reset(){this.pendingCanvasMutations.clear(),this.resetObservers&&this.resetObservers()}freeze(){this.frozen=!0}unfreeze(){this.frozen=!1}lock(){this.locked=!0}unlock(){this.locked=!1}initCanvasFPSObserver(e,t,n,r,s){const i=Ne(t,n,r),o=new Map,a=new We;a.onmessage=e=>{const{id:t}=e.data;if(o.set(t,!1),!("base64"in e.data))return;const{base64:n,type:r,width:s,height:i}=e.data;this.mutationCb({id:t,type:J["2D"],commands:[{property:"clearRect",args:[0,0,s,i]},{property:"drawImage",args:[{rr_type:"ImageBitmap",args:[{rr_type:"Blob",data:[{rr_type:"ArrayBuffer",base64:n}],type:r}]},0,0]}]})};const c=1e3/e;let l,d=0;const u=e=>{d&&e-d<c||(d=e,(()=>{const e=[];return t.document.querySelectorAll("canvas").forEach(t=>{L(t,n,r,!0)||e.push(t)}),e})().forEach(e=>Se(this,0,void 0,function*(){var t;const n=this.mirror.getId(e);if(o.get(n))return;if(o.set(n,!0),["webgl","webgl2"].includes(e.__context)){const n=e.getContext(e.__context);!1===(null===(t=null==n?void 0:n.getContextAttributes())||void 0===t?void 0:t.preserveDrawingBuffer)&&(null==n||n.clear(n.COLOR_BUFFER_BIT))}const r=yield createImageBitmap(e);a.postMessage({id:n,bitmap:r,width:e.width,height:e.height,dataURLOptions:s.dataURLOptions},[r])}))),l=requestAnimationFrame(u)};l=requestAnimationFrame(u),this.resetObservers=()=>{i(),cancelAnimationFrame(l)}}initCanvasMutationObserver(e,t,n){this.startRAFTimestamping(),this.startPendingCanvasMutationFlusher();const r=Ne(e,t,n),s=function(e,t,n,r){const s=[],i=Object.getOwnPropertyNames(t.CanvasRenderingContext2D.prototype);for(const o of i)try{if("function"!=typeof t.CanvasRenderingContext2D.prototype[o])continue;const i=F(t.CanvasRenderingContext2D.prototype,o,function(s){return function(...i){return L(this.canvas,n,r,!0)||setTimeout(()=>{const n=Re([...i],t,this);e(this.canvas,{type:J["2D"],property:o,args:n})},0),s.apply(this,i)}});s.push(i)}catch(n){const r=x(t.CanvasRenderingContext2D.prototype,o,{set(t){e(this.canvas,{type:J["2D"],property:o,args:[t],setter:!0})}});s.push(r)}return()=>{s.forEach(e=>e())}}(this.processMutation.bind(this),e,t,n),i=function(e,t,n,r){const s=[];return s.push(...xe(t.WebGLRenderingContext.prototype,J.WebGL,e,n,r,0,t)),void 0!==t.WebGL2RenderingContext&&s.push(...xe(t.WebGL2RenderingContext.prototype,J.WebGL2,e,n,r,0,t)),()=>{s.forEach(e=>e())}}(this.processMutation.bind(this),e,t,n,this.mirror);this.resetObservers=()=>{r(),s(),i()}}startPendingCanvasMutationFlusher(){requestAnimationFrame(()=>this.flushPendingCanvasMutations())}startRAFTimestamping(){const e=t=>{this.rafStamps.latestId=t,requestAnimationFrame(e)};requestAnimationFrame(e)}flushPendingCanvasMutations(){this.pendingCanvasMutations.forEach((e,t)=>{const n=this.mirror.getId(t);this.flushPendingCanvasMutationFor(t,n)}),requestAnimationFrame(()=>this.flushPendingCanvasMutations())}flushPendingCanvasMutationFor(e,t){if(this.frozen||this.locked)return;const n=this.pendingCanvasMutations.get(e);if(!n||-1===t)return;const r=n.map(e=>{const t=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var s=0;for(r=Object.getOwnPropertySymbols(e);s<r.length;s++)t.indexOf(r[s])<0&&Object.prototype.propertyIsEnumerable.call(e,r[s])&&(n[r[s]]=e[r[s]])}return n}(e,["type"]);return t}),{type:s}=n[0];this.mutationCb({id:t,type:s,commands:r}),this.pendingCanvasMutations.delete(e)}}class Ge{constructor(e){this.trackedLinkElements=new WeakSet,this.styleMirror=new K,this.mutationCb=e.mutationCb,this.adoptedStyleSheetCb=e.adoptedStyleSheetCb}attachLinkElement(e,t){"_cssText"in t.attributes&&this.mutationCb({adds:[],removes:[],texts:[],attributes:[{id:t.id,attributes:t.attributes}]}),this.trackLinkElement(e)}trackLinkElement(e){this.trackedLinkElements.has(e)||(this.trackedLinkElements.add(e),this.trackStylesheetInLinkElement(e))}adoptStyleSheets(e,t){if(0===e.length)return;const n={id:t,styleIds:[]},r=[];for(const t of e){let e;if(this.styleMirror.has(t))e=this.styleMirror.getId(t);else{e=this.styleMirror.add(t);const n=Array.from(t.rules||CSSRule);r.push({styleId:e,rules:n.map((e,t)=>({rule:s(e),index:t}))})}n.styleIds.push(e)}r.length>0&&(n.styles=r),this.adoptedStyleSheetCb(n)}reset(){this.styleMirror.reset(),this.trackedLinkElements=new WeakSet}trackStylesheetInLinkElement(e){}}function Ve(e){return Object.assign(Object.assign({},e),{timestamp:Date.now()})}let Ke,_e,ze,Ye=!1;const Je=new i;function Qe(e={}){const{emit:t,checkoutEveryNms:n,checkoutEveryNth:r,blockClass:s="rr-block",blockSelector:o=null,ignoreClass:a="rr-ignore",maskTextClass:c="rr-mask",maskTextSelector:l=null,inlineStylesheet:d=!0,maskAllInputs:u,maskInputOptions:h,slimDOMOptions:g,maskInputFn:p,maskTextFn:m,hooks:f,packFn:I,sampling:C={},dataURLOptions:y={},mousemoveWait:v,recordCanvas:S=!1,recordCrossOriginIframes:b=!1,userTriggeredOnInput:A=!1,collectFonts:k=!1,inlineImages:w=!1,plugins:M,keepIframeSrcFn:E=()=>!1,ignoreCSSAttributes:N=new Set([])}=e,x=!b||window.parent===window;let F=!1;if(!x)try{window.parent.document,F=!1}catch(e){F=!0}if(x&&!t)throw new Error("emit function is required");void 0!==v&&void 0===C.mousemove&&(C.mousemove=v),Je.reset();const L=!0===u?{color:!0,date:!0,"datetime-local":!0,email:!0,month:!0,number:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0,textarea:!0,select:!0,password:!0}:void 0!==h?h:{password:!0},B=!0===g||"all"===g?{script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaVerification:!0,headMetaAuthorship:"all"===g,headMetaDescKeywords:"all"===g}:g||{};let U;!function(e=window){"NodeList"in e&&!e.NodeList.prototype.forEach&&(e.NodeList.prototype.forEach=Array.prototype.forEach),"DOMTokenList"in e&&!e.DOMTokenList.prototype.forEach&&(e.DOMTokenList.prototype.forEach=Array.prototype.forEach),Node.prototype.contains||(Node.prototype.contains=(...e)=>{let t=e[0];if(!(0 in e))throw new TypeError("1 argument is required");do{if(this===t)return!0}while(t=t&&t.parentNode);return!1})}();let W=0;const K=e=>{for(const t of M||[])t.eventProcessor&&(e=t.eventProcessor(e));return I&&(e=I(e)),e};Ke=(e,s)=>{var i;if(!(null===(i=ne[0])||void 0===i?void 0:i.isFrozen())||e.type===_.FullSnapshot||e.type===_.IncrementalSnapshot&&e.data.source===z.Mutation||ne.forEach(e=>e.unfreeze()),x)null==t||t(K(e),s);else if(F){const t={type:"rrweb",event:K(e),isCheckout:s};window.parent.postMessage(t,"*")}if(e.type===_.FullSnapshot)U=e,W=0;else if(e.type===_.IncrementalSnapshot){if(e.data.source===z.Mutation&&e.data.isAttachIframe)return;W++;const t=r&&W>=r,s=n&&e.timestamp-U.timestamp>n;(t||s)&&_e(!0)}};const Y=e=>{Ke(Ve({type:_.IncrementalSnapshot,data:Object.assign({source:z.Mutation},e)}))},J=e=>Ke(Ve({type:_.IncrementalSnapshot,data:Object.assign({source:z.Scroll},e)})),Q=e=>Ke(Ve({type:_.IncrementalSnapshot,data:Object.assign({source:z.CanvasMutation},e)})),P=new Ge({mutationCb:Y,adoptedStyleSheetCb:e=>Ke(Ve({type:_.IncrementalSnapshot,data:Object.assign({source:z.AdoptedStyleSheet},e)}))}),H=new ye({mirror:Je,mutationCb:Y,stylesheetManager:P,recordCrossOriginIframes:b,wrappedEmit:Ke});for(const e of M||[])e.getMirror&&e.getMirror({nodeMirror:Je,crossOriginIframeMirror:H.crossOriginIframeMirror,crossOriginIframeStyleMirror:H.crossOriginIframeStyleMirror});ze=new Ze({recordCanvas:S,mutationCb:Q,win:window,blockClass:s,blockSelector:o,mirror:Je,sampling:C.canvas,dataURLOptions:y});const X=new ve({mutationCb:Y,scrollCb:J,bypassOptions:{blockClass:s,blockSelector:o,maskTextClass:c,maskTextSelector:l,inlineStylesheet:d,maskInputOptions:L,dataURLOptions:y,maskTextFn:m,maskInputFn:p,recordCanvas:S,inlineImages:w,sampling:C,slimDOMOptions:B,iframeManager:H,stylesheetManager:P,canvasManager:ze,keepIframeSrcFn:E},mirror:Je});_e=(e=!1)=>{var t,n,r,a,u,h;Ke(Ve({type:_.Meta,data:{href:window.location.href,width:D(),height:O()}}),e),P.reset(),ne.forEach(e=>e.lock());const g=function(e,t){var n=t||{},r=n.mirror,s=void 0===r?new i:r,o=n.blockClass,a=void 0===o?"rr-block":o,c=n.blockSelector,l=void 0===c?null:c,d=n.maskTextClass,u=void 0===d?"rr-mask":d,h=n.maskTextSelector,g=void 0===h?null:h,p=n.inlineStylesheet,m=void 0===p||p,f=n.inlineImages,I=void 0!==f&&f,C=n.recordCanvas,y=void 0!==C&&C,v=n.maskAllInputs,S=void 0!==v&&v,b=n.maskTextFn,A=n.maskInputFn,k=n.slimDOM,w=void 0!==k&&k,M=n.dataURLOptions,R=n.preserveWhiteSpace,E=n.onSerialize,N=n.onIframeLoad,x=n.iframeLoadTimeout,F=n.onStylesheetLoad,O=n.stylesheetLoadTimeout,D=n.keepIframeSrcFn;return T(e,{doc:e,mirror:s,blockClass:a,blockSelector:l,maskTextClass:u,maskTextSelector:g,skipChild:!1,inlineStylesheet:m,maskInputOptions:!0===S?{color:!0,date:!0,"datetime-local":!0,email:!0,month:!0,number:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0,textarea:!0,select:!0,password:!0}:!1===S?{password:!0}:S,maskTextFn:b,maskInputFn:A,slimDOMOptions:!0===w||"all"===w?{script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaDescKeywords:"all"===w,headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaAuthorship:!0,headMetaVerification:!0}:!1===w?{}:w,dataURLOptions:M,inlineImages:I,recordCanvas:y,preserveWhiteSpace:R,onSerialize:E,onIframeLoad:N,iframeLoadTimeout:x,onStylesheetLoad:F,stylesheetLoadTimeout:O,keepIframeSrcFn:void 0===D?function(){return!1}:D,newlyAddedElement:!1})}(document,{mirror:Je,blockClass:s,blockSelector:o,maskTextClass:c,maskTextSelector:l,inlineStylesheet:d,maskAllInputs:L,maskTextFn:m,slimDOM:B,dataURLOptions:y,recordCanvas:S,inlineImages:w,onSerialize:e=>{Z(e,Je)&&H.addIframe(e),G(e,Je)&&P.trackLinkElement(e),V(e)&&X.addShadowRoot(e.shadowRoot,document)},onIframeLoad:(e,t)=>{H.attachIframe(e,t),X.observeAttachShadow(e)},onStylesheetLoad:(e,t)=>{P.attachLinkElement(e,t)},keepIframeSrcFn:E});g&&(Ke(Ve({type:_.FullSnapshot,data:{node:g,initialOffset:{left:void 0!==window.pageXOffset?window.pageXOffset:(null===document||void 0===document?void 0:document.documentElement.scrollLeft)||(null===(n=null===(t=null===document||void 0===document?void 0:document.body)||void 0===t?void 0:t.parentElement)||void 0===n?void 0:n.scrollLeft)||(null===(r=null===document||void 0===document?void 0:document.body)||void 0===r?void 0:r.scrollLeft)||0,top:void 0!==window.pageYOffset?window.pageYOffset:(null===document||void 0===document?void 0:document.documentElement.scrollTop)||(null===(u=null===(a=null===document||void 0===document?void 0:document.body)||void 0===a?void 0:a.parentElement)||void 0===u?void 0:u.scrollTop)||(null===(h=null===document||void 0===document?void 0:document.body)||void 0===h?void 0:h.scrollTop)||0}}})),ne.forEach(e=>e.unlock()),document.adoptedStyleSheets&&document.adoptedStyleSheets.length>0&&P.adoptStyleSheets(document.adoptedStyleSheets,Je.getId(document)))};try{const e=[];e.push(R("DOMContentLoaded",()=>{Ke(Ve({type:_.DomContentLoaded,data:{}}))}));const t=e=>{var t;return Ie({mutationCb:Y,mousemoveCb:(e,t)=>Ke(Ve({type:_.IncrementalSnapshot,data:{source:t,positions:e}})),mouseInteractionCb:e=>Ke(Ve({type:_.IncrementalSnapshot,data:Object.assign({source:z.MouseInteraction},e)})),scrollCb:J,viewportResizeCb:e=>Ke(Ve({type:_.IncrementalSnapshot,data:Object.assign({source:z.ViewportResize},e)})),inputCb:e=>Ke(Ve({type:_.IncrementalSnapshot,data:Object.assign({source:z.Input},e)})),mediaInteractionCb:e=>Ke(Ve({type:_.IncrementalSnapshot,data:Object.assign({source:z.MediaInteraction},e)})),styleSheetRuleCb:e=>Ke(Ve({type:_.IncrementalSnapshot,data:Object.assign({source:z.StyleSheetRule},e)})),styleDeclarationCb:e=>Ke(Ve({type:_.IncrementalSnapshot,data:Object.assign({source:z.StyleDeclaration},e)})),canvasMutationCb:Q,fontCb:e=>Ke(Ve({type:_.IncrementalSnapshot,data:Object.assign({source:z.Font},e)})),selectionCb:e=>{Ke(Ve({type:_.IncrementalSnapshot,data:Object.assign({source:z.Selection},e)}))},blockClass:s,ignoreClass:a,maskTextClass:c,maskTextSelector:l,maskInputOptions:L,inlineStylesheet:d,sampling:C,recordCanvas:S,inlineImages:w,userTriggeredOnInput:A,collectFonts:k,doc:e,maskInputFn:p,maskTextFn:m,keepIframeSrcFn:E,blockSelector:o,slimDOMOptions:B,dataURLOptions:y,mirror:Je,iframeManager:H,stylesheetManager:P,shadowDomManager:X,canvasManager:ze,ignoreCSSAttributes:N,plugins:(null===(t=null==M?void 0:M.filter(e=>e.observer))||void 0===t?void 0:t.map(e=>({observer:e.observer,options:e.options,callback:t=>Ke(Ve({type:_.Plugin,data:{plugin:e.name,payload:t}}))})))||[]},f)};H.addLoadListener(n=>{e.push(t(n.contentDocument))});const n=()=>{_e(),e.push(t(document)),Ye=!0};return"interactive"===document.readyState||"complete"===document.readyState?n():e.push(R("load",()=>{Ke(Ve({type:_.Load,data:{}})),n()},window)),()=>{e.forEach(e=>e()),Ye=!1}}catch(e){}}Qe.addCustomEvent=(e,t)=>{if(!Ye)throw new Error("please add custom event after start recording");Ke(Ve({type:_.Custom,data:{tag:e,payload:t}}))},Qe.freezePage=()=>{ne.forEach(e=>e.freeze())},Qe.takeFullSnapshot=e=>{if(!Ye)throw new Error("please take full snapshot after start recording");_e(e)},Qe.mirror=Je;var Pe=Uint8Array,He=Uint16Array,Xe=Uint32Array,je=new Pe([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),qe=new Pe([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),$e=new Pe([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),et=function(e,t){for(var n=new He(31),r=0;r<31;++r)n[r]=t+=1<<e[r-1];var s=new Xe(n[30]);for(r=1;r<30;++r)for(var i=n[r];i<n[r+1];++i)s[i]=i-n[r]<<5|r;return[n,s]},tt=et(je,2),nt=tt[0],rt=tt[1];nt[28]=258,rt[258]=28;for(var st=et(qe,0)[1],it=new He(32768),ot=0;ot<32768;++ot){var at=(43690&ot)>>>1|(21845&ot)<<1;at=(61680&(at=(52428&at)>>>2|(13107&at)<<2))>>>4|(3855&at)<<4,it[ot]=((65280&at)>>>8|(255&at)<<8)>>>1}var ct=function(e,t,n){for(var r=e.length,s=0,i=new He(t);s<r;++s)++i[e[s]-1];var o,a=new He(t);for(s=0;s<t;++s)a[s]=a[s-1]+i[s-1]<<1;if(n){o=new He(1<<t);var c=15-t;for(s=0;s<r;++s)if(e[s])for(var l=s<<4|e[s],d=t-e[s],u=a[e[s]-1]++<<d,h=u|(1<<d)-1;u<=h;++u)o[it[u]>>>c]=l}else for(o=new He(r),s=0;s<r;++s)o[s]=it[a[e[s]-1]++]>>>15-e[s];return o},lt=new Pe(288);for(ot=0;ot<144;++ot)lt[ot]=8;for(ot=144;ot<256;++ot)lt[ot]=9;for(ot=256;ot<280;++ot)lt[ot]=7;for(ot=280;ot<288;++ot)lt[ot]=8;var dt=new Pe(32);for(ot=0;ot<32;++ot)dt[ot]=5;var ut=ct(lt,9,0),ht=ct(dt,5,0),gt=function(e){return(e/8|0)+(7&e&&1)},pt=function(e,t,n){(null==n||n>e.length)&&(n=e.length);var r=new(e instanceof He?He:e instanceof Xe?Xe:Pe)(n-t);return r.set(e.subarray(t,n)),r},mt=function(e,t,n){n<<=7&t;var r=t/8|0;e[r]|=n,e[r+1]|=n>>>8},ft=function(e,t,n){n<<=7&t;var r=t/8|0;e[r]|=n,e[r+1]|=n>>>8,e[r+2]|=n>>>16},It=function(e,t){for(var n=[],r=0;r<e.length;++r)e[r]&&n.push({s:r,f:e[r]});var s=n.length,i=n.slice();if(!s)return[new Pe(0),0];if(1==s){var o=new Pe(n[0].s+1);return o[n[0].s]=1,[o,1]}n.sort(function(e,t){return e.f-t.f}),n.push({s:-1,f:25001});var a=n[0],c=n[1],l=0,d=1,u=2;for(n[0]={s:-1,f:a.f+c.f,l:a,r:c};d!=s-1;)a=n[n[l].f<n[u].f?l++:u++],c=n[l!=d&&n[l].f<n[u].f?l++:u++],n[d++]={s:-1,f:a.f+c.f,l:a,r:c};var h=i[0].s;for(r=1;r<s;++r)i[r].s>h&&(h=i[r].s);var g=new He(h+1),p=Ct(n[d-1],g,0);if(p>t){r=0;var m=0,f=p-t,I=1<<f;for(i.sort(function(e,t){return g[t.s]-g[e.s]||e.f-t.f});r<s;++r){var C=i[r].s;if(!(g[C]>t))break;m+=I-(1<<p-g[C]),g[C]=t}for(m>>>=f;m>0;){var y=i[r].s;g[y]<t?m-=1<<t-g[y]++-1:++r}for(;r>=0&&m;--r){var v=i[r].s;g[v]==t&&(--g[v],++m)}p=t}return[new Pe(g),p]},Ct=function(e,t,n){return-1==e.s?Math.max(Ct(e.l,t,n+1),Ct(e.r,t,n+1)):t[e.s]=n},yt=function(e){for(var t=e.length;t&&!e[--t];);for(var n=new He(++t),r=0,s=e[0],i=1,o=function(e){n[r++]=e},a=1;a<=t;++a)if(e[a]==s&&a!=t)++i;else{if(!s&&i>2){for(;i>138;i-=138)o(32754);i>2&&(o(i>10?i-11<<5|28690:i-3<<5|12305),i=0)}else if(i>3){for(o(s),--i;i>6;i-=6)o(8304);i>2&&(o(i-3<<5|8208),i=0)}for(;i--;)o(s);i=1,s=e[a]}return[n.subarray(0,r),t]},vt=function(e,t){for(var n=0,r=0;r<t.length;++r)n+=e[r]*t[r];return n},St=function(e,t,n){var r=n.length,s=gt(t+2);e[s]=255&r,e[s+1]=r>>>8,e[s+2]=255^e[s],e[s+3]=255^e[s+1];for(var i=0;i<r;++i)e[s+i+4]=n[i];return 8*(s+4+r)},bt=function(e,t,n,r,s,i,o,a,c,l,d){mt(t,d++,n),++s[256];for(var u=It(s,15),h=u[0],g=u[1],p=It(i,15),m=p[0],f=p[1],I=yt(h),C=I[0],y=I[1],v=yt(m),S=v[0],b=v[1],A=new He(19),k=0;k<C.length;++k)A[31&C[k]]++;for(k=0;k<S.length;++k)A[31&S[k]]++;for(var w=It(A,7),M=w[0],T=w[1],R=19;R>4&&!M[$e[R-1]];--R);var E,N,x,F,O=l+5<<3,D=vt(s,lt)+vt(i,dt)+o,L=vt(s,h)+vt(i,m)+o+14+3*R+vt(A,M)+(2*A[16]+3*A[17]+7*A[18]);if(O<=D&&O<=L)return St(t,d,e.subarray(c,c+l));if(mt(t,d,1+(L<D)),d+=2,L<D){E=ct(h,g,0),N=h,x=ct(m,f,0),F=m;var B=ct(M,T,0);mt(t,d,y-257),mt(t,d+5,b-1),mt(t,d+10,R-4),d+=14;for(k=0;k<R;++k)mt(t,d+3*k,M[$e[k]]);d+=3*R;for(var U=[C,S],W=0;W<2;++W){var Z=U[W];for(k=0;k<Z.length;++k){var G=31&Z[k];mt(t,d,B[G]),d+=M[G],G>15&&(mt(t,d,Z[k]>>>5&127),d+=Z[k]>>>12)}}}else E=ut,N=lt,x=ht,F=dt;for(k=0;k<a;++k)if(r[k]>255){G=r[k]>>>18&31;ft(t,d,E[G+257]),d+=N[G+257],G>7&&(mt(t,d,r[k]>>>23&31),d+=je[G]);var V=31&r[k];ft(t,d,x[V]),d+=F[V],V>3&&(ft(t,d,r[k]>>>5&8191),d+=qe[V])}else ft(t,d,E[r[k]]),d+=N[r[k]];return ft(t,d,E[256]),d+N[256]},At=new Xe([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),kt=function(e,t,n,r,s){return function(e,t,n,r,s,i){var o=e.length,a=new Pe(r+o+5*(1+Math.floor(o/7e3))+s),c=a.subarray(r,a.length-s),l=0;if(!t||o<8)for(var d=0;d<=o;d+=65535){var u=d+65535;u<o?l=St(c,l,e.subarray(d,u)):(c[d]=i,l=St(c,l,e.subarray(d,o)))}else{for(var h=At[t-1],g=h>>>13,p=8191&h,m=(1<<n)-1,f=new He(32768),I=new He(m+1),C=Math.ceil(n/3),y=2*C,v=function(t){return(e[t]^e[t+1]<<C^e[t+2]<<y)&m},S=new Xe(25e3),b=new He(288),A=new He(32),k=0,w=0,M=(d=0,0),T=0,R=0;d<o;++d){var E=v(d),N=32767&d,x=I[E];if(f[N]=x,I[E]=N,T<=d){var F=o-d;if((k>7e3||M>24576)&&F>423){l=bt(e,c,0,S,b,A,w,M,R,d-R,l),M=k=w=0,R=d;for(var O=0;O<286;++O)b[O]=0;for(O=0;O<30;++O)A[O]=0}var D=2,L=0,B=p,U=N-x&32767;if(F>2&&E==v(d-U))for(var W=Math.min(g,F)-1,Z=Math.min(32767,d),G=Math.min(258,F);U<=Z&&--B&&N!=x;){if(e[d+D]==e[d+D-U]){for(var V=0;V<G&&e[d+V]==e[d+V-U];++V);if(V>D){if(D=V,L=U,V>W)break;var K=Math.min(U,V-2),_=0;for(O=0;O<K;++O){var z=d-U+O+32768&32767,Y=z-f[z]+32768&32767;Y>_&&(_=Y,x=z)}}}U+=(N=x)-(x=f[N])+32768&32767}if(L){S[M++]=268435456|rt[D]<<18|st[L];var J=31&rt[D],Q=31&st[L];w+=je[J]+qe[Q],++b[257+J],++A[Q],T=d+D,++k}else S[M++]=e[d],++b[e[d]]}}l=bt(e,c,i,S,b,A,w,M,R,d-R,l)}return pt(a,0,r+gt(l)+s)}(e,null==t.level?6:t.level,null==t.mem?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(e.length)))):12+t.mem,n,r,!0)};function wt(e,t){void 0===t&&(t={});var n=function(){var e=1,t=0;return{p:function(n){for(var r=e,s=t,i=n.length,o=0;o!=i;){for(var a=Math.min(o+5552,i);o<a;++o)s+=r+=n[o];r%=65521,s%=65521}e=r,t=s},d:function(){return(e>>>8<<16|(255&t)<<8|t>>>8)+2*((255&e)<<23)}}}();n.p(e);var r,s,i,o=kt(e,t,2,4);return r=o,s=t.level,i=0==s?0:s<6?1:9==s?3:2,r[0]=120,r[1]=i<<6|(i?32-2*i:1),function(e,t,n){for(;n;++t)e[t]=n,n>>>=8}(o,o.length-4,n.d()),o}const Mt=e=>{const t={...e,v:"v1"};return function(e){for(var t="",n=0;n<e.length;){var r=e[n++];t+=String.fromCharCode(r)}return t}(wt(function(e,t){var n=e.length;if("undefined"!=typeof TextEncoder)return(new TextEncoder).encode(e);for(var r=new Pe(e.length+(e.length>>>1)),s=0,i=function(e){r[s++]=e},o=0;o<n;++o){if(s+5>r.length){var a=new Pe(s+8+(n-o<<1));a.set(r),r=a}var c=e.charCodeAt(o);c<128||t?i(c):c<2048?(i(192|c>>>6),i(128|63&c)):c>55295&&c<57344?(i(240|(c=65536+(1047552&c)|1023&e.charCodeAt(++o))>>>18),i(128|c>>>12&63),i(128|c>>>6&63),i(128|63&c)):(i(224|c>>>12),i(128|c>>>6&63),i(128|63&c))}return pt(r,0,s)}(JSON.stringify(t))))};class Tt{constructor(e){this.name="session-tracker",this.version='"0.9.5"',this.context=null,this.config={},this.userConfig=null,this.sessionStartTime=0,this.isActive=!1,this.stopRecordingFn=null,this.sessionEvents=[],this.sessionId="",this.currentSessionSize=0,this.lastBatchTime=0,this.activeBatchCount=0,this.userId="",this.appId="",this.pendingEvents=[],this.eventsInFlight=[],this.sentEventCount=0,this.isSendingBatch=!1,this.delayedS3Url=null,this.delayedUrlExpiry=0,this.delayedUrlRefreshTimer=null,this.userConfig=e||{}}init(e,t){this.context=e;const n="object"==typeof t?.webSessions?t?.webSessions:null,r={enableSessionRecording:!1!==t?.webSessions&&(!0===t?.webSessions||!1!==n?.enabled),maxBatchSize:1048576,maxSessionDuration:null,batchSize:150,batchInterval:3e4,minimumSessionDuration:5e3,compressionEnabled:!1,recordingOptions:{recordCanvas:!0,recordCrossOriginIframes:!1,recordAfter:"DOMContentLoaded",maskAllInputs:!1,maskInputOptions:{password:!0,email:!0,text:!1},blockClass:"sensitive-field",slimDOMOptions:{script:!1,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaDescKeywords:!0,headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaAuthorship:!0,headMetaVerification:!0},sampling:{scroll:150,mouseInteraction:!0,input:"last",mutation:!0},...this.userConfig?this.userConfig:{},...this.config.recordingOptions?this.config.recordingOptions:{}}};this.config={...r}}start(){if(!this.context)return;if(this.isActive)return;this.delayedUrlRefreshTimer&&(clearTimeout(this.delayedUrlRefreshTimer),this.delayedUrlRefreshTimer=null),this.isActive=!0,this.userId=this.context.userManager.getUserId(),this.appId=this.context.appManager.getAppId();const e=String(this.context.userManager.getSessionId());(!this.sessionId||this.sessionId!==e)&&(this.sessionEvents=[],this.pendingEvents=[],this.eventsInFlight=[],this.currentSessionSize=0,this.sentEventCount=0,this.sessionStartTime=Date.now(),this.delayedS3Url=null,this.delayedUrlExpiry=0),this.sessionId=e,this.config.enableSessionRecording&&this.startRecording()}stop(){this.isActive&&this.stopRecording()}destroy(){this.stopRecording(),this.pendingEvents=[],this.eventsInFlight=[],this.sessionEvents=[],this.currentSessionSize=0,this.sentEventCount=0,this.delayedS3Url=null,this.delayedUrlExpiry=0,this.context?.removePluginField("recordingSessionId"),this.context?.setPluginField("isRecordingActive",!1),this.context=null}onEvent(e,t){this.isActive&&"session_start"===e&&(this.sessionStartTime=Date.now())}async onUserChange(e){this.isActive&&(await this.sendBatchToBackend(),this.stopRecording(),this.isActive=!1,this.start())}async onFocus(){this.pendingEvents.length>0&&await this.sendBatchToBackend(),this.isActive||this.start()}onBlur(){this.isActive&&(this.sendFinalBatch().catch(e=>{this.context?.logger.error(e)}),this.stopRecording(!0))}async onBeforeUnload(){const e=this.pendingEvents.length>0||this.eventsInFlight.length>0;(this.isActive||e)&&this.sendFinalBatch().catch(e=>{this.context?.logger.error(e)})}async onTrackingChange(e){e?this.isActive||this.start():this.isActive&&(await this.sendBatchToBackend(),this.stopRecording())}async onSessionStart(){await this.sendBatchToBackend(),this.isActive||this.start()}stopRecording(e=!1){e||this.context?.setPluginField("isRecordingActive",!1),this.isActive=!1,this.delayedUrlRefreshTimer&&(clearTimeout(this.delayedUrlRefreshTimer),this.delayedUrlRefreshTimer=null),this.stopRecordingFn&&(this.stopRecordingFn(),this.stopRecordingFn=null)}async startRecording(){if(!this.context)return;this.lastBatchTime=Date.now(),this.isSendingBatch=!1;const e=Date.now();if(!this.delayedS3Url||this.delayedUrlExpiry>0&&e>this.delayedUrlExpiry)this.fetchDelayedUrl();else if(this.delayedS3Url){const t=Math.max(0,this.delayedUrlExpiry-e);this.scheduleDelayedUrlRefresh(t+1e4)}const t=this.context.getPluginField("recordingSessionId"),n=!!t&&t===this.context.userManager.getSessionId(),r=this.context.getPluginField("isRecordingActive");if(n&&r)this.startSessionRecording();else try{const e=this.context.api.buildUrl(["sessions","configurations","get"],{appId:this.appId}),t=await this.sendRequest(e,null,"GET");if(t&&t.data){const e=t.data;if(e.blocked||!e.active)return this.context.logger.debug("Session configuration is "+(e.blocked?"blocked":"inactive")),void this.context.setPluginField("isRecordingActive",!1);100*Math.random()<e.record_chance_percent?(this.context.setPluginField("isRecordingActive",!0),this.startSessionRecording()):this.context.setPluginField("isRecordingActive",!1)}}catch(e){this.context.logger.error("Failed to fetch session configuration",{error:e}),this.context.setPluginField("isRecordingActive",!1)}}startSessionRecording(){if(!this.config.enableSessionRecording)return;this.context?.setPluginField("recordingSessionId",this.context?.userManager.getSessionId()),this.lastBatchTime=Date.now();const e={emit:e=>{this.addEventToSession(e),this.pendingEvents.push(e),this.currentSessionSize+=JSON.stringify(e).length,e.type,this.checkBatchLimits()},...this.config.recordingOptions};this.config.compressionEnabled&&(e.packFn=Mt);const t=Qe(e);this.stopRecordingFn=t||null}addEventToSession(e){this.sessionEvents.push(e);this.sessionEvents.length>1e4&&(this.sessionEvents=this.sessionEvents.slice(-Math.floor(5e3)))}hasMinimumSessionDuration(){return Date.now()-this.sessionStartTime>=this.config.minimumSessionDuration}checkBatchLimits(){if(this.isSendingBatch)return;const e=Date.now()-this.sessionStartTime,t=this.pendingEvents.length>=this.config.batchSize,n=this.currentSessionSize>=this.config.maxBatchSize,r=this.config.maxSessionDuration&&e>=this.config.maxSessionDuration,s=Date.now()-this.lastBatchTime>=this.config.batchInterval;(t||n||r||s)&&this.sendBatchToBackend().catch(e=>{this.context?.logger.error("Error in checkBatchLimits sendBatchToBackend",{error:e instanceof Error?e.message:e,pendingEventsCount:this.pendingEvents.length})})}async sendBatchToBackend(){if(!this.pendingEvents.length||!this.context||this.isSendingBatch)return;if(!this.hasMinimumSessionDuration())return;this.isSendingBatch=!0,this.eventsInFlight=[...this.pendingEvents],this.pendingEvents=[];const e=this.eventsInFlight.reduce((e,t)=>e+JSON.stringify(t).length,0);this.currentSessionSize-=e,this.currentSessionSize=Math.max(0,this.currentSessionSize),this.activeBatchCount++;try{const e=this.eventsInFlight[0]?.timestamp||Date.now(),t=this.eventsInFlight[this.eventsInFlight.length-1]?.timestamp||Date.now(),n={appId:this.appId,session_id:this.sessionId,user_id:this.userId,start_time:e,end_time:t},r=this.context.api.buildUrl(["sessions","add"],n),s=await this.sendRequest(r,null,"GET",{},!0);if(204===s.status)return this.context.logger.warning("Session storage exceeded"),this.eventsInFlight=[],void this.stop();const i=s.data,o="string"==typeof i?i:i?.url;if(!o)throw new Error("No S3 URL returned");await this.uploadToS3(o,this.eventsInFlight),this.sentEventCount+=this.eventsInFlight.length,this.lastBatchTime=Date.now(),this.eventsInFlight=[]}catch(t){throw this.context?.logger.error("Error sending session batch to backend",{error:t instanceof Error?t.message:t,eventsCount:this.eventsInFlight.length}),this.pendingEvents.unshift(...this.eventsInFlight),this.eventsInFlight=[],this.currentSessionSize+=e,t}finally{this.activeBatchCount--,this.isSendingBatch=!1,this.pendingEvents.length>0&&this.checkBatchLimits()}}async fetchDelayedUrl(){if(this.context)try{const e=this.context.api.buildUrl(["sessions","addDelayed"],{session_id:this.sessionId,appId:this.appId,user_id:this.userId}),t=await this.sendRequest(e,null,"GET");if(t&&t.data){const e=t.data;this.delayedS3Url=e.url,this.delayedUrlExpiry=Date.now()+e.ttl,this.scheduleDelayedUrlRefresh(e.ttl)}}catch(e){this.context.logger.error("Failed to fetch delayed URL",{error:e})}}scheduleDelayedUrlRefresh(e){this.delayedUrlRefreshTimer&&clearTimeout(this.delayedUrlRefreshTimer);const t=Math.max(0,e-1e4);this.delayedUrlRefreshTimer=setTimeout(()=>{this.fetchDelayedUrl()},t)}async sendFinalBatch(){if(!this.context)return;if(!this.hasMinimumSessionDuration())return;const e=[...this.eventsInFlight,...this.pendingEvents];if(!e.length)return;if(!this.delayedS3Url)return void this.context.logger.error("No delayed URL available for final batch - cannot send.");const t=[...this.pendingEvents],n=[...this.eventsInFlight];this.pendingEvents=[],this.eventsInFlight=[],this.currentSessionSize=0;const r=JSON.stringify(e),s=new Blob([r],{type:"application/json"});try{const e=await fetch(this.delayedS3Url,{method:"PUT",body:s,keepalive:!0,credentials:"omit"});if(!e.ok)throw new Error(`S3 upload failed: ${e.statusText}`);this.lastBatchTime=Date.now()}catch(e){this.pendingEvents=t,this.eventsInFlight=n,this.context?.logger.error(`Failed to send final batch: ${e}`)}}async uploadToS3(e,t){const n=JSON.stringify(t),r=await fetch(e,{method:"PUT",body:n});if(!r.ok)throw new Error(`S3 upload failed: ${r.statusText}`)}sendRequest(e,t,n="POST",r={},s=!1){return new Promise((i,o)=>{if(!this.context)return o(new Error("No context"));const a=this.context.api.createRequestStructure(e,t,r,n);this.context.api.sendRequest(`req-${Date.now()}-${Math.random()}`,a,(e,t,n)=>{e>=200&&e<300?i({status:e,data:t}):o({status:e,data:t,error:n})},{gzip:!1,method:n,noContentType:s})})}}"undefined"!=typeof window&&(window.DTDWebSessionTracker=Tt)}();
|
package/dist/index.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ type WebSessionConfig = {
|
|
|
10
10
|
};
|
|
11
11
|
blockClass: string;
|
|
12
12
|
};
|
|
13
|
-
declare class
|
|
13
|
+
declare class DTDWebSessionTracker implements IPlugin {
|
|
14
14
|
name: string;
|
|
15
15
|
version: string;
|
|
16
16
|
private context;
|
|
@@ -59,5 +59,5 @@ declare class D2DWebSessionTracker implements IPlugin {
|
|
|
59
59
|
private sendRequest;
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
-
export {
|
|
62
|
+
export { DTDWebSessionTracker as default };
|
|
63
63
|
export type { WebSessionConfig };
|
package/dist/index.esm.js
CHANGED
|
@@ -12,4 +12,4 @@ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
|
12
12
|
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
13
13
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
14
14
|
PERFORMANCE OF THIS SOFTWARE.
|
|
15
|
-
***************************************************************************** */function Se(e,t,n,r){return new(n||(n=Promise))(function(t,s){function o(e){try{a(r.next(e))}catch(e){s(e)}}function i(e){try{a(r.throw(e))}catch(e){s(e)}}function a(e){var r;e.done?t(e.value):(r=e.value,r instanceof n?r:new n(function(e){e(r)})).then(o,i)}a((r=r.apply(e,[])).next())})}for(var be="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Ae="undefined"==typeof Uint8Array?[]:new Uint8Array(256),ke=0;ke<64;ke++)Ae[be.charCodeAt(ke)]=ke;const we=new Map;const Me=(e,t,n)=>{if(!e||!Ee(e,t)&&"object"!=typeof e)return;const r=function(e,t){let n=we.get(e);return n||(n=new Map,we.set(e,n)),n.has(t)||n.set(t,[]),n.get(t)}(n,e.constructor.name);let s=r.indexOf(e);return-1===s&&(s=r.length,r.push(e)),s};function Te(e,t,n){if(e instanceof Array)return e.map(e=>Te(e,t,n));if(null===e)return e;if(e instanceof Float32Array||e instanceof Float64Array||e instanceof Int32Array||e instanceof Uint32Array||e instanceof Uint8Array||e instanceof Uint16Array||e instanceof Int16Array||e instanceof Int8Array||e instanceof Uint8ClampedArray){return{rr_type:e.constructor.name,args:[Object.values(e)]}}if(e instanceof ArrayBuffer){const t=e.constructor.name,n=function(e){var t,n=new Uint8Array(e),r=n.length,s="";for(t=0;t<r;t+=3)s+=be[n[t]>>2],s+=be[(3&n[t])<<4|n[t+1]>>4],s+=be[(15&n[t+1])<<2|n[t+2]>>6],s+=be[63&n[t+2]];return r%3==2?s=s.substring(0,s.length-1)+"=":r%3==1&&(s=s.substring(0,s.length-2)+"=="),s}(e);return{rr_type:t,base64:n}}if(e instanceof DataView){return{rr_type:e.constructor.name,args:[Te(e.buffer,t,n),e.byteOffset,e.byteLength]}}if(e instanceof HTMLImageElement){const t=e.constructor.name,{src:n}=e;return{rr_type:t,src:n}}if(e instanceof HTMLCanvasElement){return{rr_type:"HTMLImageElement",src:e.toDataURL()}}if(e instanceof ImageData){return{rr_type:e.constructor.name,args:[Te(e.data,t,n),e.width,e.height]}}if(Ee(e,t)||"object"==typeof e){return{rr_type:e.constructor.name,index:Me(e,t,n)}}return e}const Re=(e,t,n)=>[...e].map(e=>Te(e,t,n)),Ee=(e,t)=>{const n=["WebGLActiveInfo","WebGLBuffer","WebGLFramebuffer","WebGLProgram","WebGLRenderbuffer","WebGLShader","WebGLShaderPrecisionFormat","WebGLTexture","WebGLUniformLocation","WebGLVertexArrayObject","WebGLVertexArrayObjectOES"].filter(e=>"function"==typeof t[e]);return Boolean(n.find(n=>e instanceof t[n]))};function Ne(e,t,n){const r=[];try{const s=F(e.HTMLCanvasElement.prototype,"getContext",function(e){return function(r,...s){return L(this,t,n,!0)||"__context"in this||(this.__context=r),e.apply(this,[r,...s])}});r.push(s)}catch(e){}return()=>{r.forEach(e=>e())}}function xe(e,t,n,r,s,o,i){const a=[],c=Object.getOwnPropertyNames(e);for(const o of c)if(!["isContextLost","canvas","drawingBufferWidth","drawingBufferHeight"].includes(o))try{if("function"!=typeof e[o])continue;const c=F(e,o,function(e){return function(...a){const c=e.apply(this,a);if(Me(c,i,this),!L(this.canvas,r,s,!0)){const e=Re([...a],i,this),r={type:t,property:o,args:e};n(this.canvas,r)}return c}});a.push(c)}catch(r){const s=x(e,o,{set(e){n(this.canvas,{type:t,property:o,args:[e],setter:!0})}});a.push(s)}return a}var Fe=null;try{var Oe="undefined"!=typeof module&&"function"==typeof module.require&&module.require("worker_threads")||"function"==typeof __non_webpack_require__&&__non_webpack_require__("worker_threads")||"function"==typeof require&&require("worker_threads");Fe=Oe.Worker}catch(e){}function De(e,t,n){var r=function(e){return Buffer.from(e,"base64").toString("utf8")}(e),s=r.indexOf("\n",10)+1,o=r.substring(s)+"";return function(e){return new Fe(o,Object.assign({},e,{eval:!0}))}}function Le(e,t,n){var r=function(e){return atob(e)}(e),s=r.indexOf("\n",10)+1,o=r.substring(s)+"",i=new Blob([o],{type:"application/javascript"});return URL.createObjectURL(i)}var Be="[object process]"===Object.prototype.toString.call("undefined"!=typeof process?process:0);var Ue,We=(Ue="Lyogcm9sbHVwLXBsdWdpbi13ZWItd29ya2VyLWxvYWRlciAqLwooZnVuY3Rpb24gKCkgewogICAgJ3VzZSBzdHJpY3QnOwoKICAgIC8qISAqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKg0KICAgIENvcHlyaWdodCAoYykgTWljcm9zb2Z0IENvcnBvcmF0aW9uLg0KDQogICAgUGVybWlzc2lvbiB0byB1c2UsIGNvcHksIG1vZGlmeSwgYW5kL29yIGRpc3RyaWJ1dGUgdGhpcyBzb2Z0d2FyZSBmb3IgYW55DQogICAgcHVycG9zZSB3aXRoIG9yIHdpdGhvdXQgZmVlIGlzIGhlcmVieSBncmFudGVkLg0KDQogICAgVEhFIFNPRlRXQVJFIElTIFBST1ZJREVEICJBUyBJUyIgQU5EIFRIRSBBVVRIT1IgRElTQ0xBSU1TIEFMTCBXQVJSQU5USUVTIFdJVEgNCiAgICBSRUdBUkQgVE8gVEhJUyBTT0ZUV0FSRSBJTkNMVURJTkcgQUxMIElNUExJRUQgV0FSUkFOVElFUyBPRiBNRVJDSEFOVEFCSUxJVFkNCiAgICBBTkQgRklUTkVTUy4gSU4gTk8gRVZFTlQgU0hBTEwgVEhFIEFVVEhPUiBCRSBMSUFCTEUgRk9SIEFOWSBTUEVDSUFMLCBESVJFQ1QsDQogICAgSU5ESVJFQ1QsIE9SIENPTlNFUVVFTlRJQUwgREFNQUdFUyBPUiBBTlkgREFNQUdFUyBXSEFUU09FVkVSIFJFU1VMVElORyBGUk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xvYk1hcC5oYXMoaWQpKQ0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gdHJhbnNwYXJlbnRCbG9iTWFwLmdldChpZCk7DQogICAgICAgICAgICAgICAgY29uc3Qgb2Zmc2NyZWVuID0gbmV3IE9mZnNjcmVlbkNhbnZhcyh3aWR0aCwgaGVpZ2h0KTsNCiAgICAgICAgICAgICAgICBvZmZzY3JlZW4uZ2V0Q29udGV4dCgnMmQnKTsNCiAgICAgICAgICAgICAgICBjb25zdCBibG9iID0geWllbGQgb2Zmc2NyZWVuLmNvbnZlcnRUb0Jsb2IoZGF0YVVSTE9wdGlvbnMpOw0KICAgICAgICAgICAgICAgIGNvbnN0IGFycmF5QnVmZmVyID0geWllbGQgYmxvYi5hcnJheUJ1ZmZlcigpOw0KICAgICAgICAgICAgICAgIGNvbnN0IGJhc2U2NCA9IGVuY29kZShhcnJheUJ1ZmZlcik7DQogICAgICAgICAgICAgICAgdHJhbnNwYXJlbnRCbG9iTWFwLnNldChpZCwgYmFzZTY0KTsNCiAgICAgICAgICAgICAgICByZXR1cm4gYmFzZTY0Ow0KICAgICAgICAgICAgfQ0KICAgICAgICAgICAgZWxzZSB7DQogICAgICAgICAgICAgICAgcmV0dXJuICcnOw0KICAgICAgICAgICAgfQ0KICAgICAgICB9KTsNCiAgICB9DQogICAgY29uc3Qgd29ya2VyID0gc2VsZjsNCiAgICB3b3JrZXIub25tZXNzYWdlID0gZnVuY3Rpb24gKGUpIHsNCiAgICAgICAgcmV0dXJuIF9fYXdhaXRlcih0aGlzLCB2b2lkIDAsIHZvaWQgMCwgZnVuY3Rpb24qICgpIHsNCiAgICAgICAgICAgIGlmICgnT2Zmc2NyZWVuQ2FudmFzJyBpbiBnbG9iYWxUaGlzKSB7DQogICAgICAgICAgICAgICAgY29uc3QgeyBpZCwgYml0bWFwLCB3aWR0aCwgaGVpZ2h0LCBkYXRhVVJMT3B0aW9ucyB9ID0gZS5kYXRhOw0KICAgICAgICAgICAgICAgIGNvbnN0IH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AgICAgICAgICAgd29ya2VyLnBvc3RNZXNzYWdlKHsNCiAgICAgICAgICAgICAgICAgICAgaWQsDQogICAgICAgICAgICAgICAgICAgIHR5cGUsDQogICAgICAgICAgICAgICAgICAgIGJhc2U2NCwNCiAgICAgICAgICAgICAgICAgICAgd2lkdGgsDQogICAgICAgICAgICAgICAgICAgIGhlaWdodCwNCiAgICAgICAgICAgICAgICB9KTsNCiAgICAgICAgICAgICAgICBsYXN0QmxvYk1hcC5zZXQoaWQsIGJhc2U2NCk7DQogICAgICAgICAgICB9DQogICAgICAgICAgICBlbHNlIHsNCiAgICAgICAgICAgICAgICByZXR1cm4gd29ya2VyLnBvc3RNZXNzYWdlKHsgaWQ6IGUuZGF0YS5pZCB9KTsNCiAgICAgICAgICAgIH0NCiAgICAgICAgfSk7DQogICAgfTsKCn0pKCk7Cgo=",Be?De(Ue):function(e){var t;return function(n){return t=t||Le(e),new Worker(t,n)}}(Ue));class Ze{constructor(e){this.pendingCanvasMutations=new Map,this.rafStamps={latestId:0,invokeId:null},this.frozen=!1,this.locked=!1,this.processMutation=(e,t)=>{!(this.rafStamps.invokeId&&this.rafStamps.latestId!==this.rafStamps.invokeId)&&this.rafStamps.invokeId||(this.rafStamps.invokeId=this.rafStamps.latestId),this.pendingCanvasMutations.has(e)||this.pendingCanvasMutations.set(e,[]),this.pendingCanvasMutations.get(e).push(t)};const{sampling:t="all",win:n,blockClass:r,blockSelector:s,recordCanvas:o,dataURLOptions:i}=e;this.mutationCb=e.mutationCb,this.mirror=e.mirror,o&&"all"===t&&this.initCanvasMutationObserver(n,r,s),o&&"number"==typeof t&&this.initCanvasFPSObserver(t,n,r,s,{dataURLOptions:i})}reset(){this.pendingCanvasMutations.clear(),this.resetObservers&&this.resetObservers()}freeze(){this.frozen=!0}unfreeze(){this.frozen=!1}lock(){this.locked=!0}unlock(){this.locked=!1}initCanvasFPSObserver(e,t,n,r,s){const o=Ne(t,n,r),i=new Map,a=new We;a.onmessage=e=>{const{id:t}=e.data;if(i.set(t,!1),!("base64"in e.data))return;const{base64:n,type:r,width:s,height:o}=e.data;this.mutationCb({id:t,type:J["2D"],commands:[{property:"clearRect",args:[0,0,s,o]},{property:"drawImage",args:[{rr_type:"ImageBitmap",args:[{rr_type:"Blob",data:[{rr_type:"ArrayBuffer",base64:n}],type:r}]},0,0]}]})};const c=1e3/e;let l,d=0;const h=e=>{d&&e-d<c||(d=e,(()=>{const e=[];return t.document.querySelectorAll("canvas").forEach(t=>{L(t,n,r,!0)||e.push(t)}),e})().forEach(e=>Se(this,0,void 0,function*(){var t;const n=this.mirror.getId(e);if(i.get(n))return;if(i.set(n,!0),["webgl","webgl2"].includes(e.__context)){const n=e.getContext(e.__context);!1===(null===(t=null==n?void 0:n.getContextAttributes())||void 0===t?void 0:t.preserveDrawingBuffer)&&(null==n||n.clear(n.COLOR_BUFFER_BIT))}const r=yield createImageBitmap(e);a.postMessage({id:n,bitmap:r,width:e.width,height:e.height,dataURLOptions:s.dataURLOptions},[r])}))),l=requestAnimationFrame(h)};l=requestAnimationFrame(h),this.resetObservers=()=>{o(),cancelAnimationFrame(l)}}initCanvasMutationObserver(e,t,n){this.startRAFTimestamping(),this.startPendingCanvasMutationFlusher();const r=Ne(e,t,n),s=function(e,t,n,r){const s=[],o=Object.getOwnPropertyNames(t.CanvasRenderingContext2D.prototype);for(const i of o)try{if("function"!=typeof t.CanvasRenderingContext2D.prototype[i])continue;const o=F(t.CanvasRenderingContext2D.prototype,i,function(s){return function(...o){return L(this.canvas,n,r,!0)||setTimeout(()=>{const n=Re([...o],t,this);e(this.canvas,{type:J["2D"],property:i,args:n})},0),s.apply(this,o)}});s.push(o)}catch(n){const r=x(t.CanvasRenderingContext2D.prototype,i,{set(t){e(this.canvas,{type:J["2D"],property:i,args:[t],setter:!0})}});s.push(r)}return()=>{s.forEach(e=>e())}}(this.processMutation.bind(this),e,t,n),o=function(e,t,n,r){const s=[];return s.push(...xe(t.WebGLRenderingContext.prototype,J.WebGL,e,n,r,0,t)),void 0!==t.WebGL2RenderingContext&&s.push(...xe(t.WebGL2RenderingContext.prototype,J.WebGL2,e,n,r,0,t)),()=>{s.forEach(e=>e())}}(this.processMutation.bind(this),e,t,n,this.mirror);this.resetObservers=()=>{r(),s(),o()}}startPendingCanvasMutationFlusher(){requestAnimationFrame(()=>this.flushPendingCanvasMutations())}startRAFTimestamping(){const e=t=>{this.rafStamps.latestId=t,requestAnimationFrame(e)};requestAnimationFrame(e)}flushPendingCanvasMutations(){this.pendingCanvasMutations.forEach((e,t)=>{const n=this.mirror.getId(t);this.flushPendingCanvasMutationFor(t,n)}),requestAnimationFrame(()=>this.flushPendingCanvasMutations())}flushPendingCanvasMutationFor(e,t){if(this.frozen||this.locked)return;const n=this.pendingCanvasMutations.get(e);if(!n||-1===t)return;const r=n.map(e=>{const t=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var s=0;for(r=Object.getOwnPropertySymbols(e);s<r.length;s++)t.indexOf(r[s])<0&&Object.prototype.propertyIsEnumerable.call(e,r[s])&&(n[r[s]]=e[r[s]])}return n}(e,["type"]);return t}),{type:s}=n[0];this.mutationCb({id:t,type:s,commands:r}),this.pendingCanvasMutations.delete(e)}}class Ge{constructor(e){this.trackedLinkElements=new WeakSet,this.styleMirror=new K,this.mutationCb=e.mutationCb,this.adoptedStyleSheetCb=e.adoptedStyleSheetCb}attachLinkElement(e,t){"_cssText"in t.attributes&&this.mutationCb({adds:[],removes:[],texts:[],attributes:[{id:t.id,attributes:t.attributes}]}),this.trackLinkElement(e)}trackLinkElement(e){this.trackedLinkElements.has(e)||(this.trackedLinkElements.add(e),this.trackStylesheetInLinkElement(e))}adoptStyleSheets(e,t){if(0===e.length)return;const n={id:t,styleIds:[]},r=[];for(const t of e){let e;if(this.styleMirror.has(t))e=this.styleMirror.getId(t);else{e=this.styleMirror.add(t);const n=Array.from(t.rules||CSSRule);r.push({styleId:e,rules:n.map((e,t)=>({rule:s(e),index:t}))})}n.styleIds.push(e)}r.length>0&&(n.styles=r),this.adoptedStyleSheetCb(n)}reset(){this.styleMirror.reset(),this.trackedLinkElements=new WeakSet}trackStylesheetInLinkElement(e){}}function Ve(e){return Object.assign(Object.assign({},e),{timestamp:Date.now()})}let Ke,_e,ze,Ye=!1;const Je=new o;function Qe(e={}){const{emit:t,checkoutEveryNms:n,checkoutEveryNth:r,blockClass:s="rr-block",blockSelector:i=null,ignoreClass:a="rr-ignore",maskTextClass:c="rr-mask",maskTextSelector:l=null,inlineStylesheet:d=!0,maskAllInputs:h,maskInputOptions:u,slimDOMOptions:g,maskInputFn:p,maskTextFn:m,hooks:f,packFn:I,sampling:C={},dataURLOptions:y={},mousemoveWait:v,recordCanvas:S=!1,recordCrossOriginIframes:b=!1,userTriggeredOnInput:A=!1,collectFonts:k=!1,inlineImages:w=!1,plugins:M,keepIframeSrcFn:E=()=>!1,ignoreCSSAttributes:N=new Set([])}=e,x=!b||window.parent===window;let F=!1;if(!x)try{window.parent.document,F=!1}catch(e){F=!0}if(x&&!t)throw new Error("emit function is required");void 0!==v&&void 0===C.mousemove&&(C.mousemove=v),Je.reset();const L=!0===h?{color:!0,date:!0,"datetime-local":!0,email:!0,month:!0,number:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0,textarea:!0,select:!0,password:!0}:void 0!==u?u:{password:!0},B=!0===g||"all"===g?{script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaVerification:!0,headMetaAuthorship:"all"===g,headMetaDescKeywords:"all"===g}:g||{};let U;!function(e=window){"NodeList"in e&&!e.NodeList.prototype.forEach&&(e.NodeList.prototype.forEach=Array.prototype.forEach),"DOMTokenList"in e&&!e.DOMTokenList.prototype.forEach&&(e.DOMTokenList.prototype.forEach=Array.prototype.forEach),Node.prototype.contains||(Node.prototype.contains=(...e)=>{let t=e[0];if(!(0 in e))throw new TypeError("1 argument is required");do{if(this===t)return!0}while(t=t&&t.parentNode);return!1})}();let W=0;const K=e=>{for(const t of M||[])t.eventProcessor&&(e=t.eventProcessor(e));return I&&(e=I(e)),e};Ke=(e,s)=>{var o;if(!(null===(o=ne[0])||void 0===o?void 0:o.isFrozen())||e.type===_.FullSnapshot||e.type===_.IncrementalSnapshot&&e.data.source===z.Mutation||ne.forEach(e=>e.unfreeze()),x)null==t||t(K(e),s);else if(F){const t={type:"rrweb",event:K(e),isCheckout:s};window.parent.postMessage(t,"*")}if(e.type===_.FullSnapshot)U=e,W=0;else if(e.type===_.IncrementalSnapshot){if(e.data.source===z.Mutation&&e.data.isAttachIframe)return;W++;const t=r&&W>=r,s=n&&e.timestamp-U.timestamp>n;(t||s)&&_e(!0)}};const Y=e=>{Ke(Ve({type:_.IncrementalSnapshot,data:Object.assign({source:z.Mutation},e)}))},J=e=>Ke(Ve({type:_.IncrementalSnapshot,data:Object.assign({source:z.Scroll},e)})),Q=e=>Ke(Ve({type:_.IncrementalSnapshot,data:Object.assign({source:z.CanvasMutation},e)})),P=new Ge({mutationCb:Y,adoptedStyleSheetCb:e=>Ke(Ve({type:_.IncrementalSnapshot,data:Object.assign({source:z.AdoptedStyleSheet},e)}))}),H=new ye({mirror:Je,mutationCb:Y,stylesheetManager:P,recordCrossOriginIframes:b,wrappedEmit:Ke});for(const e of M||[])e.getMirror&&e.getMirror({nodeMirror:Je,crossOriginIframeMirror:H.crossOriginIframeMirror,crossOriginIframeStyleMirror:H.crossOriginIframeStyleMirror});ze=new Ze({recordCanvas:S,mutationCb:Q,win:window,blockClass:s,blockSelector:i,mirror:Je,sampling:C.canvas,dataURLOptions:y});const X=new ve({mutationCb:Y,scrollCb:J,bypassOptions:{blockClass:s,blockSelector:i,maskTextClass:c,maskTextSelector:l,inlineStylesheet:d,maskInputOptions:L,dataURLOptions:y,maskTextFn:m,maskInputFn:p,recordCanvas:S,inlineImages:w,sampling:C,slimDOMOptions:B,iframeManager:H,stylesheetManager:P,canvasManager:ze,keepIframeSrcFn:E},mirror:Je});_e=(e=!1)=>{var t,n,r,a,h,u;Ke(Ve({type:_.Meta,data:{href:window.location.href,width:D(),height:O()}}),e),P.reset(),ne.forEach(e=>e.lock());const g=function(e,t){var n=t||{},r=n.mirror,s=void 0===r?new o:r,i=n.blockClass,a=void 0===i?"rr-block":i,c=n.blockSelector,l=void 0===c?null:c,d=n.maskTextClass,h=void 0===d?"rr-mask":d,u=n.maskTextSelector,g=void 0===u?null:u,p=n.inlineStylesheet,m=void 0===p||p,f=n.inlineImages,I=void 0!==f&&f,C=n.recordCanvas,y=void 0!==C&&C,v=n.maskAllInputs,S=void 0!==v&&v,b=n.maskTextFn,A=n.maskInputFn,k=n.slimDOM,w=void 0!==k&&k,M=n.dataURLOptions,R=n.preserveWhiteSpace,E=n.onSerialize,N=n.onIframeLoad,x=n.iframeLoadTimeout,F=n.onStylesheetLoad,O=n.stylesheetLoadTimeout,D=n.keepIframeSrcFn;return T(e,{doc:e,mirror:s,blockClass:a,blockSelector:l,maskTextClass:h,maskTextSelector:g,skipChild:!1,inlineStylesheet:m,maskInputOptions:!0===S?{color:!0,date:!0,"datetime-local":!0,email:!0,month:!0,number:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0,textarea:!0,select:!0,password:!0}:!1===S?{password:!0}:S,maskTextFn:b,maskInputFn:A,slimDOMOptions:!0===w||"all"===w?{script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaDescKeywords:"all"===w,headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaAuthorship:!0,headMetaVerification:!0}:!1===w?{}:w,dataURLOptions:M,inlineImages:I,recordCanvas:y,preserveWhiteSpace:R,onSerialize:E,onIframeLoad:N,iframeLoadTimeout:x,onStylesheetLoad:F,stylesheetLoadTimeout:O,keepIframeSrcFn:void 0===D?function(){return!1}:D,newlyAddedElement:!1})}(document,{mirror:Je,blockClass:s,blockSelector:i,maskTextClass:c,maskTextSelector:l,inlineStylesheet:d,maskAllInputs:L,maskTextFn:m,slimDOM:B,dataURLOptions:y,recordCanvas:S,inlineImages:w,onSerialize:e=>{Z(e,Je)&&H.addIframe(e),G(e,Je)&&P.trackLinkElement(e),V(e)&&X.addShadowRoot(e.shadowRoot,document)},onIframeLoad:(e,t)=>{H.attachIframe(e,t),X.observeAttachShadow(e)},onStylesheetLoad:(e,t)=>{P.attachLinkElement(e,t)},keepIframeSrcFn:E});g&&(Ke(Ve({type:_.FullSnapshot,data:{node:g,initialOffset:{left:void 0!==window.pageXOffset?window.pageXOffset:(null===document||void 0===document?void 0:document.documentElement.scrollLeft)||(null===(n=null===(t=null===document||void 0===document?void 0:document.body)||void 0===t?void 0:t.parentElement)||void 0===n?void 0:n.scrollLeft)||(null===(r=null===document||void 0===document?void 0:document.body)||void 0===r?void 0:r.scrollLeft)||0,top:void 0!==window.pageYOffset?window.pageYOffset:(null===document||void 0===document?void 0:document.documentElement.scrollTop)||(null===(h=null===(a=null===document||void 0===document?void 0:document.body)||void 0===a?void 0:a.parentElement)||void 0===h?void 0:h.scrollTop)||(null===(u=null===document||void 0===document?void 0:document.body)||void 0===u?void 0:u.scrollTop)||0}}})),ne.forEach(e=>e.unlock()),document.adoptedStyleSheets&&document.adoptedStyleSheets.length>0&&P.adoptStyleSheets(document.adoptedStyleSheets,Je.getId(document)))};try{const e=[];e.push(R("DOMContentLoaded",()=>{Ke(Ve({type:_.DomContentLoaded,data:{}}))}));const t=e=>{var t;return Ie({mutationCb:Y,mousemoveCb:(e,t)=>Ke(Ve({type:_.IncrementalSnapshot,data:{source:t,positions:e}})),mouseInteractionCb:e=>Ke(Ve({type:_.IncrementalSnapshot,data:Object.assign({source:z.MouseInteraction},e)})),scrollCb:J,viewportResizeCb:e=>Ke(Ve({type:_.IncrementalSnapshot,data:Object.assign({source:z.ViewportResize},e)})),inputCb:e=>Ke(Ve({type:_.IncrementalSnapshot,data:Object.assign({source:z.Input},e)})),mediaInteractionCb:e=>Ke(Ve({type:_.IncrementalSnapshot,data:Object.assign({source:z.MediaInteraction},e)})),styleSheetRuleCb:e=>Ke(Ve({type:_.IncrementalSnapshot,data:Object.assign({source:z.StyleSheetRule},e)})),styleDeclarationCb:e=>Ke(Ve({type:_.IncrementalSnapshot,data:Object.assign({source:z.StyleDeclaration},e)})),canvasMutationCb:Q,fontCb:e=>Ke(Ve({type:_.IncrementalSnapshot,data:Object.assign({source:z.Font},e)})),selectionCb:e=>{Ke(Ve({type:_.IncrementalSnapshot,data:Object.assign({source:z.Selection},e)}))},blockClass:s,ignoreClass:a,maskTextClass:c,maskTextSelector:l,maskInputOptions:L,inlineStylesheet:d,sampling:C,recordCanvas:S,inlineImages:w,userTriggeredOnInput:A,collectFonts:k,doc:e,maskInputFn:p,maskTextFn:m,keepIframeSrcFn:E,blockSelector:i,slimDOMOptions:B,dataURLOptions:y,mirror:Je,iframeManager:H,stylesheetManager:P,shadowDomManager:X,canvasManager:ze,ignoreCSSAttributes:N,plugins:(null===(t=null==M?void 0:M.filter(e=>e.observer))||void 0===t?void 0:t.map(e=>({observer:e.observer,options:e.options,callback:t=>Ke(Ve({type:_.Plugin,data:{plugin:e.name,payload:t}}))})))||[]},f)};H.addLoadListener(n=>{e.push(t(n.contentDocument))});const n=()=>{_e(),e.push(t(document)),Ye=!0};return"interactive"===document.readyState||"complete"===document.readyState?n():e.push(R("load",()=>{Ke(Ve({type:_.Load,data:{}})),n()},window)),()=>{e.forEach(e=>e()),Ye=!1}}catch(e){}}Qe.addCustomEvent=(e,t)=>{if(!Ye)throw new Error("please add custom event after start recording");Ke(Ve({type:_.Custom,data:{tag:e,payload:t}}))},Qe.freezePage=()=>{ne.forEach(e=>e.freeze())},Qe.takeFullSnapshot=e=>{if(!Ye)throw new Error("please take full snapshot after start recording");_e(e)},Qe.mirror=Je;var Pe=Uint8Array,He=Uint16Array,Xe=Uint32Array,je=new Pe([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),qe=new Pe([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),$e=new Pe([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),et=function(e,t){for(var n=new He(31),r=0;r<31;++r)n[r]=t+=1<<e[r-1];var s=new Xe(n[30]);for(r=1;r<30;++r)for(var o=n[r];o<n[r+1];++o)s[o]=o-n[r]<<5|r;return[n,s]},tt=et(je,2),nt=tt[0],rt=tt[1];nt[28]=258,rt[258]=28;for(var st=et(qe,0)[1],ot=new He(32768),it=0;it<32768;++it){var at=(43690&it)>>>1|(21845&it)<<1;at=(61680&(at=(52428&at)>>>2|(13107&at)<<2))>>>4|(3855&at)<<4,ot[it]=((65280&at)>>>8|(255&at)<<8)>>>1}var ct=function(e,t,n){for(var r=e.length,s=0,o=new He(t);s<r;++s)++o[e[s]-1];var i,a=new He(t);for(s=0;s<t;++s)a[s]=a[s-1]+o[s-1]<<1;if(n){i=new He(1<<t);var c=15-t;for(s=0;s<r;++s)if(e[s])for(var l=s<<4|e[s],d=t-e[s],h=a[e[s]-1]++<<d,u=h|(1<<d)-1;h<=u;++h)i[ot[h]>>>c]=l}else for(i=new He(r),s=0;s<r;++s)i[s]=ot[a[e[s]-1]++]>>>15-e[s];return i},lt=new Pe(288);for(it=0;it<144;++it)lt[it]=8;for(it=144;it<256;++it)lt[it]=9;for(it=256;it<280;++it)lt[it]=7;for(it=280;it<288;++it)lt[it]=8;var dt=new Pe(32);for(it=0;it<32;++it)dt[it]=5;var ht=ct(lt,9,0),ut=ct(dt,5,0),gt=function(e){return(e/8|0)+(7&e&&1)},pt=function(e,t,n){(null==n||n>e.length)&&(n=e.length);var r=new(e instanceof He?He:e instanceof Xe?Xe:Pe)(n-t);return r.set(e.subarray(t,n)),r},mt=function(e,t,n){n<<=7&t;var r=t/8|0;e[r]|=n,e[r+1]|=n>>>8},ft=function(e,t,n){n<<=7&t;var r=t/8|0;e[r]|=n,e[r+1]|=n>>>8,e[r+2]|=n>>>16},It=function(e,t){for(var n=[],r=0;r<e.length;++r)e[r]&&n.push({s:r,f:e[r]});var s=n.length,o=n.slice();if(!s)return[new Pe(0),0];if(1==s){var i=new Pe(n[0].s+1);return i[n[0].s]=1,[i,1]}n.sort(function(e,t){return e.f-t.f}),n.push({s:-1,f:25001});var a=n[0],c=n[1],l=0,d=1,h=2;for(n[0]={s:-1,f:a.f+c.f,l:a,r:c};d!=s-1;)a=n[n[l].f<n[h].f?l++:h++],c=n[l!=d&&n[l].f<n[h].f?l++:h++],n[d++]={s:-1,f:a.f+c.f,l:a,r:c};var u=o[0].s;for(r=1;r<s;++r)o[r].s>u&&(u=o[r].s);var g=new He(u+1),p=Ct(n[d-1],g,0);if(p>t){r=0;var m=0,f=p-t,I=1<<f;for(o.sort(function(e,t){return g[t.s]-g[e.s]||e.f-t.f});r<s;++r){var C=o[r].s;if(!(g[C]>t))break;m+=I-(1<<p-g[C]),g[C]=t}for(m>>>=f;m>0;){var y=o[r].s;g[y]<t?m-=1<<t-g[y]++-1:++r}for(;r>=0&&m;--r){var v=o[r].s;g[v]==t&&(--g[v],++m)}p=t}return[new Pe(g),p]},Ct=function(e,t,n){return-1==e.s?Math.max(Ct(e.l,t,n+1),Ct(e.r,t,n+1)):t[e.s]=n},yt=function(e){for(var t=e.length;t&&!e[--t];);for(var n=new He(++t),r=0,s=e[0],o=1,i=function(e){n[r++]=e},a=1;a<=t;++a)if(e[a]==s&&a!=t)++o;else{if(!s&&o>2){for(;o>138;o-=138)i(32754);o>2&&(i(o>10?o-11<<5|28690:o-3<<5|12305),o=0)}else if(o>3){for(i(s),--o;o>6;o-=6)i(8304);o>2&&(i(o-3<<5|8208),o=0)}for(;o--;)i(s);o=1,s=e[a]}return[n.subarray(0,r),t]},vt=function(e,t){for(var n=0,r=0;r<t.length;++r)n+=e[r]*t[r];return n},St=function(e,t,n){var r=n.length,s=gt(t+2);e[s]=255&r,e[s+1]=r>>>8,e[s+2]=255^e[s],e[s+3]=255^e[s+1];for(var o=0;o<r;++o)e[s+o+4]=n[o];return 8*(s+4+r)},bt=function(e,t,n,r,s,o,i,a,c,l,d){mt(t,d++,n),++s[256];for(var h=It(s,15),u=h[0],g=h[1],p=It(o,15),m=p[0],f=p[1],I=yt(u),C=I[0],y=I[1],v=yt(m),S=v[0],b=v[1],A=new He(19),k=0;k<C.length;++k)A[31&C[k]]++;for(k=0;k<S.length;++k)A[31&S[k]]++;for(var w=It(A,7),M=w[0],T=w[1],R=19;R>4&&!M[$e[R-1]];--R);var E,N,x,F,O=l+5<<3,D=vt(s,lt)+vt(o,dt)+i,L=vt(s,u)+vt(o,m)+i+14+3*R+vt(A,M)+(2*A[16]+3*A[17]+7*A[18]);if(O<=D&&O<=L)return St(t,d,e.subarray(c,c+l));if(mt(t,d,1+(L<D)),d+=2,L<D){E=ct(u,g,0),N=u,x=ct(m,f,0),F=m;var B=ct(M,T,0);mt(t,d,y-257),mt(t,d+5,b-1),mt(t,d+10,R-4),d+=14;for(k=0;k<R;++k)mt(t,d+3*k,M[$e[k]]);d+=3*R;for(var U=[C,S],W=0;W<2;++W){var Z=U[W];for(k=0;k<Z.length;++k){var G=31&Z[k];mt(t,d,B[G]),d+=M[G],G>15&&(mt(t,d,Z[k]>>>5&127),d+=Z[k]>>>12)}}}else E=ht,N=lt,x=ut,F=dt;for(k=0;k<a;++k)if(r[k]>255){G=r[k]>>>18&31;ft(t,d,E[G+257]),d+=N[G+257],G>7&&(mt(t,d,r[k]>>>23&31),d+=je[G]);var V=31&r[k];ft(t,d,x[V]),d+=F[V],V>3&&(ft(t,d,r[k]>>>5&8191),d+=qe[V])}else ft(t,d,E[r[k]]),d+=N[r[k]];return ft(t,d,E[256]),d+N[256]},At=new Xe([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),kt=function(e,t,n,r,s){return function(e,t,n,r,s,o){var i=e.length,a=new Pe(r+i+5*(1+Math.floor(i/7e3))+s),c=a.subarray(r,a.length-s),l=0;if(!t||i<8)for(var d=0;d<=i;d+=65535){var h=d+65535;h<i?l=St(c,l,e.subarray(d,h)):(c[d]=o,l=St(c,l,e.subarray(d,i)))}else{for(var u=At[t-1],g=u>>>13,p=8191&u,m=(1<<n)-1,f=new He(32768),I=new He(m+1),C=Math.ceil(n/3),y=2*C,v=function(t){return(e[t]^e[t+1]<<C^e[t+2]<<y)&m},S=new Xe(25e3),b=new He(288),A=new He(32),k=0,w=0,M=(d=0,0),T=0,R=0;d<i;++d){var E=v(d),N=32767&d,x=I[E];if(f[N]=x,I[E]=N,T<=d){var F=i-d;if((k>7e3||M>24576)&&F>423){l=bt(e,c,0,S,b,A,w,M,R,d-R,l),M=k=w=0,R=d;for(var O=0;O<286;++O)b[O]=0;for(O=0;O<30;++O)A[O]=0}var D=2,L=0,B=p,U=N-x&32767;if(F>2&&E==v(d-U))for(var W=Math.min(g,F)-1,Z=Math.min(32767,d),G=Math.min(258,F);U<=Z&&--B&&N!=x;){if(e[d+D]==e[d+D-U]){for(var V=0;V<G&&e[d+V]==e[d+V-U];++V);if(V>D){if(D=V,L=U,V>W)break;var K=Math.min(U,V-2),_=0;for(O=0;O<K;++O){var z=d-U+O+32768&32767,Y=z-f[z]+32768&32767;Y>_&&(_=Y,x=z)}}}U+=(N=x)-(x=f[N])+32768&32767}if(L){S[M++]=268435456|rt[D]<<18|st[L];var J=31&rt[D],Q=31&st[L];w+=je[J]+qe[Q],++b[257+J],++A[Q],T=d+D,++k}else S[M++]=e[d],++b[e[d]]}}l=bt(e,c,o,S,b,A,w,M,R,d-R,l)}return pt(a,0,r+gt(l)+s)}(e,null==t.level?6:t.level,null==t.mem?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(e.length)))):12+t.mem,n,r,!0)};function wt(e,t){void 0===t&&(t={});var n=function(){var e=1,t=0;return{p:function(n){for(var r=e,s=t,o=n.length,i=0;i!=o;){for(var a=Math.min(i+5552,o);i<a;++i)s+=r+=n[i];r%=65521,s%=65521}e=r,t=s},d:function(){return(e>>>8<<16|(255&t)<<8|t>>>8)+2*((255&e)<<23)}}}();n.p(e);var r,s,o,i=kt(e,t,2,4);return r=i,s=t.level,o=0==s?0:s<6?1:9==s?3:2,r[0]=120,r[1]=o<<6|(o?32-2*o:1),function(e,t,n){for(;n;++t)e[t]=n,n>>>=8}(i,i.length-4,n.d()),i}const Mt=e=>{const t={...e,v:"v1"};return function(e){for(var t="",n=0;n<e.length;){var r=e[n++];t+=String.fromCharCode(r)}return t}(wt(function(e,t){var n=e.length;if("undefined"!=typeof TextEncoder)return(new TextEncoder).encode(e);for(var r=new Pe(e.length+(e.length>>>1)),s=0,o=function(e){r[s++]=e},i=0;i<n;++i){if(s+5>r.length){var a=new Pe(s+8+(n-i<<1));a.set(r),r=a}var c=e.charCodeAt(i);c<128||t?o(c):c<2048?(o(192|c>>>6),o(128|63&c)):c>55295&&c<57344?(o(240|(c=65536+(1047552&c)|1023&e.charCodeAt(++i))>>>18),o(128|c>>>12&63),o(128|c>>>6&63),o(128|63&c)):(o(224|c>>>12),o(128|c>>>6&63),o(128|63&c))}return pt(r,0,s)}(JSON.stringify(t))))};class Tt{constructor(e){this.name="session-tracker",this.version='"0.9.4"',this.context=null,this.config={},this.userConfig=null,this.sessionStartTime=0,this.isActive=!1,this.stopRecordingFn=null,this.sessionEvents=[],this.sessionId="",this.currentSessionSize=0,this.lastBatchTime=0,this.activeBatchCount=0,this.userId="",this.appId="",this.pendingEvents=[],this.eventsInFlight=[],this.sentEventCount=0,this.isSendingBatch=!1,this.delayedS3Url=null,this.delayedUrlExpiry=0,this.delayedUrlRefreshTimer=null,this.userConfig=e||{}}init(e,t){this.context=e;const n="object"==typeof t?.webSessions?t?.webSessions:null,r={enableSessionRecording:!1!==t?.webSessions&&(!0===t?.webSessions||!1!==n?.enabled),maxBatchSize:1048576,maxSessionDuration:null,batchSize:150,batchInterval:3e4,minimumSessionDuration:5e3,compressionEnabled:!1,recordingOptions:{recordCanvas:!0,recordCrossOriginIframes:!1,recordAfter:"DOMContentLoaded",maskAllInputs:!1,maskInputOptions:{password:!0,email:!0,text:!1},blockClass:"sensitive-field",slimDOMOptions:{script:!1,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaDescKeywords:!0,headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaAuthorship:!0,headMetaVerification:!0},sampling:{scroll:150,mouseInteraction:!0,input:"last",mutation:!0},...this.userConfig?this.userConfig:{},...this.config.recordingOptions?this.config.recordingOptions:{}}};this.config={...r}}start(){if(!this.context)return;if(this.isActive)return;this.delayedUrlRefreshTimer&&(clearTimeout(this.delayedUrlRefreshTimer),this.delayedUrlRefreshTimer=null),this.isActive=!0,this.userId=this.context.userManager.getUserId(),this.appId=this.context.appManager.getAppId();const e=String(this.context.userManager.getSessionId());(!this.sessionId||this.sessionId!==e)&&(this.sessionEvents=[],this.pendingEvents=[],this.eventsInFlight=[],this.currentSessionSize=0,this.sentEventCount=0,this.sessionStartTime=Date.now(),this.delayedS3Url=null,this.delayedUrlExpiry=0),this.sessionId=e,this.config.enableSessionRecording&&this.startRecording()}stop(){this.isActive&&this.stopRecording()}destroy(){this.stopRecording(),this.pendingEvents=[],this.eventsInFlight=[],this.sessionEvents=[],this.currentSessionSize=0,this.sentEventCount=0,this.delayedS3Url=null,this.delayedUrlExpiry=0,this.context?.removePluginField("recordingSessionId"),this.context?.setPluginField("isRecordingActive",!1),this.context=null}onEvent(e,t){this.isActive&&"session_start"===e&&(this.sessionStartTime=Date.now())}async onUserChange(e){this.isActive&&(await this.sendBatchToBackend(),this.stopRecording(),this.isActive=!1,this.start())}async onFocus(){this.pendingEvents.length>0&&await this.sendBatchToBackend(),this.isActive||this.start()}onBlur(){this.isActive&&(this.sendFinalBatch().catch(e=>{this.context?.logger.error(e)}),this.stopRecording(!0))}async onBeforeUnload(){const e=this.pendingEvents.length>0||this.eventsInFlight.length>0;(this.isActive||e)&&this.sendFinalBatch().catch(e=>{this.context?.logger.error(e)})}async onTrackingChange(e){e?this.isActive||this.start():this.isActive&&(await this.sendBatchToBackend(),this.stopRecording())}async onSessionStart(){await this.sendBatchToBackend(),this.isActive||this.start()}stopRecording(e=!1){e||this.context?.setPluginField("isRecordingActive",!1),this.isActive=!1,this.delayedUrlRefreshTimer&&(clearTimeout(this.delayedUrlRefreshTimer),this.delayedUrlRefreshTimer=null),this.stopRecordingFn&&(this.stopRecordingFn(),this.stopRecordingFn=null)}async startRecording(){if(!this.context)return;this.lastBatchTime=Date.now(),this.isSendingBatch=!1;const e=Date.now();if(!this.delayedS3Url||this.delayedUrlExpiry>0&&e>this.delayedUrlExpiry)this.fetchDelayedUrl();else if(this.delayedS3Url){const t=Math.max(0,this.delayedUrlExpiry-e);this.scheduleDelayedUrlRefresh(t+1e4)}const t=this.context.getPluginField("recordingSessionId"),n=!!t&&t===this.context.userManager.getSessionId(),r=this.context.getPluginField("isRecordingActive");if(n&&r)this.startSessionRecording();else try{const e=this.context.api.buildUrl(["sessions","configurations","get"],{appId:this.appId}),t=await this.sendRequest(e,null,"GET");if(t&&t.data){const e=t.data;if(e.blocked||!e.active)return this.context.logger.debug("Session configuration is "+(e.blocked?"blocked":"inactive")),void this.context.setPluginField("isRecordingActive",!1);100*Math.random()<e.record_chance_percent?(this.context.setPluginField("isRecordingActive",!0),this.startSessionRecording()):this.context.setPluginField("isRecordingActive",!1)}}catch(e){this.context.logger.error("Failed to fetch session configuration",{error:e}),this.context.setPluginField("isRecordingActive",!1)}}startSessionRecording(){if(!this.config.enableSessionRecording)return;this.context?.setPluginField("recordingSessionId",this.context?.userManager.getSessionId()),this.lastBatchTime=Date.now();const e={emit:e=>{this.addEventToSession(e),this.pendingEvents.push(e),this.currentSessionSize+=JSON.stringify(e).length,e.type,this.checkBatchLimits()},...this.config.recordingOptions};this.config.compressionEnabled&&(e.packFn=Mt);const t=Qe(e);this.stopRecordingFn=t||null}addEventToSession(e){this.sessionEvents.push(e);this.sessionEvents.length>1e4&&(this.sessionEvents=this.sessionEvents.slice(-Math.floor(5e3)))}hasMinimumSessionDuration(){return Date.now()-this.sessionStartTime>=this.config.minimumSessionDuration}checkBatchLimits(){if(this.isSendingBatch)return;const e=Date.now()-this.sessionStartTime,t=this.pendingEvents.length>=this.config.batchSize,n=this.currentSessionSize>=this.config.maxBatchSize,r=this.config.maxSessionDuration&&e>=this.config.maxSessionDuration,s=Date.now()-this.lastBatchTime>=this.config.batchInterval;(t||n||r||s)&&this.sendBatchToBackend().catch(e=>{this.context?.logger.error("Error in checkBatchLimits sendBatchToBackend",{error:e instanceof Error?e.message:e,pendingEventsCount:this.pendingEvents.length})})}async sendBatchToBackend(){if(!this.pendingEvents.length||!this.context||this.isSendingBatch)return;if(!this.hasMinimumSessionDuration())return;this.isSendingBatch=!0,this.eventsInFlight=[...this.pendingEvents],this.pendingEvents=[];const e=this.eventsInFlight.reduce((e,t)=>e+JSON.stringify(t).length,0);this.currentSessionSize-=e,this.currentSessionSize=Math.max(0,this.currentSessionSize),this.activeBatchCount++;try{const e=this.eventsInFlight[0]?.timestamp||Date.now(),t=this.eventsInFlight[this.eventsInFlight.length-1]?.timestamp||Date.now(),n={appId:this.appId,session_id:this.sessionId,user_id:this.userId,start_time:e,end_time:t},r=this.context.api.buildUrl(["sessions","add"],n),s=await this.sendRequest(r,null,"GET",{},!0);if(204===s.status)return this.context.logger.warning("Session storage exceeded"),this.eventsInFlight=[],void this.stop();const o=s.data,i="string"==typeof o?o:o?.url;if(!i)throw new Error("No S3 URL returned");await this.uploadToS3(i,this.eventsInFlight),this.sentEventCount+=this.eventsInFlight.length,this.lastBatchTime=Date.now(),this.eventsInFlight=[]}catch(t){throw this.context?.logger.error("Error sending session batch to backend",{error:t instanceof Error?t.message:t,eventsCount:this.eventsInFlight.length}),this.pendingEvents.unshift(...this.eventsInFlight),this.eventsInFlight=[],this.currentSessionSize+=e,t}finally{this.activeBatchCount--,this.isSendingBatch=!1,this.pendingEvents.length>0&&this.checkBatchLimits()}}async fetchDelayedUrl(){if(this.context)try{const e=this.context.api.buildUrl(["sessions","addDelayed"],{session_id:this.sessionId,appId:this.appId,user_id:this.userId}),t=await this.sendRequest(e,null,"GET");if(t&&t.data){const e=t.data;this.delayedS3Url=e.url,this.delayedUrlExpiry=Date.now()+e.ttl,this.scheduleDelayedUrlRefresh(e.ttl)}}catch(e){this.context.logger.error("Failed to fetch delayed URL",{error:e})}}scheduleDelayedUrlRefresh(e){this.delayedUrlRefreshTimer&&clearTimeout(this.delayedUrlRefreshTimer);const t=Math.max(0,e-1e4);this.delayedUrlRefreshTimer=setTimeout(()=>{this.fetchDelayedUrl()},t)}async sendFinalBatch(){if(!this.context)return;if(!this.hasMinimumSessionDuration())return;const e=[...this.eventsInFlight,...this.pendingEvents];if(!e.length)return;if(!this.delayedS3Url)return void this.context.logger.error("No delayed URL available for final batch - cannot send.");const t=[...this.pendingEvents],n=[...this.eventsInFlight];this.pendingEvents=[],this.eventsInFlight=[],this.currentSessionSize=0;const r=JSON.stringify(e),s=new Blob([r],{type:"application/json"});try{const e=await fetch(this.delayedS3Url,{method:"PUT",body:s,keepalive:!0,credentials:"omit"});if(!e.ok)throw new Error(`S3 upload failed: ${e.statusText}`);this.lastBatchTime=Date.now()}catch(e){this.pendingEvents=t,this.eventsInFlight=n,this.context?.logger.error(`Failed to send final batch: ${e}`)}}async uploadToS3(e,t){const n=JSON.stringify(t),r=await fetch(e,{method:"PUT",body:n});if(!r.ok)throw new Error(`S3 upload failed: ${r.statusText}`)}sendRequest(e,t,n="POST",r={},s=!1){return new Promise((o,i)=>{if(!this.context)return i(new Error("No context"));const a=this.context.api.createRequestStructure(e,t,r,n);this.context.api.sendRequest(`req-${Date.now()}-${Math.random()}`,a,(e,t,n)=>{e>=200&&e<300?o({status:e,data:t}):i({status:e,data:t,error:n})},{gzip:!1,method:n,noContentType:s})})}}export{Tt as default};
|
|
15
|
+
***************************************************************************** */function Se(e,t,n,r){return new(n||(n=Promise))(function(t,s){function o(e){try{a(r.next(e))}catch(e){s(e)}}function i(e){try{a(r.throw(e))}catch(e){s(e)}}function a(e){var r;e.done?t(e.value):(r=e.value,r instanceof n?r:new n(function(e){e(r)})).then(o,i)}a((r=r.apply(e,[])).next())})}for(var be="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Ae="undefined"==typeof Uint8Array?[]:new Uint8Array(256),ke=0;ke<64;ke++)Ae[be.charCodeAt(ke)]=ke;const we=new Map;const Me=(e,t,n)=>{if(!e||!Ee(e,t)&&"object"!=typeof e)return;const r=function(e,t){let n=we.get(e);return n||(n=new Map,we.set(e,n)),n.has(t)||n.set(t,[]),n.get(t)}(n,e.constructor.name);let s=r.indexOf(e);return-1===s&&(s=r.length,r.push(e)),s};function Te(e,t,n){if(e instanceof Array)return e.map(e=>Te(e,t,n));if(null===e)return e;if(e instanceof Float32Array||e instanceof Float64Array||e instanceof Int32Array||e instanceof Uint32Array||e instanceof Uint8Array||e instanceof Uint16Array||e instanceof Int16Array||e instanceof Int8Array||e instanceof Uint8ClampedArray){return{rr_type:e.constructor.name,args:[Object.values(e)]}}if(e instanceof ArrayBuffer){const t=e.constructor.name,n=function(e){var t,n=new Uint8Array(e),r=n.length,s="";for(t=0;t<r;t+=3)s+=be[n[t]>>2],s+=be[(3&n[t])<<4|n[t+1]>>4],s+=be[(15&n[t+1])<<2|n[t+2]>>6],s+=be[63&n[t+2]];return r%3==2?s=s.substring(0,s.length-1)+"=":r%3==1&&(s=s.substring(0,s.length-2)+"=="),s}(e);return{rr_type:t,base64:n}}if(e instanceof DataView){return{rr_type:e.constructor.name,args:[Te(e.buffer,t,n),e.byteOffset,e.byteLength]}}if(e instanceof HTMLImageElement){const t=e.constructor.name,{src:n}=e;return{rr_type:t,src:n}}if(e instanceof HTMLCanvasElement){return{rr_type:"HTMLImageElement",src:e.toDataURL()}}if(e instanceof ImageData){return{rr_type:e.constructor.name,args:[Te(e.data,t,n),e.width,e.height]}}if(Ee(e,t)||"object"==typeof e){return{rr_type:e.constructor.name,index:Me(e,t,n)}}return e}const Re=(e,t,n)=>[...e].map(e=>Te(e,t,n)),Ee=(e,t)=>{const n=["WebGLActiveInfo","WebGLBuffer","WebGLFramebuffer","WebGLProgram","WebGLRenderbuffer","WebGLShader","WebGLShaderPrecisionFormat","WebGLTexture","WebGLUniformLocation","WebGLVertexArrayObject","WebGLVertexArrayObjectOES"].filter(e=>"function"==typeof t[e]);return Boolean(n.find(n=>e instanceof t[n]))};function Ne(e,t,n){const r=[];try{const s=F(e.HTMLCanvasElement.prototype,"getContext",function(e){return function(r,...s){return L(this,t,n,!0)||"__context"in this||(this.__context=r),e.apply(this,[r,...s])}});r.push(s)}catch(e){}return()=>{r.forEach(e=>e())}}function xe(e,t,n,r,s,o,i){const a=[],c=Object.getOwnPropertyNames(e);for(const o of c)if(!["isContextLost","canvas","drawingBufferWidth","drawingBufferHeight"].includes(o))try{if("function"!=typeof e[o])continue;const c=F(e,o,function(e){return function(...a){const c=e.apply(this,a);if(Me(c,i,this),!L(this.canvas,r,s,!0)){const e=Re([...a],i,this),r={type:t,property:o,args:e};n(this.canvas,r)}return c}});a.push(c)}catch(r){const s=x(e,o,{set(e){n(this.canvas,{type:t,property:o,args:[e],setter:!0})}});a.push(s)}return a}var Fe=null;try{var Oe="undefined"!=typeof module&&"function"==typeof module.require&&module.require("worker_threads")||"function"==typeof __non_webpack_require__&&__non_webpack_require__("worker_threads")||"function"==typeof require&&require("worker_threads");Fe=Oe.Worker}catch(e){}function De(e,t,n){var r=function(e){return Buffer.from(e,"base64").toString("utf8")}(e),s=r.indexOf("\n",10)+1,o=r.substring(s)+"";return function(e){return new Fe(o,Object.assign({},e,{eval:!0}))}}function Le(e,t,n){var r=function(e){return atob(e)}(e),s=r.indexOf("\n",10)+1,o=r.substring(s)+"",i=new Blob([o],{type:"application/javascript"});return URL.createObjectURL(i)}var Be="[object process]"===Object.prototype.toString.call("undefined"!=typeof process?process:0);var Ue,We=(Ue="Ly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A9IG9mZnNjcmVlbi5nZXRDb250ZXh0KCcyZCcpOw0KICAgICAgICAgICAgICAgIGN0eC5kcmF3SW1hZ2UoYml0bWFwLCAwLCAwKTsNCiAgICAgICAgICAgICAgICBiaXRtYXAuY2xvc2UoKTsNCiAgICAgICAgICAgICAgICBjb25zdCBibG9iID0geWllbGQgb2Zmc2NyZWVuLmNvbnZlcnRUb0Jsb2IoZGF0YVVSTE9wdGlvbnMpOw0KICAgICAgICAgICAgICAgIGNvbnN0IHR5cGUgPSBibG9iLnR5cGU7DQogICAgICAgICAgICAgICAgY29uc3QgYXJyYXlCdWZmZXIgPSB5aWVsZCBibG9iLmFycmF5QnVmZmVyKCk7DQogICAgICAgICAgICAgICAgY29uc3QgYmFzZTY0ID0gZW5jb2RlKGFycmF5QnVmZmVyKTsNCiAgICAgICAgICAgICAgICBpZiAoIWxhc3RCbG9iTWFwLmhhcyhpZCkgJiYgKHlpZWxkIHRyYW5zcGFyZW50QmFzZTY0KSA9PT0gYmFzZTY0KSB7DQogICAgICAgICAgICAgICAgICAgIGxhc3RCbG9iTWFwLnNldChpZCwgYmFzZTY0KTsNCiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHdvcmtlci5wb3N0TWVzc2FnZSh7IGlkIH0pOw0KICAgICAgICAgICAgICAgIH0NCiAgICAgICAgICAgICAgICBpZiAobGFzdEJsb2JNYXAuZ2V0KGlkKSA9PT0gYmFzZTY0KQ0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gd29ya2VyLnBvc3RNZXNzYWdlKHsgaWQgfSk7DQogICAgICAgICAgICAgICAgd29ya2VyLnBvc3RNZXNzYWdlKHsNCiAgICAgICAgICAgICAgICAgICAgaWQsDQogICAgICAgICAgICAgICAgICAgIHR5cGUsDQogICAgICAgICAgICAgICAgICAgIGJhc2U2NCwNCiAgICAgICAgICAgICAgICAgICAgd2lkdGgsDQogICAgICAgICAgICAgICAgICAgIGhlaWdodCwNCiAgICAgICAgICAgICAgICB9KTsNCiAgICAgICAgICAgICAgICBsYXN0QmxvYk1hcC5zZXQoaWQsIGJhc2U2NCk7DQogICAgICAgICAgICB9DQogICAgICAgICAgICBlbHNlIHsNCiAgICAgICAgICAgICAgICByZXR1cm4gd29ya2VyLnBvc3RNZXNzYWdlKHsgaWQ6IGUuZGF0YS5pZCB9KTsNCiAgICAgICAgICAgIH0NCiAgICAgICAgfSk7DQogICAgfTsKCn0pKCk7Cgo=",Be?De(Ue):function(e){var t;return function(n){return t=t||Le(e),new Worker(t,n)}}(Ue));class Ze{constructor(e){this.pendingCanvasMutations=new Map,this.rafStamps={latestId:0,invokeId:null},this.frozen=!1,this.locked=!1,this.processMutation=(e,t)=>{!(this.rafStamps.invokeId&&this.rafStamps.latestId!==this.rafStamps.invokeId)&&this.rafStamps.invokeId||(this.rafStamps.invokeId=this.rafStamps.latestId),this.pendingCanvasMutations.has(e)||this.pendingCanvasMutations.set(e,[]),this.pendingCanvasMutations.get(e).push(t)};const{sampling:t="all",win:n,blockClass:r,blockSelector:s,recordCanvas:o,dataURLOptions:i}=e;this.mutationCb=e.mutationCb,this.mirror=e.mirror,o&&"all"===t&&this.initCanvasMutationObserver(n,r,s),o&&"number"==typeof t&&this.initCanvasFPSObserver(t,n,r,s,{dataURLOptions:i})}reset(){this.pendingCanvasMutations.clear(),this.resetObservers&&this.resetObservers()}freeze(){this.frozen=!0}unfreeze(){this.frozen=!1}lock(){this.locked=!0}unlock(){this.locked=!1}initCanvasFPSObserver(e,t,n,r,s){const o=Ne(t,n,r),i=new Map,a=new We;a.onmessage=e=>{const{id:t}=e.data;if(i.set(t,!1),!("base64"in e.data))return;const{base64:n,type:r,width:s,height:o}=e.data;this.mutationCb({id:t,type:J["2D"],commands:[{property:"clearRect",args:[0,0,s,o]},{property:"drawImage",args:[{rr_type:"ImageBitmap",args:[{rr_type:"Blob",data:[{rr_type:"ArrayBuffer",base64:n}],type:r}]},0,0]}]})};const c=1e3/e;let l,d=0;const h=e=>{d&&e-d<c||(d=e,(()=>{const e=[];return t.document.querySelectorAll("canvas").forEach(t=>{L(t,n,r,!0)||e.push(t)}),e})().forEach(e=>Se(this,0,void 0,function*(){var t;const n=this.mirror.getId(e);if(i.get(n))return;if(i.set(n,!0),["webgl","webgl2"].includes(e.__context)){const n=e.getContext(e.__context);!1===(null===(t=null==n?void 0:n.getContextAttributes())||void 0===t?void 0:t.preserveDrawingBuffer)&&(null==n||n.clear(n.COLOR_BUFFER_BIT))}const r=yield createImageBitmap(e);a.postMessage({id:n,bitmap:r,width:e.width,height:e.height,dataURLOptions:s.dataURLOptions},[r])}))),l=requestAnimationFrame(h)};l=requestAnimationFrame(h),this.resetObservers=()=>{o(),cancelAnimationFrame(l)}}initCanvasMutationObserver(e,t,n){this.startRAFTimestamping(),this.startPendingCanvasMutationFlusher();const r=Ne(e,t,n),s=function(e,t,n,r){const s=[],o=Object.getOwnPropertyNames(t.CanvasRenderingContext2D.prototype);for(const i of o)try{if("function"!=typeof t.CanvasRenderingContext2D.prototype[i])continue;const o=F(t.CanvasRenderingContext2D.prototype,i,function(s){return function(...o){return L(this.canvas,n,r,!0)||setTimeout(()=>{const n=Re([...o],t,this);e(this.canvas,{type:J["2D"],property:i,args:n})},0),s.apply(this,o)}});s.push(o)}catch(n){const r=x(t.CanvasRenderingContext2D.prototype,i,{set(t){e(this.canvas,{type:J["2D"],property:i,args:[t],setter:!0})}});s.push(r)}return()=>{s.forEach(e=>e())}}(this.processMutation.bind(this),e,t,n),o=function(e,t,n,r){const s=[];return s.push(...xe(t.WebGLRenderingContext.prototype,J.WebGL,e,n,r,0,t)),void 0!==t.WebGL2RenderingContext&&s.push(...xe(t.WebGL2RenderingContext.prototype,J.WebGL2,e,n,r,0,t)),()=>{s.forEach(e=>e())}}(this.processMutation.bind(this),e,t,n,this.mirror);this.resetObservers=()=>{r(),s(),o()}}startPendingCanvasMutationFlusher(){requestAnimationFrame(()=>this.flushPendingCanvasMutations())}startRAFTimestamping(){const e=t=>{this.rafStamps.latestId=t,requestAnimationFrame(e)};requestAnimationFrame(e)}flushPendingCanvasMutations(){this.pendingCanvasMutations.forEach((e,t)=>{const n=this.mirror.getId(t);this.flushPendingCanvasMutationFor(t,n)}),requestAnimationFrame(()=>this.flushPendingCanvasMutations())}flushPendingCanvasMutationFor(e,t){if(this.frozen||this.locked)return;const n=this.pendingCanvasMutations.get(e);if(!n||-1===t)return;const r=n.map(e=>{const t=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var s=0;for(r=Object.getOwnPropertySymbols(e);s<r.length;s++)t.indexOf(r[s])<0&&Object.prototype.propertyIsEnumerable.call(e,r[s])&&(n[r[s]]=e[r[s]])}return n}(e,["type"]);return t}),{type:s}=n[0];this.mutationCb({id:t,type:s,commands:r}),this.pendingCanvasMutations.delete(e)}}class Ge{constructor(e){this.trackedLinkElements=new WeakSet,this.styleMirror=new K,this.mutationCb=e.mutationCb,this.adoptedStyleSheetCb=e.adoptedStyleSheetCb}attachLinkElement(e,t){"_cssText"in t.attributes&&this.mutationCb({adds:[],removes:[],texts:[],attributes:[{id:t.id,attributes:t.attributes}]}),this.trackLinkElement(e)}trackLinkElement(e){this.trackedLinkElements.has(e)||(this.trackedLinkElements.add(e),this.trackStylesheetInLinkElement(e))}adoptStyleSheets(e,t){if(0===e.length)return;const n={id:t,styleIds:[]},r=[];for(const t of e){let e;if(this.styleMirror.has(t))e=this.styleMirror.getId(t);else{e=this.styleMirror.add(t);const n=Array.from(t.rules||CSSRule);r.push({styleId:e,rules:n.map((e,t)=>({rule:s(e),index:t}))})}n.styleIds.push(e)}r.length>0&&(n.styles=r),this.adoptedStyleSheetCb(n)}reset(){this.styleMirror.reset(),this.trackedLinkElements=new WeakSet}trackStylesheetInLinkElement(e){}}function Ve(e){return Object.assign(Object.assign({},e),{timestamp:Date.now()})}let Ke,_e,ze,Ye=!1;const Je=new o;function Qe(e={}){const{emit:t,checkoutEveryNms:n,checkoutEveryNth:r,blockClass:s="rr-block",blockSelector:i=null,ignoreClass:a="rr-ignore",maskTextClass:c="rr-mask",maskTextSelector:l=null,inlineStylesheet:d=!0,maskAllInputs:h,maskInputOptions:u,slimDOMOptions:g,maskInputFn:p,maskTextFn:m,hooks:f,packFn:I,sampling:C={},dataURLOptions:y={},mousemoveWait:v,recordCanvas:S=!1,recordCrossOriginIframes:b=!1,userTriggeredOnInput:A=!1,collectFonts:k=!1,inlineImages:w=!1,plugins:M,keepIframeSrcFn:E=()=>!1,ignoreCSSAttributes:N=new Set([])}=e,x=!b||window.parent===window;let F=!1;if(!x)try{window.parent.document,F=!1}catch(e){F=!0}if(x&&!t)throw new Error("emit function is required");void 0!==v&&void 0===C.mousemove&&(C.mousemove=v),Je.reset();const L=!0===h?{color:!0,date:!0,"datetime-local":!0,email:!0,month:!0,number:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0,textarea:!0,select:!0,password:!0}:void 0!==u?u:{password:!0},B=!0===g||"all"===g?{script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaVerification:!0,headMetaAuthorship:"all"===g,headMetaDescKeywords:"all"===g}:g||{};let U;!function(e=window){"NodeList"in e&&!e.NodeList.prototype.forEach&&(e.NodeList.prototype.forEach=Array.prototype.forEach),"DOMTokenList"in e&&!e.DOMTokenList.prototype.forEach&&(e.DOMTokenList.prototype.forEach=Array.prototype.forEach),Node.prototype.contains||(Node.prototype.contains=(...e)=>{let t=e[0];if(!(0 in e))throw new TypeError("1 argument is required");do{if(this===t)return!0}while(t=t&&t.parentNode);return!1})}();let W=0;const K=e=>{for(const t of M||[])t.eventProcessor&&(e=t.eventProcessor(e));return I&&(e=I(e)),e};Ke=(e,s)=>{var o;if(!(null===(o=ne[0])||void 0===o?void 0:o.isFrozen())||e.type===_.FullSnapshot||e.type===_.IncrementalSnapshot&&e.data.source===z.Mutation||ne.forEach(e=>e.unfreeze()),x)null==t||t(K(e),s);else if(F){const t={type:"rrweb",event:K(e),isCheckout:s};window.parent.postMessage(t,"*")}if(e.type===_.FullSnapshot)U=e,W=0;else if(e.type===_.IncrementalSnapshot){if(e.data.source===z.Mutation&&e.data.isAttachIframe)return;W++;const t=r&&W>=r,s=n&&e.timestamp-U.timestamp>n;(t||s)&&_e(!0)}};const Y=e=>{Ke(Ve({type:_.IncrementalSnapshot,data:Object.assign({source:z.Mutation},e)}))},J=e=>Ke(Ve({type:_.IncrementalSnapshot,data:Object.assign({source:z.Scroll},e)})),Q=e=>Ke(Ve({type:_.IncrementalSnapshot,data:Object.assign({source:z.CanvasMutation},e)})),P=new Ge({mutationCb:Y,adoptedStyleSheetCb:e=>Ke(Ve({type:_.IncrementalSnapshot,data:Object.assign({source:z.AdoptedStyleSheet},e)}))}),H=new ye({mirror:Je,mutationCb:Y,stylesheetManager:P,recordCrossOriginIframes:b,wrappedEmit:Ke});for(const e of M||[])e.getMirror&&e.getMirror({nodeMirror:Je,crossOriginIframeMirror:H.crossOriginIframeMirror,crossOriginIframeStyleMirror:H.crossOriginIframeStyleMirror});ze=new Ze({recordCanvas:S,mutationCb:Q,win:window,blockClass:s,blockSelector:i,mirror:Je,sampling:C.canvas,dataURLOptions:y});const X=new ve({mutationCb:Y,scrollCb:J,bypassOptions:{blockClass:s,blockSelector:i,maskTextClass:c,maskTextSelector:l,inlineStylesheet:d,maskInputOptions:L,dataURLOptions:y,maskTextFn:m,maskInputFn:p,recordCanvas:S,inlineImages:w,sampling:C,slimDOMOptions:B,iframeManager:H,stylesheetManager:P,canvasManager:ze,keepIframeSrcFn:E},mirror:Je});_e=(e=!1)=>{var t,n,r,a,h,u;Ke(Ve({type:_.Meta,data:{href:window.location.href,width:D(),height:O()}}),e),P.reset(),ne.forEach(e=>e.lock());const g=function(e,t){var n=t||{},r=n.mirror,s=void 0===r?new o:r,i=n.blockClass,a=void 0===i?"rr-block":i,c=n.blockSelector,l=void 0===c?null:c,d=n.maskTextClass,h=void 0===d?"rr-mask":d,u=n.maskTextSelector,g=void 0===u?null:u,p=n.inlineStylesheet,m=void 0===p||p,f=n.inlineImages,I=void 0!==f&&f,C=n.recordCanvas,y=void 0!==C&&C,v=n.maskAllInputs,S=void 0!==v&&v,b=n.maskTextFn,A=n.maskInputFn,k=n.slimDOM,w=void 0!==k&&k,M=n.dataURLOptions,R=n.preserveWhiteSpace,E=n.onSerialize,N=n.onIframeLoad,x=n.iframeLoadTimeout,F=n.onStylesheetLoad,O=n.stylesheetLoadTimeout,D=n.keepIframeSrcFn;return T(e,{doc:e,mirror:s,blockClass:a,blockSelector:l,maskTextClass:h,maskTextSelector:g,skipChild:!1,inlineStylesheet:m,maskInputOptions:!0===S?{color:!0,date:!0,"datetime-local":!0,email:!0,month:!0,number:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0,textarea:!0,select:!0,password:!0}:!1===S?{password:!0}:S,maskTextFn:b,maskInputFn:A,slimDOMOptions:!0===w||"all"===w?{script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaDescKeywords:"all"===w,headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaAuthorship:!0,headMetaVerification:!0}:!1===w?{}:w,dataURLOptions:M,inlineImages:I,recordCanvas:y,preserveWhiteSpace:R,onSerialize:E,onIframeLoad:N,iframeLoadTimeout:x,onStylesheetLoad:F,stylesheetLoadTimeout:O,keepIframeSrcFn:void 0===D?function(){return!1}:D,newlyAddedElement:!1})}(document,{mirror:Je,blockClass:s,blockSelector:i,maskTextClass:c,maskTextSelector:l,inlineStylesheet:d,maskAllInputs:L,maskTextFn:m,slimDOM:B,dataURLOptions:y,recordCanvas:S,inlineImages:w,onSerialize:e=>{Z(e,Je)&&H.addIframe(e),G(e,Je)&&P.trackLinkElement(e),V(e)&&X.addShadowRoot(e.shadowRoot,document)},onIframeLoad:(e,t)=>{H.attachIframe(e,t),X.observeAttachShadow(e)},onStylesheetLoad:(e,t)=>{P.attachLinkElement(e,t)},keepIframeSrcFn:E});g&&(Ke(Ve({type:_.FullSnapshot,data:{node:g,initialOffset:{left:void 0!==window.pageXOffset?window.pageXOffset:(null===document||void 0===document?void 0:document.documentElement.scrollLeft)||(null===(n=null===(t=null===document||void 0===document?void 0:document.body)||void 0===t?void 0:t.parentElement)||void 0===n?void 0:n.scrollLeft)||(null===(r=null===document||void 0===document?void 0:document.body)||void 0===r?void 0:r.scrollLeft)||0,top:void 0!==window.pageYOffset?window.pageYOffset:(null===document||void 0===document?void 0:document.documentElement.scrollTop)||(null===(h=null===(a=null===document||void 0===document?void 0:document.body)||void 0===a?void 0:a.parentElement)||void 0===h?void 0:h.scrollTop)||(null===(u=null===document||void 0===document?void 0:document.body)||void 0===u?void 0:u.scrollTop)||0}}})),ne.forEach(e=>e.unlock()),document.adoptedStyleSheets&&document.adoptedStyleSheets.length>0&&P.adoptStyleSheets(document.adoptedStyleSheets,Je.getId(document)))};try{const e=[];e.push(R("DOMContentLoaded",()=>{Ke(Ve({type:_.DomContentLoaded,data:{}}))}));const t=e=>{var t;return Ie({mutationCb:Y,mousemoveCb:(e,t)=>Ke(Ve({type:_.IncrementalSnapshot,data:{source:t,positions:e}})),mouseInteractionCb:e=>Ke(Ve({type:_.IncrementalSnapshot,data:Object.assign({source:z.MouseInteraction},e)})),scrollCb:J,viewportResizeCb:e=>Ke(Ve({type:_.IncrementalSnapshot,data:Object.assign({source:z.ViewportResize},e)})),inputCb:e=>Ke(Ve({type:_.IncrementalSnapshot,data:Object.assign({source:z.Input},e)})),mediaInteractionCb:e=>Ke(Ve({type:_.IncrementalSnapshot,data:Object.assign({source:z.MediaInteraction},e)})),styleSheetRuleCb:e=>Ke(Ve({type:_.IncrementalSnapshot,data:Object.assign({source:z.StyleSheetRule},e)})),styleDeclarationCb:e=>Ke(Ve({type:_.IncrementalSnapshot,data:Object.assign({source:z.StyleDeclaration},e)})),canvasMutationCb:Q,fontCb:e=>Ke(Ve({type:_.IncrementalSnapshot,data:Object.assign({source:z.Font},e)})),selectionCb:e=>{Ke(Ve({type:_.IncrementalSnapshot,data:Object.assign({source:z.Selection},e)}))},blockClass:s,ignoreClass:a,maskTextClass:c,maskTextSelector:l,maskInputOptions:L,inlineStylesheet:d,sampling:C,recordCanvas:S,inlineImages:w,userTriggeredOnInput:A,collectFonts:k,doc:e,maskInputFn:p,maskTextFn:m,keepIframeSrcFn:E,blockSelector:i,slimDOMOptions:B,dataURLOptions:y,mirror:Je,iframeManager:H,stylesheetManager:P,shadowDomManager:X,canvasManager:ze,ignoreCSSAttributes:N,plugins:(null===(t=null==M?void 0:M.filter(e=>e.observer))||void 0===t?void 0:t.map(e=>({observer:e.observer,options:e.options,callback:t=>Ke(Ve({type:_.Plugin,data:{plugin:e.name,payload:t}}))})))||[]},f)};H.addLoadListener(n=>{e.push(t(n.contentDocument))});const n=()=>{_e(),e.push(t(document)),Ye=!0};return"interactive"===document.readyState||"complete"===document.readyState?n():e.push(R("load",()=>{Ke(Ve({type:_.Load,data:{}})),n()},window)),()=>{e.forEach(e=>e()),Ye=!1}}catch(e){}}Qe.addCustomEvent=(e,t)=>{if(!Ye)throw new Error("please add custom event after start recording");Ke(Ve({type:_.Custom,data:{tag:e,payload:t}}))},Qe.freezePage=()=>{ne.forEach(e=>e.freeze())},Qe.takeFullSnapshot=e=>{if(!Ye)throw new Error("please take full snapshot after start recording");_e(e)},Qe.mirror=Je;var Pe=Uint8Array,He=Uint16Array,Xe=Uint32Array,je=new Pe([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),qe=new Pe([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),$e=new Pe([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),et=function(e,t){for(var n=new He(31),r=0;r<31;++r)n[r]=t+=1<<e[r-1];var s=new Xe(n[30]);for(r=1;r<30;++r)for(var o=n[r];o<n[r+1];++o)s[o]=o-n[r]<<5|r;return[n,s]},tt=et(je,2),nt=tt[0],rt=tt[1];nt[28]=258,rt[258]=28;for(var st=et(qe,0)[1],ot=new He(32768),it=0;it<32768;++it){var at=(43690&it)>>>1|(21845&it)<<1;at=(61680&(at=(52428&at)>>>2|(13107&at)<<2))>>>4|(3855&at)<<4,ot[it]=((65280&at)>>>8|(255&at)<<8)>>>1}var ct=function(e,t,n){for(var r=e.length,s=0,o=new He(t);s<r;++s)++o[e[s]-1];var i,a=new He(t);for(s=0;s<t;++s)a[s]=a[s-1]+o[s-1]<<1;if(n){i=new He(1<<t);var c=15-t;for(s=0;s<r;++s)if(e[s])for(var l=s<<4|e[s],d=t-e[s],h=a[e[s]-1]++<<d,u=h|(1<<d)-1;h<=u;++h)i[ot[h]>>>c]=l}else for(i=new He(r),s=0;s<r;++s)i[s]=ot[a[e[s]-1]++]>>>15-e[s];return i},lt=new Pe(288);for(it=0;it<144;++it)lt[it]=8;for(it=144;it<256;++it)lt[it]=9;for(it=256;it<280;++it)lt[it]=7;for(it=280;it<288;++it)lt[it]=8;var dt=new Pe(32);for(it=0;it<32;++it)dt[it]=5;var ht=ct(lt,9,0),ut=ct(dt,5,0),gt=function(e){return(e/8|0)+(7&e&&1)},pt=function(e,t,n){(null==n||n>e.length)&&(n=e.length);var r=new(e instanceof He?He:e instanceof Xe?Xe:Pe)(n-t);return r.set(e.subarray(t,n)),r},mt=function(e,t,n){n<<=7&t;var r=t/8|0;e[r]|=n,e[r+1]|=n>>>8},ft=function(e,t,n){n<<=7&t;var r=t/8|0;e[r]|=n,e[r+1]|=n>>>8,e[r+2]|=n>>>16},It=function(e,t){for(var n=[],r=0;r<e.length;++r)e[r]&&n.push({s:r,f:e[r]});var s=n.length,o=n.slice();if(!s)return[new Pe(0),0];if(1==s){var i=new Pe(n[0].s+1);return i[n[0].s]=1,[i,1]}n.sort(function(e,t){return e.f-t.f}),n.push({s:-1,f:25001});var a=n[0],c=n[1],l=0,d=1,h=2;for(n[0]={s:-1,f:a.f+c.f,l:a,r:c};d!=s-1;)a=n[n[l].f<n[h].f?l++:h++],c=n[l!=d&&n[l].f<n[h].f?l++:h++],n[d++]={s:-1,f:a.f+c.f,l:a,r:c};var u=o[0].s;for(r=1;r<s;++r)o[r].s>u&&(u=o[r].s);var g=new He(u+1),p=Ct(n[d-1],g,0);if(p>t){r=0;var m=0,f=p-t,I=1<<f;for(o.sort(function(e,t){return g[t.s]-g[e.s]||e.f-t.f});r<s;++r){var C=o[r].s;if(!(g[C]>t))break;m+=I-(1<<p-g[C]),g[C]=t}for(m>>>=f;m>0;){var y=o[r].s;g[y]<t?m-=1<<t-g[y]++-1:++r}for(;r>=0&&m;--r){var v=o[r].s;g[v]==t&&(--g[v],++m)}p=t}return[new Pe(g),p]},Ct=function(e,t,n){return-1==e.s?Math.max(Ct(e.l,t,n+1),Ct(e.r,t,n+1)):t[e.s]=n},yt=function(e){for(var t=e.length;t&&!e[--t];);for(var n=new He(++t),r=0,s=e[0],o=1,i=function(e){n[r++]=e},a=1;a<=t;++a)if(e[a]==s&&a!=t)++o;else{if(!s&&o>2){for(;o>138;o-=138)i(32754);o>2&&(i(o>10?o-11<<5|28690:o-3<<5|12305),o=0)}else if(o>3){for(i(s),--o;o>6;o-=6)i(8304);o>2&&(i(o-3<<5|8208),o=0)}for(;o--;)i(s);o=1,s=e[a]}return[n.subarray(0,r),t]},vt=function(e,t){for(var n=0,r=0;r<t.length;++r)n+=e[r]*t[r];return n},St=function(e,t,n){var r=n.length,s=gt(t+2);e[s]=255&r,e[s+1]=r>>>8,e[s+2]=255^e[s],e[s+3]=255^e[s+1];for(var o=0;o<r;++o)e[s+o+4]=n[o];return 8*(s+4+r)},bt=function(e,t,n,r,s,o,i,a,c,l,d){mt(t,d++,n),++s[256];for(var h=It(s,15),u=h[0],g=h[1],p=It(o,15),m=p[0],f=p[1],I=yt(u),C=I[0],y=I[1],v=yt(m),S=v[0],b=v[1],A=new He(19),k=0;k<C.length;++k)A[31&C[k]]++;for(k=0;k<S.length;++k)A[31&S[k]]++;for(var w=It(A,7),M=w[0],T=w[1],R=19;R>4&&!M[$e[R-1]];--R);var E,N,x,F,O=l+5<<3,D=vt(s,lt)+vt(o,dt)+i,L=vt(s,u)+vt(o,m)+i+14+3*R+vt(A,M)+(2*A[16]+3*A[17]+7*A[18]);if(O<=D&&O<=L)return St(t,d,e.subarray(c,c+l));if(mt(t,d,1+(L<D)),d+=2,L<D){E=ct(u,g,0),N=u,x=ct(m,f,0),F=m;var B=ct(M,T,0);mt(t,d,y-257),mt(t,d+5,b-1),mt(t,d+10,R-4),d+=14;for(k=0;k<R;++k)mt(t,d+3*k,M[$e[k]]);d+=3*R;for(var U=[C,S],W=0;W<2;++W){var Z=U[W];for(k=0;k<Z.length;++k){var G=31&Z[k];mt(t,d,B[G]),d+=M[G],G>15&&(mt(t,d,Z[k]>>>5&127),d+=Z[k]>>>12)}}}else E=ht,N=lt,x=ut,F=dt;for(k=0;k<a;++k)if(r[k]>255){G=r[k]>>>18&31;ft(t,d,E[G+257]),d+=N[G+257],G>7&&(mt(t,d,r[k]>>>23&31),d+=je[G]);var V=31&r[k];ft(t,d,x[V]),d+=F[V],V>3&&(ft(t,d,r[k]>>>5&8191),d+=qe[V])}else ft(t,d,E[r[k]]),d+=N[r[k]];return ft(t,d,E[256]),d+N[256]},At=new Xe([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),kt=function(e,t,n,r,s){return function(e,t,n,r,s,o){var i=e.length,a=new Pe(r+i+5*(1+Math.floor(i/7e3))+s),c=a.subarray(r,a.length-s),l=0;if(!t||i<8)for(var d=0;d<=i;d+=65535){var h=d+65535;h<i?l=St(c,l,e.subarray(d,h)):(c[d]=o,l=St(c,l,e.subarray(d,i)))}else{for(var u=At[t-1],g=u>>>13,p=8191&u,m=(1<<n)-1,f=new He(32768),I=new He(m+1),C=Math.ceil(n/3),y=2*C,v=function(t){return(e[t]^e[t+1]<<C^e[t+2]<<y)&m},S=new Xe(25e3),b=new He(288),A=new He(32),k=0,w=0,M=(d=0,0),T=0,R=0;d<i;++d){var E=v(d),N=32767&d,x=I[E];if(f[N]=x,I[E]=N,T<=d){var F=i-d;if((k>7e3||M>24576)&&F>423){l=bt(e,c,0,S,b,A,w,M,R,d-R,l),M=k=w=0,R=d;for(var O=0;O<286;++O)b[O]=0;for(O=0;O<30;++O)A[O]=0}var D=2,L=0,B=p,U=N-x&32767;if(F>2&&E==v(d-U))for(var W=Math.min(g,F)-1,Z=Math.min(32767,d),G=Math.min(258,F);U<=Z&&--B&&N!=x;){if(e[d+D]==e[d+D-U]){for(var V=0;V<G&&e[d+V]==e[d+V-U];++V);if(V>D){if(D=V,L=U,V>W)break;var K=Math.min(U,V-2),_=0;for(O=0;O<K;++O){var z=d-U+O+32768&32767,Y=z-f[z]+32768&32767;Y>_&&(_=Y,x=z)}}}U+=(N=x)-(x=f[N])+32768&32767}if(L){S[M++]=268435456|rt[D]<<18|st[L];var J=31&rt[D],Q=31&st[L];w+=je[J]+qe[Q],++b[257+J],++A[Q],T=d+D,++k}else S[M++]=e[d],++b[e[d]]}}l=bt(e,c,o,S,b,A,w,M,R,d-R,l)}return pt(a,0,r+gt(l)+s)}(e,null==t.level?6:t.level,null==t.mem?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(e.length)))):12+t.mem,n,r,!0)};function wt(e,t){void 0===t&&(t={});var n=function(){var e=1,t=0;return{p:function(n){for(var r=e,s=t,o=n.length,i=0;i!=o;){for(var a=Math.min(i+5552,o);i<a;++i)s+=r+=n[i];r%=65521,s%=65521}e=r,t=s},d:function(){return(e>>>8<<16|(255&t)<<8|t>>>8)+2*((255&e)<<23)}}}();n.p(e);var r,s,o,i=kt(e,t,2,4);return r=i,s=t.level,o=0==s?0:s<6?1:9==s?3:2,r[0]=120,r[1]=o<<6|(o?32-2*o:1),function(e,t,n){for(;n;++t)e[t]=n,n>>>=8}(i,i.length-4,n.d()),i}const Mt=e=>{const t={...e,v:"v1"};return function(e){for(var t="",n=0;n<e.length;){var r=e[n++];t+=String.fromCharCode(r)}return t}(wt(function(e,t){var n=e.length;if("undefined"!=typeof TextEncoder)return(new TextEncoder).encode(e);for(var r=new Pe(e.length+(e.length>>>1)),s=0,o=function(e){r[s++]=e},i=0;i<n;++i){if(s+5>r.length){var a=new Pe(s+8+(n-i<<1));a.set(r),r=a}var c=e.charCodeAt(i);c<128||t?o(c):c<2048?(o(192|c>>>6),o(128|63&c)):c>55295&&c<57344?(o(240|(c=65536+(1047552&c)|1023&e.charCodeAt(++i))>>>18),o(128|c>>>12&63),o(128|c>>>6&63),o(128|63&c)):(o(224|c>>>12),o(128|c>>>6&63),o(128|63&c))}return pt(r,0,s)}(JSON.stringify(t))))};class Tt{constructor(e){this.name="session-tracker",this.version='"0.9.5"',this.context=null,this.config={},this.userConfig=null,this.sessionStartTime=0,this.isActive=!1,this.stopRecordingFn=null,this.sessionEvents=[],this.sessionId="",this.currentSessionSize=0,this.lastBatchTime=0,this.activeBatchCount=0,this.userId="",this.appId="",this.pendingEvents=[],this.eventsInFlight=[],this.sentEventCount=0,this.isSendingBatch=!1,this.delayedS3Url=null,this.delayedUrlExpiry=0,this.delayedUrlRefreshTimer=null,this.userConfig=e||{}}init(e,t){this.context=e;const n="object"==typeof t?.webSessions?t?.webSessions:null,r={enableSessionRecording:!1!==t?.webSessions&&(!0===t?.webSessions||!1!==n?.enabled),maxBatchSize:1048576,maxSessionDuration:null,batchSize:150,batchInterval:3e4,minimumSessionDuration:5e3,compressionEnabled:!1,recordingOptions:{recordCanvas:!0,recordCrossOriginIframes:!1,recordAfter:"DOMContentLoaded",maskAllInputs:!1,maskInputOptions:{password:!0,email:!0,text:!1},blockClass:"sensitive-field",slimDOMOptions:{script:!1,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaDescKeywords:!0,headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaAuthorship:!0,headMetaVerification:!0},sampling:{scroll:150,mouseInteraction:!0,input:"last",mutation:!0},...this.userConfig?this.userConfig:{},...this.config.recordingOptions?this.config.recordingOptions:{}}};this.config={...r}}start(){if(!this.context)return;if(this.isActive)return;this.delayedUrlRefreshTimer&&(clearTimeout(this.delayedUrlRefreshTimer),this.delayedUrlRefreshTimer=null),this.isActive=!0,this.userId=this.context.userManager.getUserId(),this.appId=this.context.appManager.getAppId();const e=String(this.context.userManager.getSessionId());(!this.sessionId||this.sessionId!==e)&&(this.sessionEvents=[],this.pendingEvents=[],this.eventsInFlight=[],this.currentSessionSize=0,this.sentEventCount=0,this.sessionStartTime=Date.now(),this.delayedS3Url=null,this.delayedUrlExpiry=0),this.sessionId=e,this.config.enableSessionRecording&&this.startRecording()}stop(){this.isActive&&this.stopRecording()}destroy(){this.stopRecording(),this.pendingEvents=[],this.eventsInFlight=[],this.sessionEvents=[],this.currentSessionSize=0,this.sentEventCount=0,this.delayedS3Url=null,this.delayedUrlExpiry=0,this.context?.removePluginField("recordingSessionId"),this.context?.setPluginField("isRecordingActive",!1),this.context=null}onEvent(e,t){this.isActive&&"session_start"===e&&(this.sessionStartTime=Date.now())}async onUserChange(e){this.isActive&&(await this.sendBatchToBackend(),this.stopRecording(),this.isActive=!1,this.start())}async onFocus(){this.pendingEvents.length>0&&await this.sendBatchToBackend(),this.isActive||this.start()}onBlur(){this.isActive&&(this.sendFinalBatch().catch(e=>{this.context?.logger.error(e)}),this.stopRecording(!0))}async onBeforeUnload(){const e=this.pendingEvents.length>0||this.eventsInFlight.length>0;(this.isActive||e)&&this.sendFinalBatch().catch(e=>{this.context?.logger.error(e)})}async onTrackingChange(e){e?this.isActive||this.start():this.isActive&&(await this.sendBatchToBackend(),this.stopRecording())}async onSessionStart(){await this.sendBatchToBackend(),this.isActive||this.start()}stopRecording(e=!1){e||this.context?.setPluginField("isRecordingActive",!1),this.isActive=!1,this.delayedUrlRefreshTimer&&(clearTimeout(this.delayedUrlRefreshTimer),this.delayedUrlRefreshTimer=null),this.stopRecordingFn&&(this.stopRecordingFn(),this.stopRecordingFn=null)}async startRecording(){if(!this.context)return;this.lastBatchTime=Date.now(),this.isSendingBatch=!1;const e=Date.now();if(!this.delayedS3Url||this.delayedUrlExpiry>0&&e>this.delayedUrlExpiry)this.fetchDelayedUrl();else if(this.delayedS3Url){const t=Math.max(0,this.delayedUrlExpiry-e);this.scheduleDelayedUrlRefresh(t+1e4)}const t=this.context.getPluginField("recordingSessionId"),n=!!t&&t===this.context.userManager.getSessionId(),r=this.context.getPluginField("isRecordingActive");if(n&&r)this.startSessionRecording();else try{const e=this.context.api.buildUrl(["sessions","configurations","get"],{appId:this.appId}),t=await this.sendRequest(e,null,"GET");if(t&&t.data){const e=t.data;if(e.blocked||!e.active)return this.context.logger.debug("Session configuration is "+(e.blocked?"blocked":"inactive")),void this.context.setPluginField("isRecordingActive",!1);100*Math.random()<e.record_chance_percent?(this.context.setPluginField("isRecordingActive",!0),this.startSessionRecording()):this.context.setPluginField("isRecordingActive",!1)}}catch(e){this.context.logger.error("Failed to fetch session configuration",{error:e}),this.context.setPluginField("isRecordingActive",!1)}}startSessionRecording(){if(!this.config.enableSessionRecording)return;this.context?.setPluginField("recordingSessionId",this.context?.userManager.getSessionId()),this.lastBatchTime=Date.now();const e={emit:e=>{this.addEventToSession(e),this.pendingEvents.push(e),this.currentSessionSize+=JSON.stringify(e).length,e.type,this.checkBatchLimits()},...this.config.recordingOptions};this.config.compressionEnabled&&(e.packFn=Mt);const t=Qe(e);this.stopRecordingFn=t||null}addEventToSession(e){this.sessionEvents.push(e);this.sessionEvents.length>1e4&&(this.sessionEvents=this.sessionEvents.slice(-Math.floor(5e3)))}hasMinimumSessionDuration(){return Date.now()-this.sessionStartTime>=this.config.minimumSessionDuration}checkBatchLimits(){if(this.isSendingBatch)return;const e=Date.now()-this.sessionStartTime,t=this.pendingEvents.length>=this.config.batchSize,n=this.currentSessionSize>=this.config.maxBatchSize,r=this.config.maxSessionDuration&&e>=this.config.maxSessionDuration,s=Date.now()-this.lastBatchTime>=this.config.batchInterval;(t||n||r||s)&&this.sendBatchToBackend().catch(e=>{this.context?.logger.error("Error in checkBatchLimits sendBatchToBackend",{error:e instanceof Error?e.message:e,pendingEventsCount:this.pendingEvents.length})})}async sendBatchToBackend(){if(!this.pendingEvents.length||!this.context||this.isSendingBatch)return;if(!this.hasMinimumSessionDuration())return;this.isSendingBatch=!0,this.eventsInFlight=[...this.pendingEvents],this.pendingEvents=[];const e=this.eventsInFlight.reduce((e,t)=>e+JSON.stringify(t).length,0);this.currentSessionSize-=e,this.currentSessionSize=Math.max(0,this.currentSessionSize),this.activeBatchCount++;try{const e=this.eventsInFlight[0]?.timestamp||Date.now(),t=this.eventsInFlight[this.eventsInFlight.length-1]?.timestamp||Date.now(),n={appId:this.appId,session_id:this.sessionId,user_id:this.userId,start_time:e,end_time:t},r=this.context.api.buildUrl(["sessions","add"],n),s=await this.sendRequest(r,null,"GET",{},!0);if(204===s.status)return this.context.logger.warning("Session storage exceeded"),this.eventsInFlight=[],void this.stop();const o=s.data,i="string"==typeof o?o:o?.url;if(!i)throw new Error("No S3 URL returned");await this.uploadToS3(i,this.eventsInFlight),this.sentEventCount+=this.eventsInFlight.length,this.lastBatchTime=Date.now(),this.eventsInFlight=[]}catch(t){throw this.context?.logger.error("Error sending session batch to backend",{error:t instanceof Error?t.message:t,eventsCount:this.eventsInFlight.length}),this.pendingEvents.unshift(...this.eventsInFlight),this.eventsInFlight=[],this.currentSessionSize+=e,t}finally{this.activeBatchCount--,this.isSendingBatch=!1,this.pendingEvents.length>0&&this.checkBatchLimits()}}async fetchDelayedUrl(){if(this.context)try{const e=this.context.api.buildUrl(["sessions","addDelayed"],{session_id:this.sessionId,appId:this.appId,user_id:this.userId}),t=await this.sendRequest(e,null,"GET");if(t&&t.data){const e=t.data;this.delayedS3Url=e.url,this.delayedUrlExpiry=Date.now()+e.ttl,this.scheduleDelayedUrlRefresh(e.ttl)}}catch(e){this.context.logger.error("Failed to fetch delayed URL",{error:e})}}scheduleDelayedUrlRefresh(e){this.delayedUrlRefreshTimer&&clearTimeout(this.delayedUrlRefreshTimer);const t=Math.max(0,e-1e4);this.delayedUrlRefreshTimer=setTimeout(()=>{this.fetchDelayedUrl()},t)}async sendFinalBatch(){if(!this.context)return;if(!this.hasMinimumSessionDuration())return;const e=[...this.eventsInFlight,...this.pendingEvents];if(!e.length)return;if(!this.delayedS3Url)return void this.context.logger.error("No delayed URL available for final batch - cannot send.");const t=[...this.pendingEvents],n=[...this.eventsInFlight];this.pendingEvents=[],this.eventsInFlight=[],this.currentSessionSize=0;const r=JSON.stringify(e),s=new Blob([r],{type:"application/json"});try{const e=await fetch(this.delayedS3Url,{method:"PUT",body:s,keepalive:!0,credentials:"omit"});if(!e.ok)throw new Error(`S3 upload failed: ${e.statusText}`);this.lastBatchTime=Date.now()}catch(e){this.pendingEvents=t,this.eventsInFlight=n,this.context?.logger.error(`Failed to send final batch: ${e}`)}}async uploadToS3(e,t){const n=JSON.stringify(t),r=await fetch(e,{method:"PUT",body:n});if(!r.ok)throw new Error(`S3 upload failed: ${r.statusText}`)}sendRequest(e,t,n="POST",r={},s=!1){return new Promise((o,i)=>{if(!this.context)return i(new Error("No context"));const a=this.context.api.createRequestStructure(e,t,r,n);this.context.api.sendRequest(`req-${Date.now()}-${Math.random()}`,a,(e,t,n)=>{e>=200&&e<300?o({status:e,data:t}):i({status:e,data:t,error:n})},{gzip:!1,method:n,noContentType:s})})}}export{Tt as default};
|
package/dist/index.js
CHANGED
|
@@ -12,4 +12,4 @@ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
|
12
12
|
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
13
13
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
14
14
|
PERFORMANCE OF THIS SOFTWARE.
|
|
15
|
-
***************************************************************************** */function Se(e,t,n,r){return new(n||(n=Promise))(function(t,s){function o(e){try{a(r.next(e))}catch(e){s(e)}}function i(e){try{a(r.throw(e))}catch(e){s(e)}}function a(e){var r;e.done?t(e.value):(r=e.value,r instanceof n?r:new n(function(e){e(r)})).then(o,i)}a((r=r.apply(e,[])).next())})}for(var be="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Ae="undefined"==typeof Uint8Array?[]:new Uint8Array(256),ke=0;ke<64;ke++)Ae[be.charCodeAt(ke)]=ke;const we=new Map;const Me=(e,t,n)=>{if(!e||!Ee(e,t)&&"object"!=typeof e)return;const r=function(e,t){let n=we.get(e);return n||(n=new Map,we.set(e,n)),n.has(t)||n.set(t,[]),n.get(t)}(n,e.constructor.name);let s=r.indexOf(e);return-1===s&&(s=r.length,r.push(e)),s};function Te(e,t,n){if(e instanceof Array)return e.map(e=>Te(e,t,n));if(null===e)return e;if(e instanceof Float32Array||e instanceof Float64Array||e instanceof Int32Array||e instanceof Uint32Array||e instanceof Uint8Array||e instanceof Uint16Array||e instanceof Int16Array||e instanceof Int8Array||e instanceof Uint8ClampedArray){return{rr_type:e.constructor.name,args:[Object.values(e)]}}if(e instanceof ArrayBuffer){const t=e.constructor.name,n=function(e){var t,n=new Uint8Array(e),r=n.length,s="";for(t=0;t<r;t+=3)s+=be[n[t]>>2],s+=be[(3&n[t])<<4|n[t+1]>>4],s+=be[(15&n[t+1])<<2|n[t+2]>>6],s+=be[63&n[t+2]];return r%3==2?s=s.substring(0,s.length-1)+"=":r%3==1&&(s=s.substring(0,s.length-2)+"=="),s}(e);return{rr_type:t,base64:n}}if(e instanceof DataView){return{rr_type:e.constructor.name,args:[Te(e.buffer,t,n),e.byteOffset,e.byteLength]}}if(e instanceof HTMLImageElement){const t=e.constructor.name,{src:n}=e;return{rr_type:t,src:n}}if(e instanceof HTMLCanvasElement){return{rr_type:"HTMLImageElement",src:e.toDataURL()}}if(e instanceof ImageData){return{rr_type:e.constructor.name,args:[Te(e.data,t,n),e.width,e.height]}}if(Ee(e,t)||"object"==typeof e){return{rr_type:e.constructor.name,index:Me(e,t,n)}}return e}const Re=(e,t,n)=>[...e].map(e=>Te(e,t,n)),Ee=(e,t)=>{const n=["WebGLActiveInfo","WebGLBuffer","WebGLFramebuffer","WebGLProgram","WebGLRenderbuffer","WebGLShader","WebGLShaderPrecisionFormat","WebGLTexture","WebGLUniformLocation","WebGLVertexArrayObject","WebGLVertexArrayObjectOES"].filter(e=>"function"==typeof t[e]);return Boolean(n.find(n=>e instanceof t[n]))};function Ne(e,t,n){const r=[];try{const s=F(e.HTMLCanvasElement.prototype,"getContext",function(e){return function(r,...s){return L(this,t,n,!0)||"__context"in this||(this.__context=r),e.apply(this,[r,...s])}});r.push(s)}catch(e){}return()=>{r.forEach(e=>e())}}function xe(e,t,n,r,s,o,i){const a=[],c=Object.getOwnPropertyNames(e);for(const o of c)if(!["isContextLost","canvas","drawingBufferWidth","drawingBufferHeight"].includes(o))try{if("function"!=typeof e[o])continue;const c=F(e,o,function(e){return function(...a){const c=e.apply(this,a);if(Me(c,i,this),!L(this.canvas,r,s,!0)){const e=Re([...a],i,this),r={type:t,property:o,args:e};n(this.canvas,r)}return c}});a.push(c)}catch(r){const s=x(e,o,{set(e){n(this.canvas,{type:t,property:o,args:[e],setter:!0})}});a.push(s)}return a}var Fe=null;try{var Oe="undefined"!=typeof module&&"function"==typeof module.require&&module.require("worker_threads")||"function"==typeof __non_webpack_require__&&__non_webpack_require__("worker_threads")||"function"==typeof require&&require("worker_threads");Fe=Oe.Worker}catch(e){}function De(e,t,n){var r=function(e){return Buffer.from(e,"base64").toString("utf8")}(e),s=r.indexOf("\n",10)+1,o=r.substring(s)+"";return function(e){return new Fe(o,Object.assign({},e,{eval:!0}))}}function Le(e,t,n){var r=function(e){return atob(e)}(e),s=r.indexOf("\n",10)+1,o=r.substring(s)+"",i=new Blob([o],{type:"application/javascript"});return URL.createObjectURL(i)}var Be="[object process]"===Object.prototype.toString.call("undefined"!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AgICAgICAgICAgIGNvbnN0IGN0eCA9IG9mZnNjcmVlbi5nZXRDb250ZXh0KCcyZCcpOw0KICAgICAgICAgICAgICAgIGN0eC5kcmF3SW1hZ2UoYml0bWFwLCAwLCAwKTsNCiAgICAgICAgICAgICAgICBiaXRtYXAuY2xvc2UoKTsNCiAgICAgICAgICAgICAgICBjb25zdCBibG9iID0geWllbGQgb2Zmc2NyZWVuLmNvbnZlcnRUb0Jsb2IoZGF0YVVSTE9wdGlvbnMpOw0KICAgICAgICAgICAgICAgIGNvbnN0IHR5cGUgPSBibG9iLnR5cGU7DQogICAgICAgICAgICAgICAgY29uc3QgYXJyYXlCdWZmZXIgPSB5aWVsZCBibG9iLmFycmF5QnVmZmVyKCk7DQogICAgICAgICAgICAgICAgY29uc3QgYmFzZTY0ID0gZW5jb2RlKGFycmF5QnVmZmVyKTsNCiAgICAgICAgICAgICAgICBpZiAoIWxhc3RCbG9iTWFwLmhhcyhpZCkgJiYgKHlpZWxkIHRyYW5zcGFyZW50QmFzZTY0KSA9PT0gYmFzZTY0KSB7DQogICAgICAgICAgICAgICAgICAgIGxhc3RCbG9iTWFwLnNldChpZCwgYmFzZTY0KTsNCiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHdvcmtlci5wb3N0TWVzc2FnZSh7IGlkIH0pOw0KICAgICAgICAgICAgICAgIH0NCiAgICAgICAgICAgICAgICBpZiAobGFzdEJsb2JNYXAuZ2V0KGlkKSA9PT0gYmFzZTY0KQ0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gd29ya2VyLnBvc3RNZXNzYWdlKHsgaWQgfSk7DQogICAgICAgICAgICAgICAgd29ya2VyLnBvc3RNZXNzYWdlKHsNCiAgICAgICAgICAgICAgICAgICAgaWQsDQogICAgICAgICAgICAgICAgICAgIHR5cGUsDQogICAgICAgICAgICAgICAgICAgIGJhc2U2NCwNCiAgICAgICAgICAgICAgICAgICAgd2lkdGgsDQogICAgICAgICAgICAgICAgICAgIGhlaWdodCwNCiAgICAgICAgICAgICAgICB9KTsNCiAgICAgICAgICAgICAgICBsYXN0QmxvYk1hcC5zZXQoaWQsIGJhc2U2NCk7DQogICAgICAgICAgICB9DQogICAgICAgICAgICBlbHNlIHsNCiAgICAgICAgICAgICAgICByZXR1cm4gd29ya2VyLnBvc3RNZXNzYWdlKHsgaWQ6IGUuZGF0YS5pZCB9KTsNCiAgICAgICAgICAgIH0NCiAgICAgICAgfSk7DQogICAgfTsKCn0pKCk7Cgo=",Be?De(Ue):function(e){var t;return function(n){return t=t||Le(e),new Worker(t,n)}}(Ue));class Ze{constructor(e){this.pendingCanvasMutations=new Map,this.rafStamps={latestId:0,invokeId:null},this.frozen=!1,this.locked=!1,this.processMutation=(e,t)=>{!(this.rafStamps.invokeId&&this.rafStamps.latestId!==this.rafStamps.invokeId)&&this.rafStamps.invokeId||(this.rafStamps.invokeId=this.rafStamps.latestId),this.pendingCanvasMutations.has(e)||this.pendingCanvasMutations.set(e,[]),this.pendingCanvasMutations.get(e).push(t)};const{sampling:t="all",win:n,blockClass:r,blockSelector:s,recordCanvas:o,dataURLOptions:i}=e;this.mutationCb=e.mutationCb,this.mirror=e.mirror,o&&"all"===t&&this.initCanvasMutationObserver(n,r,s),o&&"number"==typeof t&&this.initCanvasFPSObserver(t,n,r,s,{dataURLOptions:i})}reset(){this.pendingCanvasMutations.clear(),this.resetObservers&&this.resetObservers()}freeze(){this.frozen=!0}unfreeze(){this.frozen=!1}lock(){this.locked=!0}unlock(){this.locked=!1}initCanvasFPSObserver(e,t,n,r,s){const o=Ne(t,n,r),i=new Map,a=new We;a.onmessage=e=>{const{id:t}=e.data;if(i.set(t,!1),!("base64"in e.data))return;const{base64:n,type:r,width:s,height:o}=e.data;this.mutationCb({id:t,type:J["2D"],commands:[{property:"clearRect",args:[0,0,s,o]},{property:"drawImage",args:[{rr_type:"ImageBitmap",args:[{rr_type:"Blob",data:[{rr_type:"ArrayBuffer",base64:n}],type:r}]},0,0]}]})};const c=1e3/e;let l,d=0;const u=e=>{d&&e-d<c||(d=e,(()=>{const e=[];return t.document.querySelectorAll("canvas").forEach(t=>{L(t,n,r,!0)||e.push(t)}),e})().forEach(e=>Se(this,0,void 0,function*(){var t;const n=this.mirror.getId(e);if(i.get(n))return;if(i.set(n,!0),["webgl","webgl2"].includes(e.__context)){const n=e.getContext(e.__context);!1===(null===(t=null==n?void 0:n.getContextAttributes())||void 0===t?void 0:t.preserveDrawingBuffer)&&(null==n||n.clear(n.COLOR_BUFFER_BIT))}const r=yield createImageBitmap(e);a.postMessage({id:n,bitmap:r,width:e.width,height:e.height,dataURLOptions:s.dataURLOptions},[r])}))),l=requestAnimationFrame(u)};l=requestAnimationFrame(u),this.resetObservers=()=>{o(),cancelAnimationFrame(l)}}initCanvasMutationObserver(e,t,n){this.startRAFTimestamping(),this.startPendingCanvasMutationFlusher();const r=Ne(e,t,n),s=function(e,t,n,r){const s=[],o=Object.getOwnPropertyNames(t.CanvasRenderingContext2D.prototype);for(const i of o)try{if("function"!=typeof t.CanvasRenderingContext2D.prototype[i])continue;const o=F(t.CanvasRenderingContext2D.prototype,i,function(s){return function(...o){return L(this.canvas,n,r,!0)||setTimeout(()=>{const n=Re([...o],t,this);e(this.canvas,{type:J["2D"],property:i,args:n})},0),s.apply(this,o)}});s.push(o)}catch(n){const r=x(t.CanvasRenderingContext2D.prototype,i,{set(t){e(this.canvas,{type:J["2D"],property:i,args:[t],setter:!0})}});s.push(r)}return()=>{s.forEach(e=>e())}}(this.processMutation.bind(this),e,t,n),o=function(e,t,n,r){const s=[];return s.push(...xe(t.WebGLRenderingContext.prototype,J.WebGL,e,n,r,0,t)),void 0!==t.WebGL2RenderingContext&&s.push(...xe(t.WebGL2RenderingContext.prototype,J.WebGL2,e,n,r,0,t)),()=>{s.forEach(e=>e())}}(this.processMutation.bind(this),e,t,n,this.mirror);this.resetObservers=()=>{r(),s(),o()}}startPendingCanvasMutationFlusher(){requestAnimationFrame(()=>this.flushPendingCanvasMutations())}startRAFTimestamping(){const e=t=>{this.rafStamps.latestId=t,requestAnimationFrame(e)};requestAnimationFrame(e)}flushPendingCanvasMutations(){this.pendingCanvasMutations.forEach((e,t)=>{const n=this.mirror.getId(t);this.flushPendingCanvasMutationFor(t,n)}),requestAnimationFrame(()=>this.flushPendingCanvasMutations())}flushPendingCanvasMutationFor(e,t){if(this.frozen||this.locked)return;const n=this.pendingCanvasMutations.get(e);if(!n||-1===t)return;const r=n.map(e=>{const t=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var s=0;for(r=Object.getOwnPropertySymbols(e);s<r.length;s++)t.indexOf(r[s])<0&&Object.prototype.propertyIsEnumerable.call(e,r[s])&&(n[r[s]]=e[r[s]])}return n}(e,["type"]);return t}),{type:s}=n[0];this.mutationCb({id:t,type:s,commands:r}),this.pendingCanvasMutations.delete(e)}}class Ge{constructor(e){this.trackedLinkElements=new WeakSet,this.styleMirror=new K,this.mutationCb=e.mutationCb,this.adoptedStyleSheetCb=e.adoptedStyleSheetCb}attachLinkElement(e,t){"_cssText"in t.attributes&&this.mutationCb({adds:[],removes:[],texts:[],attributes:[{id:t.id,attributes:t.attributes}]}),this.trackLinkElement(e)}trackLinkElement(e){this.trackedLinkElements.has(e)||(this.trackedLinkElements.add(e),this.trackStylesheetInLinkElement(e))}adoptStyleSheets(e,t){if(0===e.length)return;const n={id:t,styleIds:[]},r=[];for(const t of e){let e;if(this.styleMirror.has(t))e=this.styleMirror.getId(t);else{e=this.styleMirror.add(t);const n=Array.from(t.rules||CSSRule);r.push({styleId:e,rules:n.map((e,t)=>({rule:s(e),index:t}))})}n.styleIds.push(e)}r.length>0&&(n.styles=r),this.adoptedStyleSheetCb(n)}reset(){this.styleMirror.reset(),this.trackedLinkElements=new WeakSet}trackStylesheetInLinkElement(e){}}function Ve(e){return Object.assign(Object.assign({},e),{timestamp:Date.now()})}let Ke,_e,ze,Ye=!1;const Je=new o;function Qe(e={}){const{emit:t,checkoutEveryNms:n,checkoutEveryNth:r,blockClass:s="rr-block",blockSelector:i=null,ignoreClass:a="rr-ignore",maskTextClass:c="rr-mask",maskTextSelector:l=null,inlineStylesheet:d=!0,maskAllInputs:u,maskInputOptions:h,slimDOMOptions:g,maskInputFn:p,maskTextFn:m,hooks:f,packFn:I,sampling:C={},dataURLOptions:y={},mousemoveWait:v,recordCanvas:S=!1,recordCrossOriginIframes:b=!1,userTriggeredOnInput:A=!1,collectFonts:k=!1,inlineImages:w=!1,plugins:M,keepIframeSrcFn:E=()=>!1,ignoreCSSAttributes:N=new Set([])}=e,x=!b||window.parent===window;let F=!1;if(!x)try{window.parent.document,F=!1}catch(e){F=!0}if(x&&!t)throw new Error("emit function is required");void 0!==v&&void 0===C.mousemove&&(C.mousemove=v),Je.reset();const L=!0===u?{color:!0,date:!0,"datetime-local":!0,email:!0,month:!0,number:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0,textarea:!0,select:!0,password:!0}:void 0!==h?h:{password:!0},B=!0===g||"all"===g?{script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaVerification:!0,headMetaAuthorship:"all"===g,headMetaDescKeywords:"all"===g}:g||{};let U;!function(e=window){"NodeList"in e&&!e.NodeList.prototype.forEach&&(e.NodeList.prototype.forEach=Array.prototype.forEach),"DOMTokenList"in e&&!e.DOMTokenList.prototype.forEach&&(e.DOMTokenList.prototype.forEach=Array.prototype.forEach),Node.prototype.contains||(Node.prototype.contains=(...e)=>{let t=e[0];if(!(0 in e))throw new TypeError("1 argument is required");do{if(this===t)return!0}while(t=t&&t.parentNode);return!1})}();let W=0;const K=e=>{for(const t of M||[])t.eventProcessor&&(e=t.eventProcessor(e));return I&&(e=I(e)),e};Ke=(e,s)=>{var o;if(!(null===(o=ne[0])||void 0===o?void 0:o.isFrozen())||e.type===_.FullSnapshot||e.type===_.IncrementalSnapshot&&e.data.source===z.Mutation||ne.forEach(e=>e.unfreeze()),x)null==t||t(K(e),s);else if(F){const t={type:"rrweb",event:K(e),isCheckout:s};window.parent.postMessage(t,"*")}if(e.type===_.FullSnapshot)U=e,W=0;else if(e.type===_.IncrementalSnapshot){if(e.data.source===z.Mutation&&e.data.isAttachIframe)return;W++;const t=r&&W>=r,s=n&&e.timestamp-U.timestamp>n;(t||s)&&_e(!0)}};const Y=e=>{Ke(Ve({type:_.IncrementalSnapshot,data:Object.assign({source:z.Mutation},e)}))},J=e=>Ke(Ve({type:_.IncrementalSnapshot,data:Object.assign({source:z.Scroll},e)})),Q=e=>Ke(Ve({type:_.IncrementalSnapshot,data:Object.assign({source:z.CanvasMutation},e)})),P=new Ge({mutationCb:Y,adoptedStyleSheetCb:e=>Ke(Ve({type:_.IncrementalSnapshot,data:Object.assign({source:z.AdoptedStyleSheet},e)}))}),H=new ye({mirror:Je,mutationCb:Y,stylesheetManager:P,recordCrossOriginIframes:b,wrappedEmit:Ke});for(const e of M||[])e.getMirror&&e.getMirror({nodeMirror:Je,crossOriginIframeMirror:H.crossOriginIframeMirror,crossOriginIframeStyleMirror:H.crossOriginIframeStyleMirror});ze=new Ze({recordCanvas:S,mutationCb:Q,win:window,blockClass:s,blockSelector:i,mirror:Je,sampling:C.canvas,dataURLOptions:y});const j=new ve({mutationCb:Y,scrollCb:J,bypassOptions:{blockClass:s,blockSelector:i,maskTextClass:c,maskTextSelector:l,inlineStylesheet:d,maskInputOptions:L,dataURLOptions:y,maskTextFn:m,maskInputFn:p,recordCanvas:S,inlineImages:w,sampling:C,slimDOMOptions:B,iframeManager:H,stylesheetManager:P,canvasManager:ze,keepIframeSrcFn:E},mirror:Je});_e=(e=!1)=>{var t,n,r,a,u,h;Ke(Ve({type:_.Meta,data:{href:window.location.href,width:D(),height:O()}}),e),P.reset(),ne.forEach(e=>e.lock());const g=function(e,t){var n=t||{},r=n.mirror,s=void 0===r?new o:r,i=n.blockClass,a=void 0===i?"rr-block":i,c=n.blockSelector,l=void 0===c?null:c,d=n.maskTextClass,u=void 0===d?"rr-mask":d,h=n.maskTextSelector,g=void 0===h?null:h,p=n.inlineStylesheet,m=void 0===p||p,f=n.inlineImages,I=void 0!==f&&f,C=n.recordCanvas,y=void 0!==C&&C,v=n.maskAllInputs,S=void 0!==v&&v,b=n.maskTextFn,A=n.maskInputFn,k=n.slimDOM,w=void 0!==k&&k,M=n.dataURLOptions,R=n.preserveWhiteSpace,E=n.onSerialize,N=n.onIframeLoad,x=n.iframeLoadTimeout,F=n.onStylesheetLoad,O=n.stylesheetLoadTimeout,D=n.keepIframeSrcFn;return T(e,{doc:e,mirror:s,blockClass:a,blockSelector:l,maskTextClass:u,maskTextSelector:g,skipChild:!1,inlineStylesheet:m,maskInputOptions:!0===S?{color:!0,date:!0,"datetime-local":!0,email:!0,month:!0,number:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0,textarea:!0,select:!0,password:!0}:!1===S?{password:!0}:S,maskTextFn:b,maskInputFn:A,slimDOMOptions:!0===w||"all"===w?{script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaDescKeywords:"all"===w,headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaAuthorship:!0,headMetaVerification:!0}:!1===w?{}:w,dataURLOptions:M,inlineImages:I,recordCanvas:y,preserveWhiteSpace:R,onSerialize:E,onIframeLoad:N,iframeLoadTimeout:x,onStylesheetLoad:F,stylesheetLoadTimeout:O,keepIframeSrcFn:void 0===D?function(){return!1}:D,newlyAddedElement:!1})}(document,{mirror:Je,blockClass:s,blockSelector:i,maskTextClass:c,maskTextSelector:l,inlineStylesheet:d,maskAllInputs:L,maskTextFn:m,slimDOM:B,dataURLOptions:y,recordCanvas:S,inlineImages:w,onSerialize:e=>{Z(e,Je)&&H.addIframe(e),G(e,Je)&&P.trackLinkElement(e),V(e)&&j.addShadowRoot(e.shadowRoot,document)},onIframeLoad:(e,t)=>{H.attachIframe(e,t),j.observeAttachShadow(e)},onStylesheetLoad:(e,t)=>{P.attachLinkElement(e,t)},keepIframeSrcFn:E});g&&(Ke(Ve({type:_.FullSnapshot,data:{node:g,initialOffset:{left:void 0!==window.pageXOffset?window.pageXOffset:(null===document||void 0===document?void 0:document.documentElement.scrollLeft)||(null===(n=null===(t=null===document||void 0===document?void 0:document.body)||void 0===t?void 0:t.parentElement)||void 0===n?void 0:n.scrollLeft)||(null===(r=null===document||void 0===document?void 0:document.body)||void 0===r?void 0:r.scrollLeft)||0,top:void 0!==window.pageYOffset?window.pageYOffset:(null===document||void 0===document?void 0:document.documentElement.scrollTop)||(null===(u=null===(a=null===document||void 0===document?void 0:document.body)||void 0===a?void 0:a.parentElement)||void 0===u?void 0:u.scrollTop)||(null===(h=null===document||void 0===document?void 0:document.body)||void 0===h?void 0:h.scrollTop)||0}}})),ne.forEach(e=>e.unlock()),document.adoptedStyleSheets&&document.adoptedStyleSheets.length>0&&P.adoptStyleSheets(document.adoptedStyleSheets,Je.getId(document)))};try{const e=[];e.push(R("DOMContentLoaded",()=>{Ke(Ve({type:_.DomContentLoaded,data:{}}))}));const t=e=>{var t;return Ie({mutationCb:Y,mousemoveCb:(e,t)=>Ke(Ve({type:_.IncrementalSnapshot,data:{source:t,positions:e}})),mouseInteractionCb:e=>Ke(Ve({type:_.IncrementalSnapshot,data:Object.assign({source:z.MouseInteraction},e)})),scrollCb:J,viewportResizeCb:e=>Ke(Ve({type:_.IncrementalSnapshot,data:Object.assign({source:z.ViewportResize},e)})),inputCb:e=>Ke(Ve({type:_.IncrementalSnapshot,data:Object.assign({source:z.Input},e)})),mediaInteractionCb:e=>Ke(Ve({type:_.IncrementalSnapshot,data:Object.assign({source:z.MediaInteraction},e)})),styleSheetRuleCb:e=>Ke(Ve({type:_.IncrementalSnapshot,data:Object.assign({source:z.StyleSheetRule},e)})),styleDeclarationCb:e=>Ke(Ve({type:_.IncrementalSnapshot,data:Object.assign({source:z.StyleDeclaration},e)})),canvasMutationCb:Q,fontCb:e=>Ke(Ve({type:_.IncrementalSnapshot,data:Object.assign({source:z.Font},e)})),selectionCb:e=>{Ke(Ve({type:_.IncrementalSnapshot,data:Object.assign({source:z.Selection},e)}))},blockClass:s,ignoreClass:a,maskTextClass:c,maskTextSelector:l,maskInputOptions:L,inlineStylesheet:d,sampling:C,recordCanvas:S,inlineImages:w,userTriggeredOnInput:A,collectFonts:k,doc:e,maskInputFn:p,maskTextFn:m,keepIframeSrcFn:E,blockSelector:i,slimDOMOptions:B,dataURLOptions:y,mirror:Je,iframeManager:H,stylesheetManager:P,shadowDomManager:j,canvasManager:ze,ignoreCSSAttributes:N,plugins:(null===(t=null==M?void 0:M.filter(e=>e.observer))||void 0===t?void 0:t.map(e=>({observer:e.observer,options:e.options,callback:t=>Ke(Ve({type:_.Plugin,data:{plugin:e.name,payload:t}}))})))||[]},f)};H.addLoadListener(n=>{e.push(t(n.contentDocument))});const n=()=>{_e(),e.push(t(document)),Ye=!0};return"interactive"===document.readyState||"complete"===document.readyState?n():e.push(R("load",()=>{Ke(Ve({type:_.Load,data:{}})),n()},window)),()=>{e.forEach(e=>e()),Ye=!1}}catch(e){}}Qe.addCustomEvent=(e,t)=>{if(!Ye)throw new Error("please add custom event after start recording");Ke(Ve({type:_.Custom,data:{tag:e,payload:t}}))},Qe.freezePage=()=>{ne.forEach(e=>e.freeze())},Qe.takeFullSnapshot=e=>{if(!Ye)throw new Error("please take full snapshot after start recording");_e(e)},Qe.mirror=Je;var Pe=Uint8Array,He=Uint16Array,je=Uint32Array,Xe=new Pe([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),qe=new Pe([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),$e=new Pe([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),et=function(e,t){for(var n=new He(31),r=0;r<31;++r)n[r]=t+=1<<e[r-1];var s=new je(n[30]);for(r=1;r<30;++r)for(var o=n[r];o<n[r+1];++o)s[o]=o-n[r]<<5|r;return[n,s]},tt=et(Xe,2),nt=tt[0],rt=tt[1];nt[28]=258,rt[258]=28;for(var st=et(qe,0)[1],ot=new He(32768),it=0;it<32768;++it){var at=(43690&it)>>>1|(21845&it)<<1;at=(61680&(at=(52428&at)>>>2|(13107&at)<<2))>>>4|(3855&at)<<4,ot[it]=((65280&at)>>>8|(255&at)<<8)>>>1}var ct=function(e,t,n){for(var r=e.length,s=0,o=new He(t);s<r;++s)++o[e[s]-1];var i,a=new He(t);for(s=0;s<t;++s)a[s]=a[s-1]+o[s-1]<<1;if(n){i=new He(1<<t);var c=15-t;for(s=0;s<r;++s)if(e[s])for(var l=s<<4|e[s],d=t-e[s],u=a[e[s]-1]++<<d,h=u|(1<<d)-1;u<=h;++u)i[ot[u]>>>c]=l}else for(i=new He(r),s=0;s<r;++s)i[s]=ot[a[e[s]-1]++]>>>15-e[s];return i},lt=new Pe(288);for(it=0;it<144;++it)lt[it]=8;for(it=144;it<256;++it)lt[it]=9;for(it=256;it<280;++it)lt[it]=7;for(it=280;it<288;++it)lt[it]=8;var dt=new Pe(32);for(it=0;it<32;++it)dt[it]=5;var ut=ct(lt,9,0),ht=ct(dt,5,0),gt=function(e){return(e/8|0)+(7&e&&1)},pt=function(e,t,n){(null==n||n>e.length)&&(n=e.length);var r=new(e instanceof He?He:e instanceof je?je:Pe)(n-t);return r.set(e.subarray(t,n)),r},mt=function(e,t,n){n<<=7&t;var r=t/8|0;e[r]|=n,e[r+1]|=n>>>8},ft=function(e,t,n){n<<=7&t;var r=t/8|0;e[r]|=n,e[r+1]|=n>>>8,e[r+2]|=n>>>16},It=function(e,t){for(var n=[],r=0;r<e.length;++r)e[r]&&n.push({s:r,f:e[r]});var s=n.length,o=n.slice();if(!s)return[new Pe(0),0];if(1==s){var i=new Pe(n[0].s+1);return i[n[0].s]=1,[i,1]}n.sort(function(e,t){return e.f-t.f}),n.push({s:-1,f:25001});var a=n[0],c=n[1],l=0,d=1,u=2;for(n[0]={s:-1,f:a.f+c.f,l:a,r:c};d!=s-1;)a=n[n[l].f<n[u].f?l++:u++],c=n[l!=d&&n[l].f<n[u].f?l++:u++],n[d++]={s:-1,f:a.f+c.f,l:a,r:c};var h=o[0].s;for(r=1;r<s;++r)o[r].s>h&&(h=o[r].s);var g=new He(h+1),p=Ct(n[d-1],g,0);if(p>t){r=0;var m=0,f=p-t,I=1<<f;for(o.sort(function(e,t){return g[t.s]-g[e.s]||e.f-t.f});r<s;++r){var C=o[r].s;if(!(g[C]>t))break;m+=I-(1<<p-g[C]),g[C]=t}for(m>>>=f;m>0;){var y=o[r].s;g[y]<t?m-=1<<t-g[y]++-1:++r}for(;r>=0&&m;--r){var v=o[r].s;g[v]==t&&(--g[v],++m)}p=t}return[new Pe(g),p]},Ct=function(e,t,n){return-1==e.s?Math.max(Ct(e.l,t,n+1),Ct(e.r,t,n+1)):t[e.s]=n},yt=function(e){for(var t=e.length;t&&!e[--t];);for(var n=new He(++t),r=0,s=e[0],o=1,i=function(e){n[r++]=e},a=1;a<=t;++a)if(e[a]==s&&a!=t)++o;else{if(!s&&o>2){for(;o>138;o-=138)i(32754);o>2&&(i(o>10?o-11<<5|28690:o-3<<5|12305),o=0)}else if(o>3){for(i(s),--o;o>6;o-=6)i(8304);o>2&&(i(o-3<<5|8208),o=0)}for(;o--;)i(s);o=1,s=e[a]}return[n.subarray(0,r),t]},vt=function(e,t){for(var n=0,r=0;r<t.length;++r)n+=e[r]*t[r];return n},St=function(e,t,n){var r=n.length,s=gt(t+2);e[s]=255&r,e[s+1]=r>>>8,e[s+2]=255^e[s],e[s+3]=255^e[s+1];for(var o=0;o<r;++o)e[s+o+4]=n[o];return 8*(s+4+r)},bt=function(e,t,n,r,s,o,i,a,c,l,d){mt(t,d++,n),++s[256];for(var u=It(s,15),h=u[0],g=u[1],p=It(o,15),m=p[0],f=p[1],I=yt(h),C=I[0],y=I[1],v=yt(m),S=v[0],b=v[1],A=new He(19),k=0;k<C.length;++k)A[31&C[k]]++;for(k=0;k<S.length;++k)A[31&S[k]]++;for(var w=It(A,7),M=w[0],T=w[1],R=19;R>4&&!M[$e[R-1]];--R);var E,N,x,F,O=l+5<<3,D=vt(s,lt)+vt(o,dt)+i,L=vt(s,h)+vt(o,m)+i+14+3*R+vt(A,M)+(2*A[16]+3*A[17]+7*A[18]);if(O<=D&&O<=L)return St(t,d,e.subarray(c,c+l));if(mt(t,d,1+(L<D)),d+=2,L<D){E=ct(h,g,0),N=h,x=ct(m,f,0),F=m;var B=ct(M,T,0);mt(t,d,y-257),mt(t,d+5,b-1),mt(t,d+10,R-4),d+=14;for(k=0;k<R;++k)mt(t,d+3*k,M[$e[k]]);d+=3*R;for(var U=[C,S],W=0;W<2;++W){var Z=U[W];for(k=0;k<Z.length;++k){var G=31&Z[k];mt(t,d,B[G]),d+=M[G],G>15&&(mt(t,d,Z[k]>>>5&127),d+=Z[k]>>>12)}}}else E=ut,N=lt,x=ht,F=dt;for(k=0;k<a;++k)if(r[k]>255){G=r[k]>>>18&31;ft(t,d,E[G+257]),d+=N[G+257],G>7&&(mt(t,d,r[k]>>>23&31),d+=Xe[G]);var V=31&r[k];ft(t,d,x[V]),d+=F[V],V>3&&(ft(t,d,r[k]>>>5&8191),d+=qe[V])}else ft(t,d,E[r[k]]),d+=N[r[k]];return ft(t,d,E[256]),d+N[256]},At=new je([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),kt=function(e,t,n,r,s){return function(e,t,n,r,s,o){var i=e.length,a=new Pe(r+i+5*(1+Math.floor(i/7e3))+s),c=a.subarray(r,a.length-s),l=0;if(!t||i<8)for(var d=0;d<=i;d+=65535){var u=d+65535;u<i?l=St(c,l,e.subarray(d,u)):(c[d]=o,l=St(c,l,e.subarray(d,i)))}else{for(var h=At[t-1],g=h>>>13,p=8191&h,m=(1<<n)-1,f=new He(32768),I=new He(m+1),C=Math.ceil(n/3),y=2*C,v=function(t){return(e[t]^e[t+1]<<C^e[t+2]<<y)&m},S=new je(25e3),b=new He(288),A=new He(32),k=0,w=0,M=(d=0,0),T=0,R=0;d<i;++d){var E=v(d),N=32767&d,x=I[E];if(f[N]=x,I[E]=N,T<=d){var F=i-d;if((k>7e3||M>24576)&&F>423){l=bt(e,c,0,S,b,A,w,M,R,d-R,l),M=k=w=0,R=d;for(var O=0;O<286;++O)b[O]=0;for(O=0;O<30;++O)A[O]=0}var D=2,L=0,B=p,U=N-x&32767;if(F>2&&E==v(d-U))for(var W=Math.min(g,F)-1,Z=Math.min(32767,d),G=Math.min(258,F);U<=Z&&--B&&N!=x;){if(e[d+D]==e[d+D-U]){for(var V=0;V<G&&e[d+V]==e[d+V-U];++V);if(V>D){if(D=V,L=U,V>W)break;var K=Math.min(U,V-2),_=0;for(O=0;O<K;++O){var z=d-U+O+32768&32767,Y=z-f[z]+32768&32767;Y>_&&(_=Y,x=z)}}}U+=(N=x)-(x=f[N])+32768&32767}if(L){S[M++]=268435456|rt[D]<<18|st[L];var J=31&rt[D],Q=31&st[L];w+=Xe[J]+qe[Q],++b[257+J],++A[Q],T=d+D,++k}else S[M++]=e[d],++b[e[d]]}}l=bt(e,c,o,S,b,A,w,M,R,d-R,l)}return pt(a,0,r+gt(l)+s)}(e,null==t.level?6:t.level,null==t.mem?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(e.length)))):12+t.mem,n,r,!0)};function wt(e,t){void 0===t&&(t={});var n=function(){var e=1,t=0;return{p:function(n){for(var r=e,s=t,o=n.length,i=0;i!=o;){for(var a=Math.min(i+5552,o);i<a;++i)s+=r+=n[i];r%=65521,s%=65521}e=r,t=s},d:function(){return(e>>>8<<16|(255&t)<<8|t>>>8)+2*((255&e)<<23)}}}();n.p(e);var r,s,o,i=kt(e,t,2,4);return r=i,s=t.level,o=0==s?0:s<6?1:9==s?3:2,r[0]=120,r[1]=o<<6|(o?32-2*o:1),function(e,t,n){for(;n;++t)e[t]=n,n>>>=8}(i,i.length-4,n.d()),i}const Mt=e=>{const t={...e,v:"v1"};return function(e){for(var t="",n=0;n<e.length;){var r=e[n++];t+=String.fromCharCode(r)}return t}(wt(function(e,t){var n=e.length;if("undefined"!=typeof TextEncoder)return(new TextEncoder).encode(e);for(var r=new Pe(e.length+(e.length>>>1)),s=0,o=function(e){r[s++]=e},i=0;i<n;++i){if(s+5>r.length){var a=new Pe(s+8+(n-i<<1));a.set(r),r=a}var c=e.charCodeAt(i);c<128||t?o(c):c<2048?(o(192|c>>>6),o(128|63&c)):c>55295&&c<57344?(o(240|(c=65536+(1047552&c)|1023&e.charCodeAt(++i))>>>18),o(128|c>>>12&63),o(128|c>>>6&63),o(128|63&c)):(o(224|c>>>12),o(128|c>>>6&63),o(128|63&c))}return pt(r,0,s)}(JSON.stringify(t))))};exports.default=class{constructor(e){this.name="session-tracker",this.version='"0.9.4"',this.context=null,this.config={},this.userConfig=null,this.sessionStartTime=0,this.isActive=!1,this.stopRecordingFn=null,this.sessionEvents=[],this.sessionId="",this.currentSessionSize=0,this.lastBatchTime=0,this.activeBatchCount=0,this.userId="",this.appId="",this.pendingEvents=[],this.eventsInFlight=[],this.sentEventCount=0,this.isSendingBatch=!1,this.delayedS3Url=null,this.delayedUrlExpiry=0,this.delayedUrlRefreshTimer=null,this.userConfig=e||{}}init(e,t){this.context=e;const n="object"==typeof t?.webSessions?t?.webSessions:null,r={enableSessionRecording:!1!==t?.webSessions&&(!0===t?.webSessions||!1!==n?.enabled),maxBatchSize:1048576,maxSessionDuration:null,batchSize:150,batchInterval:3e4,minimumSessionDuration:5e3,compressionEnabled:!1,recordingOptions:{recordCanvas:!0,recordCrossOriginIframes:!1,recordAfter:"DOMContentLoaded",maskAllInputs:!1,maskInputOptions:{password:!0,email:!0,text:!1},blockClass:"sensitive-field",slimDOMOptions:{script:!1,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaDescKeywords:!0,headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaAuthorship:!0,headMetaVerification:!0},sampling:{scroll:150,mouseInteraction:!0,input:"last",mutation:!0},...this.userConfig?this.userConfig:{},...this.config.recordingOptions?this.config.recordingOptions:{}}};this.config={...r}}start(){if(!this.context)return;if(this.isActive)return;this.delayedUrlRefreshTimer&&(clearTimeout(this.delayedUrlRefreshTimer),this.delayedUrlRefreshTimer=null),this.isActive=!0,this.userId=this.context.userManager.getUserId(),this.appId=this.context.appManager.getAppId();const e=String(this.context.userManager.getSessionId());(!this.sessionId||this.sessionId!==e)&&(this.sessionEvents=[],this.pendingEvents=[],this.eventsInFlight=[],this.currentSessionSize=0,this.sentEventCount=0,this.sessionStartTime=Date.now(),this.delayedS3Url=null,this.delayedUrlExpiry=0),this.sessionId=e,this.config.enableSessionRecording&&this.startRecording()}stop(){this.isActive&&this.stopRecording()}destroy(){this.stopRecording(),this.pendingEvents=[],this.eventsInFlight=[],this.sessionEvents=[],this.currentSessionSize=0,this.sentEventCount=0,this.delayedS3Url=null,this.delayedUrlExpiry=0,this.context?.removePluginField("recordingSessionId"),this.context?.setPluginField("isRecordingActive",!1),this.context=null}onEvent(e,t){this.isActive&&"session_start"===e&&(this.sessionStartTime=Date.now())}async onUserChange(e){this.isActive&&(await this.sendBatchToBackend(),this.stopRecording(),this.isActive=!1,this.start())}async onFocus(){this.pendingEvents.length>0&&await this.sendBatchToBackend(),this.isActive||this.start()}onBlur(){this.isActive&&(this.sendFinalBatch().catch(e=>{this.context?.logger.error(e)}),this.stopRecording(!0))}async onBeforeUnload(){const e=this.pendingEvents.length>0||this.eventsInFlight.length>0;(this.isActive||e)&&this.sendFinalBatch().catch(e=>{this.context?.logger.error(e)})}async onTrackingChange(e){e?this.isActive||this.start():this.isActive&&(await this.sendBatchToBackend(),this.stopRecording())}async onSessionStart(){await this.sendBatchToBackend(),this.isActive||this.start()}stopRecording(e=!1){e||this.context?.setPluginField("isRecordingActive",!1),this.isActive=!1,this.delayedUrlRefreshTimer&&(clearTimeout(this.delayedUrlRefreshTimer),this.delayedUrlRefreshTimer=null),this.stopRecordingFn&&(this.stopRecordingFn(),this.stopRecordingFn=null)}async startRecording(){if(!this.context)return;this.lastBatchTime=Date.now(),this.isSendingBatch=!1;const e=Date.now();if(!this.delayedS3Url||this.delayedUrlExpiry>0&&e>this.delayedUrlExpiry)this.fetchDelayedUrl();else if(this.delayedS3Url){const t=Math.max(0,this.delayedUrlExpiry-e);this.scheduleDelayedUrlRefresh(t+1e4)}const t=this.context.getPluginField("recordingSessionId"),n=!!t&&t===this.context.userManager.getSessionId(),r=this.context.getPluginField("isRecordingActive");if(n&&r)this.startSessionRecording();else try{const e=this.context.api.buildUrl(["sessions","configurations","get"],{appId:this.appId}),t=await this.sendRequest(e,null,"GET");if(t&&t.data){const e=t.data;if(e.blocked||!e.active)return this.context.logger.debug("Session configuration is "+(e.blocked?"blocked":"inactive")),void this.context.setPluginField("isRecordingActive",!1);100*Math.random()<e.record_chance_percent?(this.context.setPluginField("isRecordingActive",!0),this.startSessionRecording()):this.context.setPluginField("isRecordingActive",!1)}}catch(e){this.context.logger.error("Failed to fetch session configuration",{error:e}),this.context.setPluginField("isRecordingActive",!1)}}startSessionRecording(){if(!this.config.enableSessionRecording)return;this.context?.setPluginField("recordingSessionId",this.context?.userManager.getSessionId()),this.lastBatchTime=Date.now();const e={emit:e=>{this.addEventToSession(e),this.pendingEvents.push(e),this.currentSessionSize+=JSON.stringify(e).length,e.type,this.checkBatchLimits()},...this.config.recordingOptions};this.config.compressionEnabled&&(e.packFn=Mt);const t=Qe(e);this.stopRecordingFn=t||null}addEventToSession(e){this.sessionEvents.push(e);this.sessionEvents.length>1e4&&(this.sessionEvents=this.sessionEvents.slice(-Math.floor(5e3)))}hasMinimumSessionDuration(){return Date.now()-this.sessionStartTime>=this.config.minimumSessionDuration}checkBatchLimits(){if(this.isSendingBatch)return;const e=Date.now()-this.sessionStartTime,t=this.pendingEvents.length>=this.config.batchSize,n=this.currentSessionSize>=this.config.maxBatchSize,r=this.config.maxSessionDuration&&e>=this.config.maxSessionDuration,s=Date.now()-this.lastBatchTime>=this.config.batchInterval;(t||n||r||s)&&this.sendBatchToBackend().catch(e=>{this.context?.logger.error("Error in checkBatchLimits sendBatchToBackend",{error:e instanceof Error?e.message:e,pendingEventsCount:this.pendingEvents.length})})}async sendBatchToBackend(){if(!this.pendingEvents.length||!this.context||this.isSendingBatch)return;if(!this.hasMinimumSessionDuration())return;this.isSendingBatch=!0,this.eventsInFlight=[...this.pendingEvents],this.pendingEvents=[];const e=this.eventsInFlight.reduce((e,t)=>e+JSON.stringify(t).length,0);this.currentSessionSize-=e,this.currentSessionSize=Math.max(0,this.currentSessionSize),this.activeBatchCount++;try{const e=this.eventsInFlight[0]?.timestamp||Date.now(),t=this.eventsInFlight[this.eventsInFlight.length-1]?.timestamp||Date.now(),n={appId:this.appId,session_id:this.sessionId,user_id:this.userId,start_time:e,end_time:t},r=this.context.api.buildUrl(["sessions","add"],n),s=await this.sendRequest(r,null,"GET",{},!0);if(204===s.status)return this.context.logger.warning("Session storage exceeded"),this.eventsInFlight=[],void this.stop();const o=s.data,i="string"==typeof o?o:o?.url;if(!i)throw new Error("No S3 URL returned");await this.uploadToS3(i,this.eventsInFlight),this.sentEventCount+=this.eventsInFlight.length,this.lastBatchTime=Date.now(),this.eventsInFlight=[]}catch(t){throw this.context?.logger.error("Error sending session batch to backend",{error:t instanceof Error?t.message:t,eventsCount:this.eventsInFlight.length}),this.pendingEvents.unshift(...this.eventsInFlight),this.eventsInFlight=[],this.currentSessionSize+=e,t}finally{this.activeBatchCount--,this.isSendingBatch=!1,this.pendingEvents.length>0&&this.checkBatchLimits()}}async fetchDelayedUrl(){if(this.context)try{const e=this.context.api.buildUrl(["sessions","addDelayed"],{session_id:this.sessionId,appId:this.appId,user_id:this.userId}),t=await this.sendRequest(e,null,"GET");if(t&&t.data){const e=t.data;this.delayedS3Url=e.url,this.delayedUrlExpiry=Date.now()+e.ttl,this.scheduleDelayedUrlRefresh(e.ttl)}}catch(e){this.context.logger.error("Failed to fetch delayed URL",{error:e})}}scheduleDelayedUrlRefresh(e){this.delayedUrlRefreshTimer&&clearTimeout(this.delayedUrlRefreshTimer);const t=Math.max(0,e-1e4);this.delayedUrlRefreshTimer=setTimeout(()=>{this.fetchDelayedUrl()},t)}async sendFinalBatch(){if(!this.context)return;if(!this.hasMinimumSessionDuration())return;const e=[...this.eventsInFlight,...this.pendingEvents];if(!e.length)return;if(!this.delayedS3Url)return void this.context.logger.error("No delayed URL available for final batch - cannot send.");const t=[...this.pendingEvents],n=[...this.eventsInFlight];this.pendingEvents=[],this.eventsInFlight=[],this.currentSessionSize=0;const r=JSON.stringify(e),s=new Blob([r],{type:"application/json"});try{const e=await fetch(this.delayedS3Url,{method:"PUT",body:s,keepalive:!0,credentials:"omit"});if(!e.ok)throw new Error(`S3 upload failed: ${e.statusText}`);this.lastBatchTime=Date.now()}catch(e){this.pendingEvents=t,this.eventsInFlight=n,this.context?.logger.error(`Failed to send final batch: ${e}`)}}async uploadToS3(e,t){const n=JSON.stringify(t),r=await fetch(e,{method:"PUT",body:n});if(!r.ok)throw new Error(`S3 upload failed: ${r.statusText}`)}sendRequest(e,t,n="POST",r={},s=!1){return new Promise((o,i)=>{if(!this.context)return i(new Error("No context"));const a=this.context.api.createRequestStructure(e,t,r,n);this.context.api.sendRequest(`req-${Date.now()}-${Math.random()}`,a,(e,t,n)=>{e>=200&&e<300?o({status:e,data:t}):i({status:e,data:t,error:n})},{gzip:!1,method:n,noContentType:s})})}};
|
|
15
|
+
***************************************************************************** */function Se(e,t,n,r){return new(n||(n=Promise))(function(t,s){function o(e){try{a(r.next(e))}catch(e){s(e)}}function i(e){try{a(r.throw(e))}catch(e){s(e)}}function a(e){var r;e.done?t(e.value):(r=e.value,r instanceof n?r:new n(function(e){e(r)})).then(o,i)}a((r=r.apply(e,[])).next())})}for(var be="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Ae="undefined"==typeof Uint8Array?[]:new Uint8Array(256),ke=0;ke<64;ke++)Ae[be.charCodeAt(ke)]=ke;const we=new Map;const Me=(e,t,n)=>{if(!e||!Ee(e,t)&&"object"!=typeof e)return;const r=function(e,t){let n=we.get(e);return n||(n=new Map,we.set(e,n)),n.has(t)||n.set(t,[]),n.get(t)}(n,e.constructor.name);let s=r.indexOf(e);return-1===s&&(s=r.length,r.push(e)),s};function Te(e,t,n){if(e instanceof Array)return e.map(e=>Te(e,t,n));if(null===e)return e;if(e instanceof Float32Array||e instanceof Float64Array||e instanceof Int32Array||e instanceof Uint32Array||e instanceof Uint8Array||e instanceof Uint16Array||e instanceof Int16Array||e instanceof Int8Array||e instanceof Uint8ClampedArray){return{rr_type:e.constructor.name,args:[Object.values(e)]}}if(e instanceof ArrayBuffer){const t=e.constructor.name,n=function(e){var t,n=new Uint8Array(e),r=n.length,s="";for(t=0;t<r;t+=3)s+=be[n[t]>>2],s+=be[(3&n[t])<<4|n[t+1]>>4],s+=be[(15&n[t+1])<<2|n[t+2]>>6],s+=be[63&n[t+2]];return r%3==2?s=s.substring(0,s.length-1)+"=":r%3==1&&(s=s.substring(0,s.length-2)+"=="),s}(e);return{rr_type:t,base64:n}}if(e instanceof DataView){return{rr_type:e.constructor.name,args:[Te(e.buffer,t,n),e.byteOffset,e.byteLength]}}if(e instanceof HTMLImageElement){const t=e.constructor.name,{src:n}=e;return{rr_type:t,src:n}}if(e instanceof HTMLCanvasElement){return{rr_type:"HTMLImageElement",src:e.toDataURL()}}if(e instanceof ImageData){return{rr_type:e.constructor.name,args:[Te(e.data,t,n),e.width,e.height]}}if(Ee(e,t)||"object"==typeof e){return{rr_type:e.constructor.name,index:Me(e,t,n)}}return e}const Re=(e,t,n)=>[...e].map(e=>Te(e,t,n)),Ee=(e,t)=>{const n=["WebGLActiveInfo","WebGLBuffer","WebGLFramebuffer","WebGLProgram","WebGLRenderbuffer","WebGLShader","WebGLShaderPrecisionFormat","WebGLTexture","WebGLUniformLocation","WebGLVertexArrayObject","WebGLVertexArrayObjectOES"].filter(e=>"function"==typeof t[e]);return Boolean(n.find(n=>e instanceof t[n]))};function Ne(e,t,n){const r=[];try{const s=F(e.HTMLCanvasElement.prototype,"getContext",function(e){return function(r,...s){return L(this,t,n,!0)||"__context"in this||(this.__context=r),e.apply(this,[r,...s])}});r.push(s)}catch(e){}return()=>{r.forEach(e=>e())}}function xe(e,t,n,r,s,o,i){const a=[],c=Object.getOwnPropertyNames(e);for(const o of c)if(!["isContextLost","canvas","drawingBufferWidth","drawingBufferHeight"].includes(o))try{if("function"!=typeof e[o])continue;const c=F(e,o,function(e){return function(...a){const c=e.apply(this,a);if(Me(c,i,this),!L(this.canvas,r,s,!0)){const e=Re([...a],i,this),r={type:t,property:o,args:e};n(this.canvas,r)}return c}});a.push(c)}catch(r){const s=x(e,o,{set(e){n(this.canvas,{type:t,property:o,args:[e],setter:!0})}});a.push(s)}return a}var Fe=null;try{var Oe="undefined"!=typeof module&&"function"==typeof module.require&&module.require("worker_threads")||"function"==typeof __non_webpack_require__&&__non_webpack_require__("worker_threads")||"function"==typeof require&&require("worker_threads");Fe=Oe.Worker}catch(e){}function De(e,t,n){var r=function(e){return Buffer.from(e,"base64").toString("utf8")}(e),s=r.indexOf("\n",10)+1,o=r.substring(s)+"";return function(e){return new Fe(o,Object.assign({},e,{eval:!0}))}}function Le(e,t,n){var r=function(e){return atob(e)}(e),s=r.indexOf("\n",10)+1,o=r.substring(s)+"",i=new Blob([o],{type:"application/javascript"});return URL.createObjectURL(i)}var Be="[object process]"===Object.prototype.toString.call("undefined"!=typeof process?process:0);var Ue,We=(Ue="Lyogcm9sbHVwLXBsdWdpbi13ZWItd29ya2VyLWxvYWRlciAqLwooZnVuY3Rpb24gKCkgewogICAgJ3VzZSBzdHJpY3QnOwoKICAgIC8qISAqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKg0KICAgIENvcHlyaWdodCAoYykgTWljcm9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sb2IoZGF0YVVSTE9wdGlvbnMpOw0KICAgICAgICAgICAgICAgIGNvbnN0IHR5cGUgPSBibG9iLnR5cGU7DQogICAgICAgICAgICAgICAgY29uc3QgYXJyYXlCdWZmZXIgPSB5aWVsZCBibG9iLmFycmF5QnVmZmVyKCk7DQogICAgICAgICAgICAgICAgY29uc3QgYmFzZTY0ID0gZW5jb2RlKGFycmF5QnVmZmVyKTsNCiAgICAgICAgICAgICAgICBpZiAoIWxhc3RCbG9iTWFwLmhhcyhpZCkgJiYgKHlpZWxkIHRyYW5zcGFyZW50QmFzZTY0KSA9PT0gYmFzZTY0KSB7DQogICAgICAgICAgICAgICAgICAgIGxhc3RCbG9iTWFwLnNldChpZCwgYmFzZTY0KTsNCiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHdvcmtlci5wb3N0TWVzc2FnZSh7IGlkIH0pOw0KICAgICAgICAgICAgICAgIH0NCiAgICAgICAgICAgICAgICBpZiAobGFzdEJsb2JNYXAuZ2V0KGlkKSA9PT0gYmFzZTY0KQ0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gd29ya2VyLnBvc3RNZXNzYWdlKHsgaWQgfSk7DQogICAgICAgICAgICAgICAgd29ya2VyLnBvc3RNZXNzYWdlKHsNCiAgICAgICAgICAgICAgICAgICAgaWQsDQogICAgICAgICAgICAgICAgICAgIHR5cGUsDQogICAgICAgICAgICAgICAgICAgIGJhc2U2NCwNCiAgICAgICAgICAgICAgICAgICAgd2lkdGgsDQogICAgICAgICAgICAgICAgICAgIGhlaWdodCwNCiAgICAgICAgICAgICAgICB9KTsNCiAgICAgICAgICAgICAgICBsYXN0QmxvYk1hcC5zZXQoaWQsIGJhc2U2NCk7DQogICAgICAgICAgICB9DQogICAgICAgICAgICBlbHNlIHsNCiAgICAgICAgICAgICAgICByZXR1cm4gd29ya2VyLnBvc3RNZXNzYWdlKHsgaWQ6IGUuZGF0YS5pZCB9KTsNCiAgICAgICAgICAgIH0NCiAgICAgICAgfSk7DQogICAgfTsKCn0pKCk7Cgo=",Be?De(Ue):function(e){var t;return function(n){return t=t||Le(e),new Worker(t,n)}}(Ue));class Ze{constructor(e){this.pendingCanvasMutations=new Map,this.rafStamps={latestId:0,invokeId:null},this.frozen=!1,this.locked=!1,this.processMutation=(e,t)=>{!(this.rafStamps.invokeId&&this.rafStamps.latestId!==this.rafStamps.invokeId)&&this.rafStamps.invokeId||(this.rafStamps.invokeId=this.rafStamps.latestId),this.pendingCanvasMutations.has(e)||this.pendingCanvasMutations.set(e,[]),this.pendingCanvasMutations.get(e).push(t)};const{sampling:t="all",win:n,blockClass:r,blockSelector:s,recordCanvas:o,dataURLOptions:i}=e;this.mutationCb=e.mutationCb,this.mirror=e.mirror,o&&"all"===t&&this.initCanvasMutationObserver(n,r,s),o&&"number"==typeof t&&this.initCanvasFPSObserver(t,n,r,s,{dataURLOptions:i})}reset(){this.pendingCanvasMutations.clear(),this.resetObservers&&this.resetObservers()}freeze(){this.frozen=!0}unfreeze(){this.frozen=!1}lock(){this.locked=!0}unlock(){this.locked=!1}initCanvasFPSObserver(e,t,n,r,s){const o=Ne(t,n,r),i=new Map,a=new We;a.onmessage=e=>{const{id:t}=e.data;if(i.set(t,!1),!("base64"in e.data))return;const{base64:n,type:r,width:s,height:o}=e.data;this.mutationCb({id:t,type:J["2D"],commands:[{property:"clearRect",args:[0,0,s,o]},{property:"drawImage",args:[{rr_type:"ImageBitmap",args:[{rr_type:"Blob",data:[{rr_type:"ArrayBuffer",base64:n}],type:r}]},0,0]}]})};const c=1e3/e;let l,d=0;const u=e=>{d&&e-d<c||(d=e,(()=>{const e=[];return t.document.querySelectorAll("canvas").forEach(t=>{L(t,n,r,!0)||e.push(t)}),e})().forEach(e=>Se(this,0,void 0,function*(){var t;const n=this.mirror.getId(e);if(i.get(n))return;if(i.set(n,!0),["webgl","webgl2"].includes(e.__context)){const n=e.getContext(e.__context);!1===(null===(t=null==n?void 0:n.getContextAttributes())||void 0===t?void 0:t.preserveDrawingBuffer)&&(null==n||n.clear(n.COLOR_BUFFER_BIT))}const r=yield createImageBitmap(e);a.postMessage({id:n,bitmap:r,width:e.width,height:e.height,dataURLOptions:s.dataURLOptions},[r])}))),l=requestAnimationFrame(u)};l=requestAnimationFrame(u),this.resetObservers=()=>{o(),cancelAnimationFrame(l)}}initCanvasMutationObserver(e,t,n){this.startRAFTimestamping(),this.startPendingCanvasMutationFlusher();const r=Ne(e,t,n),s=function(e,t,n,r){const s=[],o=Object.getOwnPropertyNames(t.CanvasRenderingContext2D.prototype);for(const i of o)try{if("function"!=typeof t.CanvasRenderingContext2D.prototype[i])continue;const o=F(t.CanvasRenderingContext2D.prototype,i,function(s){return function(...o){return L(this.canvas,n,r,!0)||setTimeout(()=>{const n=Re([...o],t,this);e(this.canvas,{type:J["2D"],property:i,args:n})},0),s.apply(this,o)}});s.push(o)}catch(n){const r=x(t.CanvasRenderingContext2D.prototype,i,{set(t){e(this.canvas,{type:J["2D"],property:i,args:[t],setter:!0})}});s.push(r)}return()=>{s.forEach(e=>e())}}(this.processMutation.bind(this),e,t,n),o=function(e,t,n,r){const s=[];return s.push(...xe(t.WebGLRenderingContext.prototype,J.WebGL,e,n,r,0,t)),void 0!==t.WebGL2RenderingContext&&s.push(...xe(t.WebGL2RenderingContext.prototype,J.WebGL2,e,n,r,0,t)),()=>{s.forEach(e=>e())}}(this.processMutation.bind(this),e,t,n,this.mirror);this.resetObservers=()=>{r(),s(),o()}}startPendingCanvasMutationFlusher(){requestAnimationFrame(()=>this.flushPendingCanvasMutations())}startRAFTimestamping(){const e=t=>{this.rafStamps.latestId=t,requestAnimationFrame(e)};requestAnimationFrame(e)}flushPendingCanvasMutations(){this.pendingCanvasMutations.forEach((e,t)=>{const n=this.mirror.getId(t);this.flushPendingCanvasMutationFor(t,n)}),requestAnimationFrame(()=>this.flushPendingCanvasMutations())}flushPendingCanvasMutationFor(e,t){if(this.frozen||this.locked)return;const n=this.pendingCanvasMutations.get(e);if(!n||-1===t)return;const r=n.map(e=>{const t=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var s=0;for(r=Object.getOwnPropertySymbols(e);s<r.length;s++)t.indexOf(r[s])<0&&Object.prototype.propertyIsEnumerable.call(e,r[s])&&(n[r[s]]=e[r[s]])}return n}(e,["type"]);return t}),{type:s}=n[0];this.mutationCb({id:t,type:s,commands:r}),this.pendingCanvasMutations.delete(e)}}class Ge{constructor(e){this.trackedLinkElements=new WeakSet,this.styleMirror=new K,this.mutationCb=e.mutationCb,this.adoptedStyleSheetCb=e.adoptedStyleSheetCb}attachLinkElement(e,t){"_cssText"in t.attributes&&this.mutationCb({adds:[],removes:[],texts:[],attributes:[{id:t.id,attributes:t.attributes}]}),this.trackLinkElement(e)}trackLinkElement(e){this.trackedLinkElements.has(e)||(this.trackedLinkElements.add(e),this.trackStylesheetInLinkElement(e))}adoptStyleSheets(e,t){if(0===e.length)return;const n={id:t,styleIds:[]},r=[];for(const t of e){let e;if(this.styleMirror.has(t))e=this.styleMirror.getId(t);else{e=this.styleMirror.add(t);const n=Array.from(t.rules||CSSRule);r.push({styleId:e,rules:n.map((e,t)=>({rule:s(e),index:t}))})}n.styleIds.push(e)}r.length>0&&(n.styles=r),this.adoptedStyleSheetCb(n)}reset(){this.styleMirror.reset(),this.trackedLinkElements=new WeakSet}trackStylesheetInLinkElement(e){}}function Ve(e){return Object.assign(Object.assign({},e),{timestamp:Date.now()})}let Ke,_e,ze,Ye=!1;const Je=new o;function Qe(e={}){const{emit:t,checkoutEveryNms:n,checkoutEveryNth:r,blockClass:s="rr-block",blockSelector:i=null,ignoreClass:a="rr-ignore",maskTextClass:c="rr-mask",maskTextSelector:l=null,inlineStylesheet:d=!0,maskAllInputs:u,maskInputOptions:h,slimDOMOptions:g,maskInputFn:p,maskTextFn:m,hooks:f,packFn:I,sampling:C={},dataURLOptions:y={},mousemoveWait:v,recordCanvas:S=!1,recordCrossOriginIframes:b=!1,userTriggeredOnInput:A=!1,collectFonts:k=!1,inlineImages:w=!1,plugins:M,keepIframeSrcFn:E=()=>!1,ignoreCSSAttributes:N=new Set([])}=e,x=!b||window.parent===window;let F=!1;if(!x)try{window.parent.document,F=!1}catch(e){F=!0}if(x&&!t)throw new Error("emit function is required");void 0!==v&&void 0===C.mousemove&&(C.mousemove=v),Je.reset();const L=!0===u?{color:!0,date:!0,"datetime-local":!0,email:!0,month:!0,number:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0,textarea:!0,select:!0,password:!0}:void 0!==h?h:{password:!0},B=!0===g||"all"===g?{script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaVerification:!0,headMetaAuthorship:"all"===g,headMetaDescKeywords:"all"===g}:g||{};let U;!function(e=window){"NodeList"in e&&!e.NodeList.prototype.forEach&&(e.NodeList.prototype.forEach=Array.prototype.forEach),"DOMTokenList"in e&&!e.DOMTokenList.prototype.forEach&&(e.DOMTokenList.prototype.forEach=Array.prototype.forEach),Node.prototype.contains||(Node.prototype.contains=(...e)=>{let t=e[0];if(!(0 in e))throw new TypeError("1 argument is required");do{if(this===t)return!0}while(t=t&&t.parentNode);return!1})}();let W=0;const K=e=>{for(const t of M||[])t.eventProcessor&&(e=t.eventProcessor(e));return I&&(e=I(e)),e};Ke=(e,s)=>{var o;if(!(null===(o=ne[0])||void 0===o?void 0:o.isFrozen())||e.type===_.FullSnapshot||e.type===_.IncrementalSnapshot&&e.data.source===z.Mutation||ne.forEach(e=>e.unfreeze()),x)null==t||t(K(e),s);else if(F){const t={type:"rrweb",event:K(e),isCheckout:s};window.parent.postMessage(t,"*")}if(e.type===_.FullSnapshot)U=e,W=0;else if(e.type===_.IncrementalSnapshot){if(e.data.source===z.Mutation&&e.data.isAttachIframe)return;W++;const t=r&&W>=r,s=n&&e.timestamp-U.timestamp>n;(t||s)&&_e(!0)}};const Y=e=>{Ke(Ve({type:_.IncrementalSnapshot,data:Object.assign({source:z.Mutation},e)}))},J=e=>Ke(Ve({type:_.IncrementalSnapshot,data:Object.assign({source:z.Scroll},e)})),Q=e=>Ke(Ve({type:_.IncrementalSnapshot,data:Object.assign({source:z.CanvasMutation},e)})),P=new Ge({mutationCb:Y,adoptedStyleSheetCb:e=>Ke(Ve({type:_.IncrementalSnapshot,data:Object.assign({source:z.AdoptedStyleSheet},e)}))}),H=new ye({mirror:Je,mutationCb:Y,stylesheetManager:P,recordCrossOriginIframes:b,wrappedEmit:Ke});for(const e of M||[])e.getMirror&&e.getMirror({nodeMirror:Je,crossOriginIframeMirror:H.crossOriginIframeMirror,crossOriginIframeStyleMirror:H.crossOriginIframeStyleMirror});ze=new Ze({recordCanvas:S,mutationCb:Q,win:window,blockClass:s,blockSelector:i,mirror:Je,sampling:C.canvas,dataURLOptions:y});const j=new ve({mutationCb:Y,scrollCb:J,bypassOptions:{blockClass:s,blockSelector:i,maskTextClass:c,maskTextSelector:l,inlineStylesheet:d,maskInputOptions:L,dataURLOptions:y,maskTextFn:m,maskInputFn:p,recordCanvas:S,inlineImages:w,sampling:C,slimDOMOptions:B,iframeManager:H,stylesheetManager:P,canvasManager:ze,keepIframeSrcFn:E},mirror:Je});_e=(e=!1)=>{var t,n,r,a,u,h;Ke(Ve({type:_.Meta,data:{href:window.location.href,width:D(),height:O()}}),e),P.reset(),ne.forEach(e=>e.lock());const g=function(e,t){var n=t||{},r=n.mirror,s=void 0===r?new o:r,i=n.blockClass,a=void 0===i?"rr-block":i,c=n.blockSelector,l=void 0===c?null:c,d=n.maskTextClass,u=void 0===d?"rr-mask":d,h=n.maskTextSelector,g=void 0===h?null:h,p=n.inlineStylesheet,m=void 0===p||p,f=n.inlineImages,I=void 0!==f&&f,C=n.recordCanvas,y=void 0!==C&&C,v=n.maskAllInputs,S=void 0!==v&&v,b=n.maskTextFn,A=n.maskInputFn,k=n.slimDOM,w=void 0!==k&&k,M=n.dataURLOptions,R=n.preserveWhiteSpace,E=n.onSerialize,N=n.onIframeLoad,x=n.iframeLoadTimeout,F=n.onStylesheetLoad,O=n.stylesheetLoadTimeout,D=n.keepIframeSrcFn;return T(e,{doc:e,mirror:s,blockClass:a,blockSelector:l,maskTextClass:u,maskTextSelector:g,skipChild:!1,inlineStylesheet:m,maskInputOptions:!0===S?{color:!0,date:!0,"datetime-local":!0,email:!0,month:!0,number:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0,textarea:!0,select:!0,password:!0}:!1===S?{password:!0}:S,maskTextFn:b,maskInputFn:A,slimDOMOptions:!0===w||"all"===w?{script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaDescKeywords:"all"===w,headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaAuthorship:!0,headMetaVerification:!0}:!1===w?{}:w,dataURLOptions:M,inlineImages:I,recordCanvas:y,preserveWhiteSpace:R,onSerialize:E,onIframeLoad:N,iframeLoadTimeout:x,onStylesheetLoad:F,stylesheetLoadTimeout:O,keepIframeSrcFn:void 0===D?function(){return!1}:D,newlyAddedElement:!1})}(document,{mirror:Je,blockClass:s,blockSelector:i,maskTextClass:c,maskTextSelector:l,inlineStylesheet:d,maskAllInputs:L,maskTextFn:m,slimDOM:B,dataURLOptions:y,recordCanvas:S,inlineImages:w,onSerialize:e=>{Z(e,Je)&&H.addIframe(e),G(e,Je)&&P.trackLinkElement(e),V(e)&&j.addShadowRoot(e.shadowRoot,document)},onIframeLoad:(e,t)=>{H.attachIframe(e,t),j.observeAttachShadow(e)},onStylesheetLoad:(e,t)=>{P.attachLinkElement(e,t)},keepIframeSrcFn:E});g&&(Ke(Ve({type:_.FullSnapshot,data:{node:g,initialOffset:{left:void 0!==window.pageXOffset?window.pageXOffset:(null===document||void 0===document?void 0:document.documentElement.scrollLeft)||(null===(n=null===(t=null===document||void 0===document?void 0:document.body)||void 0===t?void 0:t.parentElement)||void 0===n?void 0:n.scrollLeft)||(null===(r=null===document||void 0===document?void 0:document.body)||void 0===r?void 0:r.scrollLeft)||0,top:void 0!==window.pageYOffset?window.pageYOffset:(null===document||void 0===document?void 0:document.documentElement.scrollTop)||(null===(u=null===(a=null===document||void 0===document?void 0:document.body)||void 0===a?void 0:a.parentElement)||void 0===u?void 0:u.scrollTop)||(null===(h=null===document||void 0===document?void 0:document.body)||void 0===h?void 0:h.scrollTop)||0}}})),ne.forEach(e=>e.unlock()),document.adoptedStyleSheets&&document.adoptedStyleSheets.length>0&&P.adoptStyleSheets(document.adoptedStyleSheets,Je.getId(document)))};try{const e=[];e.push(R("DOMContentLoaded",()=>{Ke(Ve({type:_.DomContentLoaded,data:{}}))}));const t=e=>{var t;return Ie({mutationCb:Y,mousemoveCb:(e,t)=>Ke(Ve({type:_.IncrementalSnapshot,data:{source:t,positions:e}})),mouseInteractionCb:e=>Ke(Ve({type:_.IncrementalSnapshot,data:Object.assign({source:z.MouseInteraction},e)})),scrollCb:J,viewportResizeCb:e=>Ke(Ve({type:_.IncrementalSnapshot,data:Object.assign({source:z.ViewportResize},e)})),inputCb:e=>Ke(Ve({type:_.IncrementalSnapshot,data:Object.assign({source:z.Input},e)})),mediaInteractionCb:e=>Ke(Ve({type:_.IncrementalSnapshot,data:Object.assign({source:z.MediaInteraction},e)})),styleSheetRuleCb:e=>Ke(Ve({type:_.IncrementalSnapshot,data:Object.assign({source:z.StyleSheetRule},e)})),styleDeclarationCb:e=>Ke(Ve({type:_.IncrementalSnapshot,data:Object.assign({source:z.StyleDeclaration},e)})),canvasMutationCb:Q,fontCb:e=>Ke(Ve({type:_.IncrementalSnapshot,data:Object.assign({source:z.Font},e)})),selectionCb:e=>{Ke(Ve({type:_.IncrementalSnapshot,data:Object.assign({source:z.Selection},e)}))},blockClass:s,ignoreClass:a,maskTextClass:c,maskTextSelector:l,maskInputOptions:L,inlineStylesheet:d,sampling:C,recordCanvas:S,inlineImages:w,userTriggeredOnInput:A,collectFonts:k,doc:e,maskInputFn:p,maskTextFn:m,keepIframeSrcFn:E,blockSelector:i,slimDOMOptions:B,dataURLOptions:y,mirror:Je,iframeManager:H,stylesheetManager:P,shadowDomManager:j,canvasManager:ze,ignoreCSSAttributes:N,plugins:(null===(t=null==M?void 0:M.filter(e=>e.observer))||void 0===t?void 0:t.map(e=>({observer:e.observer,options:e.options,callback:t=>Ke(Ve({type:_.Plugin,data:{plugin:e.name,payload:t}}))})))||[]},f)};H.addLoadListener(n=>{e.push(t(n.contentDocument))});const n=()=>{_e(),e.push(t(document)),Ye=!0};return"interactive"===document.readyState||"complete"===document.readyState?n():e.push(R("load",()=>{Ke(Ve({type:_.Load,data:{}})),n()},window)),()=>{e.forEach(e=>e()),Ye=!1}}catch(e){}}Qe.addCustomEvent=(e,t)=>{if(!Ye)throw new Error("please add custom event after start recording");Ke(Ve({type:_.Custom,data:{tag:e,payload:t}}))},Qe.freezePage=()=>{ne.forEach(e=>e.freeze())},Qe.takeFullSnapshot=e=>{if(!Ye)throw new Error("please take full snapshot after start recording");_e(e)},Qe.mirror=Je;var Pe=Uint8Array,He=Uint16Array,je=Uint32Array,Xe=new Pe([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),qe=new Pe([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),$e=new Pe([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),et=function(e,t){for(var n=new He(31),r=0;r<31;++r)n[r]=t+=1<<e[r-1];var s=new je(n[30]);for(r=1;r<30;++r)for(var o=n[r];o<n[r+1];++o)s[o]=o-n[r]<<5|r;return[n,s]},tt=et(Xe,2),nt=tt[0],rt=tt[1];nt[28]=258,rt[258]=28;for(var st=et(qe,0)[1],ot=new He(32768),it=0;it<32768;++it){var at=(43690&it)>>>1|(21845&it)<<1;at=(61680&(at=(52428&at)>>>2|(13107&at)<<2))>>>4|(3855&at)<<4,ot[it]=((65280&at)>>>8|(255&at)<<8)>>>1}var ct=function(e,t,n){for(var r=e.length,s=0,o=new He(t);s<r;++s)++o[e[s]-1];var i,a=new He(t);for(s=0;s<t;++s)a[s]=a[s-1]+o[s-1]<<1;if(n){i=new He(1<<t);var c=15-t;for(s=0;s<r;++s)if(e[s])for(var l=s<<4|e[s],d=t-e[s],u=a[e[s]-1]++<<d,h=u|(1<<d)-1;u<=h;++u)i[ot[u]>>>c]=l}else for(i=new He(r),s=0;s<r;++s)i[s]=ot[a[e[s]-1]++]>>>15-e[s];return i},lt=new Pe(288);for(it=0;it<144;++it)lt[it]=8;for(it=144;it<256;++it)lt[it]=9;for(it=256;it<280;++it)lt[it]=7;for(it=280;it<288;++it)lt[it]=8;var dt=new Pe(32);for(it=0;it<32;++it)dt[it]=5;var ut=ct(lt,9,0),ht=ct(dt,5,0),gt=function(e){return(e/8|0)+(7&e&&1)},pt=function(e,t,n){(null==n||n>e.length)&&(n=e.length);var r=new(e instanceof He?He:e instanceof je?je:Pe)(n-t);return r.set(e.subarray(t,n)),r},mt=function(e,t,n){n<<=7&t;var r=t/8|0;e[r]|=n,e[r+1]|=n>>>8},ft=function(e,t,n){n<<=7&t;var r=t/8|0;e[r]|=n,e[r+1]|=n>>>8,e[r+2]|=n>>>16},It=function(e,t){for(var n=[],r=0;r<e.length;++r)e[r]&&n.push({s:r,f:e[r]});var s=n.length,o=n.slice();if(!s)return[new Pe(0),0];if(1==s){var i=new Pe(n[0].s+1);return i[n[0].s]=1,[i,1]}n.sort(function(e,t){return e.f-t.f}),n.push({s:-1,f:25001});var a=n[0],c=n[1],l=0,d=1,u=2;for(n[0]={s:-1,f:a.f+c.f,l:a,r:c};d!=s-1;)a=n[n[l].f<n[u].f?l++:u++],c=n[l!=d&&n[l].f<n[u].f?l++:u++],n[d++]={s:-1,f:a.f+c.f,l:a,r:c};var h=o[0].s;for(r=1;r<s;++r)o[r].s>h&&(h=o[r].s);var g=new He(h+1),p=Ct(n[d-1],g,0);if(p>t){r=0;var m=0,f=p-t,I=1<<f;for(o.sort(function(e,t){return g[t.s]-g[e.s]||e.f-t.f});r<s;++r){var C=o[r].s;if(!(g[C]>t))break;m+=I-(1<<p-g[C]),g[C]=t}for(m>>>=f;m>0;){var y=o[r].s;g[y]<t?m-=1<<t-g[y]++-1:++r}for(;r>=0&&m;--r){var v=o[r].s;g[v]==t&&(--g[v],++m)}p=t}return[new Pe(g),p]},Ct=function(e,t,n){return-1==e.s?Math.max(Ct(e.l,t,n+1),Ct(e.r,t,n+1)):t[e.s]=n},yt=function(e){for(var t=e.length;t&&!e[--t];);for(var n=new He(++t),r=0,s=e[0],o=1,i=function(e){n[r++]=e},a=1;a<=t;++a)if(e[a]==s&&a!=t)++o;else{if(!s&&o>2){for(;o>138;o-=138)i(32754);o>2&&(i(o>10?o-11<<5|28690:o-3<<5|12305),o=0)}else if(o>3){for(i(s),--o;o>6;o-=6)i(8304);o>2&&(i(o-3<<5|8208),o=0)}for(;o--;)i(s);o=1,s=e[a]}return[n.subarray(0,r),t]},vt=function(e,t){for(var n=0,r=0;r<t.length;++r)n+=e[r]*t[r];return n},St=function(e,t,n){var r=n.length,s=gt(t+2);e[s]=255&r,e[s+1]=r>>>8,e[s+2]=255^e[s],e[s+3]=255^e[s+1];for(var o=0;o<r;++o)e[s+o+4]=n[o];return 8*(s+4+r)},bt=function(e,t,n,r,s,o,i,a,c,l,d){mt(t,d++,n),++s[256];for(var u=It(s,15),h=u[0],g=u[1],p=It(o,15),m=p[0],f=p[1],I=yt(h),C=I[0],y=I[1],v=yt(m),S=v[0],b=v[1],A=new He(19),k=0;k<C.length;++k)A[31&C[k]]++;for(k=0;k<S.length;++k)A[31&S[k]]++;for(var w=It(A,7),M=w[0],T=w[1],R=19;R>4&&!M[$e[R-1]];--R);var E,N,x,F,O=l+5<<3,D=vt(s,lt)+vt(o,dt)+i,L=vt(s,h)+vt(o,m)+i+14+3*R+vt(A,M)+(2*A[16]+3*A[17]+7*A[18]);if(O<=D&&O<=L)return St(t,d,e.subarray(c,c+l));if(mt(t,d,1+(L<D)),d+=2,L<D){E=ct(h,g,0),N=h,x=ct(m,f,0),F=m;var B=ct(M,T,0);mt(t,d,y-257),mt(t,d+5,b-1),mt(t,d+10,R-4),d+=14;for(k=0;k<R;++k)mt(t,d+3*k,M[$e[k]]);d+=3*R;for(var U=[C,S],W=0;W<2;++W){var Z=U[W];for(k=0;k<Z.length;++k){var G=31&Z[k];mt(t,d,B[G]),d+=M[G],G>15&&(mt(t,d,Z[k]>>>5&127),d+=Z[k]>>>12)}}}else E=ut,N=lt,x=ht,F=dt;for(k=0;k<a;++k)if(r[k]>255){G=r[k]>>>18&31;ft(t,d,E[G+257]),d+=N[G+257],G>7&&(mt(t,d,r[k]>>>23&31),d+=Xe[G]);var V=31&r[k];ft(t,d,x[V]),d+=F[V],V>3&&(ft(t,d,r[k]>>>5&8191),d+=qe[V])}else ft(t,d,E[r[k]]),d+=N[r[k]];return ft(t,d,E[256]),d+N[256]},At=new je([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),kt=function(e,t,n,r,s){return function(e,t,n,r,s,o){var i=e.length,a=new Pe(r+i+5*(1+Math.floor(i/7e3))+s),c=a.subarray(r,a.length-s),l=0;if(!t||i<8)for(var d=0;d<=i;d+=65535){var u=d+65535;u<i?l=St(c,l,e.subarray(d,u)):(c[d]=o,l=St(c,l,e.subarray(d,i)))}else{for(var h=At[t-1],g=h>>>13,p=8191&h,m=(1<<n)-1,f=new He(32768),I=new He(m+1),C=Math.ceil(n/3),y=2*C,v=function(t){return(e[t]^e[t+1]<<C^e[t+2]<<y)&m},S=new je(25e3),b=new He(288),A=new He(32),k=0,w=0,M=(d=0,0),T=0,R=0;d<i;++d){var E=v(d),N=32767&d,x=I[E];if(f[N]=x,I[E]=N,T<=d){var F=i-d;if((k>7e3||M>24576)&&F>423){l=bt(e,c,0,S,b,A,w,M,R,d-R,l),M=k=w=0,R=d;for(var O=0;O<286;++O)b[O]=0;for(O=0;O<30;++O)A[O]=0}var D=2,L=0,B=p,U=N-x&32767;if(F>2&&E==v(d-U))for(var W=Math.min(g,F)-1,Z=Math.min(32767,d),G=Math.min(258,F);U<=Z&&--B&&N!=x;){if(e[d+D]==e[d+D-U]){for(var V=0;V<G&&e[d+V]==e[d+V-U];++V);if(V>D){if(D=V,L=U,V>W)break;var K=Math.min(U,V-2),_=0;for(O=0;O<K;++O){var z=d-U+O+32768&32767,Y=z-f[z]+32768&32767;Y>_&&(_=Y,x=z)}}}U+=(N=x)-(x=f[N])+32768&32767}if(L){S[M++]=268435456|rt[D]<<18|st[L];var J=31&rt[D],Q=31&st[L];w+=Xe[J]+qe[Q],++b[257+J],++A[Q],T=d+D,++k}else S[M++]=e[d],++b[e[d]]}}l=bt(e,c,o,S,b,A,w,M,R,d-R,l)}return pt(a,0,r+gt(l)+s)}(e,null==t.level?6:t.level,null==t.mem?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(e.length)))):12+t.mem,n,r,!0)};function wt(e,t){void 0===t&&(t={});var n=function(){var e=1,t=0;return{p:function(n){for(var r=e,s=t,o=n.length,i=0;i!=o;){for(var a=Math.min(i+5552,o);i<a;++i)s+=r+=n[i];r%=65521,s%=65521}e=r,t=s},d:function(){return(e>>>8<<16|(255&t)<<8|t>>>8)+2*((255&e)<<23)}}}();n.p(e);var r,s,o,i=kt(e,t,2,4);return r=i,s=t.level,o=0==s?0:s<6?1:9==s?3:2,r[0]=120,r[1]=o<<6|(o?32-2*o:1),function(e,t,n){for(;n;++t)e[t]=n,n>>>=8}(i,i.length-4,n.d()),i}const Mt=e=>{const t={...e,v:"v1"};return function(e){for(var t="",n=0;n<e.length;){var r=e[n++];t+=String.fromCharCode(r)}return t}(wt(function(e,t){var n=e.length;if("undefined"!=typeof TextEncoder)return(new TextEncoder).encode(e);for(var r=new Pe(e.length+(e.length>>>1)),s=0,o=function(e){r[s++]=e},i=0;i<n;++i){if(s+5>r.length){var a=new Pe(s+8+(n-i<<1));a.set(r),r=a}var c=e.charCodeAt(i);c<128||t?o(c):c<2048?(o(192|c>>>6),o(128|63&c)):c>55295&&c<57344?(o(240|(c=65536+(1047552&c)|1023&e.charCodeAt(++i))>>>18),o(128|c>>>12&63),o(128|c>>>6&63),o(128|63&c)):(o(224|c>>>12),o(128|c>>>6&63),o(128|63&c))}return pt(r,0,s)}(JSON.stringify(t))))};exports.default=class{constructor(e){this.name="session-tracker",this.version='"0.9.5"',this.context=null,this.config={},this.userConfig=null,this.sessionStartTime=0,this.isActive=!1,this.stopRecordingFn=null,this.sessionEvents=[],this.sessionId="",this.currentSessionSize=0,this.lastBatchTime=0,this.activeBatchCount=0,this.userId="",this.appId="",this.pendingEvents=[],this.eventsInFlight=[],this.sentEventCount=0,this.isSendingBatch=!1,this.delayedS3Url=null,this.delayedUrlExpiry=0,this.delayedUrlRefreshTimer=null,this.userConfig=e||{}}init(e,t){this.context=e;const n="object"==typeof t?.webSessions?t?.webSessions:null,r={enableSessionRecording:!1!==t?.webSessions&&(!0===t?.webSessions||!1!==n?.enabled),maxBatchSize:1048576,maxSessionDuration:null,batchSize:150,batchInterval:3e4,minimumSessionDuration:5e3,compressionEnabled:!1,recordingOptions:{recordCanvas:!0,recordCrossOriginIframes:!1,recordAfter:"DOMContentLoaded",maskAllInputs:!1,maskInputOptions:{password:!0,email:!0,text:!1},blockClass:"sensitive-field",slimDOMOptions:{script:!1,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaDescKeywords:!0,headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaAuthorship:!0,headMetaVerification:!0},sampling:{scroll:150,mouseInteraction:!0,input:"last",mutation:!0},...this.userConfig?this.userConfig:{},...this.config.recordingOptions?this.config.recordingOptions:{}}};this.config={...r}}start(){if(!this.context)return;if(this.isActive)return;this.delayedUrlRefreshTimer&&(clearTimeout(this.delayedUrlRefreshTimer),this.delayedUrlRefreshTimer=null),this.isActive=!0,this.userId=this.context.userManager.getUserId(),this.appId=this.context.appManager.getAppId();const e=String(this.context.userManager.getSessionId());(!this.sessionId||this.sessionId!==e)&&(this.sessionEvents=[],this.pendingEvents=[],this.eventsInFlight=[],this.currentSessionSize=0,this.sentEventCount=0,this.sessionStartTime=Date.now(),this.delayedS3Url=null,this.delayedUrlExpiry=0),this.sessionId=e,this.config.enableSessionRecording&&this.startRecording()}stop(){this.isActive&&this.stopRecording()}destroy(){this.stopRecording(),this.pendingEvents=[],this.eventsInFlight=[],this.sessionEvents=[],this.currentSessionSize=0,this.sentEventCount=0,this.delayedS3Url=null,this.delayedUrlExpiry=0,this.context?.removePluginField("recordingSessionId"),this.context?.setPluginField("isRecordingActive",!1),this.context=null}onEvent(e,t){this.isActive&&"session_start"===e&&(this.sessionStartTime=Date.now())}async onUserChange(e){this.isActive&&(await this.sendBatchToBackend(),this.stopRecording(),this.isActive=!1,this.start())}async onFocus(){this.pendingEvents.length>0&&await this.sendBatchToBackend(),this.isActive||this.start()}onBlur(){this.isActive&&(this.sendFinalBatch().catch(e=>{this.context?.logger.error(e)}),this.stopRecording(!0))}async onBeforeUnload(){const e=this.pendingEvents.length>0||this.eventsInFlight.length>0;(this.isActive||e)&&this.sendFinalBatch().catch(e=>{this.context?.logger.error(e)})}async onTrackingChange(e){e?this.isActive||this.start():this.isActive&&(await this.sendBatchToBackend(),this.stopRecording())}async onSessionStart(){await this.sendBatchToBackend(),this.isActive||this.start()}stopRecording(e=!1){e||this.context?.setPluginField("isRecordingActive",!1),this.isActive=!1,this.delayedUrlRefreshTimer&&(clearTimeout(this.delayedUrlRefreshTimer),this.delayedUrlRefreshTimer=null),this.stopRecordingFn&&(this.stopRecordingFn(),this.stopRecordingFn=null)}async startRecording(){if(!this.context)return;this.lastBatchTime=Date.now(),this.isSendingBatch=!1;const e=Date.now();if(!this.delayedS3Url||this.delayedUrlExpiry>0&&e>this.delayedUrlExpiry)this.fetchDelayedUrl();else if(this.delayedS3Url){const t=Math.max(0,this.delayedUrlExpiry-e);this.scheduleDelayedUrlRefresh(t+1e4)}const t=this.context.getPluginField("recordingSessionId"),n=!!t&&t===this.context.userManager.getSessionId(),r=this.context.getPluginField("isRecordingActive");if(n&&r)this.startSessionRecording();else try{const e=this.context.api.buildUrl(["sessions","configurations","get"],{appId:this.appId}),t=await this.sendRequest(e,null,"GET");if(t&&t.data){const e=t.data;if(e.blocked||!e.active)return this.context.logger.debug("Session configuration is "+(e.blocked?"blocked":"inactive")),void this.context.setPluginField("isRecordingActive",!1);100*Math.random()<e.record_chance_percent?(this.context.setPluginField("isRecordingActive",!0),this.startSessionRecording()):this.context.setPluginField("isRecordingActive",!1)}}catch(e){this.context.logger.error("Failed to fetch session configuration",{error:e}),this.context.setPluginField("isRecordingActive",!1)}}startSessionRecording(){if(!this.config.enableSessionRecording)return;this.context?.setPluginField("recordingSessionId",this.context?.userManager.getSessionId()),this.lastBatchTime=Date.now();const e={emit:e=>{this.addEventToSession(e),this.pendingEvents.push(e),this.currentSessionSize+=JSON.stringify(e).length,e.type,this.checkBatchLimits()},...this.config.recordingOptions};this.config.compressionEnabled&&(e.packFn=Mt);const t=Qe(e);this.stopRecordingFn=t||null}addEventToSession(e){this.sessionEvents.push(e);this.sessionEvents.length>1e4&&(this.sessionEvents=this.sessionEvents.slice(-Math.floor(5e3)))}hasMinimumSessionDuration(){return Date.now()-this.sessionStartTime>=this.config.minimumSessionDuration}checkBatchLimits(){if(this.isSendingBatch)return;const e=Date.now()-this.sessionStartTime,t=this.pendingEvents.length>=this.config.batchSize,n=this.currentSessionSize>=this.config.maxBatchSize,r=this.config.maxSessionDuration&&e>=this.config.maxSessionDuration,s=Date.now()-this.lastBatchTime>=this.config.batchInterval;(t||n||r||s)&&this.sendBatchToBackend().catch(e=>{this.context?.logger.error("Error in checkBatchLimits sendBatchToBackend",{error:e instanceof Error?e.message:e,pendingEventsCount:this.pendingEvents.length})})}async sendBatchToBackend(){if(!this.pendingEvents.length||!this.context||this.isSendingBatch)return;if(!this.hasMinimumSessionDuration())return;this.isSendingBatch=!0,this.eventsInFlight=[...this.pendingEvents],this.pendingEvents=[];const e=this.eventsInFlight.reduce((e,t)=>e+JSON.stringify(t).length,0);this.currentSessionSize-=e,this.currentSessionSize=Math.max(0,this.currentSessionSize),this.activeBatchCount++;try{const e=this.eventsInFlight[0]?.timestamp||Date.now(),t=this.eventsInFlight[this.eventsInFlight.length-1]?.timestamp||Date.now(),n={appId:this.appId,session_id:this.sessionId,user_id:this.userId,start_time:e,end_time:t},r=this.context.api.buildUrl(["sessions","add"],n),s=await this.sendRequest(r,null,"GET",{},!0);if(204===s.status)return this.context.logger.warning("Session storage exceeded"),this.eventsInFlight=[],void this.stop();const o=s.data,i="string"==typeof o?o:o?.url;if(!i)throw new Error("No S3 URL returned");await this.uploadToS3(i,this.eventsInFlight),this.sentEventCount+=this.eventsInFlight.length,this.lastBatchTime=Date.now(),this.eventsInFlight=[]}catch(t){throw this.context?.logger.error("Error sending session batch to backend",{error:t instanceof Error?t.message:t,eventsCount:this.eventsInFlight.length}),this.pendingEvents.unshift(...this.eventsInFlight),this.eventsInFlight=[],this.currentSessionSize+=e,t}finally{this.activeBatchCount--,this.isSendingBatch=!1,this.pendingEvents.length>0&&this.checkBatchLimits()}}async fetchDelayedUrl(){if(this.context)try{const e=this.context.api.buildUrl(["sessions","addDelayed"],{session_id:this.sessionId,appId:this.appId,user_id:this.userId}),t=await this.sendRequest(e,null,"GET");if(t&&t.data){const e=t.data;this.delayedS3Url=e.url,this.delayedUrlExpiry=Date.now()+e.ttl,this.scheduleDelayedUrlRefresh(e.ttl)}}catch(e){this.context.logger.error("Failed to fetch delayed URL",{error:e})}}scheduleDelayedUrlRefresh(e){this.delayedUrlRefreshTimer&&clearTimeout(this.delayedUrlRefreshTimer);const t=Math.max(0,e-1e4);this.delayedUrlRefreshTimer=setTimeout(()=>{this.fetchDelayedUrl()},t)}async sendFinalBatch(){if(!this.context)return;if(!this.hasMinimumSessionDuration())return;const e=[...this.eventsInFlight,...this.pendingEvents];if(!e.length)return;if(!this.delayedS3Url)return void this.context.logger.error("No delayed URL available for final batch - cannot send.");const t=[...this.pendingEvents],n=[...this.eventsInFlight];this.pendingEvents=[],this.eventsInFlight=[],this.currentSessionSize=0;const r=JSON.stringify(e),s=new Blob([r],{type:"application/json"});try{const e=await fetch(this.delayedS3Url,{method:"PUT",body:s,keepalive:!0,credentials:"omit"});if(!e.ok)throw new Error(`S3 upload failed: ${e.statusText}`);this.lastBatchTime=Date.now()}catch(e){this.pendingEvents=t,this.eventsInFlight=n,this.context?.logger.error(`Failed to send final batch: ${e}`)}}async uploadToS3(e,t){const n=JSON.stringify(t),r=await fetch(e,{method:"PUT",body:n});if(!r.ok)throw new Error(`S3 upload failed: ${r.statusText}`)}sendRequest(e,t,n="POST",r={},s=!1){return new Promise((o,i)=>{if(!this.context)return i(new Error("No context"));const a=this.context.api.createRequestStructure(e,t,r,n);this.context.api.sendRequest(`req-${Date.now()}-${Math.random()}`,a,(e,t,n)=>{e>=200&&e<300?o({status:e,data:t}):i({status:e,data:t,error:n})},{gzip:!1,method:n,noContentType:s})})}};
|