@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.
@@ -78,7 +78,8 @@ export declare const enum Type {
78
78
  Redux = 121,
79
79
  SetPageLocation = 122,
80
80
  GraphQL = 123,
81
- WebVitals = 124
81
+ WebVitals = 124,
82
+ IssueEvent = 125
82
83
  }
83
84
  export type Timestamp = [
84
85
  Type.Timestamp,
@@ -577,8 +578,18 @@ export type WebVitals = [
577
578
  string,
578
579
  string
579
580
  ];
581
+ export type IssueEvent = [
582
+ Type.IssueEvent,
583
+ number,
584
+ number,
585
+ string,
586
+ string,
587
+ string,
588
+ string,
589
+ string
590
+ ];
580
591
  export declare const ASSET_MESSAGES: ReadonlySet<number>;
581
592
  export declare const DEVTOOLS_MESSAGES: ReadonlySet<number>;
582
593
  export declare const ANALYTICS_MESSAGES: ReadonlySet<number>;
583
- type Message = Timestamp | SetPageLocationDeprecated | SetViewportSize | SetViewportScroll | CreateDocument | CreateElementNode | CreateTextNode | MoveNode | RemoveNode | SetNodeAttribute | RemoveNodeAttribute | SetNodeData | SetNodeScroll | SetInputTarget | SetInputValue | SetInputChecked | MouseMove | NetworkRequestDeprecated | ConsoleLog | PageLoadTiming | PageRenderTiming | CustomEvent | UserID | UserAnonymousID | Metadata | StringDictGlobal | SetNodeAttributeDictGlobal | NodeAnimationResult | Profiler | OTable | StateAction | ReduxDeprecated | Vuex | MobX | NgRx | GraphQLDeprecated | PerformanceTrack | StringDictDeprecated | SetNodeAttributeDictDeprecated | StringDict | SetNodeAttributeDict | ResourceTimingDeprecatedDeprecated | ConnectionInformation | SetPageVisibility | LoadFontFace | SetNodeFocus | SetNodeAttributeURLBased | SetCSSDataURLBased | TechnicalInfo | CustomIssue | SetNodeSlot | MouseClick | MouseClickDeprecated | CreateIFrameDocument | AdoptedSSReplaceURLBased | AdoptedSSInsertRuleURLBased | AdoptedSSDeleteRule | AdoptedSSAddOwner | AdoptedSSRemoveOwner | JSException | Zustand | BatchMetadata | NetworkRequest | WSChannel | ResourceTiming | Incident | LongAnimationTask | InputChange | SelectionChange | MouseThrashing | UnbindNodes | ResourceTimingDeprecated | TabChange | TabData | CanvasNode | TagTrigger | Redux | SetPageLocation | GraphQL | WebVitals;
594
+ type Message = Timestamp | SetPageLocationDeprecated | SetViewportSize | SetViewportScroll | CreateDocument | CreateElementNode | CreateTextNode | MoveNode | RemoveNode | SetNodeAttribute | RemoveNodeAttribute | SetNodeData | SetNodeScroll | SetInputTarget | SetInputValue | SetInputChecked | MouseMove | NetworkRequestDeprecated | ConsoleLog | PageLoadTiming | PageRenderTiming | CustomEvent | UserID | UserAnonymousID | Metadata | StringDictGlobal | SetNodeAttributeDictGlobal | NodeAnimationResult | Profiler | OTable | StateAction | ReduxDeprecated | Vuex | MobX | NgRx | GraphQLDeprecated | PerformanceTrack | StringDictDeprecated | SetNodeAttributeDictDeprecated | StringDict | SetNodeAttributeDict | ResourceTimingDeprecatedDeprecated | ConnectionInformation | SetPageVisibility | LoadFontFace | SetNodeFocus | SetNodeAttributeURLBased | SetCSSDataURLBased | TechnicalInfo | CustomIssue | SetNodeSlot | MouseClick | MouseClickDeprecated | CreateIFrameDocument | AdoptedSSReplaceURLBased | AdoptedSSInsertRuleURLBased | AdoptedSSDeleteRule | AdoptedSSAddOwner | AdoptedSSRemoveOwner | JSException | Zustand | BatchMetadata | NetworkRequest | WSChannel | ResourceTiming | Incident | LongAnimationTask | InputChange | SelectionChange | MouseThrashing | UnbindNodes | ResourceTimingDeprecated | TabChange | TabData | CanvasNode | TagTrigger | Redux | SetPageLocation | GraphQL | WebVitals | IssueEvent;
584
595
  export default Message;
package/dist/cjs/entry.js CHANGED
@@ -1392,6 +1392,18 @@ function WebVitals(name, value) {
1392
1392
  value,
1393
1393
  ];
1394
1394
  }
1395
+ function IssueEvent(messageID, timestamp, type, contextString, context, payload, url) {
1396
+ return [
1397
+ 125 /* Messages.Type.IssueEvent */,
1398
+ messageID,
1399
+ timestamp,
1400
+ type,
1401
+ contextString,
1402
+ context,
1403
+ payload,
1404
+ url,
1405
+ ];
1406
+ }
1395
1407
 
1396
1408
  var _Messages = /*#__PURE__*/Object.freeze({
1397
1409
  __proto__: null,
@@ -1414,6 +1426,7 @@ var _Messages = /*#__PURE__*/Object.freeze({
1414
1426
  GraphQLDeprecated: GraphQLDeprecated,
1415
1427
  Incident: Incident,
1416
1428
  InputChange: InputChange,
1429
+ IssueEvent: IssueEvent,
1417
1430
  JSException: JSException,
1418
1431
  LoadFontFace: LoadFontFace,
1419
1432
  LongAnimationTask: LongAnimationTask$1,
@@ -4299,7 +4312,7 @@ class Ticker {
4299
4312
  * this value is injected during build time via rollup
4300
4313
  * */
4301
4314
  // @ts-ignore
4302
- 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";
4315
+ 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";
4303
4316
  const CANCELED = 'canceled';
4304
4317
  const bufferStorageKey = 'or_buffer_1';
4305
4318
  const UnsuccessfulStart = (reason) => ({ reason, success: false });
@@ -4364,7 +4377,7 @@ class App {
4364
4377
  this.stopCallbacks = [];
4365
4378
  this.commitCallbacks = [];
4366
4379
  this.activityState = ActivityState.NotActive;
4367
- this.version = '18.1.2'; // TODO: version compatability check inside each plugin.
4380
+ this.version = '19.0.0-beta.0'; // TODO: version compatability check inside each plugin.
4368
4381
  this.socketMode = false;
4369
4382
  this.compressionThreshold = 24 * 1000;
4370
4383
  this.bc = null;
@@ -6359,166 +6372,163 @@ function Console (app, opts) {
6359
6372
  app.observer.attachContextCallback(patchContext);
6360
6373
  }
6361
6374
 
6375
+ //#region src/lite.ts
6362
6376
  const FIREFOX_SAFARI_STACK_REGEXP = /(^|@)\S+:\d+/;
6363
6377
  const CHROME_IE_STACK_REGEXP = /^\s*at .*(\S+:\d+|\(native\))/m;
6364
6378
  const SAFARI_NATIVE_CODE_REGEXP = /^(eval@)?(\[native code\])?$/;
6379
+ /**
6380
+ * Given an Error object, extract the most information from it.
6381
+ *
6382
+ * @param {Error} error object
6383
+ * @param {ParseOptions} options
6384
+ * @return {Array} of StackFrames
6385
+ */
6365
6386
  function parse$1(error, options) {
6366
- if (typeof error.stacktrace !== "undefined" || typeof error["opera#sourceloc"] !== "undefined")
6367
- return parseOpera(error);
6368
- else if (error.stack && error.stack.match(CHROME_IE_STACK_REGEXP))
6369
- return parseV8OrIE(error);
6370
- else if (error.stack)
6371
- return parseFFOrSafari(error);
6372
- else throw new Error("Cannot parse given Error object");
6387
+ if (typeof error.stacktrace !== "undefined" || typeof error["opera#sourceloc"] !== "undefined") return parseOpera(error);
6388
+ else if (error.stack && CHROME_IE_STACK_REGEXP.test(error.stack)) return parseV8OrIE(error);
6389
+ else if (error.stack) return parseFFOrSafari(error);
6390
+ else throw new Error("Cannot parse given Error object");
6373
6391
  }
6392
+ /**
6393
+ * Separate line and column numbers from a string of the form: (URI:Line:Column)
6394
+ */
6374
6395
  function extractLocation(urlLike) {
6375
- if (!urlLike.includes(":"))
6376
- return [urlLike, void 0, void 0];
6377
- const regExp = /(.+?)(?::(\d+))?(?::(\d+))?$/;
6378
- const parts = regExp.exec(urlLike.replace(/[()]/g, ""));
6379
- return [parts[1], parts[2] || void 0, parts[3] || void 0];
6396
+ if (!urlLike.includes(":")) return [
6397
+ urlLike,
6398
+ void 0,
6399
+ void 0
6400
+ ];
6401
+ const parts = /(.+?)(?::(\d+))?(?::(\d+))?$/.exec(urlLike.replace(/[()]/g, ""));
6402
+ return [
6403
+ parts[1],
6404
+ parts[2] || void 0,
6405
+ parts[3] || void 0
6406
+ ];
6380
6407
  }
6381
6408
  function applySlice(lines, options) {
6382
- return lines;
6409
+ return lines;
6383
6410
  }
6384
6411
  function parseV8OrIE(error, options) {
6385
- return parseV8OrIeString(error.stack);
6412
+ return parseV8OrIeString(error.stack);
6386
6413
  }
6387
6414
  function parseV8OrIeString(stack, options) {
6388
- const filtered = applySlice(
6389
- stack.split("\n").filter((line) => {
6390
- return !!line.match(CHROME_IE_STACK_REGEXP);
6391
- }));
6392
- return filtered.map((line) => {
6393
- if (line.includes("(eval ")) {
6394
- line = line.replace(/eval code/g, "eval").replace(/(\(eval at [^()]*)|(,.*$)/g, "");
6395
- }
6396
- let sanitizedLine = line.replace(/^\s+/, "").replace(/\(eval code/g, "(").replace(/^.*?\s+/, "");
6397
- const location = sanitizedLine.match(/ (\(.+\)$)/);
6398
- sanitizedLine = location ? sanitizedLine.replace(location[0], "") : sanitizedLine;
6399
- const locationParts = extractLocation(location ? location[1] : sanitizedLine);
6400
- const functionName = location && sanitizedLine || void 0;
6401
- const fileName = ["eval", "<anonymous>"].includes(locationParts[0]) ? void 0 : locationParts[0];
6402
- return {
6403
- function: functionName,
6404
- file: fileName,
6405
- line: locationParts[1] ? +locationParts[1] : void 0,
6406
- col: locationParts[2] ? +locationParts[2] : void 0,
6407
- raw: line
6408
- };
6409
- });
6415
+ return applySlice(stack.split("\n").filter((line) => {
6416
+ return !!line.match(CHROME_IE_STACK_REGEXP);
6417
+ })).map((line) => {
6418
+ if (line.includes("(eval ")) line = line.replace(/eval code/g, "eval").replace(/(\(eval at [^()]*)|(,.*$)/g, "");
6419
+ let sanitizedLine = line.replace(/^\s+/, "").replace(/\(eval code/g, "(").replace(/^.*?\s+/, "");
6420
+ const location = sanitizedLine.match(/ (\(.+\)$)/);
6421
+ sanitizedLine = location ? sanitizedLine.replace(location[0], "") : sanitizedLine;
6422
+ const locationParts = extractLocation(location ? location[1] : sanitizedLine);
6423
+ return {
6424
+ function: location && sanitizedLine || void 0,
6425
+ file: ["eval", "<anonymous>"].includes(locationParts[0]) ? void 0 : locationParts[0],
6426
+ line: locationParts[1] ? +locationParts[1] : void 0,
6427
+ col: locationParts[2] ? +locationParts[2] : void 0,
6428
+ raw: line
6429
+ };
6430
+ });
6410
6431
  }
6411
6432
  function parseFFOrSafari(error, options) {
6412
- return parseFFOrSafariString(error.stack);
6433
+ return parseFFOrSafariString(error.stack);
6413
6434
  }
6414
6435
  function parseFFOrSafariString(stack, options) {
6415
- const filtered = applySlice(
6416
- stack.split("\n").filter((line) => {
6417
- return !line.match(SAFARI_NATIVE_CODE_REGEXP);
6418
- }));
6419
- return filtered.map((line) => {
6420
- if (line.includes(" > eval"))
6421
- line = line.replace(/ line (\d+)(?: > eval line \d+)* > eval:\d+:\d+/g, ":$1");
6422
- if (!line.includes("@") && !line.includes(":")) {
6423
- return {
6424
- function: line
6425
- };
6426
- } else {
6427
- 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][^@]*)?)?[^@]*)@/;
6428
- const matches = line.match(functionNameRegex);
6429
- const functionName = matches && matches[1] ? matches[1] : void 0;
6430
- const locationParts = extractLocation(line.replace(functionNameRegex, ""));
6431
- return {
6432
- function: functionName,
6433
- file: locationParts[0],
6434
- line: locationParts[1] ? +locationParts[1] : void 0,
6435
- col: locationParts[2] ? +locationParts[2] : void 0,
6436
- raw: line
6437
- };
6438
- }
6439
- });
6436
+ return applySlice(stack.split("\n").filter((line) => {
6437
+ return !line.match(SAFARI_NATIVE_CODE_REGEXP);
6438
+ })).map((line) => {
6439
+ if (line.includes(" > eval")) line = line.replace(/ line (\d+)(?: > eval line \d+)* > eval:\d+:\d+/g, ":$1");
6440
+ if (!line.includes("@") && !line.includes(":")) return { function: line };
6441
+ else {
6442
+ 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][^@]*)?)?[^@]*)@/;
6443
+ const matches = line.match(functionNameRegex);
6444
+ const functionName = matches && matches[1] ? matches[1] : void 0;
6445
+ const locationParts = extractLocation(line.replace(functionNameRegex, ""));
6446
+ return {
6447
+ function: functionName,
6448
+ file: locationParts[0],
6449
+ line: locationParts[1] ? +locationParts[1] : void 0,
6450
+ col: locationParts[2] ? +locationParts[2] : void 0,
6451
+ raw: line
6452
+ };
6453
+ }
6454
+ });
6440
6455
  }
6441
6456
  function parseOpera(e, options) {
6442
- if (!e.stacktrace || e.message.includes("\n") && e.message.split("\n").length > e.stacktrace.split("\n").length)
6443
- return parseOpera9(e);
6444
- else if (!e.stack)
6445
- return parseOpera10(e);
6446
- else
6447
- return parseOpera11(e);
6457
+ if (!e.stacktrace || e.message.includes("\n") && e.message.split("\n").length > e.stacktrace.split("\n").length) return parseOpera9(e);
6458
+ else if (!e.stack) return parseOpera10(e);
6459
+ else return parseOpera11(e);
6448
6460
  }
6449
6461
  function parseOpera9(e, options) {
6450
- const lineRE = /Line (\d+).*script (?:in )?(\S+)/i;
6451
- const lines = e.message.split("\n");
6452
- const result = [];
6453
- for (let i = 2, len = lines.length; i < len; i += 2) {
6454
- const match = lineRE.exec(lines[i]);
6455
- if (match) {
6456
- result.push({
6457
- file: match[2],
6458
- line: +match[1],
6459
- raw: lines[i]
6460
- });
6461
- }
6462
- }
6463
- return applySlice(result);
6462
+ const lineRE = /Line (\d+).*script (?:in )?(\S+)/i;
6463
+ const lines = e.message.split("\n");
6464
+ const result = [];
6465
+ for (let i = 2, len = lines.length; i < len; i += 2) {
6466
+ const match = lineRE.exec(lines[i]);
6467
+ if (match) result.push({
6468
+ file: match[2],
6469
+ line: +match[1],
6470
+ raw: lines[i]
6471
+ });
6472
+ }
6473
+ return applySlice(result);
6464
6474
  }
6465
6475
  function parseOpera10(e, options) {
6466
- const lineRE = /Line (\d+).*script (?:in )?(\S+)(?:: In function (\S+))?$/i;
6467
- const lines = e.stacktrace.split("\n");
6468
- const result = [];
6469
- for (let i = 0, len = lines.length; i < len; i += 2) {
6470
- const match = lineRE.exec(lines[i]);
6471
- if (match) {
6472
- result.push({
6473
- function: match[3] || void 0,
6474
- file: match[2],
6475
- line: match[1] ? +match[1] : void 0,
6476
- raw: lines[i]
6477
- });
6478
- }
6479
- }
6480
- return applySlice(result);
6476
+ const lineRE = /Line (\d+).*script (?:in )?(\S+)(?:: In function (\S+))?$/i;
6477
+ const lines = e.stacktrace.split("\n");
6478
+ const result = [];
6479
+ for (let i = 0, len = lines.length; i < len; i += 2) {
6480
+ const match = lineRE.exec(lines[i]);
6481
+ if (match) result.push({
6482
+ function: match[3] || void 0,
6483
+ file: match[2],
6484
+ line: match[1] ? +match[1] : void 0,
6485
+ raw: lines[i]
6486
+ });
6487
+ }
6488
+ return applySlice(result);
6481
6489
  }
6482
6490
  function parseOpera11(error, options) {
6483
- const filtered = applySlice(
6484
- // @ts-expect-error missing stack property
6485
- error.stack.split("\n").filter((line) => {
6486
- return !!line.match(FIREFOX_SAFARI_STACK_REGEXP) && !line.match(/^Error created at/);
6487
- }));
6488
- return filtered.map((line) => {
6489
- const tokens = line.split("@");
6490
- const locationParts = extractLocation(tokens.pop());
6491
- const functionCall = tokens.shift() || "";
6492
- const functionName = functionCall.replace(/<anonymous function(: (\w+))?>/, "$2").replace(/\([^)]*\)/g, "") || void 0;
6493
- let argsRaw;
6494
- if (functionCall.match(/\(([^)]*)\)/))
6495
- argsRaw = functionCall.replace(/^[^(]+\(([^)]*)\)$/, "$1");
6496
- const args = argsRaw === void 0 || argsRaw === "[arguments not available]" ? void 0 : argsRaw.split(",");
6497
- return {
6498
- function: functionName,
6499
- args,
6500
- file: locationParts[0],
6501
- line: locationParts[1] ? +locationParts[1] : void 0,
6502
- col: locationParts[2] ? +locationParts[2] : void 0,
6503
- raw: line
6504
- };
6505
- });
6491
+ return applySlice(error.stack.split("\n").filter((line) => {
6492
+ return !!line.match(FIREFOX_SAFARI_STACK_REGEXP) && !line.match(/^Error created at/);
6493
+ })).map((line) => {
6494
+ const tokens = line.split("@");
6495
+ const locationParts = extractLocation(tokens.pop());
6496
+ const functionCall = tokens.shift() || "";
6497
+ const functionName = functionCall.replace(/<anonymous function(: (\w+))?>/, "$2").replace(/\([^)]*\)/g, "") || void 0;
6498
+ let argsRaw;
6499
+ if (/\([^)]*\)/.test(functionCall)) argsRaw = functionCall.replace(/^[^(]+\(([^)]*)\)$/, "$1");
6500
+ return {
6501
+ function: functionName,
6502
+ args: argsRaw === void 0 || argsRaw === "[arguments not available]" ? void 0 : argsRaw.split(","),
6503
+ file: locationParts[0],
6504
+ line: locationParts[1] ? +locationParts[1] : void 0,
6505
+ col: locationParts[2] ? +locationParts[2] : void 0,
6506
+ raw: line
6507
+ };
6508
+ });
6506
6509
  }
6507
6510
 
6511
+ //#region src/index.ts
6508
6512
  function stackframesLiteToStackframes(liteStackframes) {
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
- });
6513
+ return liteStackframes.map((liteStackframe) => {
6514
+ return {
6515
+ functionName: liteStackframe.function,
6516
+ args: liteStackframe.args,
6517
+ fileName: liteStackframe.file,
6518
+ lineNumber: liteStackframe.line,
6519
+ columnNumber: liteStackframe.col,
6520
+ source: liteStackframe.raw
6521
+ };
6522
+ });
6519
6523
  }
6524
+ /**
6525
+ * Given an Error object, extract the most information from it.
6526
+ *
6527
+ * @param {Error} error object
6528
+ * @return {Array} of StackFrames
6529
+ */
6520
6530
  function parse(error, options) {
6521
- return stackframesLiteToStackframes(parse$1(error));
6531
+ return stackframesLiteToStackframes(parse$1(error));
6522
6532
  }
6523
6533
 
6524
6534
  function getDefaultStack(e) {
@@ -9794,7 +9804,7 @@ class ConstantProperties {
9794
9804
  user_id: this.user_id,
9795
9805
  distinct_id: this.deviceId,
9796
9806
  sdk_edition: 'web',
9797
- sdk_version: '18.1.2',
9807
+ sdk_version: '19.0.0-beta.0',
9798
9808
  timezone: getUTCOffsetString(),
9799
9809
  search_engine: this.searchEngine,
9800
9810
  };
@@ -10535,7 +10545,7 @@ class API {
10535
10545
  this.signalStartIssue = (reason, missingApi) => {
10536
10546
  const doNotTrack = this.checkDoNotTrack();
10537
10547
  console.log("Tracker couldn't start due to:", JSON.stringify({
10538
- trackerVersion: '18.1.2',
10548
+ trackerVersion: '19.0.0-beta.0',
10539
10549
  projectKey: this.options.projectKey,
10540
10550
  doNotTrack,
10541
10551
  reason: missingApi.length ? `missing api: ${missingApi.join(',')}` : reason,