@openreplay/tracker 18.1.2 → 18.1.4
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/cjs/common/interaction.d.ts +4 -17
- package/dist/cjs/entry.js +150 -173
- package/dist/cjs/entry.js.map +1 -1
- package/dist/cjs/index.js +150 -173
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/main/app/index.d.ts +0 -1
- package/dist/lib/common/interaction.d.ts +4 -17
- package/dist/lib/entry.js +150 -173
- package/dist/lib/entry.js.map +1 -1
- package/dist/lib/index.js +150 -173
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/main/app/index.d.ts +0 -1
- package/dist/types/common/interaction.d.ts +4 -17
- package/dist/types/main/app/index.d.ts +0 -1
- package/package.json +19 -18
|
@@ -12,24 +12,16 @@ type Start = {
|
|
|
12
12
|
url: string;
|
|
13
13
|
tabId: string;
|
|
14
14
|
localDebug?: boolean;
|
|
15
|
+
compressionThreshold?: number;
|
|
15
16
|
} & Options;
|
|
16
17
|
type Auth = {
|
|
17
18
|
type: 'auth';
|
|
18
19
|
token: string;
|
|
19
20
|
beaconSizeLimit?: number;
|
|
20
21
|
protocolVersion?: number;
|
|
22
|
+
compressionThreshold?: number;
|
|
21
23
|
};
|
|
22
|
-
export type ToWorkerData = null | 'stop' | Start | Auth | Array<Message> |
|
|
23
|
-
type: 'compressed';
|
|
24
|
-
batch: Uint8Array;
|
|
25
|
-
dataType: DataType;
|
|
26
|
-
split?: number;
|
|
27
|
-
} | {
|
|
28
|
-
type: 'uncompressed';
|
|
29
|
-
batch: Uint8Array;
|
|
30
|
-
dataType: DataType;
|
|
31
|
-
split?: number;
|
|
32
|
-
} | 'forceFlushBatch' | 'closing' | 'check_queue';
|
|
24
|
+
export type ToWorkerData = null | 'stop' | Start | Auth | Array<Message> | 'forceFlushBatch' | 'closing' | 'check_queue';
|
|
33
25
|
type Failure = {
|
|
34
26
|
type: 'failure';
|
|
35
27
|
reason: string;
|
|
@@ -42,10 +34,5 @@ type LocalSave = {
|
|
|
42
34
|
name: string;
|
|
43
35
|
batch: Uint8Array;
|
|
44
36
|
};
|
|
45
|
-
export type FromWorkerData = 'a_stop' | 'a_start' | Failure | 'not_init' |
|
|
46
|
-
type: 'compress';
|
|
47
|
-
batch: Uint8Array;
|
|
48
|
-
dataType: DataType;
|
|
49
|
-
split?: number;
|
|
50
|
-
} | QEmpty | LocalSave;
|
|
37
|
+
export type FromWorkerData = 'a_stop' | 'a_start' | Failure | 'not_init' | QEmpty | LocalSave;
|
|
51
38
|
export {};
|
package/dist/cjs/entry.js
CHANGED
|
@@ -635,11 +635,21 @@ class FIFOTaskScheduler {
|
|
|
635
635
|
this.isRunning = false;
|
|
636
636
|
return;
|
|
637
637
|
}
|
|
638
|
-
// Get the next task and execute it
|
|
638
|
+
// Get the next task and execute it. A task that throws (or rejects) must
|
|
639
|
+
// still schedule the next one: leaving `isRunning` true strands the queue
|
|
640
|
+
// for the lifetime of the page, and since commits run through here that
|
|
641
|
+
// silently ends the recording. See #4836.
|
|
639
642
|
const nextTask = this.taskQueue.shift();
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
+
const scheduleNext = () => requestAnimationFrame(() => executeNextTask());
|
|
644
|
+
let result;
|
|
645
|
+
try {
|
|
646
|
+
result = nextTask();
|
|
647
|
+
}
|
|
648
|
+
catch (e) {
|
|
649
|
+
scheduleNext();
|
|
650
|
+
throw e;
|
|
651
|
+
}
|
|
652
|
+
Promise.resolve(result).then(scheduleNext, scheduleNext);
|
|
643
653
|
};
|
|
644
654
|
executeNextTask();
|
|
645
655
|
}
|
|
@@ -4299,7 +4309,7 @@ class Ticker {
|
|
|
4299
4309
|
* this value is injected during build time via rollup
|
|
4300
4310
|
* */
|
|
4301
4311
|
// @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";
|
|
4312
|
+
const workerBodyFn = "!function(){\"use strict\";function t(t,i,s,e){return new(s||(s=Promise))((function(n,h){function r(t){try{u(e.next(t))}catch(t){h(t)}}function a(t){try{u(e.throw(t))}catch(t){h(t)}}function u(t){var i;t.done?n(t.value):(i=t.value,i instanceof s?i:new s((function(t){t(i)}))).then(r,a)}u((e=e.apply(t,i||[])).next())}))}\"function\"==typeof SuppressedError&&SuppressedError;const i=\"undefined\"!=typeof CompressionStream;class s{constructor(t,i,s,e=10,n=250,h,r){this.onUnauthorised=i,this.onFailure=s,this.MAX_ATTEMPTS_COUNT=e,this.ATTEMPT_TIMEOUT=n,this.pageNo=h,this.attemptsCount=0,this.queue=[],this.inFlight=null,this.inFlightDispatched=!1,this.compressionEpoch=0,this.token=null,this.stopped=!1,this.lastSeq=0,this.compressionThreshold=24e3,this.inflightKeepaliveBytes=0,this.ingestURL=t+\"/v1/web/i\",\"number\"==typeof r&&(this.compressionThreshold=r)}getQueueStatus(){return 0===this.queue.length&&null===this.inFlight}setCompressionThreshold(t){this.compressionThreshold=t}authorise(t){this.token=t,this.pump()}push(t,i=\"player\",s,e=!1){this.stopped||(this.queue.push({seq:++this.lastSeq,batch:t,dataType:i,split:s,raw:e}),this.pump())}pump(){if(this.stopped||null!==this.inFlight||null===this.token||0===this.queue.length)return;const t=this.queue.shift();if(this.inFlight=t,this.inFlightDispatched=!1,t.raw||!i||t.batch.length<=this.compressionThreshold)return void this.dispatch(t,t.batch,!1);const s=++this.compressionEpoch;this.gzip(t.batch).then((i=>{this.compressionEpoch===s&&this.inFlight===t&&this.dispatch(t,i,!0)})).catch((()=>{this.compressionEpoch===s&&this.inFlight===t&&this.dispatch(t,t.batch,!1)}))}gzip(i){return t(this,void 0,void 0,(function*(){const t=new Blob([i]).stream().pipeThrough(new CompressionStream(\"gzip\"));return new Uint8Array(yield new Response(t).arrayBuffer())}))}finish(){this.inFlight=null,this.inFlightDispatched=!1,this.pump()}retry(t,i,s,e){if(this.attemptsCount>=this.MAX_ATTEMPTS_COUNT)return void this.onFailure(`Failed to send batch after ${this.attemptsCount} attempts.`);this.attemptsCount++;const n=new Uint8Array(i);setTimeout((()=>this.dispatch(t,n,s,e)),this.ATTEMPT_TIMEOUT*this.attemptsCount)}dispatch(t,i,s,e=\"\"){var n;if(0===i.length)return console.error(\"OpenReplay: refusing to send 0-byte batch.\",{seq:t.seq,dataType:t.dataType,isCompressed:s}),this.attemptsCount=0,void this.finish();this.inFlight===t&&(this.inFlightDispatched=!0);const h={Authorization:`Bearer ${this.token}`,DataType:t.dataType};if(s&&(h[\"Content-Encoding\"]=\"gzip\"),null===this.token)return void setTimeout((()=>this.dispatch(t,i,s,\"newToken\")),500);const r=i.length<65536&&this.inflightKeepaliveBytes+i.length<=65536;r&&(this.inflightKeepaliveBytes+=i.length);let a=!1;const u=()=>{r&&!a&&(a=!0,this.inflightKeepaliveBytes-=i.length)};let o=this.ingestURL;o+=`?batch=${null!==(n=this.pageNo)&&void 0!==n?n:0}`,o+=`_${t.seq}`,o+=`_${i.byteLength}`,o+=\"_\"+(r?\"kyes\":\"kno\"),e&&(o+=`_${e}`),void 0!==t.split&&(o+=`&split=${t.split}`),fetch(o,{body:i,method:\"POST\",headers:h,keepalive:r}).then((e=>{var n;if(u(),null===(n=e.body)||void 0===n||n.cancel().catch((()=>{})),401===e.status)return this.inFlight=null,this.inFlightDispatched=!1,void this.onUnauthorised();e.status>=400?this.retry(t,i,s,`network:${e.status}`):(this.attemptsCount=0,this.finish())})).catch((e=>{u(),console.warn(\"OpenReplay:\",e),this.retry(t,i,s,`reject:${e.message}`)}))}flushAll(){if(null===this.token)return;const t=this.queue.splice(0),i=this.inFlight;null===i||this.inFlightDispatched||(this.compressionEpoch++,this.inFlight=null,t.unshift(i));for(const i of t)i.raw=!0,this.dispatch(i,i.batch,!1)}clean(){this.flushAll(),this.stopped=!0,setTimeout((()=>{this.token=null,this.queue.length=0,this.inFlight=null,this.inFlightDispatched=!1}),10)}}const e=new Set([60,61,71,73]),n=new Set([21,22,40,41,44,45,46,47,48,79,83,84,85,87,89,116,120,121,123]),h=new Set([17,23,24,27,28,29,30,42,63,64,78,112,115,124]),r=\"function\"==typeof TextEncoder?new TextEncoder:{encode(t){const i=t.length,s=new Uint8Array(3*i);let e=-1;for(let n=0,h=0,r=0;r!==i;){if(n=t.charCodeAt(r),r+=1,n>=55296&&n<=56319){if(r===i){s[e+=1]=239,s[e+=1]=191,s[e+=1]=189;break}if(h=t.charCodeAt(r),!(h>=56320&&h<=57343)){s[e+=1]=239,s[e+=1]=191,s[e+=1]=189;continue}if(n=1024*(n-55296)+h-56320+65536,r+=1,n>65535){s[e+=1]=240|n>>>18,s[e+=1]=128|n>>>12&63,s[e+=1]=128|n>>>6&63,s[e+=1]=128|63&n;continue}}n<=127?s[e+=1]=0|n:n<=2047?(s[e+=1]=192|n>>>6,s[e+=1]=128|63&n):(s[e+=1]=224|n>>>12,s[e+=1]=128|n>>>6&63,s[e+=1]=128|63&n)}return s.subarray(0,e+1)}};class a{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,i){this.data.set(t,i)}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 i=r.encode(t),s=i.byteLength;return!(!this.uint(s)||this.offset+s>this.size)&&(this.data.set(i,this.offset),this.offset+=s,!0)}reset(){this.offset=0,this.checkpointOffset=0}rewind(t,i){t>this.offset||i>this.checkpointOffset||(this.offset=t,this.checkpointOffset=i)}flush(){const t=this.data.slice(0,this.checkpointOffset);return this.reset(),t}}class u extends a{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 o{constructor(t,i,s){this.bufferSize=t,this.version=i,this.dataType=s,this.sizeBuffer=new Uint8Array(3),this.snap=null,this.hasNonTimestamp=!1,this.lastPushedTs=0,this.encoder=new u(t)}push(t,i){const s=this.encoder,e=null===this.snap,n=s.getCurrentOffset(),h=s.getCurrentCheckpoint();if(e){const t={pageNo:i.pageNo,firstIndex:i.index,timestamp:i.timestamp,url:i.url,tabId:i.tabId};if(!this.writeHeader(t))return s.rewind(n,h),!1;this.snap=t,this.lastPushedTs=i.timestamp}return 0===t[0]||i.timestamp===this.lastPushedTs||this.writeMessageWithSize([0,i.timestamp])?this.writeMessageWithSize(t)?(this.lastPushedTs=i.timestamp,0!==t[0]&&(this.hasNonTimestamp=!0),!0):(s.rewind(n,h),e&&(this.snap=null),!1):(s.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}headerOnly(t){this.reset();const i=this.writeHeader({pageNo:t.pageNo,firstIndex:t.index,timestamp:t.timestamp,url:t.url,tabId:t.tabId})?this.encoder.flush():null;return this.reset(),null!==i&&i.length>0?i:null}reset(){this.encoder.reset(),this.snap=null,this.hasNonTimestamp=!1,this.lastPushedTs=0}writeHeader(t){const i=this.encoder,s=[81,this.version,t.pageNo,t.firstIndex,t.timestamp,t.url];return!!i.uint(s[0])&&(!!i.encode(s)&&(!(i.getCurrentOffset()>this.bufferSize)&&(i.checkpoint(),!!this.writeMessageWithSize([0,t.timestamp])&&!!this.writeMessageWithSize([118,t.tabId]))))}writeMessageWithSize(t){const i=this.encoder;if(!i.uint(t[0])||!i.skip(3))return!1;const s=i.getCurrentOffset();if(!i.encode(t))return!1;const e=i.getCurrentOffset(),n=e-s;return n>16777215?(console.warn(\"OpenReplay: max message size overflow.\"),!1):!(e>this.bufferSize)&&(this.writeSizeAt(n,s-3),i.checkpoint(),!0)}writeSizeAt(t,i){for(let i=0;i<3;i++)this.sizeBuffer[i]=t>>8*i;this.encoder.set(this.sizeBuffer,i)}}class l{constructor(t,i,s,e,n,h,r=!1,a){this.pageNo=t,this.timestamp=i,this.url=s,this.onBatch=e,this.tabId=n,this.onOfflineEnd=h,this.localDebug=r,this.onLocalSave=a,this.nextIndex=0,this.beaconSize=2e5,this.beaconSizeLimit=1e6,this.protocolVersion=1,this.visualSent=!1,this.signalSeen=!1,this.heldOther=[],this.playerBuilder=new o(this.beaconSize,this.playerVersion(),\"player\"),this.assetBuilder=new o(this.beaconSize,3,\"assets\"),this.devtoolsBuilder=new o(this.beaconSize,4,\"devtools\"),this.analyticsBuilder=new o(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 o(this.beaconSizeLimit,this.playerVersion(),\"player\"),void(this.assetBuilder=new o(this.beaconSizeLimit,3,\"assets\"));2===t&&(this.visualSent=!0),this.playerBuilder.reset(),this.playerBuilder=new o(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 i=this.routeMessage(t);this.pushTo(i,t)}routeMessage(t){if(2===this.protocolVersion){const i=t[0];if(e.has(i))return this.assetBuilder;if(n.has(i))return this.devtoolsBuilder;if(h.has(i))return this.analyticsBuilder}return this.playerBuilder}pushTo(t,i){const s=this.currentCtx();if(this.initActive())return void this.pushDuringInit(t,i,s);if(t.push(i,s))return void this.nextIndex++;if(t===this.assetBuilder&&this.flushBuilder(this.playerBuilder),this.flushBuilder(t),t.push(i,s))return void this.nextIndex++;const e=new o(this.beaconSizeLimit,t.version,t.dataType);if(!e.push(i,s))return void console.warn(\"OpenReplay: beacon size overflow. Skipping large message.\",i);this.nextIndex++;const n=e.flush();n&&(t===this.assetBuilder&&this.flushBuilder(this.playerBuilder),this.emitBatch(n,t.dataType,!1))}pushDuringInit(t,i,s){const e=t===this.playerBuilder||t===this.assetBuilder;if(t.push(i,s))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(i),i);if(this.flushBuilderToHeld(t),t.push(i,s))return void this.nextIndex++;const n=new o(this.beaconSizeLimit,t.version,t.dataType);if(!n.push(i,s))return void console.warn(\"OpenReplay: beacon size overflow. Skipping large message.\",i);this.nextIndex++;const h=n.flush();h&&this.heldOther.push({batch:h,dataType:t.dataType})}flushBuilderToHeld(t){const i=t.flush();i&&this.heldOther.push({batch:i,dataType:t.dataType})}finalizeVisual(t=!1){const i=this.playerBuilder.flush(),s=this.assetBuilder.flush();this.visualSent=!0,this.playerBuilder=new o(this.beaconSize,this.playerVersion(),\"player\"),this.assetBuilder=new o(this.beaconSize,3,\"assets\");const e=i&&this.withHeader(i,\"player\",this.playerVersion()),n=s&&this.withHeader(s,\"assets\",3);if(e&&n){const i=new Uint8Array(e.length+n.length);i.set(e,0),i.set(n,e.length),this.emitBatch(i,\"visual\",t,e.length)}else e?this.emitBatch(e,\"player\",t):n&&this.emitBatch(n,\"assets\",t);for(const i of this.heldOther)this.emitBatch(i.batch,i.dataType,t);this.heldOther.length=0,this.flushBuilder(this.devtoolsBuilder,t),this.flushBuilder(this.analyticsBuilder,t)}flushBuilder(t,i=!1){const s=t.flush();return!!s&&(this.emitBatch(s,t.dataType,i),!0)}startsWithMeta(t){return t.length>0&&81===t[0]}repairHeader(t,i){const s=new o(16384,i,\"player\").headerOnly(this.currentCtx());if(!s)return null;const e=new Uint8Array(s.length+t.length);return e.set(s,0),e.set(t,s.length),e}withHeader(t,i,s){if(this.startsWithMeta(t))return t;const e=this.repairHeader(t,s);return console.warn(`OpenReplay: ${i} batch had no leading BatchMetadata (${t.length}B, head ${this.headHex(t)}) — `+(e?\"header rebuilt.\":\"could not rebuild the header, skipping.\")),e}versionOf(t){switch(t){case\"assets\":return 3;case\"devtools\":return 4;case\"analytics\":return 5;default:return this.playerVersion()}}emitBatch(t,i,s,e){const n=void 0===e?this.withHeader(t,i,this.versionOf(i)):t;if(!n)return;let h=e;if(void 0!==h&&!this.isBoundary(n,h)){const t=this.findBoundary(n);if(console.warn(`OpenReplay: ${i} batch split ${String(h)} is not a batch boundary (${n.length}B) — `+(t>0?`corrected to ${t}.`:\"no boundary found, skipping.\")),t<=0)return;h=t}this.localDebug&&this.verifyBody(n,i,h),this.localDebug&&this.onLocalSave&&this.onLocalSave(`${i}-${Date.now()}`,n.slice()),this.onBatch(n,s,i,h)}isBoundary(t,i){return i>0&&i<t.length&&81===t[i]}headHex(t){return Array.from(t.subarray(0,8),(t=>t.toString(16).padStart(2,\"0\"))).join(\" \")}scanBatch(t){let i=0,s=0;const e=()=>{let s=0,e=0;for(;i<t.length;){const n=t[i++];if(s+=(127&n)*Math.pow(2,e),!(128&n))return s;e+=7}return-1};for(;i<t.length;){const n=i,h=e();if(s++,h<0)return{boundary:-1,fault:`message ${s}: truncated type`};if(81===h){if(s>1)return{boundary:n,fault:null};for(let t=0;t<4;t++)if(e()<0)return{boundary:-1,fault:\"truncated BatchMetadata\"};const h=e();if(h<0||i+h>t.length)return{boundary:-1,fault:\"truncated BatchMetadata url\"};i+=h;continue}if(1===s)return{boundary:-1,fault:`leading message is type ${h}, not BatchMetadata`};if(i+3>t.length)return{boundary:-1,fault:`message ${s}: truncated size prefix`};const r=t[i]|t[i+1]<<8|t[i+2]<<16;if(i+=3,i+r>t.length)return{boundary:-1,fault:`message ${s}: size ${r} overruns the batch`};i+=r}return{boundary:-1,fault:null}}findBoundary(t){return this.scanBatch(t).boundary}verifyBody(t,i,s){if(void 0!==s)return this.verifyBody(t.subarray(0,s),`${i}:player`),void this.verifyBody(t.subarray(s),`${i}:assets`);const{boundary:e,fault:n}=this.scanBatch(t),h=null!=n?n:e>=0?`BatchMetadata at byte ${e} is not the first message`:null;null!==h&&console.warn(`OpenReplay: malformed ${i} batch — ${h} (${t.length}B, head ${this.headHex(t)}).`)}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 c;!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\"}(c||(c={}));let d=null,p=null,f=c.NotActive;function g(t){p&&p.finaliseBatch(t)}function y(){return new Promise((t=>{f=c.Stopping,null!==B&&(clearInterval(B),B=null),p&&(p.clean(),p=null),d&&(d.clean(),setTimeout((()=>{d=null}),20)),setTimeout((()=>{f=c.NotActive,t(null)}),100)}))}function m(){[c.Stopped,c.Stopping].includes(f)||(postMessage(\"a_stop\"),y().then((()=>{postMessage(\"a_start\")})))}let b,B=null;self.onmessage=({data:t})=>{var i;if(\"stop\"===t)return g(),void y().then((()=>{f=c.Stopped}));if(\"forceFlushBatch\"!==t){if(\"closing\"===t)return g(!0),void(null==d||d.flushAll());if(!Array.isArray(t))return\"start\"===t.type?(f=c.Starting,d=new s(t.ingestPoint,(()=>{m()}),(t=>{!function(t){postMessage({type:\"failure\",reason:t}),y()}(t)}),t.connAttemptCount,t.connAttemptGap,t.pageNo,t.compressionThreshold),p=new l(t.pageNo,t.timestamp,t.url,((t,i,s=\"player\",e)=>{d&&d.push(t,s,e,i)}),t.tabId,(()=>postMessage({type:\"queue_empty\"})),null!==(i=t.localDebug)&&void 0!==i&&i,((t,i)=>{postMessage({type:\"local_save\",name:t,batch:i},[i.buffer])})),null===B&&(B=setInterval(g,3e4)),f=c.Active):\"auth\"===t.type?d?p?(\"number\"==typeof t.compressionThreshold&&d.setCompressionThreshold(t.compressionThreshold),d.authorise(t.token),t.beaconSizeLimit&&p.setBeaconSizeLimit(t.beaconSizeLimit),void(t.protocolVersion&&p.setProtocolVersion(t.protocolVersion))):(console.debug(\"OR WebWorker: writer not initialised. Received auth.\"),void m()):(console.debug(\"OR WebWorker: sender not initialised. Received auth.\"),void m()):void 0;if(p){const i=p;t.forEach((t=>{55===t[0]&&(t[1]?b=setTimeout((()=>m()),18e5):clearTimeout(b)),i.writeMessage(t)}))}else postMessage(\"not_init\"),m()}else g()}}();\n";
|
|
4303
4313
|
const CANCELED = 'canceled';
|
|
4304
4314
|
const bufferStorageKey = 'or_buffer_1';
|
|
4305
4315
|
const UnsuccessfulStart = (reason) => ({ reason, success: false });
|
|
@@ -4364,9 +4374,8 @@ class App {
|
|
|
4364
4374
|
this.stopCallbacks = [];
|
|
4365
4375
|
this.commitCallbacks = [];
|
|
4366
4376
|
this.activityState = ActivityState.NotActive;
|
|
4367
|
-
this.version = '18.1.
|
|
4377
|
+
this.version = '18.1.4'; // TODO: version compatability check inside each plugin.
|
|
4368
4378
|
this.socketMode = false;
|
|
4369
|
-
this.compressionThreshold = 24 * 1000;
|
|
4370
4379
|
this.bc = null;
|
|
4371
4380
|
this.canvasRecorder = null;
|
|
4372
4381
|
this.conditionsManager = null;
|
|
@@ -5362,35 +5371,6 @@ class App {
|
|
|
5362
5371
|
this.debug.error('worker_failed', data.reason);
|
|
5363
5372
|
this._debug('worker_failed', data.reason);
|
|
5364
5373
|
}
|
|
5365
|
-
else if (data.type === 'compress') {
|
|
5366
|
-
const batch = data.batch;
|
|
5367
|
-
const dataType = data.dataType;
|
|
5368
|
-
// split is a decompressed-byte offset, so it survives gzip unchanged.
|
|
5369
|
-
const split = data.split;
|
|
5370
|
-
const batchSize = batch.byteLength;
|
|
5371
|
-
const hasCompressionAPI = 'CompressionStream' in globalThis;
|
|
5372
|
-
if (batchSize > this.compressionThreshold && hasCompressionAPI) {
|
|
5373
|
-
const blob = new Blob([batch]);
|
|
5374
|
-
const stream = blob.stream().pipeThrough(new CompressionStream('gzip'));
|
|
5375
|
-
new Response(stream)
|
|
5376
|
-
.arrayBuffer()
|
|
5377
|
-
.then((compressedBuffer) => {
|
|
5378
|
-
this.worker?.postMessage({
|
|
5379
|
-
type: 'compressed',
|
|
5380
|
-
batch: new Uint8Array(compressedBuffer),
|
|
5381
|
-
dataType,
|
|
5382
|
-
split,
|
|
5383
|
-
});
|
|
5384
|
-
})
|
|
5385
|
-
.catch((err) => {
|
|
5386
|
-
this.debug.error('Openreplay compression error:', err);
|
|
5387
|
-
this.worker?.postMessage({ type: 'uncompressed', batch: batch, dataType, split });
|
|
5388
|
-
});
|
|
5389
|
-
}
|
|
5390
|
-
else {
|
|
5391
|
-
this.worker?.postMessage({ type: 'uncompressed', batch: batch, dataType, split });
|
|
5392
|
-
}
|
|
5393
|
-
}
|
|
5394
5374
|
else if (data.type === 'local_save') {
|
|
5395
5375
|
const blob = new Blob([data.batch], { type: 'application/octet-stream' });
|
|
5396
5376
|
const url = URL.createObjectURL(blob);
|
|
@@ -5999,6 +5979,7 @@ class App {
|
|
|
5999
5979
|
token,
|
|
6000
5980
|
beaconSizeLimit,
|
|
6001
5981
|
protocolVersion,
|
|
5982
|
+
compressionThreshold,
|
|
6002
5983
|
});
|
|
6003
5984
|
}
|
|
6004
5985
|
if (!isNewSession && token === sessionToken) {
|
|
@@ -6009,7 +5990,6 @@ class App {
|
|
|
6009
5990
|
// (Re)send Metadata for the case of a new session
|
|
6010
5991
|
Object.entries(this.session.getInfo().metadata).forEach(([key, value]) => this.send(Metadata(key, value)));
|
|
6011
5992
|
this.localStorage.setItem(this.options.local_uuid_key, userUUID);
|
|
6012
|
-
this.compressionThreshold = compressionThreshold;
|
|
6013
5993
|
const onStartInfo = { sessionToken: token, userUUID, sessionID };
|
|
6014
5994
|
// TODO: start as early as possible (before receiving the token)
|
|
6015
5995
|
/** after start */
|
|
@@ -6359,166 +6339,163 @@ function Console (app, opts) {
|
|
|
6359
6339
|
app.observer.attachContextCallback(patchContext);
|
|
6360
6340
|
}
|
|
6361
6341
|
|
|
6342
|
+
//#region src/lite.ts
|
|
6362
6343
|
const FIREFOX_SAFARI_STACK_REGEXP = /(^|@)\S+:\d+/;
|
|
6363
6344
|
const CHROME_IE_STACK_REGEXP = /^\s*at .*(\S+:\d+|\(native\))/m;
|
|
6364
6345
|
const SAFARI_NATIVE_CODE_REGEXP = /^(eval@)?(\[native code\])?$/;
|
|
6346
|
+
/**
|
|
6347
|
+
* Given an Error object, extract the most information from it.
|
|
6348
|
+
*
|
|
6349
|
+
* @param {Error} error object
|
|
6350
|
+
* @param {ParseOptions} options
|
|
6351
|
+
* @return {Array} of StackFrames
|
|
6352
|
+
*/
|
|
6365
6353
|
function parse$1(error, options) {
|
|
6366
|
-
|
|
6367
|
-
|
|
6368
|
-
|
|
6369
|
-
|
|
6370
|
-
else if (error.stack)
|
|
6371
|
-
return parseFFOrSafari(error);
|
|
6372
|
-
else throw new Error("Cannot parse given Error object");
|
|
6354
|
+
if (typeof error.stacktrace !== "undefined" || typeof error["opera#sourceloc"] !== "undefined") return parseOpera(error);
|
|
6355
|
+
else if (error.stack && CHROME_IE_STACK_REGEXP.test(error.stack)) return parseV8OrIE(error);
|
|
6356
|
+
else if (error.stack) return parseFFOrSafari(error);
|
|
6357
|
+
else throw new Error("Cannot parse given Error object");
|
|
6373
6358
|
}
|
|
6359
|
+
/**
|
|
6360
|
+
* Separate line and column numbers from a string of the form: (URI:Line:Column)
|
|
6361
|
+
*/
|
|
6374
6362
|
function extractLocation(urlLike) {
|
|
6375
|
-
|
|
6376
|
-
|
|
6377
|
-
|
|
6378
|
-
|
|
6379
|
-
|
|
6363
|
+
if (!urlLike.includes(":")) return [
|
|
6364
|
+
urlLike,
|
|
6365
|
+
void 0,
|
|
6366
|
+
void 0
|
|
6367
|
+
];
|
|
6368
|
+
const parts = /(.+?)(?::(\d+))?(?::(\d+))?$/.exec(urlLike.replace(/[()]/g, ""));
|
|
6369
|
+
return [
|
|
6370
|
+
parts[1],
|
|
6371
|
+
parts[2] || void 0,
|
|
6372
|
+
parts[3] || void 0
|
|
6373
|
+
];
|
|
6380
6374
|
}
|
|
6381
6375
|
function applySlice(lines, options) {
|
|
6382
|
-
|
|
6376
|
+
return lines;
|
|
6383
6377
|
}
|
|
6384
6378
|
function parseV8OrIE(error, options) {
|
|
6385
|
-
|
|
6379
|
+
return parseV8OrIeString(error.stack);
|
|
6386
6380
|
}
|
|
6387
6381
|
function parseV8OrIeString(stack, options) {
|
|
6388
|
-
|
|
6389
|
-
|
|
6390
|
-
|
|
6391
|
-
|
|
6392
|
-
|
|
6393
|
-
|
|
6394
|
-
|
|
6395
|
-
|
|
6396
|
-
|
|
6397
|
-
|
|
6398
|
-
|
|
6399
|
-
|
|
6400
|
-
|
|
6401
|
-
|
|
6402
|
-
|
|
6403
|
-
|
|
6404
|
-
file: fileName,
|
|
6405
|
-
line: locationParts[1] ? +locationParts[1] : void 0,
|
|
6406
|
-
col: locationParts[2] ? +locationParts[2] : void 0,
|
|
6407
|
-
raw: line
|
|
6408
|
-
};
|
|
6409
|
-
});
|
|
6382
|
+
return applySlice(stack.split("\n").filter((line) => {
|
|
6383
|
+
return !!line.match(CHROME_IE_STACK_REGEXP);
|
|
6384
|
+
})).map((line) => {
|
|
6385
|
+
if (line.includes("(eval ")) line = line.replace(/eval code/g, "eval").replace(/(\(eval at [^()]*)|(,.*$)/g, "");
|
|
6386
|
+
let sanitizedLine = line.replace(/^\s+/, "").replace(/\(eval code/g, "(").replace(/^.*?\s+/, "");
|
|
6387
|
+
const location = sanitizedLine.match(/ (\(.+\)$)/);
|
|
6388
|
+
sanitizedLine = location ? sanitizedLine.replace(location[0], "") : sanitizedLine;
|
|
6389
|
+
const locationParts = extractLocation(location ? location[1] : sanitizedLine);
|
|
6390
|
+
return {
|
|
6391
|
+
function: location && sanitizedLine || void 0,
|
|
6392
|
+
file: ["eval", "<anonymous>"].includes(locationParts[0]) ? void 0 : locationParts[0],
|
|
6393
|
+
line: locationParts[1] ? +locationParts[1] : void 0,
|
|
6394
|
+
col: locationParts[2] ? +locationParts[2] : void 0,
|
|
6395
|
+
raw: line
|
|
6396
|
+
};
|
|
6397
|
+
});
|
|
6410
6398
|
}
|
|
6411
6399
|
function parseFFOrSafari(error, options) {
|
|
6412
|
-
|
|
6400
|
+
return parseFFOrSafariString(error.stack);
|
|
6413
6401
|
}
|
|
6414
6402
|
function parseFFOrSafariString(stack, options) {
|
|
6415
|
-
|
|
6416
|
-
|
|
6417
|
-
|
|
6418
|
-
|
|
6419
|
-
|
|
6420
|
-
|
|
6421
|
-
|
|
6422
|
-
|
|
6423
|
-
|
|
6424
|
-
|
|
6425
|
-
|
|
6426
|
-
|
|
6427
|
-
|
|
6428
|
-
|
|
6429
|
-
|
|
6430
|
-
|
|
6431
|
-
|
|
6432
|
-
|
|
6433
|
-
|
|
6434
|
-
line: locationParts[1] ? +locationParts[1] : void 0,
|
|
6435
|
-
col: locationParts[2] ? +locationParts[2] : void 0,
|
|
6436
|
-
raw: line
|
|
6437
|
-
};
|
|
6438
|
-
}
|
|
6439
|
-
});
|
|
6403
|
+
return applySlice(stack.split("\n").filter((line) => {
|
|
6404
|
+
return !line.match(SAFARI_NATIVE_CODE_REGEXP);
|
|
6405
|
+
})).map((line) => {
|
|
6406
|
+
if (line.includes(" > eval")) line = line.replace(/ line (\d+)(?: > eval line \d+)* > eval:\d+:\d+/g, ":$1");
|
|
6407
|
+
if (!line.includes("@") && !line.includes(":")) return { function: line };
|
|
6408
|
+
else {
|
|
6409
|
+
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][^@]*)?)?[^@]*)@/;
|
|
6410
|
+
const matches = line.match(functionNameRegex);
|
|
6411
|
+
const functionName = matches && matches[1] ? matches[1] : void 0;
|
|
6412
|
+
const locationParts = extractLocation(line.replace(functionNameRegex, ""));
|
|
6413
|
+
return {
|
|
6414
|
+
function: functionName,
|
|
6415
|
+
file: locationParts[0],
|
|
6416
|
+
line: locationParts[1] ? +locationParts[1] : void 0,
|
|
6417
|
+
col: locationParts[2] ? +locationParts[2] : void 0,
|
|
6418
|
+
raw: line
|
|
6419
|
+
};
|
|
6420
|
+
}
|
|
6421
|
+
});
|
|
6440
6422
|
}
|
|
6441
6423
|
function parseOpera(e, options) {
|
|
6442
|
-
|
|
6443
|
-
|
|
6444
|
-
|
|
6445
|
-
return parseOpera10(e);
|
|
6446
|
-
else
|
|
6447
|
-
return parseOpera11(e);
|
|
6424
|
+
if (!e.stacktrace || e.message.includes("\n") && e.message.split("\n").length > e.stacktrace.split("\n").length) return parseOpera9(e);
|
|
6425
|
+
else if (!e.stack) return parseOpera10(e);
|
|
6426
|
+
else return parseOpera11(e);
|
|
6448
6427
|
}
|
|
6449
6428
|
function parseOpera9(e, options) {
|
|
6450
|
-
|
|
6451
|
-
|
|
6452
|
-
|
|
6453
|
-
|
|
6454
|
-
|
|
6455
|
-
|
|
6456
|
-
|
|
6457
|
-
|
|
6458
|
-
|
|
6459
|
-
|
|
6460
|
-
|
|
6461
|
-
|
|
6462
|
-
}
|
|
6463
|
-
return applySlice(result);
|
|
6429
|
+
const lineRE = /Line (\d+).*script (?:in )?(\S+)/i;
|
|
6430
|
+
const lines = e.message.split("\n");
|
|
6431
|
+
const result = [];
|
|
6432
|
+
for (let i = 2, len = lines.length; i < len; i += 2) {
|
|
6433
|
+
const match = lineRE.exec(lines[i]);
|
|
6434
|
+
if (match) result.push({
|
|
6435
|
+
file: match[2],
|
|
6436
|
+
line: +match[1],
|
|
6437
|
+
raw: lines[i]
|
|
6438
|
+
});
|
|
6439
|
+
}
|
|
6440
|
+
return applySlice(result);
|
|
6464
6441
|
}
|
|
6465
6442
|
function parseOpera10(e, options) {
|
|
6466
|
-
|
|
6467
|
-
|
|
6468
|
-
|
|
6469
|
-
|
|
6470
|
-
|
|
6471
|
-
|
|
6472
|
-
|
|
6473
|
-
|
|
6474
|
-
|
|
6475
|
-
|
|
6476
|
-
|
|
6477
|
-
|
|
6478
|
-
|
|
6479
|
-
}
|
|
6480
|
-
return applySlice(result);
|
|
6443
|
+
const lineRE = /Line (\d+).*script (?:in )?(\S+)(?:: In function (\S+))?$/i;
|
|
6444
|
+
const lines = e.stacktrace.split("\n");
|
|
6445
|
+
const result = [];
|
|
6446
|
+
for (let i = 0, len = lines.length; i < len; i += 2) {
|
|
6447
|
+
const match = lineRE.exec(lines[i]);
|
|
6448
|
+
if (match) result.push({
|
|
6449
|
+
function: match[3] || void 0,
|
|
6450
|
+
file: match[2],
|
|
6451
|
+
line: match[1] ? +match[1] : void 0,
|
|
6452
|
+
raw: lines[i]
|
|
6453
|
+
});
|
|
6454
|
+
}
|
|
6455
|
+
return applySlice(result);
|
|
6481
6456
|
}
|
|
6482
6457
|
function parseOpera11(error, options) {
|
|
6483
|
-
|
|
6484
|
-
|
|
6485
|
-
|
|
6486
|
-
|
|
6487
|
-
|
|
6488
|
-
|
|
6489
|
-
|
|
6490
|
-
|
|
6491
|
-
|
|
6492
|
-
|
|
6493
|
-
|
|
6494
|
-
|
|
6495
|
-
|
|
6496
|
-
|
|
6497
|
-
|
|
6498
|
-
|
|
6499
|
-
|
|
6500
|
-
|
|
6501
|
-
line: locationParts[1] ? +locationParts[1] : void 0,
|
|
6502
|
-
col: locationParts[2] ? +locationParts[2] : void 0,
|
|
6503
|
-
raw: line
|
|
6504
|
-
};
|
|
6505
|
-
});
|
|
6458
|
+
return applySlice(error.stack.split("\n").filter((line) => {
|
|
6459
|
+
return !!line.match(FIREFOX_SAFARI_STACK_REGEXP) && !line.match(/^Error created at/);
|
|
6460
|
+
})).map((line) => {
|
|
6461
|
+
const tokens = line.split("@");
|
|
6462
|
+
const locationParts = extractLocation(tokens.pop());
|
|
6463
|
+
const functionCall = tokens.shift() || "";
|
|
6464
|
+
const functionName = functionCall.replace(/<anonymous function(: (\w+))?>/, "$2").replace(/\([^)]*\)/g, "") || void 0;
|
|
6465
|
+
let argsRaw;
|
|
6466
|
+
if (/\([^)]*\)/.test(functionCall)) argsRaw = functionCall.replace(/^[^(]+\(([^)]*)\)$/, "$1");
|
|
6467
|
+
return {
|
|
6468
|
+
function: functionName,
|
|
6469
|
+
args: argsRaw === void 0 || argsRaw === "[arguments not available]" ? void 0 : argsRaw.split(","),
|
|
6470
|
+
file: locationParts[0],
|
|
6471
|
+
line: locationParts[1] ? +locationParts[1] : void 0,
|
|
6472
|
+
col: locationParts[2] ? +locationParts[2] : void 0,
|
|
6473
|
+
raw: line
|
|
6474
|
+
};
|
|
6475
|
+
});
|
|
6506
6476
|
}
|
|
6507
6477
|
|
|
6478
|
+
//#region src/index.ts
|
|
6508
6479
|
function stackframesLiteToStackframes(liteStackframes) {
|
|
6509
|
-
|
|
6510
|
-
|
|
6511
|
-
|
|
6512
|
-
|
|
6513
|
-
|
|
6514
|
-
|
|
6515
|
-
|
|
6516
|
-
|
|
6517
|
-
|
|
6518
|
-
|
|
6480
|
+
return liteStackframes.map((liteStackframe) => {
|
|
6481
|
+
return {
|
|
6482
|
+
functionName: liteStackframe.function,
|
|
6483
|
+
args: liteStackframe.args,
|
|
6484
|
+
fileName: liteStackframe.file,
|
|
6485
|
+
lineNumber: liteStackframe.line,
|
|
6486
|
+
columnNumber: liteStackframe.col,
|
|
6487
|
+
source: liteStackframe.raw
|
|
6488
|
+
};
|
|
6489
|
+
});
|
|
6519
6490
|
}
|
|
6491
|
+
/**
|
|
6492
|
+
* Given an Error object, extract the most information from it.
|
|
6493
|
+
*
|
|
6494
|
+
* @param {Error} error object
|
|
6495
|
+
* @return {Array} of StackFrames
|
|
6496
|
+
*/
|
|
6520
6497
|
function parse(error, options) {
|
|
6521
|
-
|
|
6498
|
+
return stackframesLiteToStackframes(parse$1(error));
|
|
6522
6499
|
}
|
|
6523
6500
|
|
|
6524
6501
|
function getDefaultStack(e) {
|
|
@@ -7228,7 +7205,7 @@ function getUniqueSiblingClass(el) {
|
|
|
7228
7205
|
return null;
|
|
7229
7206
|
}
|
|
7230
7207
|
|
|
7231
|
-
let e=-1;const t=t=>{addEventListener("pageshow",
|
|
7208
|
+
let e=-1;const t=t=>{addEventListener("pageshow",n=>{n.persisted&&(e=n.timeStamp,t(n));},true);},n=(e,t,n,i)=>{let s,o;return r=>{t.value>=0&&(r||i)&&(o=t.value-(s??0),(o||void 0===s)&&(s=t.value,t.delta=o,t.rating=((e,t)=>e>t[1]?"poor":e>t[0]?"needs-improvement":"good")(t.value,n),e(t)));}},i=e=>{requestAnimationFrame(()=>requestAnimationFrame(e));},s=()=>{const e=performance.getEntriesByType("navigation")[0];if(e&&e.responseStart>0&&e.responseStart<performance.now())return e},o=()=>s()?.activationStart??0,r=(t,n=-1)=>{const i=s();let r="navigate";e>=0?r="back-forward-cache":i&&(document.prerendering||o()>0?r="prerender":document.wasDiscarded?r="restore":i.type&&(r=i.type.replace(/_/g,"-")));return {name:t,value:n,rating:"good",delta:0,entries:[],id:`v5-${Date.now()}-${Math.floor(8999999999999*Math.random())+1e12}`,navigationType:r}},c=new WeakMap;function a(e,t){let n=c.get(t);return n||(n=new WeakMap,c.set(t,n)),n.get(e)||n.set(e,new t),n.get(e)}class d{t;i=0;o=[];h(e){if(e.hadRecentInput)return;const t=this.o[0],n=this.o.at(-1);this.i&&t&&n&&e.startTime-n.startTime<1e3&&e.startTime-t.startTime<5e3?(this.i+=e.value,this.o.push(e)):(this.i=e.value,this.o=[e]),this.t?.(e);}}const h=(e,t,n={})=>{try{if(PerformanceObserver.supportedEntryTypes.includes(e)){const i=new PerformanceObserver(e=>{queueMicrotask(()=>{t(e.getEntries());});});return i.observe({type:e,buffered:!0,...n}),i}}catch{}},f=e=>{let t=false;return ()=>{t||(e(),t=true);}};let l=-1;const u=new Set,m=()=>"hidden"!==document.visibilityState||document.prerendering?1/0:0,p=e=>{if("hidden"===document.visibilityState){if("visibilitychange"===e.type)for(const e of u)e();isFinite(l)||(l="visibilitychange"===e.type?e.timeStamp:0,removeEventListener("prerenderingchange",p,true));}},g=()=>{if(l<0){const e=o(),n=document.prerendering?void 0:globalThis.performance.getEntriesByType("visibility-state").find(t=>"hidden"===t.name&&t.startTime>=e)?.startTime;l=n??m(),addEventListener("visibilitychange",p,true),addEventListener("prerenderingchange",p,true),t(()=>{setTimeout(()=>{l=m();});});}return {get firstHiddenTime(){return l},onHidden(e){u.add(e);}}},v=e=>{document.prerendering?addEventListener("prerenderingchange",e,true):e();},y=[1800,3e3],T=(e,s={})=>{v(()=>{const c=g();let a,d=r("FCP");const f=h("paint",e=>{for(const t of e)"first-contentful-paint"===t.name&&(f.disconnect(),t.startTime<c.firstHiddenTime&&(d.value=Math.max(t.startTime-o(),0),d.entries.push(t),a(true)));});f&&(a=n(e,d,y,s.reportAllChanges),t(t=>{d=r("FCP"),a=n(e,d,y,s.reportAllChanges),i(()=>{d.value=performance.now()-t.timeStamp,a(true);});}));});},E=[.1,.25],b=(e,s={})=>{const o=g();T(f(()=>{let c,f=r("CLS",0);const l=a(s,d),u=e=>{for(const t of e)l.h(t);l.i>f.value&&(f.value=l.i,f.entries=l.o,c());},m=h("layout-shift",u);m&&(c=n(e,f,E,s.reportAllChanges),o.onHidden(()=>{u(m.takeRecords()),c(true);}),t(()=>{l.i=0,f=r("CLS",0),c=n(e,f,E,s.reportAllChanges),i(c);}),setTimeout(c));}));};let L=0,P=1/0,_=0;const M=e=>{for(const t of e)t.interactionId&&(P=Math.min(P,t.interactionId),_=Math.max(_,t.interactionId),L=_?(_-P)/7+1:0);};let w;const C=()=>w?L:performance.interactionCount??0,I=()=>{"interactionCount"in performance||w||(w=h("event",M,{durationThreshold:0}));};let F=0;class k{l=[];u=new Map;m;p;v(){F=C(),this.l.length=0,this.u.clear();}T(){const e=Math.min(this.l.length-1,Math.floor((C()-F)/50));return this.l[e]}h(e){if(this.m?.(e),!e.interactionId&&"first-input"!==e.entryType)return;const t=this.l.at(-1);let n=this.u.get(e.interactionId);if(n||this.l.length<10||e.duration>t.L){if(n?e.duration>n.L?(n.entries=[e],n.L=e.duration):e.duration===n.L&&e.startTime===n.entries[0].startTime&&n.entries.push(e):(n={id:e.interactionId,entries:[e],L:e.duration},this.u.set(n.id,n),this.l.push(n)),this.l.sort((e,t)=>t.L-e.L),this.l.length>10){const e=this.l.splice(10);for(const t of e)this.u.delete(t.id);}this.p?.(n);}}}const A=e=>{const t=globalThis.requestIdleCallback||setTimeout,n=globalThis.cancelIdleCallback||clearTimeout;if("hidden"===document.visibilityState)e();else {const i=f(e);let s=-1;const o=()=>{n(s),i();};addEventListener("visibilitychange",o,{once:true,capture:true}),s=t(()=>{removeEventListener("visibilitychange",o,{capture:true}),i();});}},B=[200,500],S=(e,i={})=>{if(!globalThis.PerformanceEventTiming||!("interactionId"in PerformanceEventTiming.prototype))return;const s=g();v(()=>{I();let o,c=r("INP");const d=a(i,k),f=e=>{A(()=>{for(const t of e)d.h(t);const t=d.T();t&&t.L!==c.value&&(c.value=t.L,c.entries=t.entries,o());});},l=h("event",f,{durationThreshold:i.durationThreshold??40});o=n(e,c,B,i.reportAllChanges),l&&(l.observe({type:"first-input",buffered:true}),s.onHidden(()=>{f(l.takeRecords()),o(true);}),t(()=>{d.v(),c=r("INP"),o=n(e,c,B,i.reportAllChanges);}));});};class q{m;h(e){this.m?.(e);}}const N=[2500,4e3],x=(e,s={})=>{v(()=>{const c=g();let d,l=r("LCP");const u=a(s,q),m=e=>{s.reportAllChanges||(e=e.slice(-1));for(const t of e)u.h(t),t.startTime<c.firstHiddenTime&&(l.value=Math.max(t.startTime-o(),0),l.entries=[t],d());},p=h("largest-contentful-paint",m);if(p){d=n(e,l,N,s.reportAllChanges);const o=f(()=>{m(p.takeRecords()),p.disconnect(),d(true);}),c=e=>{e.isTrusted&&(A(o),removeEventListener(e.type,c,{capture:true}));};for(const e of ["keydown","click","visibilitychange"])addEventListener(e,c,{capture:true});t(t=>{l=r("LCP"),d=n(e,l,N,s.reportAllChanges),i(()=>{l.value=performance.now()-t.timeStamp,d(true);});});}});},H=[800,1800],O=e=>{document.prerendering?v(()=>O(e)):"complete"!==document.readyState?addEventListener("load",()=>O(e),true):setTimeout(e);},W=(e,i={})=>{let c=r("TTFB"),a=n(e,c,H,i.reportAllChanges);O(()=>{const d=s();d&&(c.value=Math.max(d.responseStart-o(),0),c.entries=[d],a(true),t(()=>{c=r("TTFB",0),a=n(e,c,H,i.reportAllChanges),a(true);}));});};
|
|
7232
7209
|
|
|
7233
7210
|
function getPaintBlocks(resources) {
|
|
7234
7211
|
const paintBlocks = [];
|
|
@@ -7361,10 +7338,10 @@ function Timing (app, opts) {
|
|
|
7361
7338
|
// onINP(): Chromium
|
|
7362
7339
|
// onLCP(): Chromium, Firefox
|
|
7363
7340
|
// onTTFB(): Chromium, Firefox, Safari
|
|
7364
|
-
|
|
7341
|
+
b(onVitalsSignal);
|
|
7365
7342
|
S(onVitalsSignal);
|
|
7366
7343
|
x(onVitalsSignal);
|
|
7367
|
-
|
|
7344
|
+
W(onVitalsSignal);
|
|
7368
7345
|
});
|
|
7369
7346
|
app.attachStopCallback(function () {
|
|
7370
7347
|
observer.disconnect();
|
|
@@ -9794,7 +9771,7 @@ class ConstantProperties {
|
|
|
9794
9771
|
user_id: this.user_id,
|
|
9795
9772
|
distinct_id: this.deviceId,
|
|
9796
9773
|
sdk_edition: 'web',
|
|
9797
|
-
sdk_version: '18.1.
|
|
9774
|
+
sdk_version: '18.1.4',
|
|
9798
9775
|
timezone: getUTCOffsetString(),
|
|
9799
9776
|
search_engine: this.searchEngine,
|
|
9800
9777
|
};
|
|
@@ -10535,7 +10512,7 @@ class API {
|
|
|
10535
10512
|
this.signalStartIssue = (reason, missingApi) => {
|
|
10536
10513
|
const doNotTrack = this.checkDoNotTrack();
|
|
10537
10514
|
console.log("Tracker couldn't start due to:", JSON.stringify({
|
|
10538
|
-
trackerVersion: '18.1.
|
|
10515
|
+
trackerVersion: '18.1.4',
|
|
10539
10516
|
projectKey: this.options.projectKey,
|
|
10540
10517
|
doNotTrack,
|
|
10541
10518
|
reason: missingApi.length ? `missing api: ${missingApi.join(',')}` : reason,
|