@openreplay/tracker 18.1.2 → 19.0.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/lib/index.js CHANGED
@@ -1388,6 +1388,18 @@ function WebVitals(name, value) {
1388
1388
  value,
1389
1389
  ];
1390
1390
  }
1391
+ function IssueEvent(messageID, timestamp, type, contextString, context, payload, url) {
1392
+ return [
1393
+ 125 /* Messages.Type.IssueEvent */,
1394
+ messageID,
1395
+ timestamp,
1396
+ type,
1397
+ contextString,
1398
+ context,
1399
+ payload,
1400
+ url,
1401
+ ];
1402
+ }
1391
1403
 
1392
1404
  var _Messages = /*#__PURE__*/Object.freeze({
1393
1405
  __proto__: null,
@@ -1410,6 +1422,7 @@ var _Messages = /*#__PURE__*/Object.freeze({
1410
1422
  GraphQLDeprecated: GraphQLDeprecated,
1411
1423
  Incident: Incident,
1412
1424
  InputChange: InputChange,
1425
+ IssueEvent: IssueEvent,
1413
1426
  JSException: JSException,
1414
1427
  LoadFontFace: LoadFontFace,
1415
1428
  LongAnimationTask: LongAnimationTask$1,
@@ -4295,7 +4308,7 @@ class Ticker {
4295
4308
  * this value is injected during build time via rollup
4296
4309
  * */
4297
4310
  // @ts-ignore
4298
- const workerBodyFn = "!function(){\"use strict\";class t{constructor(t,s,i,e=10,n=250,h,r){this.onUnauthorised=s,this.onFailure=i,this.MAX_ATTEMPTS_COUNT=e,this.ATTEMPT_TIMEOUT=n,this.onCompress=h,this.pageNo=r,this.attemptsCount=0,this.busy=!1,this.queue=[],this.token=null,this.lastBatchNum=0,this.inflightKeepaliveBytes=0,this.ingestURL=t+\"/v1/web/i\",this.isCompressing=void 0!==h}getQueueStatus(){return 0===this.queue.length&&!this.busy}authorise(t){this.token=t,this.busy||this.sendNext()}push(t,s=\"player\",i){if(this.busy||!this.token)this.queue.push({batch:t,dataType:s,split:i});else if(this.busy=!0,this.isCompressing&&this.onCompress)this.onCompress(t,s,i);else{const e=++this.lastBatchNum;this.sendBatch(t,!1,e,s,i)}}sendNext(){const t=this.queue.shift();if(t)if(this.busy=!0,this.isCompressing&&this.onCompress)this.onCompress(t.batch,t.dataType,t.split);else{const s=++this.lastBatchNum;this.sendBatch(t.batch,!1,s,t.dataType,t.split)}else this.busy=!1}retry(t,s,i,e=\"player\",n){if(this.attemptsCount>=this.MAX_ATTEMPTS_COUNT)return void this.onFailure(`Failed to send batch after ${this.attemptsCount} attempts.`);this.attemptsCount++;const h=new Uint8Array(t);setTimeout((()=>this.sendBatch(h,s,i,e,n)),this.ATTEMPT_TIMEOUT*this.attemptsCount)}sendBatch(t,s,i,e=\"player\",n){var h,r,a;if(0===t.length)return console.error(\"OpenReplay: refusing to send 0-byte batch.\",{batchNum:i,dataType:e,isCompressed:s,batch:t}),this.attemptsCount=0,void this.sendNext();const u=(null!==(h=null==i?void 0:i.toString())&&void 0!==h?h:\"0\").match(/^([^_]+)(?:_([^_]+))?/),o=null!==(r=null==u?void 0:u[1])&&void 0!==r?r:\"0\",l=(null==u?void 0:u[2])?u[2]:\"\";this.busy=!0;const c={Authorization:`Bearer ${this.token}`,DataType:e};if(s&&(c[\"Content-Encoding\"]=\"gzip\"),null===this.token)return void setTimeout((()=>{this.sendBatch(t,s,`${null!=i?i:\"noBatchNum\"}_newToken`,e,n)}),500);const d=t.length<65536&&this.inflightKeepaliveBytes+t.length<=65536;d&&(this.inflightKeepaliveBytes+=t.length);const p=()=>{d&&(this.inflightKeepaliveBytes-=t.length)},f=t.byteLength;let g=this.ingestURL;g+=`?batch=${null!==(a=this.pageNo)&&void 0!==a?a:0}`,g+=`_${o}`,g+=`_${f}`,g+=\"_\"+(d?\"kyes\":\"kno\"),l&&(g+=`_${l}`),void 0!==n&&(g+=`&split=${n}`),fetch(g,{body:t,method:\"POST\",headers:c,keepalive:d}).then((h=>{var r;if(p(),null===(r=h.body)||void 0===r||r.cancel().catch((()=>{})),401===h.status)return this.busy=!1,void this.onUnauthorised();h.status>=400?this.retry(t,s,`${null!=i?i:\"noBatchNum\"}_network:${h.status}`,e,n):(this.attemptsCount=0,this.sendNext())})).catch((h=>{p(),console.warn(\"OpenReplay:\",h),this.retry(t,s,`${null!=i?i:\"noBatchNum\"}_reject:${h.message}`,e,n)}))}sendCompressed(t,s=\"player\",i){const e=++this.lastBatchNum;this.sendBatch(t,!0,e,s,i)}sendUncompressed(t,s=\"player\",i){const e=++this.lastBatchNum;this.sendBatch(t,!1,e,s,i)}clean(){this.sendNext(),setTimeout((()=>{this.token=null,this.queue.length=0}),10)}}const s=new Set([60,61,71,73]),i=new Set([21,22,40,41,44,45,46,47,48,79,83,84,85,87,89,116,120,121,123]),e=new Set([17,23,24,27,28,29,30,42,63,64,78,112,115,124]),n=\"function\"==typeof TextEncoder?new TextEncoder:{encode(t){const s=t.length,i=new Uint8Array(3*s);let e=-1;for(let n=0,h=0,r=0;r!==s;){if(n=t.charCodeAt(r),r+=1,n>=55296&&n<=56319){if(r===s){i[e+=1]=239,i[e+=1]=191,i[e+=1]=189;break}if(h=t.charCodeAt(r),!(h>=56320&&h<=57343)){i[e+=1]=239,i[e+=1]=191,i[e+=1]=189;continue}if(n=1024*(n-55296)+h-56320+65536,r+=1,n>65535){i[e+=1]=240|n>>>18,i[e+=1]=128|n>>>12&63,i[e+=1]=128|n>>>6&63,i[e+=1]=128|63&n;continue}}n<=127?i[e+=1]=0|n:n<=2047?(i[e+=1]=192|n>>>6,i[e+=1]=128|63&n):(i[e+=1]=224|n>>>12,i[e+=1]=128|n>>>6&63,i[e+=1]=128|63&n)}return i.subarray(0,e+1)}};class h{constructor(t){this.size=t,this.offset=0,this.checkpointOffset=0,this.data=new Uint8Array(t)}getCurrentOffset(){return this.offset}getCurrentCheckpoint(){return this.checkpointOffset}checkpoint(){this.checkpointOffset=this.offset}get isEmpty(){return 0===this.offset}skip(t){return this.offset+=t,this.offset<=this.size}set(t,s){this.data.set(t,s)}boolean(t){return this.data[this.offset++]=+t,this.offset<=this.size}uint(t){for((t<0||t>Number.MAX_SAFE_INTEGER)&&(t=0);t>=128;)this.data[this.offset++]=t%256|128,t=Math.floor(t/128);return this.data[this.offset++]=t,this.offset<=this.size}int(t){return t=Math.round(t),this.uint(t>=0?2*t:-2*t-1)}string(t){const s=n.encode(t),i=s.byteLength;return!(!this.uint(i)||this.offset+i>this.size)&&(this.data.set(s,this.offset),this.offset+=i,!0)}reset(){this.offset=0,this.checkpointOffset=0}rewind(t,s){t>this.offset||s>this.checkpointOffset||(this.offset=t,this.checkpointOffset=s)}flush(){const t=this.data.slice(0,this.checkpointOffset);return this.reset(),t}}class r extends h{encode(t){switch(t[0]){case 0:case 11:case 114:case 115:return this.uint(t[1]);case 4:case 44:case 47:return this.string(t[1])&&this.string(t[2])&&this.uint(t[3]);case 5:case 20:case 65:case 70:case 75:case 76:case 77:return this.uint(t[1])&&this.uint(t[2]);case 6:return this.int(t[1])&&this.int(t[2]);case 7:return!0;case 8:return this.uint(t[1])&&this.uint(t[2])&&this.uint(t[3])&&this.string(t[4])&&this.boolean(t[5]);case 9:case 10:case 24:case 35:case 51:return this.uint(t[1])&&this.uint(t[2])&&this.uint(t[3]);case 12:case 52:case 61:case 71:return this.uint(t[1])&&this.string(t[2])&&this.string(t[3]);case 13:case 14:case 17:case 34:case 36:case 50:case 54:return this.uint(t[1])&&this.string(t[2]);case 16:return this.uint(t[1])&&this.int(t[2])&&this.int(t[3]);case 18:return this.uint(t[1])&&this.string(t[2])&&this.int(t[3]);case 19:return this.uint(t[1])&&this.boolean(t[2]);case 21:return this.string(t[1])&&this.string(t[2])&&this.string(t[3])&&this.string(t[4])&&this.string(t[5])&&this.uint(t[6])&&this.uint(t[7])&&this.uint(t[8]);case 22:case 27:case 30:case 41:case 45:case 46:case 43:case 63:case 64:case 79:case 124:return this.string(t[1])&&this.string(t[2]);case 23:return this.uint(t[1])&&this.uint(t[2])&&this.uint(t[3])&&this.uint(t[4])&&this.uint(t[5])&&this.uint(t[6])&&this.uint(t[7])&&this.uint(t[8])&&this.uint(t[9]);case 28:case 29:case 42:case 117:case 118:return this.string(t[1]);case 40:return this.string(t[1])&&this.uint(t[2])&&this.string(t[3])&&this.string(t[4]);case 48:return this.string(t[1])&&this.string(t[2])&&this.string(t[3])&&this.string(t[4])&&this.int(t[5]);case 49:return this.int(t[1])&&this.int(t[2])&&this.uint(t[3])&&this.uint(t[4]);case 53:return this.uint(t[1])&&this.uint(t[2])&&this.uint(t[3])&&this.uint(t[4])&&this.uint(t[5])&&this.uint(t[6])&&this.string(t[7])&&this.string(t[8]);case 55:return this.boolean(t[1]);case 57:case 60:return this.uint(t[1])&&this.string(t[2])&&this.string(t[3])&&this.string(t[4]);case 58:case 120:return this.int(t[1]);case 68:return this.uint(t[1])&&this.uint(t[2])&&this.string(t[3])&&this.string(t[4])&&this.uint(t[5])&&this.uint(t[6]);case 69:return this.uint(t[1])&&this.uint(t[2])&&this.string(t[3])&&this.string(t[4]);case 73:return this.uint(t[1])&&this.string(t[2])&&this.uint(t[3])&&this.string(t[4]);case 78:return this.string(t[1])&&this.string(t[2])&&this.string(t[3])&&this.string(t[4]);case 81:return this.uint(t[1])&&this.uint(t[2])&&this.uint(t[3])&&this.int(t[4])&&this.string(t[5]);case 83:return this.string(t[1])&&this.string(t[2])&&this.string(t[3])&&this.string(t[4])&&this.string(t[5])&&this.uint(t[6])&&this.uint(t[7])&&this.uint(t[8])&&this.uint(t[9]);case 84:return this.string(t[1])&&this.string(t[2])&&this.string(t[3])&&this.uint(t[4])&&this.string(t[5])&&this.string(t[6]);case 85:return this.uint(t[1])&&this.uint(t[2])&&this.uint(t[3])&&this.uint(t[4])&&this.uint(t[5])&&this.uint(t[6])&&this.string(t[7])&&this.string(t[8])&&this.uint(t[9])&&this.boolean(t[10])&&this.uint(t[11])&&this.uint(t[12])&&this.uint(t[13])&&this.uint(t[14])&&this.uint(t[15])&&this.uint(t[16])&&this.uint(t[17]);case 87:return this.string(t[1])&&this.int(t[2])&&this.int(t[3]);case 89:return this.string(t[1])&&this.int(t[2])&&this.int(t[3])&&this.int(t[4])&&this.int(t[5])&&this.string(t[6]);case 112:return this.uint(t[1])&&this.string(t[2])&&this.boolean(t[3])&&this.string(t[4])&&this.int(t[5])&&this.int(t[6]);case 113:return this.uint(t[1])&&this.uint(t[2])&&this.string(t[3]);case 116:return this.uint(t[1])&&this.uint(t[2])&&this.uint(t[3])&&this.uint(t[4])&&this.uint(t[5])&&this.uint(t[6])&&this.string(t[7])&&this.string(t[8])&&this.uint(t[9])&&this.boolean(t[10]);case 119:return this.string(t[1])&&this.uint(t[2]);case 121:return this.string(t[1])&&this.string(t[2])&&this.uint(t[3])&&this.uint(t[4]);case 122:return this.string(t[1])&&this.string(t[2])&&this.uint(t[3])&&this.string(t[4]);case 123:return this.string(t[1])&&this.string(t[2])&&this.string(t[3])&&this.string(t[4])&&this.uint(t[5])}}}class a{constructor(t,s,i){this.bufferSize=t,this.version=s,this.dataType=i,this.sizeBuffer=new Uint8Array(3),this.snap=null,this.hasNonTimestamp=!1,this.lastPushedTs=0,this.encoder=new r(t)}push(t,s){const i=this.encoder,e=null===this.snap,n=i.getCurrentOffset(),h=i.getCurrentCheckpoint();if(e){const t={pageNo:s.pageNo,firstIndex:s.index,timestamp:s.timestamp,url:s.url,tabId:s.tabId};if(!this.writeHeader(t))return i.rewind(n,h),!1;this.snap=t,this.lastPushedTs=s.timestamp}return 0===t[0]||s.timestamp===this.lastPushedTs||this.writeMessageWithSize([0,s.timestamp])?this.writeMessageWithSize(t)?(this.lastPushedTs=s.timestamp,0!==t[0]&&(this.hasNonTimestamp=!0),!0):(i.rewind(n,h),e&&(this.snap=null),!1):(i.rewind(n,h),!1)}hasContent(){return null!==this.snap&&this.hasNonTimestamp}size(){return null===this.snap?0:this.encoder.getCurrentOffset()}flush(){if(!this.hasContent())return this.reset(),null;const t=this.encoder.flush();return this.snap=null,this.hasNonTimestamp=!1,this.lastPushedTs=0,t}reset(){this.encoder.reset(),this.snap=null,this.hasNonTimestamp=!1,this.lastPushedTs=0}writeHeader(t){const s=this.encoder,i=[81,this.version,t.pageNo,t.firstIndex,t.timestamp,t.url];return!!s.uint(i[0])&&(!!s.encode(i)&&(!(s.getCurrentOffset()>this.bufferSize)&&(s.checkpoint(),!!this.writeMessageWithSize([0,t.timestamp])&&!!this.writeMessageWithSize([118,t.tabId]))))}writeMessageWithSize(t){const s=this.encoder;if(!s.uint(t[0])||!s.skip(3))return!1;const i=s.getCurrentOffset();if(!s.encode(t))return!1;const e=s.getCurrentOffset(),n=e-i;return n>16777215?(console.warn(\"OpenReplay: max message size overflow.\"),!1):!(e>this.bufferSize)&&(this.writeSizeAt(n,i-3),s.checkpoint(),!0)}writeSizeAt(t,s){for(let s=0;s<3;s++)this.sizeBuffer[s]=t>>8*s;this.encoder.set(this.sizeBuffer,s)}}class u{constructor(t,s,i,e,n,h,r=!1,u){this.pageNo=t,this.timestamp=s,this.url=i,this.onBatch=e,this.tabId=n,this.onOfflineEnd=h,this.localDebug=r,this.onLocalSave=u,this.nextIndex=0,this.beaconSize=2e5,this.beaconSizeLimit=1e6,this.protocolVersion=1,this.visualSent=!1,this.signalSeen=!1,this.heldOther=[],this.playerBuilder=new a(this.beaconSize,this.playerVersion(),\"player\"),this.assetBuilder=new a(this.beaconSize,3,\"assets\"),this.devtoolsBuilder=new a(this.beaconSize,4,\"devtools\"),this.analyticsBuilder=new a(this.beaconSize,5,\"analytics\")}initActive(){return 2===this.protocolVersion&&!this.visualSent}playerVersion(){return 2===this.protocolVersion?2:1}currentCtx(){return{pageNo:this.pageNo,index:this.nextIndex,timestamp:this.timestamp,url:this.url,tabId:this.tabId}}setBeaconSizeLimit(t){this.beaconSizeLimit=t}setProtocolVersion(t){if(this.protocolVersion!==t){if(this.protocolVersion=t,2===t&&!this.signalSeen)return this.playerBuilder.reset(),this.assetBuilder.reset(),this.playerBuilder=new a(this.beaconSizeLimit,this.playerVersion(),\"player\"),void(this.assetBuilder=new a(this.beaconSizeLimit,3,\"assets\"));2===t&&(this.visualSent=!0),this.playerBuilder.reset(),this.playerBuilder=new a(this.beaconSize,this.playerVersion(),\"player\")}}writeMessage(t){if(-1===t[0])return this.finaliseBatch(),this.onOfflineEnd();if(12===t[0]&&\"orloaded\"===t[2])return void(this.initActive()?this.finalizeVisual():this.signalSeen=!0);0===t[0]&&(this.timestamp=t[1]),122===t[0]&&(this.url=t[1]);const s=this.routeMessage(t);this.pushTo(s,t)}routeMessage(t){if(2===this.protocolVersion){const n=t[0];if(s.has(n))return this.assetBuilder;if(i.has(n))return this.devtoolsBuilder;if(e.has(n))return this.analyticsBuilder}return this.playerBuilder}pushTo(t,s){const i=this.currentCtx();if(this.initActive())return void this.pushDuringInit(t,s,i);if(t.push(s,i))return void this.nextIndex++;if(t===this.assetBuilder&&this.flushBuilder(this.playerBuilder),this.flushBuilder(t),t.push(s,i))return void this.nextIndex++;const e=new a(this.beaconSizeLimit,t.version,t.dataType);if(!e.push(s,i))return void console.warn(\"OpenReplay: beacon size overflow. Skipping large message.\",s);this.nextIndex++;const n=e.flush();n&&(t===this.assetBuilder&&this.flushBuilder(this.playerBuilder),this.emitBatch(n,t.dataType,!1))}pushDuringInit(t,s,i){const e=t===this.playerBuilder||t===this.assetBuilder;if(t.push(s,i))return this.nextIndex++,void(e&&this.playerBuilder.size()+this.assetBuilder.size()>=this.beaconSizeLimit&&this.finalizeVisual());if(e)return this.finalizeVisual(),void this.pushTo(this.routeMessage(s),s);if(this.flushBuilderToHeld(t),t.push(s,i))return void this.nextIndex++;const n=new a(this.beaconSizeLimit,t.version,t.dataType);if(!n.push(s,i))return void console.warn(\"OpenReplay: beacon size overflow. Skipping large message.\",s);this.nextIndex++;const h=n.flush();h&&this.heldOther.push({batch:h,dataType:t.dataType})}flushBuilderToHeld(t){const s=t.flush();s&&this.heldOther.push({batch:s,dataType:t.dataType})}finalizeVisual(t=!1){const s=this.playerBuilder.flush(),i=this.assetBuilder.flush();if(this.visualSent=!0,this.playerBuilder=new a(this.beaconSize,this.playerVersion(),\"player\"),this.assetBuilder=new a(this.beaconSize,3,\"assets\"),s&&i){const e=new Uint8Array(s.length+i.length);e.set(s,0),e.set(i,s.length),this.emitBatch(e,\"visual\",t,s.length)}else s?this.emitBatch(s,\"visual\",t):i&&this.emitBatch(i,\"assets\",t);for(const s of this.heldOther)this.emitBatch(s.batch,s.dataType,t);this.heldOther.length=0,this.flushBuilder(this.devtoolsBuilder,t),this.flushBuilder(this.analyticsBuilder,t)}flushBuilder(t,s=!1){const i=t.flush();return!!i&&(this.emitBatch(i,t.dataType,s),!0)}emitBatch(t,s,i,e){this.localDebug&&this.onLocalSave&&this.onLocalSave(`${s}-${Date.now()}`,t.slice()),this.onBatch(t,i,s,e)}finaliseBatch(t=!1){this.initActive()?this.finalizeVisual(t):(this.flushBuilder(this.playerBuilder,t),this.flushBuilder(this.assetBuilder,t),this.flushBuilder(this.devtoolsBuilder,t),this.flushBuilder(this.analyticsBuilder,t))}clean(){this.playerBuilder.reset(),this.assetBuilder.reset(),this.devtoolsBuilder.reset(),this.analyticsBuilder.reset(),this.heldOther.length=0,this.visualSent=!1,this.signalSeen=!1}}var o;!function(t){t[t.NotActive=0]=\"NotActive\",t[t.Starting=1]=\"Starting\",t[t.Stopping=2]=\"Stopping\",t[t.Active=3]=\"Active\",t[t.Stopped=4]=\"Stopped\"}(o||(o={}));let l=null,c=null,d=o.NotActive;function p(t){c&&c.finaliseBatch(t)}function f(){return new Promise((t=>{d=o.Stopping,null!==y&&(clearInterval(y),y=null),c&&(c.clean(),c=null),l&&(l.clean(),setTimeout((()=>{l=null}),20)),setTimeout((()=>{d=o.NotActive,t(null)}),100)}))}function g(){[o.Stopped,o.Stopping].includes(d)||(postMessage(\"a_stop\"),f().then((()=>{postMessage(\"a_start\")})))}let m,y=null;self.onmessage=({data:s})=>{var i;if(\"stop\"===s)return p(),void f().then((()=>{d=o.Stopped}));if(\"forceFlushBatch\"!==s)if(\"closing\"!==s){if(!Array.isArray(s)){if(\"compressed\"===s.type){if(!l)return console.debug(\"OR WebWorker: sender not initialised. Compressed batch.\"),void g();s.batch&&l.sendCompressed(s.batch,s.dataType,s.split)}if(\"uncompressed\"===s.type){if(!l)return console.debug(\"OR WebWorker: sender not initialised. Uncompressed batch.\"),void g();s.batch&&l.sendUncompressed(s.batch,s.dataType,s.split)}return\"start\"===s.type?(d=o.Starting,l=new t(s.ingestPoint,(()=>{g()}),(t=>{!function(t){postMessage({type:\"failure\",reason:t}),f()}(t)}),s.connAttemptCount,s.connAttemptGap,((t,s,i)=>{postMessage({type:\"compress\",batch:t,dataType:s,split:i},[t.buffer])}),s.pageNo),c=new u(s.pageNo,s.timestamp,s.url,((t,s,i=\"player\",e)=>{l&&(s?l.sendUncompressed(t,i,e):l.push(t,i,e))}),s.tabId,(()=>postMessage({type:\"queue_empty\"})),null!==(i=s.localDebug)&&void 0!==i&&i,((t,s)=>{postMessage({type:\"local_save\",name:t,batch:s},[s.buffer])})),null===y&&(y=setInterval(p,3e4)),d=o.Active):\"auth\"===s.type?l?c?(l.authorise(s.token),s.beaconSizeLimit&&c.setBeaconSizeLimit(s.beaconSizeLimit),void(s.protocolVersion&&c.setProtocolVersion(s.protocolVersion))):(console.debug(\"OR WebWorker: writer not initialised. Received auth.\"),void g()):(console.debug(\"OR WebWorker: sender not initialised. Received auth.\"),void g()):void 0}if(c){const t=c;s.forEach((s=>{55===s[0]&&(s[1]?m=setTimeout((()=>g()),18e5):clearTimeout(m)),t.writeMessage(s)}))}else postMessage(\"not_init\"),g()}else p(!0);else p()}}();\n";
4311
+ const workerBodyFn = "!function(){\"use strict\";class t{constructor(t,s,i,e=10,n=250,h,r){this.onUnauthorised=s,this.onFailure=i,this.MAX_ATTEMPTS_COUNT=e,this.ATTEMPT_TIMEOUT=n,this.onCompress=h,this.pageNo=r,this.attemptsCount=0,this.busy=!1,this.queue=[],this.token=null,this.lastBatchNum=0,this.inflightKeepaliveBytes=0,this.ingestURL=t+\"/v1/web/i\",this.isCompressing=void 0!==h}getQueueStatus(){return 0===this.queue.length&&!this.busy}authorise(t){this.token=t,this.busy||this.sendNext()}push(t,s=\"player\",i){if(this.busy||!this.token)this.queue.push({batch:t,dataType:s,split:i});else if(this.busy=!0,this.isCompressing&&this.onCompress)this.onCompress(t,s,i);else{const e=++this.lastBatchNum;this.sendBatch(t,!1,e,s,i)}}sendNext(){const t=this.queue.shift();if(t)if(this.busy=!0,this.isCompressing&&this.onCompress)this.onCompress(t.batch,t.dataType,t.split);else{const s=++this.lastBatchNum;this.sendBatch(t.batch,!1,s,t.dataType,t.split)}else this.busy=!1}retry(t,s,i,e=\"player\",n){if(this.attemptsCount>=this.MAX_ATTEMPTS_COUNT)return void this.onFailure(`Failed to send batch after ${this.attemptsCount} attempts.`);this.attemptsCount++;const h=new Uint8Array(t);setTimeout((()=>this.sendBatch(h,s,i,e,n)),this.ATTEMPT_TIMEOUT*this.attemptsCount)}sendBatch(t,s,i,e=\"player\",n){var h,r,a;if(0===t.length)return console.error(\"OpenReplay: refusing to send 0-byte batch.\",{batchNum:i,dataType:e,isCompressed:s,batch:t}),this.attemptsCount=0,void this.sendNext();const o=(null!==(h=null==i?void 0:i.toString())&&void 0!==h?h:\"0\").match(/^([^_]+)(?:_([^_]+))?/),u=null!==(r=null==o?void 0:o[1])&&void 0!==r?r:\"0\",l=(null==o?void 0:o[2])?o[2]:\"\";this.busy=!0;const c={Authorization:`Bearer ${this.token}`,DataType:e};if(s&&(c[\"Content-Encoding\"]=\"gzip\"),null===this.token)return void setTimeout((()=>{this.sendBatch(t,s,`${null!=i?i:\"noBatchNum\"}_newToken`,e,n)}),500);const d=t.length<65536&&this.inflightKeepaliveBytes+t.length<=65536;d&&(this.inflightKeepaliveBytes+=t.length);const p=()=>{d&&(this.inflightKeepaliveBytes-=t.length)},f=t.byteLength;let g=this.ingestURL;g+=`?batch=${null!==(a=this.pageNo)&&void 0!==a?a:0}`,g+=`_${u}`,g+=`_${f}`,g+=\"_\"+(d?\"kyes\":\"kno\"),l&&(g+=`_${l}`),void 0!==n&&(g+=`&split=${n}`),fetch(g,{body:t,method:\"POST\",headers:c,keepalive:d}).then((h=>{var r;if(p(),null===(r=h.body)||void 0===r||r.cancel().catch((()=>{})),401===h.status)return this.busy=!1,void this.onUnauthorised();h.status>=400?this.retry(t,s,`${null!=i?i:\"noBatchNum\"}_network:${h.status}`,e,n):(this.attemptsCount=0,this.sendNext())})).catch((h=>{p(),console.warn(\"OpenReplay:\",h),this.retry(t,s,`${null!=i?i:\"noBatchNum\"}_reject:${h.message}`,e,n)}))}sendCompressed(t,s=\"player\",i){const e=++this.lastBatchNum;this.sendBatch(t,!0,e,s,i)}sendUncompressed(t,s=\"player\",i){const e=++this.lastBatchNum;this.sendBatch(t,!1,e,s,i)}clean(){this.sendNext(),setTimeout((()=>{this.token=null,this.queue.length=0}),10)}}const s=new Set([60,61,71,73]),i=new Set([21,22,40,41,44,45,46,47,48,79,83,84,85,87,89,116,120,121,123]),e=new Set([17,23,24,27,28,29,30,42,63,64,78,112,115,124,125]),n=\"function\"==typeof TextEncoder?new TextEncoder:{encode(t){const s=t.length,i=new Uint8Array(3*s);let e=-1;for(let n=0,h=0,r=0;r!==s;){if(n=t.charCodeAt(r),r+=1,n>=55296&&n<=56319){if(r===s){i[e+=1]=239,i[e+=1]=191,i[e+=1]=189;break}if(h=t.charCodeAt(r),!(h>=56320&&h<=57343)){i[e+=1]=239,i[e+=1]=191,i[e+=1]=189;continue}if(n=1024*(n-55296)+h-56320+65536,r+=1,n>65535){i[e+=1]=240|n>>>18,i[e+=1]=128|n>>>12&63,i[e+=1]=128|n>>>6&63,i[e+=1]=128|63&n;continue}}n<=127?i[e+=1]=0|n:n<=2047?(i[e+=1]=192|n>>>6,i[e+=1]=128|63&n):(i[e+=1]=224|n>>>12,i[e+=1]=128|n>>>6&63,i[e+=1]=128|63&n)}return i.subarray(0,e+1)}};class h{constructor(t){this.size=t,this.offset=0,this.checkpointOffset=0,this.data=new Uint8Array(t)}getCurrentOffset(){return this.offset}getCurrentCheckpoint(){return this.checkpointOffset}checkpoint(){this.checkpointOffset=this.offset}get isEmpty(){return 0===this.offset}skip(t){return this.offset+=t,this.offset<=this.size}set(t,s){this.data.set(t,s)}boolean(t){return this.data[this.offset++]=+t,this.offset<=this.size}uint(t){for((t<0||t>Number.MAX_SAFE_INTEGER)&&(t=0);t>=128;)this.data[this.offset++]=t%256|128,t=Math.floor(t/128);return this.data[this.offset++]=t,this.offset<=this.size}int(t){return t=Math.round(t),this.uint(t>=0?2*t:-2*t-1)}string(t){const s=n.encode(t),i=s.byteLength;return!(!this.uint(i)||this.offset+i>this.size)&&(this.data.set(s,this.offset),this.offset+=i,!0)}reset(){this.offset=0,this.checkpointOffset=0}rewind(t,s){t>this.offset||s>this.checkpointOffset||(this.offset=t,this.checkpointOffset=s)}flush(){const t=this.data.slice(0,this.checkpointOffset);return this.reset(),t}}class r extends h{encode(t){switch(t[0]){case 0:case 11:case 114:case 115:return this.uint(t[1]);case 4:case 44:case 47:return this.string(t[1])&&this.string(t[2])&&this.uint(t[3]);case 5:case 20:case 65:case 70:case 75:case 76:case 77:return this.uint(t[1])&&this.uint(t[2]);case 6:return this.int(t[1])&&this.int(t[2]);case 7:return!0;case 8:return this.uint(t[1])&&this.uint(t[2])&&this.uint(t[3])&&this.string(t[4])&&this.boolean(t[5]);case 9:case 10:case 24:case 35:case 51:return this.uint(t[1])&&this.uint(t[2])&&this.uint(t[3]);case 12:case 52:case 61:case 71:return this.uint(t[1])&&this.string(t[2])&&this.string(t[3]);case 13:case 14:case 17:case 34:case 36:case 50:case 54:return this.uint(t[1])&&this.string(t[2]);case 16:return this.uint(t[1])&&this.int(t[2])&&this.int(t[3]);case 18:return this.uint(t[1])&&this.string(t[2])&&this.int(t[3]);case 19:return this.uint(t[1])&&this.boolean(t[2]);case 21:return this.string(t[1])&&this.string(t[2])&&this.string(t[3])&&this.string(t[4])&&this.string(t[5])&&this.uint(t[6])&&this.uint(t[7])&&this.uint(t[8]);case 22:case 27:case 30:case 41:case 45:case 46:case 43:case 63:case 64:case 79:case 124:return this.string(t[1])&&this.string(t[2]);case 23:return this.uint(t[1])&&this.uint(t[2])&&this.uint(t[3])&&this.uint(t[4])&&this.uint(t[5])&&this.uint(t[6])&&this.uint(t[7])&&this.uint(t[8])&&this.uint(t[9]);case 28:case 29:case 42:case 117:case 118:return this.string(t[1]);case 40:return this.string(t[1])&&this.uint(t[2])&&this.string(t[3])&&this.string(t[4]);case 48:return this.string(t[1])&&this.string(t[2])&&this.string(t[3])&&this.string(t[4])&&this.int(t[5]);case 49:return this.int(t[1])&&this.int(t[2])&&this.uint(t[3])&&this.uint(t[4]);case 53:return this.uint(t[1])&&this.uint(t[2])&&this.uint(t[3])&&this.uint(t[4])&&this.uint(t[5])&&this.uint(t[6])&&this.string(t[7])&&this.string(t[8]);case 55:return this.boolean(t[1]);case 57:case 60:return this.uint(t[1])&&this.string(t[2])&&this.string(t[3])&&this.string(t[4]);case 58:case 120:return this.int(t[1]);case 68:return this.uint(t[1])&&this.uint(t[2])&&this.string(t[3])&&this.string(t[4])&&this.uint(t[5])&&this.uint(t[6]);case 69:return this.uint(t[1])&&this.uint(t[2])&&this.string(t[3])&&this.string(t[4]);case 73:return this.uint(t[1])&&this.string(t[2])&&this.uint(t[3])&&this.string(t[4]);case 78:return this.string(t[1])&&this.string(t[2])&&this.string(t[3])&&this.string(t[4]);case 81:return this.uint(t[1])&&this.uint(t[2])&&this.uint(t[3])&&this.int(t[4])&&this.string(t[5]);case 83:return this.string(t[1])&&this.string(t[2])&&this.string(t[3])&&this.string(t[4])&&this.string(t[5])&&this.uint(t[6])&&this.uint(t[7])&&this.uint(t[8])&&this.uint(t[9]);case 84:return this.string(t[1])&&this.string(t[2])&&this.string(t[3])&&this.uint(t[4])&&this.string(t[5])&&this.string(t[6]);case 85:return this.uint(t[1])&&this.uint(t[2])&&this.uint(t[3])&&this.uint(t[4])&&this.uint(t[5])&&this.uint(t[6])&&this.string(t[7])&&this.string(t[8])&&this.uint(t[9])&&this.boolean(t[10])&&this.uint(t[11])&&this.uint(t[12])&&this.uint(t[13])&&this.uint(t[14])&&this.uint(t[15])&&this.uint(t[16])&&this.uint(t[17]);case 87:return this.string(t[1])&&this.int(t[2])&&this.int(t[3]);case 89:return this.string(t[1])&&this.int(t[2])&&this.int(t[3])&&this.int(t[4])&&this.int(t[5])&&this.string(t[6]);case 112:return this.uint(t[1])&&this.string(t[2])&&this.boolean(t[3])&&this.string(t[4])&&this.int(t[5])&&this.int(t[6]);case 113:return this.uint(t[1])&&this.uint(t[2])&&this.string(t[3]);case 116:return this.uint(t[1])&&this.uint(t[2])&&this.uint(t[3])&&this.uint(t[4])&&this.uint(t[5])&&this.uint(t[6])&&this.string(t[7])&&this.string(t[8])&&this.uint(t[9])&&this.boolean(t[10]);case 119:return this.string(t[1])&&this.uint(t[2]);case 121:return this.string(t[1])&&this.string(t[2])&&this.uint(t[3])&&this.uint(t[4]);case 122:return this.string(t[1])&&this.string(t[2])&&this.uint(t[3])&&this.string(t[4]);case 123:return this.string(t[1])&&this.string(t[2])&&this.string(t[3])&&this.string(t[4])&&this.uint(t[5]);case 125:return this.uint(t[1])&&this.uint(t[2])&&this.string(t[3])&&this.string(t[4])&&this.string(t[5])&&this.string(t[6])&&this.string(t[7])}}}class a{constructor(t,s,i){this.bufferSize=t,this.version=s,this.dataType=i,this.sizeBuffer=new Uint8Array(3),this.snap=null,this.hasNonTimestamp=!1,this.lastPushedTs=0,this.encoder=new r(t)}push(t,s){const i=this.encoder,e=null===this.snap,n=i.getCurrentOffset(),h=i.getCurrentCheckpoint();if(e){const t={pageNo:s.pageNo,firstIndex:s.index,timestamp:s.timestamp,url:s.url,tabId:s.tabId};if(!this.writeHeader(t))return i.rewind(n,h),!1;this.snap=t,this.lastPushedTs=s.timestamp}return 0===t[0]||s.timestamp===this.lastPushedTs||this.writeMessageWithSize([0,s.timestamp])?this.writeMessageWithSize(t)?(this.lastPushedTs=s.timestamp,0!==t[0]&&(this.hasNonTimestamp=!0),!0):(i.rewind(n,h),e&&(this.snap=null),!1):(i.rewind(n,h),!1)}hasContent(){return null!==this.snap&&this.hasNonTimestamp}size(){return null===this.snap?0:this.encoder.getCurrentOffset()}flush(){if(!this.hasContent())return this.reset(),null;const t=this.encoder.flush();return this.snap=null,this.hasNonTimestamp=!1,this.lastPushedTs=0,t}reset(){this.encoder.reset(),this.snap=null,this.hasNonTimestamp=!1,this.lastPushedTs=0}writeHeader(t){const s=this.encoder,i=[81,this.version,t.pageNo,t.firstIndex,t.timestamp,t.url];return!!s.uint(i[0])&&(!!s.encode(i)&&(!(s.getCurrentOffset()>this.bufferSize)&&(s.checkpoint(),!!this.writeMessageWithSize([0,t.timestamp])&&!!this.writeMessageWithSize([118,t.tabId]))))}writeMessageWithSize(t){const s=this.encoder;if(!s.uint(t[0])||!s.skip(3))return!1;const i=s.getCurrentOffset();if(!s.encode(t))return!1;const e=s.getCurrentOffset(),n=e-i;return n>16777215?(console.warn(\"OpenReplay: max message size overflow.\"),!1):!(e>this.bufferSize)&&(this.writeSizeAt(n,i-3),s.checkpoint(),!0)}writeSizeAt(t,s){for(let s=0;s<3;s++)this.sizeBuffer[s]=t>>8*s;this.encoder.set(this.sizeBuffer,s)}}class o{constructor(t,s,i,e,n,h,r=!1,o){this.pageNo=t,this.timestamp=s,this.url=i,this.onBatch=e,this.tabId=n,this.onOfflineEnd=h,this.localDebug=r,this.onLocalSave=o,this.nextIndex=0,this.beaconSize=2e5,this.beaconSizeLimit=1e6,this.protocolVersion=1,this.visualSent=!1,this.signalSeen=!1,this.heldOther=[],this.playerBuilder=new a(this.beaconSize,this.playerVersion(),\"player\"),this.assetBuilder=new a(this.beaconSize,3,\"assets\"),this.devtoolsBuilder=new a(this.beaconSize,4,\"devtools\"),this.analyticsBuilder=new a(this.beaconSize,5,\"analytics\")}initActive(){return 2===this.protocolVersion&&!this.visualSent}playerVersion(){return 2===this.protocolVersion?2:1}currentCtx(){return{pageNo:this.pageNo,index:this.nextIndex,timestamp:this.timestamp,url:this.url,tabId:this.tabId}}get currentIndex(){return this.nextIndex}setBeaconSizeLimit(t){this.beaconSizeLimit=t}setProtocolVersion(t){if(this.protocolVersion!==t){if(this.protocolVersion=t,2===t&&!this.signalSeen)return this.playerBuilder.reset(),this.assetBuilder.reset(),this.playerBuilder=new a(this.beaconSizeLimit,this.playerVersion(),\"player\"),void(this.assetBuilder=new a(this.beaconSizeLimit,3,\"assets\"));2===t&&(this.visualSent=!0),this.playerBuilder.reset(),this.playerBuilder=new a(this.beaconSize,this.playerVersion(),\"player\")}}writeMessage(t){if(-1===t[0])return this.finaliseBatch(),this.onOfflineEnd();if(12===t[0]&&\"orloaded\"===t[2])return void(this.initActive()?this.finalizeVisual():this.signalSeen=!0);0===t[0]&&(this.timestamp=t[1]),122===t[0]&&(this.url=t[1]);const s=this.routeMessage(t);this.pushTo(s,t)}routeMessage(t){if(2===this.protocolVersion){const n=t[0];if(s.has(n))return this.assetBuilder;if(i.has(n))return this.devtoolsBuilder;if(e.has(n))return this.analyticsBuilder}return this.playerBuilder}pushTo(t,s){const i=this.currentCtx();if(this.initActive())return void this.pushDuringInit(t,s,i);if(t.push(s,i))return void this.nextIndex++;if(t===this.assetBuilder&&this.flushBuilder(this.playerBuilder),this.flushBuilder(t),t.push(s,i))return void this.nextIndex++;const e=new a(this.beaconSizeLimit,t.version,t.dataType);if(!e.push(s,i))return void console.warn(\"OpenReplay: beacon size overflow. Skipping large message.\",s);this.nextIndex++;const n=e.flush();n&&(t===this.assetBuilder&&this.flushBuilder(this.playerBuilder),this.emitBatch(n,t.dataType,!1))}pushDuringInit(t,s,i){const e=t===this.playerBuilder||t===this.assetBuilder;if(t.push(s,i))return this.nextIndex++,void(e&&this.playerBuilder.size()+this.assetBuilder.size()>=this.beaconSizeLimit&&this.finalizeVisual());if(e)return this.finalizeVisual(),void this.pushTo(this.routeMessage(s),s);if(this.flushBuilderToHeld(t),t.push(s,i))return void this.nextIndex++;const n=new a(this.beaconSizeLimit,t.version,t.dataType);if(!n.push(s,i))return void console.warn(\"OpenReplay: beacon size overflow. Skipping large message.\",s);this.nextIndex++;const h=n.flush();h&&this.heldOther.push({batch:h,dataType:t.dataType})}flushBuilderToHeld(t){const s=t.flush();s&&this.heldOther.push({batch:s,dataType:t.dataType})}finalizeVisual(t=!1){const s=this.playerBuilder.flush(),i=this.assetBuilder.flush();if(this.visualSent=!0,this.playerBuilder=new a(this.beaconSize,this.playerVersion(),\"player\"),this.assetBuilder=new a(this.beaconSize,3,\"assets\"),s&&i){const e=new Uint8Array(s.length+i.length);e.set(s,0),e.set(i,s.length),this.emitBatch(e,\"visual\",t,s.length)}else s?this.emitBatch(s,\"visual\",t):i&&this.emitBatch(i,\"assets\",t);for(const s of this.heldOther)this.emitBatch(s.batch,s.dataType,t);this.heldOther.length=0,this.flushBuilder(this.devtoolsBuilder,t),this.flushBuilder(this.analyticsBuilder,t)}flushBuilder(t,s=!1){const i=t.flush();return!!i&&(this.emitBatch(i,t.dataType,s),!0)}emitBatch(t,s,i,e){this.localDebug&&this.onLocalSave&&this.onLocalSave(`${s}-${Date.now()}`,t.slice()),this.onBatch(t,i,s,e)}finaliseBatch(t=!1){this.initActive()?this.finalizeVisual(t):(this.flushBuilder(this.playerBuilder,t),this.flushBuilder(this.assetBuilder,t),this.flushBuilder(this.devtoolsBuilder,t),this.flushBuilder(this.analyticsBuilder,t))}clean(){this.playerBuilder.reset(),this.assetBuilder.reset(),this.devtoolsBuilder.reset(),this.analyticsBuilder.reset(),this.heldOther.length=0,this.visualSent=!1,this.signalSeen=!1}}const u=new Set([12,13,8,9,58,10,11,61,18,19]);class l{constructor(t){this.report=t,this.lastMouseClick=null,this.lastTimestamp=0,this.lastClickTimestamp=0,this.lastMessageId=0,this.inputIDSet=new Set}reset(){this.lastMouseClick=null,this.lastClickTimestamp=0,this.lastMessageId=0,this.inputIDSet.clear()}build(){const t=this.lastMouseClick,s=this.lastClickTimestamp,i=this.lastMessageId,e=this.lastTimestamp;this.reset(),null===t||s+1234>e||this.report({type:\"dead_click\",contextString:t[3],context:t[4],timestamp:s,messageId:i})}handle(t,s,i){const e=t[0],n=u.has(e);if(68===e||17===e||7===e||n)switch(this.lastTimestamp=i,e){case 68:{const e=t;if(\"\"===e[3])return;const n=this.inputIDSet.has(e[1]);if(this.build(),n)return;return this.lastMouseClick=e,this.lastClickTimestamp=i,void(this.lastMessageId=s)}case 17:{const s=t;return void this.inputIDSet.add(s[1])}case 7:return void this.inputIDSet.clear();default:this.build()}}}class c{constructor(t){this.report=t,this.lastTimestamp=0,this.lastLabel=\"\",this.lastSelector=\"\",this.firstInARowTimestamp=0,this.firstInARowMessageId=0,this.countsInARow=0}reset(){this.lastTimestamp=0,this.lastLabel=\"\",this.lastSelector=\"\",this.firstInARowTimestamp=0,this.firstInARowMessageId=0,this.countsInARow=0}build(){const t=this.countsInARow,s=this.lastLabel,i=this.lastSelector,e=this.firstInARowTimestamp,n=this.firstInARowMessageId;this.reset(),t<3||this.report({type:\"click_rage\",contextString:s,context:i,payload:JSON.stringify({Count:t}),timestamp:e,messageId:n})}handle(t,s,i){if(68!==t[0])return;const e=t,n=e[3],h=e[4];if(\"\"!==n){if(this.lastLabel===n&&i-this.lastTimestamp<300)return this.lastTimestamp=i,void(this.countsInARow+=1);this.build(),this.lastTimestamp=i,this.lastLabel=n,this.lastSelector=h,this.firstInARowTimestamp=i,this.firstInARowMessageId=s,this.countsInARow=1}else this.build()}}function d(t,s){return i=function(t,s){if(0===s)return 1;let i=30*t/s;return i>1&&(i=1),i}(t,s),100-Math.round(100*i);var i}class p{constructor(t){this.report=t,this.startTimestamp=0,this.startMessageId=0,this.lastTimestamp=0,this.maxRate=0,this.contextString=\"\"}duration(){return this.lastTimestamp-this.startTimestamp}reset(){this.startTimestamp=0,this.startMessageId=0,this.maxRate=0}build(){const t=this.startTimestamp,s=this.startMessageId,i=this.maxRate,e=this.duration();this.reset(),0===t||e<6e3||this.report({type:\"cpu\",contextString:this.contextString,payload:JSON.stringify({Duration:e,Rate:i}),timestamp:t,messageId:s})}handle(t,s,i){const e=t[0];if(122===e)return void(this.contextString=t[1]);if(49!==e)return;const n=t,h=n[1],r=n[2];if(i<this.lastTimestamp)return;const a=this.lastTimestamp;if(this.lastTimestamp=i,0===a)return;const o=d(r,(u=i)<(l=a)?0:u-l);var u,l;-1===h||-1===r||o<70?this.build():(0===this.startTimestamp&&(this.startTimestamp=i,this.startMessageId=s),this.maxRate<o&&(this.maxRate=o))}}class f{constructor(t){this.report=t,this.startTimestamp=0,this.startMessageId=0,this.rate=0,this.count=0,this.sum=0,this.contextString=\"\"}reset(){this.startTimestamp=0,this.startMessageId=0,this.rate=0}build(){0!==this.startTimestamp&&(this.report({type:\"memory\",contextString:this.contextString,payload:JSON.stringify({Rate:this.rate-100}),timestamp:this.startTimestamp,messageId:this.startMessageId}),this.reset())}handle(t,s,i){const e=t[0];if(122===e)return void(this.contextString=t[1]);if(49!==e)return;const n=t[4];if(this.count<3)return this.sum+=n,void this.count++;const h=this.sum/this.count,r=Math.round(n/h*100);this.sum+=n,this.count++,r>=300?(0===this.startTimestamp&&(this.startTimestamp=i,this.startMessageId=s),this.rate<r&&(this.rate=r)):this.build()}}class g{constructor(t,s=!1){this.onIssue=t,this.debug=s,this.currentUrl=\"\";const i=t=>{var s,i,e,n;this.debug&&console.log(\"[OR Heuristics]\",t.type,t),this.onIssue([125,null!==(s=t.messageId)&&void 0!==s?s:0,t.timestamp,t.type,null!==(i=t.contextString)&&void 0!==i?i:\"\",null!==(e=t.context)&&void 0!==e?e:\"\",null!==(n=t.payload)&&void 0!==n?n:\"\",t.url||this.currentUrl])};this.detectors=[new l(i),new c(i),new p(i),new f(i)]}handle(t,s,i){122===t[0]&&(this.currentUrl=t[1]);for(const e of this.detectors)e.handle(t,s,i)}}var m;!function(t){t[t.NotActive=0]=\"NotActive\",t[t.Starting=1]=\"Starting\",t[t.Stopping=2]=\"Stopping\",t[t.Active=3]=\"Active\",t[t.Stopped=4]=\"Stopped\"}(m||(m={}));let y=null,b=null,T=null,v=0,S=m.NotActive;function B(t){b&&b.finaliseBatch(t)}function w(){return new Promise((t=>{S=m.Stopping,null!==M&&(clearInterval(M),M=null),b&&(b.clean(),b=null),y&&(y.clean(),setTimeout((()=>{y=null}),20)),T=null,v=0,setTimeout((()=>{S=m.NotActive,t(null)}),100)}))}function I(){[m.Stopped,m.Stopping].includes(S)||(postMessage(\"a_stop\"),w().then((()=>{postMessage(\"a_start\")})))}let x,M=null;self.onmessage=({data:s})=>{var i,e;if(\"stop\"===s)return B(),void w().then((()=>{S=m.Stopped}));if(\"forceFlushBatch\"!==s)if(\"closing\"!==s){if(!Array.isArray(s)){if(\"compressed\"===s.type){if(!y)return console.debug(\"OR WebWorker: sender not initialised. Compressed batch.\"),void I();s.batch&&y.sendCompressed(s.batch,s.dataType,s.split)}if(\"uncompressed\"===s.type){if(!y)return console.debug(\"OR WebWorker: sender not initialised. Uncompressed batch.\"),void I();s.batch&&y.sendUncompressed(s.batch,s.dataType,s.split)}return\"start\"===s.type?(S=m.Starting,y=new t(s.ingestPoint,(()=>{I()}),(t=>{!function(t){postMessage({type:\"failure\",reason:t}),w()}(t)}),s.connAttemptCount,s.connAttemptGap,((t,s,i)=>{postMessage({type:\"compress\",batch:t,dataType:s,split:i},[t.buffer])}),s.pageNo),b=new o(s.pageNo,s.timestamp,s.url,((t,s,i=\"player\",e)=>{y&&(s?y.sendUncompressed(t,i,e):y.push(t,i,e))}),s.tabId,(()=>postMessage({type:\"queue_empty\"})),null!==(i=s.localDebug)&&void 0!==i&&i,((t,s)=>{postMessage({type:\"local_save\",name:t,batch:s},[s.buffer])})),T=new g((t=>null==b?void 0:b.writeMessage(t)),null!==(e=s.localDebug)&&void 0!==e&&e),v=0,null===M&&(M=setInterval(B,3e4)),S=m.Active):\"auth\"===s.type?y?b?(y.authorise(s.token),s.beaconSizeLimit&&b.setBeaconSizeLimit(s.beaconSizeLimit),void(s.protocolVersion&&b.setProtocolVersion(s.protocolVersion))):(console.debug(\"OR WebWorker: writer not initialised. Received auth.\"),void I()):(console.debug(\"OR WebWorker: sender not initialised. Received auth.\"),void I()):void 0}if(b){const t=b;s.forEach((s=>{55===s[0]&&(s[1]?x=setTimeout((()=>I()),18e5):clearTimeout(x)),0===s[0]&&(v=s[1]);const i=t.currentIndex;t.writeMessage(s),T&&t.currentIndex>i&&T.handle(s,i,v)}))}else postMessage(\"not_init\"),I()}else B(!0);else B()}}();\n";
4299
4312
  const CANCELED = 'canceled';
4300
4313
  const bufferStorageKey = 'or_buffer_1';
4301
4314
  const UnsuccessfulStart = (reason) => ({ reason, success: false });
@@ -4360,7 +4373,7 @@ class App {
4360
4373
  this.stopCallbacks = [];
4361
4374
  this.commitCallbacks = [];
4362
4375
  this.activityState = ActivityState.NotActive;
4363
- this.version = '18.1.2'; // TODO: version compatability check inside each plugin.
4376
+ this.version = '19.0.0-beta.0'; // TODO: version compatability check inside each plugin.
4364
4377
  this.socketMode = false;
4365
4378
  this.compressionThreshold = 24 * 1000;
4366
4379
  this.bc = null;
@@ -6355,166 +6368,163 @@ function Console (app, opts) {
6355
6368
  app.observer.attachContextCallback(patchContext);
6356
6369
  }
6357
6370
 
6371
+ //#region src/lite.ts
6358
6372
  const FIREFOX_SAFARI_STACK_REGEXP = /(^|@)\S+:\d+/;
6359
6373
  const CHROME_IE_STACK_REGEXP = /^\s*at .*(\S+:\d+|\(native\))/m;
6360
6374
  const SAFARI_NATIVE_CODE_REGEXP = /^(eval@)?(\[native code\])?$/;
6375
+ /**
6376
+ * Given an Error object, extract the most information from it.
6377
+ *
6378
+ * @param {Error} error object
6379
+ * @param {ParseOptions} options
6380
+ * @return {Array} of StackFrames
6381
+ */
6361
6382
  function parse$1(error, options) {
6362
- if (typeof error.stacktrace !== "undefined" || typeof error["opera#sourceloc"] !== "undefined")
6363
- return parseOpera(error);
6364
- else if (error.stack && error.stack.match(CHROME_IE_STACK_REGEXP))
6365
- return parseV8OrIE(error);
6366
- else if (error.stack)
6367
- return parseFFOrSafari(error);
6368
- else throw new Error("Cannot parse given Error object");
6383
+ if (typeof error.stacktrace !== "undefined" || typeof error["opera#sourceloc"] !== "undefined") return parseOpera(error);
6384
+ else if (error.stack && CHROME_IE_STACK_REGEXP.test(error.stack)) return parseV8OrIE(error);
6385
+ else if (error.stack) return parseFFOrSafari(error);
6386
+ else throw new Error("Cannot parse given Error object");
6369
6387
  }
6388
+ /**
6389
+ * Separate line and column numbers from a string of the form: (URI:Line:Column)
6390
+ */
6370
6391
  function extractLocation(urlLike) {
6371
- if (!urlLike.includes(":"))
6372
- return [urlLike, void 0, void 0];
6373
- const regExp = /(.+?)(?::(\d+))?(?::(\d+))?$/;
6374
- const parts = regExp.exec(urlLike.replace(/[()]/g, ""));
6375
- return [parts[1], parts[2] || void 0, parts[3] || void 0];
6392
+ if (!urlLike.includes(":")) return [
6393
+ urlLike,
6394
+ void 0,
6395
+ void 0
6396
+ ];
6397
+ const parts = /(.+?)(?::(\d+))?(?::(\d+))?$/.exec(urlLike.replace(/[()]/g, ""));
6398
+ return [
6399
+ parts[1],
6400
+ parts[2] || void 0,
6401
+ parts[3] || void 0
6402
+ ];
6376
6403
  }
6377
6404
  function applySlice(lines, options) {
6378
- return lines;
6405
+ return lines;
6379
6406
  }
6380
6407
  function parseV8OrIE(error, options) {
6381
- return parseV8OrIeString(error.stack);
6408
+ return parseV8OrIeString(error.stack);
6382
6409
  }
6383
6410
  function parseV8OrIeString(stack, options) {
6384
- const filtered = applySlice(
6385
- stack.split("\n").filter((line) => {
6386
- return !!line.match(CHROME_IE_STACK_REGEXP);
6387
- }));
6388
- return filtered.map((line) => {
6389
- if (line.includes("(eval ")) {
6390
- line = line.replace(/eval code/g, "eval").replace(/(\(eval at [^()]*)|(,.*$)/g, "");
6391
- }
6392
- let sanitizedLine = line.replace(/^\s+/, "").replace(/\(eval code/g, "(").replace(/^.*?\s+/, "");
6393
- const location = sanitizedLine.match(/ (\(.+\)$)/);
6394
- sanitizedLine = location ? sanitizedLine.replace(location[0], "") : sanitizedLine;
6395
- const locationParts = extractLocation(location ? location[1] : sanitizedLine);
6396
- const functionName = location && sanitizedLine || void 0;
6397
- const fileName = ["eval", "<anonymous>"].includes(locationParts[0]) ? void 0 : locationParts[0];
6398
- return {
6399
- function: functionName,
6400
- file: fileName,
6401
- line: locationParts[1] ? +locationParts[1] : void 0,
6402
- col: locationParts[2] ? +locationParts[2] : void 0,
6403
- raw: line
6404
- };
6405
- });
6411
+ return applySlice(stack.split("\n").filter((line) => {
6412
+ return !!line.match(CHROME_IE_STACK_REGEXP);
6413
+ })).map((line) => {
6414
+ if (line.includes("(eval ")) line = line.replace(/eval code/g, "eval").replace(/(\(eval at [^()]*)|(,.*$)/g, "");
6415
+ let sanitizedLine = line.replace(/^\s+/, "").replace(/\(eval code/g, "(").replace(/^.*?\s+/, "");
6416
+ const location = sanitizedLine.match(/ (\(.+\)$)/);
6417
+ sanitizedLine = location ? sanitizedLine.replace(location[0], "") : sanitizedLine;
6418
+ const locationParts = extractLocation(location ? location[1] : sanitizedLine);
6419
+ return {
6420
+ function: location && sanitizedLine || void 0,
6421
+ file: ["eval", "<anonymous>"].includes(locationParts[0]) ? void 0 : locationParts[0],
6422
+ line: locationParts[1] ? +locationParts[1] : void 0,
6423
+ col: locationParts[2] ? +locationParts[2] : void 0,
6424
+ raw: line
6425
+ };
6426
+ });
6406
6427
  }
6407
6428
  function parseFFOrSafari(error, options) {
6408
- return parseFFOrSafariString(error.stack);
6429
+ return parseFFOrSafariString(error.stack);
6409
6430
  }
6410
6431
  function parseFFOrSafariString(stack, options) {
6411
- const filtered = applySlice(
6412
- stack.split("\n").filter((line) => {
6413
- return !line.match(SAFARI_NATIVE_CODE_REGEXP);
6414
- }));
6415
- return filtered.map((line) => {
6416
- if (line.includes(" > eval"))
6417
- line = line.replace(/ line (\d+)(?: > eval line \d+)* > eval:\d+:\d+/g, ":$1");
6418
- if (!line.includes("@") && !line.includes(":")) {
6419
- return {
6420
- function: line
6421
- };
6422
- } else {
6423
- const functionNameRegex = /(([^\n\r"\u2028\u2029]*".[^\n\r"\u2028\u2029]*"[^\n\r@\u2028\u2029]*(?:@[^\n\r"\u2028\u2029]*"[^\n\r@\u2028\u2029]*)*(?:[\n\r\u2028\u2029][^@]*)?)?[^@]*)@/;
6424
- const matches = line.match(functionNameRegex);
6425
- const functionName = matches && matches[1] ? matches[1] : void 0;
6426
- const locationParts = extractLocation(line.replace(functionNameRegex, ""));
6427
- return {
6428
- function: functionName,
6429
- file: locationParts[0],
6430
- line: locationParts[1] ? +locationParts[1] : void 0,
6431
- col: locationParts[2] ? +locationParts[2] : void 0,
6432
- raw: line
6433
- };
6434
- }
6435
- });
6432
+ return applySlice(stack.split("\n").filter((line) => {
6433
+ return !line.match(SAFARI_NATIVE_CODE_REGEXP);
6434
+ })).map((line) => {
6435
+ if (line.includes(" > eval")) line = line.replace(/ line (\d+)(?: > eval line \d+)* > eval:\d+:\d+/g, ":$1");
6436
+ if (!line.includes("@") && !line.includes(":")) return { function: line };
6437
+ else {
6438
+ const functionNameRegex = /(([^\n\r"\u2028\u2029]*".[^\n\r"\u2028\u2029]*"[^\n\r@\u2028\u2029]*(?:@[^\n\r"\u2028\u2029]*"[^\n\r@\u2028\u2029]*)*(?:[\n\r\u2028\u2029][^@]*)?)?[^@]*)@/;
6439
+ const matches = line.match(functionNameRegex);
6440
+ const functionName = matches && matches[1] ? matches[1] : void 0;
6441
+ const locationParts = extractLocation(line.replace(functionNameRegex, ""));
6442
+ return {
6443
+ function: functionName,
6444
+ file: locationParts[0],
6445
+ line: locationParts[1] ? +locationParts[1] : void 0,
6446
+ col: locationParts[2] ? +locationParts[2] : void 0,
6447
+ raw: line
6448
+ };
6449
+ }
6450
+ });
6436
6451
  }
6437
6452
  function parseOpera(e, options) {
6438
- if (!e.stacktrace || e.message.includes("\n") && e.message.split("\n").length > e.stacktrace.split("\n").length)
6439
- return parseOpera9(e);
6440
- else if (!e.stack)
6441
- return parseOpera10(e);
6442
- else
6443
- return parseOpera11(e);
6453
+ if (!e.stacktrace || e.message.includes("\n") && e.message.split("\n").length > e.stacktrace.split("\n").length) return parseOpera9(e);
6454
+ else if (!e.stack) return parseOpera10(e);
6455
+ else return parseOpera11(e);
6444
6456
  }
6445
6457
  function parseOpera9(e, options) {
6446
- const lineRE = /Line (\d+).*script (?:in )?(\S+)/i;
6447
- const lines = e.message.split("\n");
6448
- const result = [];
6449
- for (let i = 2, len = lines.length; i < len; i += 2) {
6450
- const match = lineRE.exec(lines[i]);
6451
- if (match) {
6452
- result.push({
6453
- file: match[2],
6454
- line: +match[1],
6455
- raw: lines[i]
6456
- });
6457
- }
6458
- }
6459
- return applySlice(result);
6458
+ const lineRE = /Line (\d+).*script (?:in )?(\S+)/i;
6459
+ const lines = e.message.split("\n");
6460
+ const result = [];
6461
+ for (let i = 2, len = lines.length; i < len; i += 2) {
6462
+ const match = lineRE.exec(lines[i]);
6463
+ if (match) result.push({
6464
+ file: match[2],
6465
+ line: +match[1],
6466
+ raw: lines[i]
6467
+ });
6468
+ }
6469
+ return applySlice(result);
6460
6470
  }
6461
6471
  function parseOpera10(e, options) {
6462
- const lineRE = /Line (\d+).*script (?:in )?(\S+)(?:: In function (\S+))?$/i;
6463
- const lines = e.stacktrace.split("\n");
6464
- const result = [];
6465
- for (let i = 0, len = lines.length; i < len; i += 2) {
6466
- const match = lineRE.exec(lines[i]);
6467
- if (match) {
6468
- result.push({
6469
- function: match[3] || void 0,
6470
- file: match[2],
6471
- line: match[1] ? +match[1] : void 0,
6472
- raw: lines[i]
6473
- });
6474
- }
6475
- }
6476
- return applySlice(result);
6472
+ const lineRE = /Line (\d+).*script (?:in )?(\S+)(?:: In function (\S+))?$/i;
6473
+ const lines = e.stacktrace.split("\n");
6474
+ const result = [];
6475
+ for (let i = 0, len = lines.length; i < len; i += 2) {
6476
+ const match = lineRE.exec(lines[i]);
6477
+ if (match) result.push({
6478
+ function: match[3] || void 0,
6479
+ file: match[2],
6480
+ line: match[1] ? +match[1] : void 0,
6481
+ raw: lines[i]
6482
+ });
6483
+ }
6484
+ return applySlice(result);
6477
6485
  }
6478
6486
  function parseOpera11(error, options) {
6479
- const filtered = applySlice(
6480
- // @ts-expect-error missing stack property
6481
- error.stack.split("\n").filter((line) => {
6482
- return !!line.match(FIREFOX_SAFARI_STACK_REGEXP) && !line.match(/^Error created at/);
6483
- }));
6484
- return filtered.map((line) => {
6485
- const tokens = line.split("@");
6486
- const locationParts = extractLocation(tokens.pop());
6487
- const functionCall = tokens.shift() || "";
6488
- const functionName = functionCall.replace(/<anonymous function(: (\w+))?>/, "$2").replace(/\([^)]*\)/g, "") || void 0;
6489
- let argsRaw;
6490
- if (functionCall.match(/\(([^)]*)\)/))
6491
- argsRaw = functionCall.replace(/^[^(]+\(([^)]*)\)$/, "$1");
6492
- const args = argsRaw === void 0 || argsRaw === "[arguments not available]" ? void 0 : argsRaw.split(",");
6493
- return {
6494
- function: functionName,
6495
- args,
6496
- file: locationParts[0],
6497
- line: locationParts[1] ? +locationParts[1] : void 0,
6498
- col: locationParts[2] ? +locationParts[2] : void 0,
6499
- raw: line
6500
- };
6501
- });
6487
+ return applySlice(error.stack.split("\n").filter((line) => {
6488
+ return !!line.match(FIREFOX_SAFARI_STACK_REGEXP) && !line.match(/^Error created at/);
6489
+ })).map((line) => {
6490
+ const tokens = line.split("@");
6491
+ const locationParts = extractLocation(tokens.pop());
6492
+ const functionCall = tokens.shift() || "";
6493
+ const functionName = functionCall.replace(/<anonymous function(: (\w+))?>/, "$2").replace(/\([^)]*\)/g, "") || void 0;
6494
+ let argsRaw;
6495
+ if (/\([^)]*\)/.test(functionCall)) argsRaw = functionCall.replace(/^[^(]+\(([^)]*)\)$/, "$1");
6496
+ return {
6497
+ function: functionName,
6498
+ args: argsRaw === void 0 || argsRaw === "[arguments not available]" ? void 0 : argsRaw.split(","),
6499
+ file: locationParts[0],
6500
+ line: locationParts[1] ? +locationParts[1] : void 0,
6501
+ col: locationParts[2] ? +locationParts[2] : void 0,
6502
+ raw: line
6503
+ };
6504
+ });
6502
6505
  }
6503
6506
 
6507
+ //#region src/index.ts
6504
6508
  function stackframesLiteToStackframes(liteStackframes) {
6505
- return liteStackframes.map((liteStackframe) => {
6506
- return {
6507
- functionName: liteStackframe.function,
6508
- args: liteStackframe.args,
6509
- fileName: liteStackframe.file,
6510
- lineNumber: liteStackframe.line,
6511
- columnNumber: liteStackframe.col,
6512
- source: liteStackframe.raw
6513
- };
6514
- });
6509
+ return liteStackframes.map((liteStackframe) => {
6510
+ return {
6511
+ functionName: liteStackframe.function,
6512
+ args: liteStackframe.args,
6513
+ fileName: liteStackframe.file,
6514
+ lineNumber: liteStackframe.line,
6515
+ columnNumber: liteStackframe.col,
6516
+ source: liteStackframe.raw
6517
+ };
6518
+ });
6515
6519
  }
6520
+ /**
6521
+ * Given an Error object, extract the most information from it.
6522
+ *
6523
+ * @param {Error} error object
6524
+ * @return {Array} of StackFrames
6525
+ */
6516
6526
  function parse(error, options) {
6517
- return stackframesLiteToStackframes(parse$1(error));
6527
+ return stackframesLiteToStackframes(parse$1(error));
6518
6528
  }
6519
6529
 
6520
6530
  function getDefaultStack(e) {
@@ -9790,7 +9800,7 @@ class ConstantProperties {
9790
9800
  user_id: this.user_id,
9791
9801
  distinct_id: this.deviceId,
9792
9802
  sdk_edition: 'web',
9793
- sdk_version: '18.1.2',
9803
+ sdk_version: '19.0.0-beta.0',
9794
9804
  timezone: getUTCOffsetString(),
9795
9805
  search_engine: this.searchEngine,
9796
9806
  };
@@ -10531,7 +10541,7 @@ class API {
10531
10541
  this.signalStartIssue = (reason, missingApi) => {
10532
10542
  const doNotTrack = this.checkDoNotTrack();
10533
10543
  console.log("Tracker couldn't start due to:", JSON.stringify({
10534
- trackerVersion: '18.1.2',
10544
+ trackerVersion: '19.0.0-beta.0',
10535
10545
  projectKey: this.options.projectKey,
10536
10546
  doNotTrack,
10537
10547
  reason: missingApi.length ? `missing api: ${missingApi.join(',')}` : reason,