@openreplay/tracker 18.1.1 → 19.0.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/common/messages.gen.d.ts +13 -2
- package/dist/cjs/entry.js +167 -140
- package/dist/cjs/entry.js.map +1 -1
- package/dist/cjs/index.js +167 -140
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/main/app/index.d.ts +4 -0
- package/dist/cjs/main/app/messages.gen.d.ts +1 -0
- package/dist/lib/common/messages.gen.d.ts +13 -2
- package/dist/lib/entry.js +167 -140
- package/dist/lib/entry.js.map +1 -1
- package/dist/lib/index.js +167 -140
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/main/app/index.d.ts +4 -0
- package/dist/lib/main/app/messages.gen.d.ts +1 -0
- package/dist/types/common/messages.gen.d.ts +13 -2
- package/dist/types/main/app/index.d.ts +4 -0
- package/dist/types/main/app/messages.gen.d.ts +1 -0
- package/package.json +3 -4
|
@@ -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 = '
|
|
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;
|
|
@@ -5119,12 +5132,14 @@ class App {
|
|
|
5119
5132
|
if (ev.data.line === proto.resp) {
|
|
5120
5133
|
const sessionToken = ev.data.token;
|
|
5121
5134
|
this.session.setSessionToken(sessionToken, this.projectKey);
|
|
5135
|
+
this.adoptSessionVersion(ev.data.version);
|
|
5122
5136
|
this.allowAppStart();
|
|
5123
5137
|
}
|
|
5124
5138
|
if (ev.data.line === proto.reg) {
|
|
5125
5139
|
const sessionToken = ev.data.token;
|
|
5126
5140
|
this.session.regenerateTabId();
|
|
5127
5141
|
this.session.setSessionToken(sessionToken, this.projectKey);
|
|
5142
|
+
this.adoptSessionVersion(ev.data.version);
|
|
5128
5143
|
this.allowAppStart();
|
|
5129
5144
|
}
|
|
5130
5145
|
if (ev.data.line === proto.ask) {
|
|
@@ -5133,6 +5148,7 @@ class App {
|
|
|
5133
5148
|
this.bc.postMessage({
|
|
5134
5149
|
line: ev.data.source === thisTab ? proto.reg : proto.resp,
|
|
5135
5150
|
token,
|
|
5151
|
+
version: this.getSessionVersionHash(),
|
|
5136
5152
|
source: thisTab,
|
|
5137
5153
|
context: this.contextId,
|
|
5138
5154
|
projectKey: this.projectKey,
|
|
@@ -5620,15 +5636,29 @@ class App {
|
|
|
5620
5636
|
const PROTO_VERSION = '2';
|
|
5621
5637
|
return `${PROTO_VERSION}x${this.version}`;
|
|
5622
5638
|
}
|
|
5639
|
+
get sessionVersionKey() {
|
|
5640
|
+
return `${this.options.session_token_key}_version`;
|
|
5641
|
+
}
|
|
5642
|
+
storeSessionVersion(version) {
|
|
5643
|
+
this.sessionStorage.setItem(this.sessionVersionKey, version);
|
|
5644
|
+
}
|
|
5645
|
+
/** a tab adopting a session over BroadcastChannel inherits its version too */
|
|
5646
|
+
adoptSessionVersion(version) {
|
|
5647
|
+
if (version) {
|
|
5648
|
+
this.storeSessionVersion(version);
|
|
5649
|
+
}
|
|
5650
|
+
}
|
|
5623
5651
|
checkSessionToken(forceNew) {
|
|
5624
5652
|
const versionHash = this.getSessionVersionHash();
|
|
5625
5653
|
const needReset = this.sessionStorage.getItem(this.options.session_reset_key) !== null;
|
|
5626
|
-
let needNewSessionID = forceNew || needReset;
|
|
5654
|
+
let needNewSessionID = Boolean(forceNew || needReset);
|
|
5627
5655
|
const sessionToken = this.session.getSessionToken(this.projectKey);
|
|
5628
5656
|
if (sessionToken) {
|
|
5629
|
-
const storedVersion = this.sessionStorage.getItem(
|
|
5630
|
-
|
|
5631
|
-
|
|
5657
|
+
const storedVersion = this.sessionStorage.getItem(this.sessionVersionKey);
|
|
5658
|
+
if (!storedVersion || storedVersion !== versionHash) {
|
|
5659
|
+
needNewSessionID = true;
|
|
5660
|
+
}
|
|
5661
|
+
this.storeSessionVersion(versionHash);
|
|
5632
5662
|
}
|
|
5633
5663
|
return needNewSessionID || !sessionToken;
|
|
5634
5664
|
}
|
|
@@ -5952,7 +5982,7 @@ class App {
|
|
|
5952
5982
|
}
|
|
5953
5983
|
this.delay = delay;
|
|
5954
5984
|
this.session.setSessionToken(token, this.projectKey);
|
|
5955
|
-
this.
|
|
5985
|
+
this.storeSessionVersion(this.getSessionVersionHash());
|
|
5956
5986
|
if (sessionToken && sessionToken !== token) {
|
|
5957
5987
|
this.bc?.postMessage({
|
|
5958
5988
|
type: proto.reset,
|
|
@@ -6342,166 +6372,163 @@ function Console (app, opts) {
|
|
|
6342
6372
|
app.observer.attachContextCallback(patchContext);
|
|
6343
6373
|
}
|
|
6344
6374
|
|
|
6375
|
+
//#region src/lite.ts
|
|
6345
6376
|
const FIREFOX_SAFARI_STACK_REGEXP = /(^|@)\S+:\d+/;
|
|
6346
6377
|
const CHROME_IE_STACK_REGEXP = /^\s*at .*(\S+:\d+|\(native\))/m;
|
|
6347
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
|
+
*/
|
|
6348
6386
|
function parse$1(error, options) {
|
|
6349
|
-
|
|
6350
|
-
|
|
6351
|
-
|
|
6352
|
-
|
|
6353
|
-
else if (error.stack)
|
|
6354
|
-
return parseFFOrSafari(error);
|
|
6355
|
-
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");
|
|
6356
6391
|
}
|
|
6392
|
+
/**
|
|
6393
|
+
* Separate line and column numbers from a string of the form: (URI:Line:Column)
|
|
6394
|
+
*/
|
|
6357
6395
|
function extractLocation(urlLike) {
|
|
6358
|
-
|
|
6359
|
-
|
|
6360
|
-
|
|
6361
|
-
|
|
6362
|
-
|
|
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
|
+
];
|
|
6363
6407
|
}
|
|
6364
6408
|
function applySlice(lines, options) {
|
|
6365
|
-
|
|
6409
|
+
return lines;
|
|
6366
6410
|
}
|
|
6367
6411
|
function parseV8OrIE(error, options) {
|
|
6368
|
-
|
|
6412
|
+
return parseV8OrIeString(error.stack);
|
|
6369
6413
|
}
|
|
6370
6414
|
function parseV8OrIeString(stack, options) {
|
|
6371
|
-
|
|
6372
|
-
|
|
6373
|
-
|
|
6374
|
-
|
|
6375
|
-
|
|
6376
|
-
|
|
6377
|
-
|
|
6378
|
-
|
|
6379
|
-
|
|
6380
|
-
|
|
6381
|
-
|
|
6382
|
-
|
|
6383
|
-
|
|
6384
|
-
|
|
6385
|
-
|
|
6386
|
-
|
|
6387
|
-
file: fileName,
|
|
6388
|
-
line: locationParts[1] ? +locationParts[1] : void 0,
|
|
6389
|
-
col: locationParts[2] ? +locationParts[2] : void 0,
|
|
6390
|
-
raw: line
|
|
6391
|
-
};
|
|
6392
|
-
});
|
|
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
|
+
});
|
|
6393
6431
|
}
|
|
6394
6432
|
function parseFFOrSafari(error, options) {
|
|
6395
|
-
|
|
6433
|
+
return parseFFOrSafariString(error.stack);
|
|
6396
6434
|
}
|
|
6397
6435
|
function parseFFOrSafariString(stack, options) {
|
|
6398
|
-
|
|
6399
|
-
|
|
6400
|
-
|
|
6401
|
-
|
|
6402
|
-
|
|
6403
|
-
|
|
6404
|
-
|
|
6405
|
-
|
|
6406
|
-
|
|
6407
|
-
|
|
6408
|
-
|
|
6409
|
-
|
|
6410
|
-
|
|
6411
|
-
|
|
6412
|
-
|
|
6413
|
-
|
|
6414
|
-
|
|
6415
|
-
|
|
6416
|
-
|
|
6417
|
-
line: locationParts[1] ? +locationParts[1] : void 0,
|
|
6418
|
-
col: locationParts[2] ? +locationParts[2] : void 0,
|
|
6419
|
-
raw: line
|
|
6420
|
-
};
|
|
6421
|
-
}
|
|
6422
|
-
});
|
|
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
|
+
});
|
|
6423
6455
|
}
|
|
6424
6456
|
function parseOpera(e, options) {
|
|
6425
|
-
|
|
6426
|
-
|
|
6427
|
-
|
|
6428
|
-
return parseOpera10(e);
|
|
6429
|
-
else
|
|
6430
|
-
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);
|
|
6431
6460
|
}
|
|
6432
6461
|
function parseOpera9(e, options) {
|
|
6433
|
-
|
|
6434
|
-
|
|
6435
|
-
|
|
6436
|
-
|
|
6437
|
-
|
|
6438
|
-
|
|
6439
|
-
|
|
6440
|
-
|
|
6441
|
-
|
|
6442
|
-
|
|
6443
|
-
|
|
6444
|
-
|
|
6445
|
-
}
|
|
6446
|
-
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);
|
|
6447
6474
|
}
|
|
6448
6475
|
function parseOpera10(e, options) {
|
|
6449
|
-
|
|
6450
|
-
|
|
6451
|
-
|
|
6452
|
-
|
|
6453
|
-
|
|
6454
|
-
|
|
6455
|
-
|
|
6456
|
-
|
|
6457
|
-
|
|
6458
|
-
|
|
6459
|
-
|
|
6460
|
-
|
|
6461
|
-
|
|
6462
|
-
}
|
|
6463
|
-
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);
|
|
6464
6489
|
}
|
|
6465
6490
|
function parseOpera11(error, options) {
|
|
6466
|
-
|
|
6467
|
-
|
|
6468
|
-
|
|
6469
|
-
|
|
6470
|
-
|
|
6471
|
-
|
|
6472
|
-
|
|
6473
|
-
|
|
6474
|
-
|
|
6475
|
-
|
|
6476
|
-
|
|
6477
|
-
|
|
6478
|
-
|
|
6479
|
-
|
|
6480
|
-
|
|
6481
|
-
|
|
6482
|
-
|
|
6483
|
-
|
|
6484
|
-
line: locationParts[1] ? +locationParts[1] : void 0,
|
|
6485
|
-
col: locationParts[2] ? +locationParts[2] : void 0,
|
|
6486
|
-
raw: line
|
|
6487
|
-
};
|
|
6488
|
-
});
|
|
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
|
+
});
|
|
6489
6509
|
}
|
|
6490
6510
|
|
|
6511
|
+
//#region src/index.ts
|
|
6491
6512
|
function stackframesLiteToStackframes(liteStackframes) {
|
|
6492
|
-
|
|
6493
|
-
|
|
6494
|
-
|
|
6495
|
-
|
|
6496
|
-
|
|
6497
|
-
|
|
6498
|
-
|
|
6499
|
-
|
|
6500
|
-
|
|
6501
|
-
|
|
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
|
+
});
|
|
6502
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
|
+
*/
|
|
6503
6530
|
function parse(error, options) {
|
|
6504
|
-
|
|
6531
|
+
return stackframesLiteToStackframes(parse$1(error));
|
|
6505
6532
|
}
|
|
6506
6533
|
|
|
6507
6534
|
function getDefaultStack(e) {
|
|
@@ -9777,7 +9804,7 @@ class ConstantProperties {
|
|
|
9777
9804
|
user_id: this.user_id,
|
|
9778
9805
|
distinct_id: this.deviceId,
|
|
9779
9806
|
sdk_edition: 'web',
|
|
9780
|
-
sdk_version: '
|
|
9807
|
+
sdk_version: '19.0.0-beta.0',
|
|
9781
9808
|
timezone: getUTCOffsetString(),
|
|
9782
9809
|
search_engine: this.searchEngine,
|
|
9783
9810
|
};
|
|
@@ -10518,7 +10545,7 @@ class API {
|
|
|
10518
10545
|
this.signalStartIssue = (reason, missingApi) => {
|
|
10519
10546
|
const doNotTrack = this.checkDoNotTrack();
|
|
10520
10547
|
console.log("Tracker couldn't start due to:", JSON.stringify({
|
|
10521
|
-
trackerVersion: '
|
|
10548
|
+
trackerVersion: '19.0.0-beta.0',
|
|
10522
10549
|
projectKey: this.options.projectKey,
|
|
10523
10550
|
doNotTrack,
|
|
10524
10551
|
reason: missingApi.length ? `missing api: ${missingApi.join(',')}` : reason,
|