@openreplay/tracker 16.3.0-beta.2 → 16.3.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 +44 -1
- package/dist/cjs/entry.js +306 -355
- package/dist/cjs/entry.js.map +1 -1
- package/dist/cjs/index.js +306 -355
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/main/app/messages.gen.d.ts +5 -0
- package/dist/cjs/main/app/observer/observer.d.ts +0 -1
- package/dist/cjs/main/modules/mouse.d.ts +2 -20
- package/dist/cjs/main/utils.d.ts +0 -3
- package/dist/lib/common/messages.gen.d.ts +44 -1
- package/dist/lib/entry.js +306 -355
- package/dist/lib/entry.js.map +1 -1
- package/dist/lib/index.js +306 -355
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/main/app/messages.gen.d.ts +5 -0
- package/dist/lib/main/app/observer/observer.d.ts +0 -1
- package/dist/lib/main/modules/mouse.d.ts +2 -20
- package/dist/lib/main/utils.d.ts +0 -3
- package/dist/types/common/messages.gen.d.ts +44 -1
- package/dist/types/main/app/messages.gen.d.ts +5 -0
- package/dist/types/main/app/observer/observer.d.ts +0 -1
- package/dist/types/main/modules/mouse.d.ts +2 -20
- package/dist/types/main/utils.d.ts +0 -3
- package/package.json +1 -2
package/dist/lib/index.js
CHANGED
|
@@ -1465,43 +1465,6 @@ function simpleMerge(defaultObj, givenObj) {
|
|
|
1465
1465
|
}
|
|
1466
1466
|
return result;
|
|
1467
1467
|
}
|
|
1468
|
-
function throttleWithTrailing(fn, interval) {
|
|
1469
|
-
const lastCalls = new Map();
|
|
1470
|
-
const timeouts = new Map();
|
|
1471
|
-
const lastArgs = new Map();
|
|
1472
|
-
const throttled = function (key, ...args) {
|
|
1473
|
-
const now = Date.now();
|
|
1474
|
-
const lastCall = lastCalls.get(key) ?? 0;
|
|
1475
|
-
const remaining = interval - (now - lastCall);
|
|
1476
|
-
lastArgs.set(key, args);
|
|
1477
|
-
if (remaining <= 0) {
|
|
1478
|
-
if (timeouts.has(key)) {
|
|
1479
|
-
clearTimeout(timeouts.get(key));
|
|
1480
|
-
timeouts.delete(key);
|
|
1481
|
-
}
|
|
1482
|
-
lastCalls.set(key, now);
|
|
1483
|
-
fn(key, ...args);
|
|
1484
|
-
}
|
|
1485
|
-
else if (!timeouts.has(key)) {
|
|
1486
|
-
const timeoutId = setTimeout(() => {
|
|
1487
|
-
lastCalls.set(key, Date.now());
|
|
1488
|
-
timeouts.delete(key);
|
|
1489
|
-
const finalArgs = lastArgs.get(key);
|
|
1490
|
-
fn(key, ...finalArgs);
|
|
1491
|
-
}, remaining);
|
|
1492
|
-
timeouts.set(key, timeoutId);
|
|
1493
|
-
}
|
|
1494
|
-
};
|
|
1495
|
-
throttled.clear = () => {
|
|
1496
|
-
for (const timeout of timeouts.values()) {
|
|
1497
|
-
clearTimeout(timeout);
|
|
1498
|
-
}
|
|
1499
|
-
timeouts.clear();
|
|
1500
|
-
lastArgs.clear();
|
|
1501
|
-
lastCalls.clear();
|
|
1502
|
-
};
|
|
1503
|
-
return throttled;
|
|
1504
|
-
}
|
|
1505
1468
|
|
|
1506
1469
|
// Auto-generated, do not edit
|
|
1507
1470
|
/* eslint-disable */
|
|
@@ -1712,6 +1675,33 @@ function SetNodeAttributeDictGlobal(id, name, value) {
|
|
|
1712
1675
|
value,
|
|
1713
1676
|
];
|
|
1714
1677
|
}
|
|
1678
|
+
function CSSInsertRule(id, rule, index) {
|
|
1679
|
+
return [
|
|
1680
|
+
37 /* Messages.Type.CSSInsertRule */,
|
|
1681
|
+
id,
|
|
1682
|
+
rule,
|
|
1683
|
+
index,
|
|
1684
|
+
];
|
|
1685
|
+
}
|
|
1686
|
+
function CSSDeleteRule(id, index) {
|
|
1687
|
+
return [
|
|
1688
|
+
38 /* Messages.Type.CSSDeleteRule */,
|
|
1689
|
+
id,
|
|
1690
|
+
index,
|
|
1691
|
+
];
|
|
1692
|
+
}
|
|
1693
|
+
function Fetch(method, url, request, response, status, timestamp, duration) {
|
|
1694
|
+
return [
|
|
1695
|
+
39 /* Messages.Type.Fetch */,
|
|
1696
|
+
method,
|
|
1697
|
+
url,
|
|
1698
|
+
request,
|
|
1699
|
+
response,
|
|
1700
|
+
status,
|
|
1701
|
+
timestamp,
|
|
1702
|
+
duration,
|
|
1703
|
+
];
|
|
1704
|
+
}
|
|
1715
1705
|
function Profiler(name, duration, args, result) {
|
|
1716
1706
|
return [
|
|
1717
1707
|
40 /* Messages.Type.Profiler */,
|
|
@@ -1854,6 +1844,18 @@ function SetNodeFocus(id) {
|
|
|
1854
1844
|
id,
|
|
1855
1845
|
];
|
|
1856
1846
|
}
|
|
1847
|
+
function LongTask(timestamp, duration, context, containerType, containerSrc, containerId, containerName) {
|
|
1848
|
+
return [
|
|
1849
|
+
59 /* Messages.Type.LongTask */,
|
|
1850
|
+
timestamp,
|
|
1851
|
+
duration,
|
|
1852
|
+
context,
|
|
1853
|
+
containerType,
|
|
1854
|
+
containerSrc,
|
|
1855
|
+
containerId,
|
|
1856
|
+
containerName,
|
|
1857
|
+
];
|
|
1858
|
+
}
|
|
1857
1859
|
function SetNodeAttributeURLBased(id, name, value, baseURL) {
|
|
1858
1860
|
return [
|
|
1859
1861
|
60 /* Messages.Type.SetNodeAttributeURLBased */,
|
|
@@ -1885,6 +1887,15 @@ function CustomIssue(name, payload) {
|
|
|
1885
1887
|
payload,
|
|
1886
1888
|
];
|
|
1887
1889
|
}
|
|
1890
|
+
function CSSInsertRuleURLBased(id, rule, index, baseURL) {
|
|
1891
|
+
return [
|
|
1892
|
+
67 /* Messages.Type.CSSInsertRuleURLBased */,
|
|
1893
|
+
id,
|
|
1894
|
+
rule,
|
|
1895
|
+
index,
|
|
1896
|
+
baseURL,
|
|
1897
|
+
];
|
|
1898
|
+
}
|
|
1888
1899
|
function MouseClick(id, hesitationTime, label, selector, normalizedX, normalizedY) {
|
|
1889
1900
|
return [
|
|
1890
1901
|
68 /* Messages.Type.MouseClick */,
|
|
@@ -2123,6 +2134,9 @@ var _Messages = /*#__PURE__*/Object.freeze({
|
|
|
2123
2134
|
AdoptedSSRemoveOwner: AdoptedSSRemoveOwner,
|
|
2124
2135
|
AdoptedSSReplaceURLBased: AdoptedSSReplaceURLBased,
|
|
2125
2136
|
BatchMetadata: BatchMetadata,
|
|
2137
|
+
CSSDeleteRule: CSSDeleteRule,
|
|
2138
|
+
CSSInsertRule: CSSInsertRule,
|
|
2139
|
+
CSSInsertRuleURLBased: CSSInsertRuleURLBased,
|
|
2126
2140
|
CanvasNode: CanvasNode,
|
|
2127
2141
|
ConnectionInformation: ConnectionInformation,
|
|
2128
2142
|
ConsoleLog: ConsoleLog,
|
|
@@ -2132,11 +2146,13 @@ var _Messages = /*#__PURE__*/Object.freeze({
|
|
|
2132
2146
|
CreateTextNode: CreateTextNode,
|
|
2133
2147
|
CustomEvent: CustomEvent,
|
|
2134
2148
|
CustomIssue: CustomIssue,
|
|
2149
|
+
Fetch: Fetch,
|
|
2135
2150
|
GraphQL: GraphQL,
|
|
2136
2151
|
GraphQLDeprecated: GraphQLDeprecated,
|
|
2137
2152
|
InputChange: InputChange,
|
|
2138
2153
|
JSException: JSException,
|
|
2139
2154
|
LoadFontFace: LoadFontFace,
|
|
2155
|
+
LongTask: LongTask,
|
|
2140
2156
|
Metadata: Metadata,
|
|
2141
2157
|
MobX: MobX,
|
|
2142
2158
|
MouseClick: MouseClick,
|
|
@@ -4252,7 +4268,6 @@ class Observer {
|
|
|
4252
4268
|
this.inlineRemoteCss = false;
|
|
4253
4269
|
this.inlinerOptions = undefined;
|
|
4254
4270
|
this.domParser = new DOMParser();
|
|
4255
|
-
this.throttledSetNodeData = throttleWithTrailing((id, parentElement, data) => this.sendNodeData(id, parentElement, data), 30);
|
|
4256
4271
|
this.disableSprites = Boolean(options.disableSprites);
|
|
4257
4272
|
this.inlineRemoteCss = Boolean(options.inlineRemoteCss);
|
|
4258
4273
|
this.inlinerOptions = options.inlinerOptions;
|
|
@@ -4564,7 +4579,7 @@ class Observer {
|
|
|
4564
4579
|
else if (isTextNode(node)) {
|
|
4565
4580
|
// for text node id != 0, hence parentID !== undefined and parent is Element
|
|
4566
4581
|
this.app.send(CreateTextNode(id, parentID, index));
|
|
4567
|
-
this.
|
|
4582
|
+
this.sendNodeData(id, parent, node.data);
|
|
4568
4583
|
}
|
|
4569
4584
|
return true;
|
|
4570
4585
|
}
|
|
@@ -4585,7 +4600,7 @@ class Observer {
|
|
|
4585
4600
|
throw 'commitNode: node is not a text';
|
|
4586
4601
|
}
|
|
4587
4602
|
// for text node id != 0, hence parent is Element
|
|
4588
|
-
this.
|
|
4603
|
+
this.sendNodeData(id, parent, node.data);
|
|
4589
4604
|
}
|
|
4590
4605
|
return true;
|
|
4591
4606
|
}
|
|
@@ -4628,7 +4643,6 @@ class Observer {
|
|
|
4628
4643
|
disconnect() {
|
|
4629
4644
|
this.observer.disconnect();
|
|
4630
4645
|
this.clear();
|
|
4631
|
-
this.throttledSetNodeData.clear();
|
|
4632
4646
|
}
|
|
4633
4647
|
}
|
|
4634
4648
|
|
|
@@ -5187,7 +5201,7 @@ class Ticker {
|
|
|
5187
5201
|
* this value is injected during build time via rollup
|
|
5188
5202
|
* */
|
|
5189
5203
|
// @ts-ignore
|
|
5190
|
-
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.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){if(this.busy||!this.token)this.queue.push(t);else if(this.busy=!0,this.isCompressing&&this.onCompress)this.onCompress(t);else{const s=++this.lastBatchNum;this.sendBatch(t,!1,s)}}sendNext(){const t=this.queue.shift();if(t)if(this.busy=!0,this.isCompressing&&this.onCompress)this.onCompress(t);else{const s=++this.lastBatchNum;this.sendBatch(t,!1,s)}else this.busy=!1}retry(t,s,i){this.attemptsCount>=this.MAX_ATTEMPTS_COUNT?this.onFailure(`Failed to send batch after ${this.attemptsCount} attempts.`):(this.attemptsCount++,setTimeout((()=>this.sendBatch(t,s,i)),this.ATTEMPT_TIMEOUT*this.attemptsCount))}sendBatch(t,s,i){var e;const n=null==i?void 0:i.toString().replace(/^([^_]+)_([^_]+).*/,\"$1_$2_$3\");this.busy=!0;const h={Authorization:`Bearer ${this.token}`};s&&(h[\"Content-Encoding\"]=\"gzip\"),null!==this.token?fetch(`${this.ingestURL}?batch=${null!==(e=this.pageNo)&&void 0!==e?e:\"noPageNum\"}_${null!=n?n:\"noBatchNum\"}`,{body:t,method:\"POST\",headers:h,keepalive:t.length<65536}).then((e=>{if(401===e.status)return this.busy=!1,void this.onUnauthorised();e.status>=400?this.retry(t,s,`${null!=i?i:\"noBatchNum\"}_network:${e.status}`):(this.attemptsCount=0,this.sendNext())})).catch((e=>{console.warn(\"OpenReplay:\",e),this.retry(t,s,`${null!=i?i:\"noBatchNum\"}_reject:${e.message}`)})):setTimeout((()=>{this.sendBatch(t,s,`${null!=i?i:\"noBatchNum\"}_newToken`)}),500)}sendCompressed(t){const s=++this.lastBatchNum;this.sendBatch(t,!0,s)}sendUncompressed(t){const s=++this.lastBatchNum;this.sendBatch(t,!1,s)}clean(){this.sendNext(),setTimeout((()=>{this.token=null,this.queue.length=0}),10)}}const s=\"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 i{constructor(t){this.size=t,this.offset=0,this.checkpointOffset=0,this.data=new Uint8Array(t)}getCurrentOffset(){return this.offset}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 i=s.encode(t),e=i.byteLength;return!(!this.uint(e)||this.offset+e>this.size)&&(this.data.set(i,this.offset),this.offset+=e,!0)}reset(){this.offset=0,this.checkpointOffset=0}flush(){const t=this.data.slice(0,this.checkpointOffset);return this.reset(),t}}class e extends i{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 70:case 75:case 76:case 77:case 82: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 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 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 n{constructor(t,s,i,n,h,r){this.pageNo=t,this.timestamp=s,this.url=i,this.onBatch=n,this.tabId=h,this.onOfflineEnd=r,this.nextIndex=0,this.beaconSize=2e5,this.encoder=new e(this.beaconSize),this.sizeBuffer=new Uint8Array(3),this.isEmpty=!0,this.beaconSizeLimit=1e6,this.prepare()}writeType(t){return this.encoder.uint(t[0])}writeFields(t){return this.encoder.encode(t)}writeSizeAt(t,s){for(let s=0;s<3;s++)this.sizeBuffer[s]=t>>8*s;this.encoder.set(this.sizeBuffer,s)}prepare(){if(!this.encoder.isEmpty)return;const t=[81,1,this.pageNo,this.nextIndex,this.timestamp,this.url],s=[0,this.timestamp],i=[118,this.tabId];this.writeType(t),this.writeFields(t),this.writeWithSize(s),this.writeWithSize(i),this.isEmpty=!0}writeWithSize(t){const s=this.encoder;if(!this.writeType(t)||!s.skip(3))return!1;const i=s.getCurrentOffset(),e=this.writeFields(t);if(e){const e=s.getCurrentOffset()-i;if(e>16777215)return console.warn(\"OpenReplay: max message size overflow.\"),!1;this.writeSizeAt(e,i-3),s.checkpoint(),this.isEmpty=this.isEmpty&&0===t[0],this.nextIndex++}return e}setBeaconSizeLimit(t){this.beaconSizeLimit=t}writeMessage(t){if(\"q_end\"===t[0])return this.finaliseBatch(),this.onOfflineEnd();0===t[0]&&(this.timestamp=t[1]),122===t[0]&&(this.url=t[1]),this.writeWithSize(t)||(this.finaliseBatch(),this.writeWithSize(t)||(this.encoder=new e(this.beaconSizeLimit),this.prepare(),this.writeWithSize(t)?this.finaliseBatch():console.warn(\"OpenReplay: beacon size overflow. Skipping large message.\",t,this),this.encoder=new e(this.beaconSize),this.prepare()))}finaliseBatch(){if(this.isEmpty)return;const t=this.encoder.flush();this.onBatch(t),this.prepare()}clean(){this.encoder.reset()}}var h;!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\"}(h||(h={}));let r=null,a=null,u=h.NotActive;function o(){a&&a.finaliseBatch()}function c(){return new Promise((t=>{u=h.Stopping,null!==p&&(clearInterval(p),p=null),a&&(a.clean(),a=null),r&&(r.clean(),setTimeout((()=>{r=null}),20)),setTimeout((()=>{u=h.NotActive,t(null)}),100)}))}function l(){[h.Stopped,h.Stopping].includes(u)||(postMessage(\"a_stop\"),c().then((()=>{postMessage(\"a_start\")})))}let g,p=null;self.onmessage=({data:s})=>{if(null!=s){if(\"stop\"===s)return o(),void c().then((()=>{u=h.Stopped}));if(\"forceFlushBatch\"!==s){if(!Array.isArray(s)){if(\"compressed\"===s.type){if(!r)return console.debug(\"OR WebWorker: sender not initialised. Compressed batch.\"),void l();s.batch&&r.sendCompressed(s.batch)}if(\"uncompressed\"===s.type){if(!r)return console.debug(\"OR WebWorker: sender not initialised. Uncompressed batch.\"),void l();s.batch&&r.sendUncompressed(s.batch)}return\"start\"===s.type?(u=h.Starting,r=new t(s.ingestPoint,(()=>{l()}),(t=>{!function(t){postMessage({type:\"failure\",reason:t}),c()}(t)}),s.connAttemptCount,s.connAttemptGap,(t=>{postMessage({type:\"compress\",batch:t},[t.buffer])}),s.pageNo),a=new n(s.pageNo,s.timestamp,s.url,(t=>{r&&r.push(t)}),s.tabId,(()=>postMessage({type:\"queue_empty\"}))),null===p&&(p=setInterval(o,1e4)),u=h.Active):\"auth\"===s.type?r?a?(r.authorise(s.token),void(s.beaconSizeLimit&&a.setBeaconSizeLimit(s.beaconSizeLimit))):(console.debug(\"OR WebWorker: writer not initialised. Received auth.\"),void l()):(console.debug(\"OR WebWorker: sender not initialised. Received auth.\"),void l()):void 0}if(a){const t=a;s.forEach((s=>{55===s[0]&&(s[1]?g=setTimeout((()=>l()),18e5):clearTimeout(g)),t.writeMessage(s)}))}else postMessage(\"not_init\"),l()}else o()}else o()}}();\n";
|
|
5204
|
+
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.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){if(this.busy||!this.token)this.queue.push(t);else if(this.busy=!0,this.isCompressing&&this.onCompress)this.onCompress(t);else{const s=++this.lastBatchNum;this.sendBatch(t,!1,s)}}sendNext(){const t=this.queue.shift();if(t)if(this.busy=!0,this.isCompressing&&this.onCompress)this.onCompress(t);else{const s=++this.lastBatchNum;this.sendBatch(t,!1,s)}else this.busy=!1}retry(t,s,i){this.attemptsCount>=this.MAX_ATTEMPTS_COUNT?this.onFailure(`Failed to send batch after ${this.attemptsCount} attempts.`):(this.attemptsCount++,setTimeout((()=>this.sendBatch(t,s,i)),this.ATTEMPT_TIMEOUT*this.attemptsCount))}sendBatch(t,s,i){var e;const n=null==i?void 0:i.toString().replace(/^([^_]+)_([^_]+).*/,\"$1_$2_$3\");this.busy=!0;const h={Authorization:`Bearer ${this.token}`};s&&(h[\"Content-Encoding\"]=\"gzip\"),null!==this.token?fetch(`${this.ingestURL}?batch=${null!==(e=this.pageNo)&&void 0!==e?e:\"noPageNum\"}_${null!=n?n:\"noBatchNum\"}`,{body:t,method:\"POST\",headers:h,keepalive:t.length<65536}).then((e=>{if(401===e.status)return this.busy=!1,void this.onUnauthorised();e.status>=400?this.retry(t,s,`${null!=i?i:\"noBatchNum\"}_network:${e.status}`):(this.attemptsCount=0,this.sendNext())})).catch((e=>{console.warn(\"OpenReplay:\",e),this.retry(t,s,`${null!=i?i:\"noBatchNum\"}_reject:${e.message}`)})):setTimeout((()=>{this.sendBatch(t,s,`${null!=i?i:\"noBatchNum\"}_newToken`)}),500)}sendCompressed(t){const s=++this.lastBatchNum;this.sendBatch(t,!0,s)}sendUncompressed(t){const s=++this.lastBatchNum;this.sendBatch(t,!1,s)}clean(){this.sendNext(),setTimeout((()=>{this.token=null,this.queue.length=0}),10)}}const s=\"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 i{constructor(t){this.size=t,this.offset=0,this.checkpointOffset=0,this.data=new Uint8Array(t)}getCurrentOffset(){return this.offset}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 i=s.encode(t),e=i.byteLength;return!(!this.uint(e)||this.offset+e>this.size)&&(this.data.set(i,this.offset),this.offset+=e,!0)}reset(){this.offset=0,this.checkpointOffset=0}flush(){const t=this.data.slice(0,this.checkpointOffset);return this.reset(),t}}class e extends i{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 38:case 70:case 75:case 76:case 77:case 82: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 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 37:return this.uint(t[1])&&this.string(t[2])&&this.uint(t[3]);case 39:return this.string(t[1])&&this.string(t[2])&&this.string(t[3])&&this.string(t[4])&&this.uint(t[5])&&this.uint(t[6])&&this.uint(t[7]);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 59:return this.uint(t[1])&&this.uint(t[2])&&this.uint(t[3])&&this.uint(t[4])&&this.string(t[5])&&this.string(t[6])&&this.string(t[7]);case 67:case 73:return this.uint(t[1])&&this.string(t[2])&&this.uint(t[3])&&this.string(t[4]);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 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 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 n{constructor(t,s,i,n,h,r){this.pageNo=t,this.timestamp=s,this.url=i,this.onBatch=n,this.tabId=h,this.onOfflineEnd=r,this.nextIndex=0,this.beaconSize=2e5,this.encoder=new e(this.beaconSize),this.sizeBuffer=new Uint8Array(3),this.isEmpty=!0,this.beaconSizeLimit=1e6,this.prepare()}writeType(t){return this.encoder.uint(t[0])}writeFields(t){return this.encoder.encode(t)}writeSizeAt(t,s){for(let s=0;s<3;s++)this.sizeBuffer[s]=t>>8*s;this.encoder.set(this.sizeBuffer,s)}prepare(){if(!this.encoder.isEmpty)return;const t=[81,1,this.pageNo,this.nextIndex,this.timestamp,this.url],s=[0,this.timestamp],i=[118,this.tabId];this.writeType(t),this.writeFields(t),this.writeWithSize(s),this.writeWithSize(i),this.isEmpty=!0}writeWithSize(t){const s=this.encoder;if(!this.writeType(t)||!s.skip(3))return!1;const i=s.getCurrentOffset(),e=this.writeFields(t);if(e){const e=s.getCurrentOffset()-i;if(e>16777215)return console.warn(\"OpenReplay: max message size overflow.\"),!1;this.writeSizeAt(e,i-3),s.checkpoint(),this.isEmpty=this.isEmpty&&0===t[0],this.nextIndex++}return e}setBeaconSizeLimit(t){this.beaconSizeLimit=t}writeMessage(t){if(\"q_end\"===t[0])return this.finaliseBatch(),this.onOfflineEnd();0===t[0]&&(this.timestamp=t[1]),122===t[0]&&(this.url=t[1]),this.writeWithSize(t)||(this.finaliseBatch(),this.writeWithSize(t)||(this.encoder=new e(this.beaconSizeLimit),this.prepare(),this.writeWithSize(t)?this.finaliseBatch():console.warn(\"OpenReplay: beacon size overflow. Skipping large message.\",t,this),this.encoder=new e(this.beaconSize),this.prepare()))}finaliseBatch(){if(this.isEmpty)return;const t=this.encoder.flush();this.onBatch(t),this.prepare()}clean(){this.encoder.reset()}}var h;!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\"}(h||(h={}));let r=null,a=null,u=h.NotActive;function o(){a&&a.finaliseBatch()}function c(){return new Promise((t=>{u=h.Stopping,null!==p&&(clearInterval(p),p=null),a&&(a.clean(),a=null),r&&(r.clean(),setTimeout((()=>{r=null}),20)),setTimeout((()=>{u=h.NotActive,t(null)}),100)}))}function g(){[h.Stopped,h.Stopping].includes(u)||(postMessage(\"a_stop\"),c().then((()=>{postMessage(\"a_start\")})))}let l,p=null;self.onmessage=({data:s})=>{if(null!=s){if(\"stop\"===s)return o(),void c().then((()=>{u=h.Stopped}));if(\"forceFlushBatch\"!==s){if(!Array.isArray(s)){if(\"compressed\"===s.type){if(!r)return console.debug(\"OR WebWorker: sender not initialised. Compressed batch.\"),void g();s.batch&&r.sendCompressed(s.batch)}if(\"uncompressed\"===s.type){if(!r)return console.debug(\"OR WebWorker: sender not initialised. Uncompressed batch.\"),void g();s.batch&&r.sendUncompressed(s.batch)}return\"start\"===s.type?(u=h.Starting,r=new t(s.ingestPoint,(()=>{g()}),(t=>{!function(t){postMessage({type:\"failure\",reason:t}),c()}(t)}),s.connAttemptCount,s.connAttemptGap,(t=>{postMessage({type:\"compress\",batch:t},[t.buffer])}),s.pageNo),a=new n(s.pageNo,s.timestamp,s.url,(t=>{r&&r.push(t)}),s.tabId,(()=>postMessage({type:\"queue_empty\"}))),null===p&&(p=setInterval(o,1e4)),u=h.Active):\"auth\"===s.type?r?a?(r.authorise(s.token),void(s.beaconSizeLimit&&a.setBeaconSizeLimit(s.beaconSizeLimit))):(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(a){const t=a;s.forEach((s=>{55===s[0]&&(s[1]?l=setTimeout((()=>g()),18e5):clearTimeout(l)),t.writeMessage(s)}))}else postMessage(\"not_init\"),g()}else o()}else o()}}();\n";
|
|
5191
5205
|
const CANCELED = 'canceled';
|
|
5192
5206
|
const uxtStorageKey = 'or_uxt_active';
|
|
5193
5207
|
const bufferStorageKey = 'or_buffer_1';
|
|
@@ -5241,7 +5255,7 @@ class App {
|
|
|
5241
5255
|
this.stopCallbacks = [];
|
|
5242
5256
|
this.commitCallbacks = [];
|
|
5243
5257
|
this.activityState = ActivityState.NotActive;
|
|
5244
|
-
this.version = '16.3.0
|
|
5258
|
+
this.version = '16.3.0'; // TODO: version compatability check inside each plugin.
|
|
5245
5259
|
this.socketMode = false;
|
|
5246
5260
|
this.compressionThreshold = 24 * 1000;
|
|
5247
5261
|
this.bc = null;
|
|
@@ -7281,308 +7295,11 @@ function Input (app, opts) {
|
|
|
7281
7295
|
}));
|
|
7282
7296
|
}
|
|
7283
7297
|
|
|
7284
|
-
|
|
7285
|
-
|
|
7286
|
-
|
|
7287
|
-
const
|
|
7288
|
-
|
|
7289
|
-
function attr(name, value) {
|
|
7290
|
-
let nameIsOk = acceptedAttrNames.has(name);
|
|
7291
|
-
nameIsOk ||= name.startsWith('data-') && wordLike(name);
|
|
7292
|
-
let valueIsOk = wordLike(value) && value.length < 100;
|
|
7293
|
-
valueIsOk ||= value.startsWith('#') && wordLike(value.slice(1));
|
|
7294
|
-
return nameIsOk && valueIsOk;
|
|
7295
|
-
}
|
|
7296
|
-
/** Check if id name is word-like. */
|
|
7297
|
-
function idName(name) {
|
|
7298
|
-
return wordLike(name);
|
|
7299
|
-
}
|
|
7300
|
-
/** Check if class name is word-like. */
|
|
7301
|
-
function className(name) {
|
|
7302
|
-
return wordLike(name);
|
|
7303
|
-
}
|
|
7304
|
-
/** Check if tag name is word-like. */
|
|
7305
|
-
function tagName(name) {
|
|
7306
|
-
return true;
|
|
7307
|
-
}
|
|
7308
|
-
/** Finds unique CSS selectors for the given element. */
|
|
7309
|
-
function finder(input, options) {
|
|
7310
|
-
if (input.nodeType !== Node.ELEMENT_NODE) {
|
|
7311
|
-
throw new Error(`Can't generate CSS selector for non-element node type.`);
|
|
7312
|
-
}
|
|
7313
|
-
if (input.tagName.toLowerCase() === 'html') {
|
|
7314
|
-
return 'html';
|
|
7315
|
-
}
|
|
7316
|
-
const defaults = {
|
|
7317
|
-
root: document.body,
|
|
7318
|
-
idName: idName,
|
|
7319
|
-
className: className,
|
|
7320
|
-
tagName: tagName,
|
|
7321
|
-
attr: attr,
|
|
7322
|
-
timeoutMs: 1000,
|
|
7323
|
-
seedMinLength: 3,
|
|
7324
|
-
optimizedMinLength: 2,
|
|
7325
|
-
maxNumberOfPathChecks: Infinity,
|
|
7326
|
-
};
|
|
7327
|
-
const startTime = new Date();
|
|
7328
|
-
const config = { ...defaults, ...options };
|
|
7329
|
-
const rootDocument = findRootDocument(config.root, defaults);
|
|
7330
|
-
let foundPath;
|
|
7331
|
-
let count = 0;
|
|
7332
|
-
for (const candidate of search(input, config, rootDocument)) {
|
|
7333
|
-
const elapsedTimeMs = new Date().getTime() - startTime.getTime();
|
|
7334
|
-
if (elapsedTimeMs > config.timeoutMs ||
|
|
7335
|
-
count >= config.maxNumberOfPathChecks) {
|
|
7336
|
-
const fPath = fallback(input, rootDocument);
|
|
7337
|
-
if (!fPath) {
|
|
7338
|
-
throw new Error(`Timeout: Can't find a unique selector after ${config.timeoutMs}ms`);
|
|
7339
|
-
}
|
|
7340
|
-
return selector(fPath);
|
|
7341
|
-
}
|
|
7342
|
-
count++;
|
|
7343
|
-
if (unique(candidate, rootDocument)) {
|
|
7344
|
-
foundPath = candidate;
|
|
7345
|
-
break;
|
|
7346
|
-
}
|
|
7347
|
-
}
|
|
7348
|
-
if (!foundPath) {
|
|
7349
|
-
throw new Error(`Selector was not found.`);
|
|
7350
|
-
}
|
|
7351
|
-
const optimized = [
|
|
7352
|
-
...optimize(foundPath, input, config, rootDocument, startTime),
|
|
7353
|
-
];
|
|
7354
|
-
optimized.sort(byPenalty);
|
|
7355
|
-
if (optimized.length > 0) {
|
|
7356
|
-
return selector(optimized[0]);
|
|
7357
|
-
}
|
|
7358
|
-
return selector(foundPath);
|
|
7359
|
-
}
|
|
7360
|
-
function* search(input, config, rootDocument) {
|
|
7361
|
-
const stack = [];
|
|
7362
|
-
let paths = [];
|
|
7363
|
-
let current = input;
|
|
7364
|
-
let i = 0;
|
|
7365
|
-
while (current && current !== rootDocument) {
|
|
7366
|
-
const level = tie(current, config);
|
|
7367
|
-
for (const node of level) {
|
|
7368
|
-
node.level = i;
|
|
7369
|
-
}
|
|
7370
|
-
stack.push(level);
|
|
7371
|
-
current = current.parentElement;
|
|
7372
|
-
i++;
|
|
7373
|
-
paths.push(...combinations(stack));
|
|
7374
|
-
if (i >= config.seedMinLength) {
|
|
7375
|
-
paths.sort(byPenalty);
|
|
7376
|
-
for (const candidate of paths) {
|
|
7377
|
-
yield candidate;
|
|
7378
|
-
}
|
|
7379
|
-
paths = [];
|
|
7380
|
-
}
|
|
7381
|
-
}
|
|
7382
|
-
paths.sort(byPenalty);
|
|
7383
|
-
for (const candidate of paths) {
|
|
7384
|
-
yield candidate;
|
|
7385
|
-
}
|
|
7386
|
-
}
|
|
7387
|
-
function wordLike(name) {
|
|
7388
|
-
if (/^[a-z\-]{3,}$/i.test(name)) {
|
|
7389
|
-
const words = name.split(/-|[A-Z]/);
|
|
7390
|
-
for (const word of words) {
|
|
7391
|
-
if (word.length <= 2) {
|
|
7392
|
-
return false;
|
|
7393
|
-
}
|
|
7394
|
-
if (/[^aeiou]{4,}/i.test(word)) {
|
|
7395
|
-
return false;
|
|
7396
|
-
}
|
|
7397
|
-
}
|
|
7398
|
-
return true;
|
|
7399
|
-
}
|
|
7400
|
-
return false;
|
|
7401
|
-
}
|
|
7402
|
-
function tie(element, config) {
|
|
7403
|
-
const level = [];
|
|
7404
|
-
const elementId = element.getAttribute('id');
|
|
7405
|
-
if (elementId && config.idName(elementId)) {
|
|
7406
|
-
level.push({
|
|
7407
|
-
name: '#' + CSS.escape(elementId),
|
|
7408
|
-
penalty: 0,
|
|
7409
|
-
});
|
|
7410
|
-
}
|
|
7411
|
-
for (let i = 0; i < element.classList.length; i++) {
|
|
7412
|
-
const name = element.classList[i];
|
|
7413
|
-
if (config.className(name)) {
|
|
7414
|
-
level.push({
|
|
7415
|
-
name: '.' + CSS.escape(name),
|
|
7416
|
-
penalty: 1,
|
|
7417
|
-
});
|
|
7418
|
-
}
|
|
7419
|
-
}
|
|
7420
|
-
for (let i = 0; i < element.attributes.length; i++) {
|
|
7421
|
-
const attr = element.attributes[i];
|
|
7422
|
-
if (config.attr(attr.name, attr.value)) {
|
|
7423
|
-
level.push({
|
|
7424
|
-
name: `[${CSS.escape(attr.name)}="${CSS.escape(attr.value)}"]`,
|
|
7425
|
-
penalty: 2,
|
|
7426
|
-
});
|
|
7427
|
-
}
|
|
7428
|
-
}
|
|
7429
|
-
const tagName = element.tagName.toLowerCase();
|
|
7430
|
-
if (config.tagName(tagName)) {
|
|
7431
|
-
level.push({
|
|
7432
|
-
name: tagName,
|
|
7433
|
-
penalty: 5,
|
|
7434
|
-
});
|
|
7435
|
-
const index = indexOf(element, tagName);
|
|
7436
|
-
if (index !== undefined) {
|
|
7437
|
-
level.push({
|
|
7438
|
-
name: nthOfType(tagName, index),
|
|
7439
|
-
penalty: 10,
|
|
7440
|
-
});
|
|
7441
|
-
}
|
|
7442
|
-
}
|
|
7443
|
-
const nth = indexOf(element);
|
|
7444
|
-
if (nth !== undefined) {
|
|
7445
|
-
level.push({
|
|
7446
|
-
name: nthChild(tagName, nth),
|
|
7447
|
-
penalty: 50,
|
|
7448
|
-
});
|
|
7449
|
-
}
|
|
7450
|
-
return level;
|
|
7451
|
-
}
|
|
7452
|
-
function selector(path) {
|
|
7453
|
-
let node = path[0];
|
|
7454
|
-
let query = node.name;
|
|
7455
|
-
for (let i = 1; i < path.length; i++) {
|
|
7456
|
-
const level = path[i].level || 0;
|
|
7457
|
-
if (node.level === level - 1) {
|
|
7458
|
-
query = `${path[i].name} > ${query}`;
|
|
7459
|
-
}
|
|
7460
|
-
else {
|
|
7461
|
-
query = `${path[i].name} ${query}`;
|
|
7462
|
-
}
|
|
7463
|
-
node = path[i];
|
|
7464
|
-
}
|
|
7465
|
-
return query;
|
|
7466
|
-
}
|
|
7467
|
-
function penalty(path) {
|
|
7468
|
-
return path.map((node) => node.penalty).reduce((acc, i) => acc + i, 0);
|
|
7469
|
-
}
|
|
7470
|
-
function byPenalty(a, b) {
|
|
7471
|
-
return penalty(a) - penalty(b);
|
|
7472
|
-
}
|
|
7473
|
-
function indexOf(input, tagName) {
|
|
7474
|
-
const parent = input.parentNode;
|
|
7475
|
-
if (!parent) {
|
|
7476
|
-
return undefined;
|
|
7477
|
-
}
|
|
7478
|
-
let child = parent.firstChild;
|
|
7479
|
-
if (!child) {
|
|
7480
|
-
return undefined;
|
|
7481
|
-
}
|
|
7482
|
-
let i = 0;
|
|
7483
|
-
while (child) {
|
|
7484
|
-
if (child.nodeType === Node.ELEMENT_NODE &&
|
|
7485
|
-
(tagName === undefined ||
|
|
7486
|
-
child.tagName.toLowerCase() === tagName)) {
|
|
7487
|
-
i++;
|
|
7488
|
-
}
|
|
7489
|
-
if (child === input) {
|
|
7490
|
-
break;
|
|
7491
|
-
}
|
|
7492
|
-
child = child.nextSibling;
|
|
7493
|
-
}
|
|
7494
|
-
return i;
|
|
7495
|
-
}
|
|
7496
|
-
function fallback(input, rootDocument) {
|
|
7497
|
-
let i = 0;
|
|
7498
|
-
let current = input;
|
|
7499
|
-
const path = [];
|
|
7500
|
-
while (current && current !== rootDocument) {
|
|
7501
|
-
const tagName = current.tagName.toLowerCase();
|
|
7502
|
-
const index = indexOf(current, tagName);
|
|
7503
|
-
if (index === undefined) {
|
|
7504
|
-
return;
|
|
7505
|
-
}
|
|
7506
|
-
path.push({
|
|
7507
|
-
name: nthOfType(tagName, index),
|
|
7508
|
-
penalty: NaN,
|
|
7509
|
-
level: i,
|
|
7510
|
-
});
|
|
7511
|
-
current = current.parentElement;
|
|
7512
|
-
i++;
|
|
7513
|
-
}
|
|
7514
|
-
if (unique(path, rootDocument)) {
|
|
7515
|
-
return path;
|
|
7516
|
-
}
|
|
7517
|
-
}
|
|
7518
|
-
function nthChild(tagName, index) {
|
|
7519
|
-
if (tagName === 'html') {
|
|
7520
|
-
return 'html';
|
|
7521
|
-
}
|
|
7522
|
-
return `${tagName}:nth-child(${index})`;
|
|
7523
|
-
}
|
|
7524
|
-
function nthOfType(tagName, index) {
|
|
7525
|
-
if (tagName === 'html') {
|
|
7526
|
-
return 'html';
|
|
7527
|
-
}
|
|
7528
|
-
return `${tagName}:nth-of-type(${index})`;
|
|
7529
|
-
}
|
|
7530
|
-
function* combinations(stack, path = []) {
|
|
7531
|
-
if (stack.length > 0) {
|
|
7532
|
-
for (let node of stack[0]) {
|
|
7533
|
-
yield* combinations(stack.slice(1, stack.length), path.concat(node));
|
|
7534
|
-
}
|
|
7535
|
-
}
|
|
7536
|
-
else {
|
|
7537
|
-
yield path;
|
|
7538
|
-
}
|
|
7539
|
-
}
|
|
7540
|
-
function findRootDocument(rootNode, defaults) {
|
|
7541
|
-
if (rootNode.nodeType === Node.DOCUMENT_NODE) {
|
|
7542
|
-
return rootNode;
|
|
7543
|
-
}
|
|
7544
|
-
if (rootNode === defaults.root) {
|
|
7545
|
-
return rootNode.ownerDocument;
|
|
7546
|
-
}
|
|
7547
|
-
return rootNode;
|
|
7548
|
-
}
|
|
7549
|
-
function unique(path, rootDocument) {
|
|
7550
|
-
const css = selector(path);
|
|
7551
|
-
switch (rootDocument.querySelectorAll(css).length) {
|
|
7552
|
-
case 0:
|
|
7553
|
-
throw new Error(`Can't select any node with this selector: ${css}`);
|
|
7554
|
-
case 1:
|
|
7555
|
-
return true;
|
|
7556
|
-
default:
|
|
7557
|
-
return false;
|
|
7558
|
-
}
|
|
7559
|
-
}
|
|
7560
|
-
function* optimize(path, input, config, rootDocument, startTime) {
|
|
7561
|
-
if (path.length > 2 && path.length > config.optimizedMinLength) {
|
|
7562
|
-
for (let i = 1; i < path.length - 1; i++) {
|
|
7563
|
-
const elapsedTimeMs = new Date().getTime() - startTime.getTime();
|
|
7564
|
-
if (elapsedTimeMs > config.timeoutMs) {
|
|
7565
|
-
return;
|
|
7566
|
-
}
|
|
7567
|
-
const newPath = [...path];
|
|
7568
|
-
newPath.splice(i, 1);
|
|
7569
|
-
if (unique(newPath, rootDocument) &&
|
|
7570
|
-
rootDocument.querySelector(selector(newPath)) === input) {
|
|
7571
|
-
yield newPath;
|
|
7572
|
-
yield* optimize(newPath, input, config, rootDocument, startTime);
|
|
7573
|
-
}
|
|
7574
|
-
}
|
|
7575
|
-
}
|
|
7576
|
-
}
|
|
7577
|
-
|
|
7578
|
-
function _getSelector(target, document, options) {
|
|
7579
|
-
const selector = finder(target, {
|
|
7580
|
-
root: document.body,
|
|
7581
|
-
seedMinLength: 3,
|
|
7582
|
-
optimizedMinLength: options?.minSelectorDepth || 2,
|
|
7583
|
-
maxNumberOfPathChecks: options?.maxOptimiseTries || 10000,
|
|
7584
|
-
});
|
|
7585
|
-
return selector;
|
|
7298
|
+
const cssEscape = (typeof CSS !== 'undefined' && CSS.escape) || ((t) => t);
|
|
7299
|
+
const docClassCache = new WeakMap();
|
|
7300
|
+
function _getSelector(target) {
|
|
7301
|
+
const selector = getCSSPath(target);
|
|
7302
|
+
return selector || '';
|
|
7586
7303
|
}
|
|
7587
7304
|
function isClickable(element) {
|
|
7588
7305
|
const tag = element.tagName.toUpperCase();
|
|
@@ -7702,8 +7419,8 @@ function Mouse (app, options) {
|
|
|
7702
7419
|
}
|
|
7703
7420
|
};
|
|
7704
7421
|
const patchDocument = (document, topframe = false) => {
|
|
7705
|
-
function getSelector(id, target
|
|
7706
|
-
return (selectorMap[id] = selectorMap[id] || _getSelector(target
|
|
7422
|
+
function getSelector(id, target) {
|
|
7423
|
+
return (selectorMap[id] = selectorMap[id] || _getSelector(target));
|
|
7707
7424
|
}
|
|
7708
7425
|
const attachListener = topframe
|
|
7709
7426
|
? app.attachEventListener.bind(app) // attached/removed on start/stop
|
|
@@ -7742,7 +7459,7 @@ function Mouse (app, options) {
|
|
|
7742
7459
|
const normalizedY = roundNumber(clickY / contentHeight);
|
|
7743
7460
|
sendMouseMove();
|
|
7744
7461
|
const label = getTargetLabel(target);
|
|
7745
|
-
app.send(MouseClick(id, mouseTarget === target ? Math.round(performance.now() - mouseTargetTime) : 0, app.sanitizer.privateMode ? label.replaceAll(/./g, '*') : label, isClickable(target) && !disableClickmaps ? getSelector(id, target
|
|
7462
|
+
app.send(MouseClick(id, mouseTarget === target ? Math.round(performance.now() - mouseTargetTime) : 0, app.sanitizer.privateMode ? label.replaceAll(/./g, '*') : label, isClickable(target) && !disableClickmaps ? getSelector(id, target) : '', normalizedX, normalizedY), true);
|
|
7746
7463
|
}
|
|
7747
7464
|
mouseTarget = null;
|
|
7748
7465
|
});
|
|
@@ -7762,6 +7479,88 @@ function Mouse (app, options) {
|
|
|
7762
7479
|
function roundNumber(num) {
|
|
7763
7480
|
return Math.round(num * 1e4);
|
|
7764
7481
|
}
|
|
7482
|
+
function isDocUniqueClass(cls, doc) {
|
|
7483
|
+
let cache = docClassCache.get(doc);
|
|
7484
|
+
if (!cache) {
|
|
7485
|
+
cache = Object.create(null);
|
|
7486
|
+
docClassCache.set(doc, cache);
|
|
7487
|
+
}
|
|
7488
|
+
if (cls in cache)
|
|
7489
|
+
return cache[cls];
|
|
7490
|
+
const unique = doc.querySelectorAll(`.${cssEscape(cls)}`).length === 1;
|
|
7491
|
+
cache[cls] = unique;
|
|
7492
|
+
return unique;
|
|
7493
|
+
}
|
|
7494
|
+
function wordLike(name) {
|
|
7495
|
+
if (/^[a-z\-]{3,}$/i.test(name)) {
|
|
7496
|
+
const words = name.split(/-|[A-Z]/);
|
|
7497
|
+
for (const word of words) {
|
|
7498
|
+
if (word.length <= 2) {
|
|
7499
|
+
return false;
|
|
7500
|
+
}
|
|
7501
|
+
if (/[^aeiou]{4,}/i.test(word)) {
|
|
7502
|
+
return false;
|
|
7503
|
+
}
|
|
7504
|
+
}
|
|
7505
|
+
return true;
|
|
7506
|
+
}
|
|
7507
|
+
return false;
|
|
7508
|
+
}
|
|
7509
|
+
function getCSSPath(el) {
|
|
7510
|
+
if (!el || el.nodeType !== 1)
|
|
7511
|
+
return false;
|
|
7512
|
+
if (el.id)
|
|
7513
|
+
return `#${cssEscape(el.id)}`;
|
|
7514
|
+
const parts = [];
|
|
7515
|
+
while (el && el.nodeType === 1 && el !== el.ownerDocument) {
|
|
7516
|
+
if (el.id) {
|
|
7517
|
+
parts.unshift(`#${cssEscape(el.id)}`);
|
|
7518
|
+
break;
|
|
7519
|
+
}
|
|
7520
|
+
const tag = el.tagName.toLowerCase();
|
|
7521
|
+
if (el.classList?.length) {
|
|
7522
|
+
for (const cls of el.classList) {
|
|
7523
|
+
if (wordLike(cls) && isDocUniqueClass(cls, el.ownerDocument)) {
|
|
7524
|
+
parts.unshift(`${tag}.${cssEscape(cls)}`);
|
|
7525
|
+
return parts.join(' > ');
|
|
7526
|
+
}
|
|
7527
|
+
}
|
|
7528
|
+
}
|
|
7529
|
+
const sibCls = getUniqueSiblingClass(el);
|
|
7530
|
+
if (sibCls) {
|
|
7531
|
+
parts.unshift(`${tag}.${cssEscape(sibCls)}`);
|
|
7532
|
+
}
|
|
7533
|
+
else if (el === el.ownerDocument.body ||
|
|
7534
|
+
el === el.ownerDocument.documentElement) {
|
|
7535
|
+
parts.unshift(tag);
|
|
7536
|
+
}
|
|
7537
|
+
else {
|
|
7538
|
+
let idx = 1;
|
|
7539
|
+
for (let sib = el.previousElementSibling; sib; sib = sib.previousElementSibling) {
|
|
7540
|
+
if (sib.tagName.toLowerCase() === tag)
|
|
7541
|
+
idx++;
|
|
7542
|
+
}
|
|
7543
|
+
parts.unshift(`${tag}:nth-of-type(${idx})`);
|
|
7544
|
+
}
|
|
7545
|
+
el = el.parentNode;
|
|
7546
|
+
}
|
|
7547
|
+
return parts.join(' > ');
|
|
7548
|
+
}
|
|
7549
|
+
function getUniqueSiblingClass(el) {
|
|
7550
|
+
if (!el.classList?.length || !el.parentNode)
|
|
7551
|
+
return null;
|
|
7552
|
+
const sibs = el.parentNode.children;
|
|
7553
|
+
outer: for (const cls of el.classList) {
|
|
7554
|
+
if (!wordLike(cls) || !isDocUniqueClass(cls, el.ownerDocument))
|
|
7555
|
+
continue;
|
|
7556
|
+
for (const sib of sibs) {
|
|
7557
|
+
if (sib !== el && sib.classList?.contains(cls))
|
|
7558
|
+
continue outer;
|
|
7559
|
+
}
|
|
7560
|
+
return cls;
|
|
7561
|
+
}
|
|
7562
|
+
return null;
|
|
7563
|
+
}
|
|
7765
7564
|
|
|
7766
7565
|
var e,o=-1,a=function(e){addEventListener("pageshow",(function(n){n.persisted&&(o=n.timeStamp,e(n));}),true);},c=function(){var e=self.performance&&performance.getEntriesByType&&performance.getEntriesByType("navigation")[0];if(e&&e.responseStart>0&&e.responseStart<performance.now())return e},u=function(){var e=c();return e&&e.activationStart||0},f=function(e,n){var t=c(),r="navigate";o>=0?r="back-forward-cache":t&&(document.prerendering||u()>0?r="prerender":document.wasDiscarded?r="restore":t.type&&(r=t.type.replace(/_/g,"-")));return {name:e,value:void 0===n?-1:n,rating:"good",delta:0,entries:[],id:"v4-".concat(Date.now(),"-").concat(Math.floor(8999999999999*Math.random())+1e12),navigationType:r}},s=function(e,n,t){try{if(PerformanceObserver.supportedEntryTypes.includes(e)){var r=new PerformanceObserver((function(e){Promise.resolve().then((function(){n(e.getEntries());}));}));return r.observe(Object.assign({type:e,buffered:!0},t||{})),r}}catch(e){}},d=function(e,n,t,r){var i,o;return function(a){n.value>=0&&(a||r)&&((o=n.value-(i||0))||void 0===i)&&(i=n.value,n.delta=o,n.rating=function(e,n){return e>n[1]?"poor":e>n[0]?"needs-improvement":"good"}(n.value,t),e(n));}},l=function(e){requestAnimationFrame((function(){return requestAnimationFrame((function(){return e()}))}));},p=function(e){document.addEventListener("visibilitychange",(function(){"hidden"===document.visibilityState&&e();}));},v=function(e){var n=false;return function(){n||(e(),n=true);}},m=-1,h=function(){return "hidden"!==document.visibilityState||document.prerendering?1/0:0},g=function(e){"hidden"===document.visibilityState&&m>-1&&(m="visibilitychange"===e.type?e.timeStamp:0,T());},y=function(){addEventListener("visibilitychange",g,true),addEventListener("prerenderingchange",g,true);},T=function(){removeEventListener("visibilitychange",g,true),removeEventListener("prerenderingchange",g,true);},E=function(){return m<0&&(m=h(),y(),a((function(){setTimeout((function(){m=h(),y();}),0);}))),{get firstHiddenTime(){return m}}},C=function(e){document.prerendering?addEventListener("prerenderingchange",(function(){return e()}),true):e();},b=[1800,3e3],S=function(e,n){n=n||{},C((function(){var t,r=E(),i=f("FCP"),o=s("paint",(function(e){e.forEach((function(e){"first-contentful-paint"===e.name&&(o.disconnect(),e.startTime<r.firstHiddenTime&&(i.value=Math.max(e.startTime-u(),0),i.entries.push(e),t(true)));}));}));o&&(t=d(e,i,b,n.reportAllChanges),a((function(r){i=f("FCP"),t=d(e,i,b,n.reportAllChanges),l((function(){i.value=performance.now()-r.timeStamp,t(true);}));})));}));},L=[.1,.25],w=function(e,n){n=n||{},S(v((function(){var t,r=f("CLS",0),i=0,o=[],c=function(e){e.forEach((function(e){if(!e.hadRecentInput){var n=o[0],t=o[o.length-1];i&&e.startTime-t.startTime<1e3&&e.startTime-n.startTime<5e3?(i+=e.value,o.push(e)):(i=e.value,o=[e]);}})),i>r.value&&(r.value=i,r.entries=o,t());},u=s("layout-shift",c);u&&(t=d(e,r,L,n.reportAllChanges),p((function(){c(u.takeRecords()),t(true);})),a((function(){i=0,r=f("CLS",0),t=d(e,r,L,n.reportAllChanges),l((function(){return t()}));})),setTimeout(t,0));})));},A=0,I=1/0,P=0,M=function(e){e.forEach((function(e){e.interactionId&&(I=Math.min(I,e.interactionId),P=Math.max(P,e.interactionId),A=P?(P-I)/7+1:0);}));},k=function(){return e?A:performance.interactionCount||0},F=function(){"interactionCount"in performance||e||(e=s("event",M,{type:"event",buffered:true,durationThreshold:0}));},D=[],x=new Map,R=0,B=function(){var e=Math.min(D.length-1,Math.floor((k()-R)/50));return D[e]},H=[],q=function(e){if(H.forEach((function(n){return n(e)})),e.interactionId||"first-input"===e.entryType){var n=D[D.length-1],t=x.get(e.interactionId);if(t||D.length<10||e.duration>n.latency){if(t)e.duration>t.latency?(t.entries=[e],t.latency=e.duration):e.duration===t.latency&&e.startTime===t.entries[0].startTime&&t.entries.push(e);else {var r={id:e.interactionId,latency:e.duration,entries:[e]};x.set(r.id,r),D.push(r);}D.sort((function(e,n){return n.latency-e.latency})),D.length>10&&D.splice(10).forEach((function(e){return x.delete(e.id)}));}}},O=function(e){var n=self.requestIdleCallback||self.setTimeout,t=-1;return e=v(e),"hidden"===document.visibilityState?e():(t=n(e),p(e)),t},N=[200,500],j=function(e,n){"PerformanceEventTiming"in self&&"interactionId"in PerformanceEventTiming.prototype&&(n=n||{},C((function(){var t;F();var r,i=f("INP"),o=function(e){O((function(){e.forEach(q);var n=B();n&&n.latency!==i.value&&(i.value=n.latency,i.entries=n.entries,r());}));},c=s("event",o,{durationThreshold:null!==(t=n.durationThreshold)&&void 0!==t?t:40});r=d(e,i,N,n.reportAllChanges),c&&(c.observe({type:"first-input",buffered:true}),p((function(){o(c.takeRecords()),r(true);})),a((function(){R=k(),D.length=0,x.clear(),i=f("INP"),r=d(e,i,N,n.reportAllChanges);})));})));},_=[2500,4e3],z={},G=function(e,n){n=n||{},C((function(){var t,r=E(),i=f("LCP"),o=function(e){n.reportAllChanges||(e=e.slice(-1)),e.forEach((function(e){e.startTime<r.firstHiddenTime&&(i.value=Math.max(e.startTime-u(),0),i.entries=[e],t());}));},c=s("largest-contentful-paint",o);if(c){t=d(e,i,_,n.reportAllChanges);var m=v((function(){z[i.id]||(o(c.takeRecords()),c.disconnect(),z[i.id]=true,t(true));}));["keydown","click"].forEach((function(e){addEventListener(e,(function(){return O(m)}),{once:true,capture:true});})),p(m),a((function(r){i=f("LCP"),t=d(e,i,_,n.reportAllChanges),l((function(){i.value=performance.now()-r.timeStamp,z[i.id]=true,t(true);}));}));}}));},J=[800,1800],K=function e(n){document.prerendering?C((function(){return e(n)})):"complete"!==document.readyState?addEventListener("load",(function(){return e(n)}),true):setTimeout(n,0);},Q=function(e,n){n=n||{};var t=f("TTFB"),r=d(e,t,J,n.reportAllChanges);K((function(){var i=c();i&&(t.value=Math.max(i.responseStart-u(),0),t.entries=[i],r(true),a((function(){t=f("TTFB",0),(r=d(e,t,J,n.reportAllChanges))(true);})));}));};
|
|
7767
7566
|
|
|
@@ -8473,6 +8272,152 @@ function isObject(thing) {
|
|
|
8473
8272
|
return thing !== null && typeof thing === 'object';
|
|
8474
8273
|
}
|
|
8475
8274
|
|
|
8275
|
+
const sensitiveParams = new Set([
|
|
8276
|
+
"password",
|
|
8277
|
+
"pass",
|
|
8278
|
+
"pwd",
|
|
8279
|
+
"mdp",
|
|
8280
|
+
"token",
|
|
8281
|
+
"bearer",
|
|
8282
|
+
"jwt",
|
|
8283
|
+
"api_key",
|
|
8284
|
+
"api-key",
|
|
8285
|
+
"apiKey",
|
|
8286
|
+
"secret",
|
|
8287
|
+
"ssn",
|
|
8288
|
+
"zip",
|
|
8289
|
+
"zipcode",
|
|
8290
|
+
"x-api-key",
|
|
8291
|
+
"www-authenticate",
|
|
8292
|
+
"x-csrf-token",
|
|
8293
|
+
"x-requested-with",
|
|
8294
|
+
"x-forwarded-for",
|
|
8295
|
+
"x-real-ip",
|
|
8296
|
+
"cookie",
|
|
8297
|
+
"authorization",
|
|
8298
|
+
"auth",
|
|
8299
|
+
"proxy-authorization",
|
|
8300
|
+
"set-cookie",
|
|
8301
|
+
"account_key",
|
|
8302
|
+
]);
|
|
8303
|
+
function numDigits(x) {
|
|
8304
|
+
return (Math.log10((x ^ (x >> 31)) - (x >> 31)) | 0) + 1;
|
|
8305
|
+
}
|
|
8306
|
+
function obscure(value) {
|
|
8307
|
+
if (typeof value === "number") {
|
|
8308
|
+
const digits = numDigits(value);
|
|
8309
|
+
return "9".repeat(digits);
|
|
8310
|
+
}
|
|
8311
|
+
if (typeof value === "string") {
|
|
8312
|
+
return value.replace(/[^\f\n\r\t\v\u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff\s]/g, '*');
|
|
8313
|
+
}
|
|
8314
|
+
return value;
|
|
8315
|
+
}
|
|
8316
|
+
function filterHeaders(headers) {
|
|
8317
|
+
const filteredHeaders = {};
|
|
8318
|
+
if (Array.isArray(headers)) {
|
|
8319
|
+
headers.forEach(({ name, value }) => {
|
|
8320
|
+
if (sensitiveParams.has(name.toLowerCase())) {
|
|
8321
|
+
filteredHeaders[name] = obscure(value);
|
|
8322
|
+
}
|
|
8323
|
+
else {
|
|
8324
|
+
filteredHeaders[name] = value;
|
|
8325
|
+
}
|
|
8326
|
+
});
|
|
8327
|
+
}
|
|
8328
|
+
else {
|
|
8329
|
+
for (const [key, value] of Object.entries(headers)) {
|
|
8330
|
+
if (sensitiveParams.has(key.toLowerCase())) {
|
|
8331
|
+
filteredHeaders[key] = obscure(value);
|
|
8332
|
+
}
|
|
8333
|
+
else {
|
|
8334
|
+
filteredHeaders[key] = value;
|
|
8335
|
+
}
|
|
8336
|
+
}
|
|
8337
|
+
}
|
|
8338
|
+
return filteredHeaders;
|
|
8339
|
+
}
|
|
8340
|
+
function filterBody(body) {
|
|
8341
|
+
if (!body) {
|
|
8342
|
+
return body;
|
|
8343
|
+
}
|
|
8344
|
+
let parsedBody;
|
|
8345
|
+
let isJSON = false;
|
|
8346
|
+
try {
|
|
8347
|
+
parsedBody = JSON.parse(body);
|
|
8348
|
+
isJSON = true;
|
|
8349
|
+
}
|
|
8350
|
+
catch (e) {
|
|
8351
|
+
// not json
|
|
8352
|
+
}
|
|
8353
|
+
if (isJSON) {
|
|
8354
|
+
obscureSensitiveData(parsedBody);
|
|
8355
|
+
return JSON.stringify(parsedBody);
|
|
8356
|
+
}
|
|
8357
|
+
else {
|
|
8358
|
+
const isUrlSearch = typeof body === "string" && body.includes("?") && body.includes("=");
|
|
8359
|
+
if (isUrlSearch) {
|
|
8360
|
+
try {
|
|
8361
|
+
const params = new URLSearchParams(body);
|
|
8362
|
+
for (const key of params.keys()) {
|
|
8363
|
+
if (sensitiveParams.has(key.toLowerCase())) {
|
|
8364
|
+
const value = obscure(params.get(key));
|
|
8365
|
+
params.set(key, value);
|
|
8366
|
+
}
|
|
8367
|
+
}
|
|
8368
|
+
return params.toString();
|
|
8369
|
+
}
|
|
8370
|
+
catch (e) {
|
|
8371
|
+
// not url query ?
|
|
8372
|
+
return body;
|
|
8373
|
+
}
|
|
8374
|
+
}
|
|
8375
|
+
else {
|
|
8376
|
+
// not json or url query
|
|
8377
|
+
return body;
|
|
8378
|
+
}
|
|
8379
|
+
}
|
|
8380
|
+
}
|
|
8381
|
+
function sanitizeObject(obj) {
|
|
8382
|
+
obscureSensitiveData(obj);
|
|
8383
|
+
return obj;
|
|
8384
|
+
}
|
|
8385
|
+
function obscureSensitiveData(obj) {
|
|
8386
|
+
if (Array.isArray(obj)) {
|
|
8387
|
+
obj.forEach(obscureSensitiveData);
|
|
8388
|
+
}
|
|
8389
|
+
else if (obj && typeof obj === "object") {
|
|
8390
|
+
for (const key in obj) {
|
|
8391
|
+
if (Object.hasOwn(obj, key)) {
|
|
8392
|
+
if (sensitiveParams.has(key.toLowerCase())) {
|
|
8393
|
+
obj[key] = obscure(obj[key]);
|
|
8394
|
+
}
|
|
8395
|
+
else if (obj[key] !== null && typeof obj[key] === "object") {
|
|
8396
|
+
obscureSensitiveData(obj[key]);
|
|
8397
|
+
}
|
|
8398
|
+
}
|
|
8399
|
+
}
|
|
8400
|
+
}
|
|
8401
|
+
}
|
|
8402
|
+
function tryFilterUrl(url) {
|
|
8403
|
+
if (!url)
|
|
8404
|
+
return "";
|
|
8405
|
+
try {
|
|
8406
|
+
const urlObj = new URL(url);
|
|
8407
|
+
if (urlObj.searchParams) {
|
|
8408
|
+
for (const key of urlObj.searchParams.keys()) {
|
|
8409
|
+
if (sensitiveParams.has(key.toLowerCase())) {
|
|
8410
|
+
urlObj.searchParams.set(key, "******");
|
|
8411
|
+
}
|
|
8412
|
+
}
|
|
8413
|
+
}
|
|
8414
|
+
return urlObj.toString();
|
|
8415
|
+
}
|
|
8416
|
+
catch (e) {
|
|
8417
|
+
return url;
|
|
8418
|
+
}
|
|
8419
|
+
}
|
|
8420
|
+
|
|
8476
8421
|
/**
|
|
8477
8422
|
* I know we're not using most of the information from this class
|
|
8478
8423
|
* but it can be useful in the future if we will decide to display more stuff in our ui
|
|
@@ -8504,13 +8449,18 @@ class NetworkMessage {
|
|
|
8504
8449
|
}
|
|
8505
8450
|
getMessage() {
|
|
8506
8451
|
const { reqHs, resHs } = this.writeHeaders();
|
|
8452
|
+
const reqBody = this.method === 'GET'
|
|
8453
|
+
? JSON.stringify(sanitizeObject(this.getData)) : filterBody(this.requestData);
|
|
8507
8454
|
const request = {
|
|
8508
|
-
headers: reqHs,
|
|
8509
|
-
body:
|
|
8455
|
+
headers: filterHeaders(reqHs),
|
|
8456
|
+
body: reqBody,
|
|
8457
|
+
};
|
|
8458
|
+
const response = {
|
|
8459
|
+
headers: filterHeaders(resHs),
|
|
8460
|
+
body: filterBody(this.response)
|
|
8510
8461
|
};
|
|
8511
|
-
const response = { headers: resHs, body: this.response };
|
|
8512
8462
|
const messageInfo = this.sanitize({
|
|
8513
|
-
url: this.url,
|
|
8463
|
+
url: tryFilterUrl(this.url),
|
|
8514
8464
|
method: this.method,
|
|
8515
8465
|
status: this.status,
|
|
8516
8466
|
request,
|
|
@@ -8826,9 +8776,10 @@ class ResponseProxyHandler {
|
|
|
8826
8776
|
if (typeof this.resp.body.getReader !== 'function') {
|
|
8827
8777
|
return;
|
|
8828
8778
|
}
|
|
8829
|
-
const
|
|
8779
|
+
const clonedResp = this.resp.clone();
|
|
8780
|
+
const _getReader = clonedResp.body.getReader;
|
|
8830
8781
|
// @ts-ignore
|
|
8831
|
-
|
|
8782
|
+
clonedResp.body.getReader = () => {
|
|
8832
8783
|
const reader = _getReader.apply(this.resp.body);
|
|
8833
8784
|
// when readyState is already 4,
|
|
8834
8785
|
// it's not a chunked stream, or it had already been read.
|
|
@@ -9670,7 +9621,7 @@ class API {
|
|
|
9670
9621
|
this.signalStartIssue = (reason, missingApi) => {
|
|
9671
9622
|
const doNotTrack = this.checkDoNotTrack();
|
|
9672
9623
|
console.log("Tracker couldn't start due to:", JSON.stringify({
|
|
9673
|
-
trackerVersion: '16.3.0
|
|
9624
|
+
trackerVersion: '16.3.0',
|
|
9674
9625
|
projectKey: this.options.projectKey,
|
|
9675
9626
|
doNotTrack,
|
|
9676
9627
|
reason: missingApi.length ? `missing api: ${missingApi.join(',')}` : reason,
|