@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/cjs/entry.js
CHANGED
|
@@ -1469,43 +1469,6 @@ function simpleMerge(defaultObj, givenObj) {
|
|
|
1469
1469
|
}
|
|
1470
1470
|
return result;
|
|
1471
1471
|
}
|
|
1472
|
-
function throttleWithTrailing(fn, interval) {
|
|
1473
|
-
const lastCalls = new Map();
|
|
1474
|
-
const timeouts = new Map();
|
|
1475
|
-
const lastArgs = new Map();
|
|
1476
|
-
const throttled = function (key, ...args) {
|
|
1477
|
-
const now = Date.now();
|
|
1478
|
-
const lastCall = lastCalls.get(key) ?? 0;
|
|
1479
|
-
const remaining = interval - (now - lastCall);
|
|
1480
|
-
lastArgs.set(key, args);
|
|
1481
|
-
if (remaining <= 0) {
|
|
1482
|
-
if (timeouts.has(key)) {
|
|
1483
|
-
clearTimeout(timeouts.get(key));
|
|
1484
|
-
timeouts.delete(key);
|
|
1485
|
-
}
|
|
1486
|
-
lastCalls.set(key, now);
|
|
1487
|
-
fn(key, ...args);
|
|
1488
|
-
}
|
|
1489
|
-
else if (!timeouts.has(key)) {
|
|
1490
|
-
const timeoutId = setTimeout(() => {
|
|
1491
|
-
lastCalls.set(key, Date.now());
|
|
1492
|
-
timeouts.delete(key);
|
|
1493
|
-
const finalArgs = lastArgs.get(key);
|
|
1494
|
-
fn(key, ...finalArgs);
|
|
1495
|
-
}, remaining);
|
|
1496
|
-
timeouts.set(key, timeoutId);
|
|
1497
|
-
}
|
|
1498
|
-
};
|
|
1499
|
-
throttled.clear = () => {
|
|
1500
|
-
for (const timeout of timeouts.values()) {
|
|
1501
|
-
clearTimeout(timeout);
|
|
1502
|
-
}
|
|
1503
|
-
timeouts.clear();
|
|
1504
|
-
lastArgs.clear();
|
|
1505
|
-
lastCalls.clear();
|
|
1506
|
-
};
|
|
1507
|
-
return throttled;
|
|
1508
|
-
}
|
|
1509
1472
|
|
|
1510
1473
|
// Auto-generated, do not edit
|
|
1511
1474
|
/* eslint-disable */
|
|
@@ -1716,6 +1679,33 @@ function SetNodeAttributeDictGlobal(id, name, value) {
|
|
|
1716
1679
|
value,
|
|
1717
1680
|
];
|
|
1718
1681
|
}
|
|
1682
|
+
function CSSInsertRule(id, rule, index) {
|
|
1683
|
+
return [
|
|
1684
|
+
37 /* Messages.Type.CSSInsertRule */,
|
|
1685
|
+
id,
|
|
1686
|
+
rule,
|
|
1687
|
+
index,
|
|
1688
|
+
];
|
|
1689
|
+
}
|
|
1690
|
+
function CSSDeleteRule(id, index) {
|
|
1691
|
+
return [
|
|
1692
|
+
38 /* Messages.Type.CSSDeleteRule */,
|
|
1693
|
+
id,
|
|
1694
|
+
index,
|
|
1695
|
+
];
|
|
1696
|
+
}
|
|
1697
|
+
function Fetch(method, url, request, response, status, timestamp, duration) {
|
|
1698
|
+
return [
|
|
1699
|
+
39 /* Messages.Type.Fetch */,
|
|
1700
|
+
method,
|
|
1701
|
+
url,
|
|
1702
|
+
request,
|
|
1703
|
+
response,
|
|
1704
|
+
status,
|
|
1705
|
+
timestamp,
|
|
1706
|
+
duration,
|
|
1707
|
+
];
|
|
1708
|
+
}
|
|
1719
1709
|
function Profiler(name, duration, args, result) {
|
|
1720
1710
|
return [
|
|
1721
1711
|
40 /* Messages.Type.Profiler */,
|
|
@@ -1858,6 +1848,18 @@ function SetNodeFocus(id) {
|
|
|
1858
1848
|
id,
|
|
1859
1849
|
];
|
|
1860
1850
|
}
|
|
1851
|
+
function LongTask(timestamp, duration, context, containerType, containerSrc, containerId, containerName) {
|
|
1852
|
+
return [
|
|
1853
|
+
59 /* Messages.Type.LongTask */,
|
|
1854
|
+
timestamp,
|
|
1855
|
+
duration,
|
|
1856
|
+
context,
|
|
1857
|
+
containerType,
|
|
1858
|
+
containerSrc,
|
|
1859
|
+
containerId,
|
|
1860
|
+
containerName,
|
|
1861
|
+
];
|
|
1862
|
+
}
|
|
1861
1863
|
function SetNodeAttributeURLBased(id, name, value, baseURL) {
|
|
1862
1864
|
return [
|
|
1863
1865
|
60 /* Messages.Type.SetNodeAttributeURLBased */,
|
|
@@ -1889,6 +1891,15 @@ function CustomIssue(name, payload) {
|
|
|
1889
1891
|
payload,
|
|
1890
1892
|
];
|
|
1891
1893
|
}
|
|
1894
|
+
function CSSInsertRuleURLBased(id, rule, index, baseURL) {
|
|
1895
|
+
return [
|
|
1896
|
+
67 /* Messages.Type.CSSInsertRuleURLBased */,
|
|
1897
|
+
id,
|
|
1898
|
+
rule,
|
|
1899
|
+
index,
|
|
1900
|
+
baseURL,
|
|
1901
|
+
];
|
|
1902
|
+
}
|
|
1892
1903
|
function MouseClick(id, hesitationTime, label, selector, normalizedX, normalizedY) {
|
|
1893
1904
|
return [
|
|
1894
1905
|
68 /* Messages.Type.MouseClick */,
|
|
@@ -2127,6 +2138,9 @@ var _Messages = /*#__PURE__*/Object.freeze({
|
|
|
2127
2138
|
AdoptedSSRemoveOwner: AdoptedSSRemoveOwner,
|
|
2128
2139
|
AdoptedSSReplaceURLBased: AdoptedSSReplaceURLBased,
|
|
2129
2140
|
BatchMetadata: BatchMetadata,
|
|
2141
|
+
CSSDeleteRule: CSSDeleteRule,
|
|
2142
|
+
CSSInsertRule: CSSInsertRule,
|
|
2143
|
+
CSSInsertRuleURLBased: CSSInsertRuleURLBased,
|
|
2130
2144
|
CanvasNode: CanvasNode,
|
|
2131
2145
|
ConnectionInformation: ConnectionInformation,
|
|
2132
2146
|
ConsoleLog: ConsoleLog,
|
|
@@ -2136,11 +2150,13 @@ var _Messages = /*#__PURE__*/Object.freeze({
|
|
|
2136
2150
|
CreateTextNode: CreateTextNode,
|
|
2137
2151
|
CustomEvent: CustomEvent,
|
|
2138
2152
|
CustomIssue: CustomIssue,
|
|
2153
|
+
Fetch: Fetch,
|
|
2139
2154
|
GraphQL: GraphQL,
|
|
2140
2155
|
GraphQLDeprecated: GraphQLDeprecated,
|
|
2141
2156
|
InputChange: InputChange,
|
|
2142
2157
|
JSException: JSException,
|
|
2143
2158
|
LoadFontFace: LoadFontFace,
|
|
2159
|
+
LongTask: LongTask,
|
|
2144
2160
|
Metadata: Metadata,
|
|
2145
2161
|
MobX: MobX,
|
|
2146
2162
|
MouseClick: MouseClick,
|
|
@@ -4256,7 +4272,6 @@ class Observer {
|
|
|
4256
4272
|
this.inlineRemoteCss = false;
|
|
4257
4273
|
this.inlinerOptions = undefined;
|
|
4258
4274
|
this.domParser = new DOMParser();
|
|
4259
|
-
this.throttledSetNodeData = throttleWithTrailing((id, parentElement, data) => this.sendNodeData(id, parentElement, data), 30);
|
|
4260
4275
|
this.disableSprites = Boolean(options.disableSprites);
|
|
4261
4276
|
this.inlineRemoteCss = Boolean(options.inlineRemoteCss);
|
|
4262
4277
|
this.inlinerOptions = options.inlinerOptions;
|
|
@@ -4568,7 +4583,7 @@ class Observer {
|
|
|
4568
4583
|
else if (isTextNode(node)) {
|
|
4569
4584
|
// for text node id != 0, hence parentID !== undefined and parent is Element
|
|
4570
4585
|
this.app.send(CreateTextNode(id, parentID, index));
|
|
4571
|
-
this.
|
|
4586
|
+
this.sendNodeData(id, parent, node.data);
|
|
4572
4587
|
}
|
|
4573
4588
|
return true;
|
|
4574
4589
|
}
|
|
@@ -4589,7 +4604,7 @@ class Observer {
|
|
|
4589
4604
|
throw 'commitNode: node is not a text';
|
|
4590
4605
|
}
|
|
4591
4606
|
// for text node id != 0, hence parent is Element
|
|
4592
|
-
this.
|
|
4607
|
+
this.sendNodeData(id, parent, node.data);
|
|
4593
4608
|
}
|
|
4594
4609
|
return true;
|
|
4595
4610
|
}
|
|
@@ -4632,7 +4647,6 @@ class Observer {
|
|
|
4632
4647
|
disconnect() {
|
|
4633
4648
|
this.observer.disconnect();
|
|
4634
4649
|
this.clear();
|
|
4635
|
-
this.throttledSetNodeData.clear();
|
|
4636
4650
|
}
|
|
4637
4651
|
}
|
|
4638
4652
|
|
|
@@ -5191,7 +5205,7 @@ class Ticker {
|
|
|
5191
5205
|
* this value is injected during build time via rollup
|
|
5192
5206
|
* */
|
|
5193
5207
|
// @ts-ignore
|
|
5194
|
-
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";
|
|
5208
|
+
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";
|
|
5195
5209
|
const CANCELED = 'canceled';
|
|
5196
5210
|
const uxtStorageKey = 'or_uxt_active';
|
|
5197
5211
|
const bufferStorageKey = 'or_buffer_1';
|
|
@@ -5245,7 +5259,7 @@ class App {
|
|
|
5245
5259
|
this.stopCallbacks = [];
|
|
5246
5260
|
this.commitCallbacks = [];
|
|
5247
5261
|
this.activityState = ActivityState.NotActive;
|
|
5248
|
-
this.version = '16.3.0
|
|
5262
|
+
this.version = '16.3.0'; // TODO: version compatability check inside each plugin.
|
|
5249
5263
|
this.socketMode = false;
|
|
5250
5264
|
this.compressionThreshold = 24 * 1000;
|
|
5251
5265
|
this.bc = null;
|
|
@@ -7285,308 +7299,11 @@ function Input (app, opts) {
|
|
|
7285
7299
|
}));
|
|
7286
7300
|
}
|
|
7287
7301
|
|
|
7288
|
-
|
|
7289
|
-
|
|
7290
|
-
|
|
7291
|
-
const
|
|
7292
|
-
|
|
7293
|
-
function attr(name, value) {
|
|
7294
|
-
let nameIsOk = acceptedAttrNames.has(name);
|
|
7295
|
-
nameIsOk ||= name.startsWith('data-') && wordLike(name);
|
|
7296
|
-
let valueIsOk = wordLike(value) && value.length < 100;
|
|
7297
|
-
valueIsOk ||= value.startsWith('#') && wordLike(value.slice(1));
|
|
7298
|
-
return nameIsOk && valueIsOk;
|
|
7299
|
-
}
|
|
7300
|
-
/** Check if id name is word-like. */
|
|
7301
|
-
function idName(name) {
|
|
7302
|
-
return wordLike(name);
|
|
7303
|
-
}
|
|
7304
|
-
/** Check if class name is word-like. */
|
|
7305
|
-
function className(name) {
|
|
7306
|
-
return wordLike(name);
|
|
7307
|
-
}
|
|
7308
|
-
/** Check if tag name is word-like. */
|
|
7309
|
-
function tagName(name) {
|
|
7310
|
-
return true;
|
|
7311
|
-
}
|
|
7312
|
-
/** Finds unique CSS selectors for the given element. */
|
|
7313
|
-
function finder(input, options) {
|
|
7314
|
-
if (input.nodeType !== Node.ELEMENT_NODE) {
|
|
7315
|
-
throw new Error(`Can't generate CSS selector for non-element node type.`);
|
|
7316
|
-
}
|
|
7317
|
-
if (input.tagName.toLowerCase() === 'html') {
|
|
7318
|
-
return 'html';
|
|
7319
|
-
}
|
|
7320
|
-
const defaults = {
|
|
7321
|
-
root: document.body,
|
|
7322
|
-
idName: idName,
|
|
7323
|
-
className: className,
|
|
7324
|
-
tagName: tagName,
|
|
7325
|
-
attr: attr,
|
|
7326
|
-
timeoutMs: 1000,
|
|
7327
|
-
seedMinLength: 3,
|
|
7328
|
-
optimizedMinLength: 2,
|
|
7329
|
-
maxNumberOfPathChecks: Infinity,
|
|
7330
|
-
};
|
|
7331
|
-
const startTime = new Date();
|
|
7332
|
-
const config = { ...defaults, ...options };
|
|
7333
|
-
const rootDocument = findRootDocument(config.root, defaults);
|
|
7334
|
-
let foundPath;
|
|
7335
|
-
let count = 0;
|
|
7336
|
-
for (const candidate of search(input, config, rootDocument)) {
|
|
7337
|
-
const elapsedTimeMs = new Date().getTime() - startTime.getTime();
|
|
7338
|
-
if (elapsedTimeMs > config.timeoutMs ||
|
|
7339
|
-
count >= config.maxNumberOfPathChecks) {
|
|
7340
|
-
const fPath = fallback(input, rootDocument);
|
|
7341
|
-
if (!fPath) {
|
|
7342
|
-
throw new Error(`Timeout: Can't find a unique selector after ${config.timeoutMs}ms`);
|
|
7343
|
-
}
|
|
7344
|
-
return selector(fPath);
|
|
7345
|
-
}
|
|
7346
|
-
count++;
|
|
7347
|
-
if (unique(candidate, rootDocument)) {
|
|
7348
|
-
foundPath = candidate;
|
|
7349
|
-
break;
|
|
7350
|
-
}
|
|
7351
|
-
}
|
|
7352
|
-
if (!foundPath) {
|
|
7353
|
-
throw new Error(`Selector was not found.`);
|
|
7354
|
-
}
|
|
7355
|
-
const optimized = [
|
|
7356
|
-
...optimize(foundPath, input, config, rootDocument, startTime),
|
|
7357
|
-
];
|
|
7358
|
-
optimized.sort(byPenalty);
|
|
7359
|
-
if (optimized.length > 0) {
|
|
7360
|
-
return selector(optimized[0]);
|
|
7361
|
-
}
|
|
7362
|
-
return selector(foundPath);
|
|
7363
|
-
}
|
|
7364
|
-
function* search(input, config, rootDocument) {
|
|
7365
|
-
const stack = [];
|
|
7366
|
-
let paths = [];
|
|
7367
|
-
let current = input;
|
|
7368
|
-
let i = 0;
|
|
7369
|
-
while (current && current !== rootDocument) {
|
|
7370
|
-
const level = tie(current, config);
|
|
7371
|
-
for (const node of level) {
|
|
7372
|
-
node.level = i;
|
|
7373
|
-
}
|
|
7374
|
-
stack.push(level);
|
|
7375
|
-
current = current.parentElement;
|
|
7376
|
-
i++;
|
|
7377
|
-
paths.push(...combinations(stack));
|
|
7378
|
-
if (i >= config.seedMinLength) {
|
|
7379
|
-
paths.sort(byPenalty);
|
|
7380
|
-
for (const candidate of paths) {
|
|
7381
|
-
yield candidate;
|
|
7382
|
-
}
|
|
7383
|
-
paths = [];
|
|
7384
|
-
}
|
|
7385
|
-
}
|
|
7386
|
-
paths.sort(byPenalty);
|
|
7387
|
-
for (const candidate of paths) {
|
|
7388
|
-
yield candidate;
|
|
7389
|
-
}
|
|
7390
|
-
}
|
|
7391
|
-
function wordLike(name) {
|
|
7392
|
-
if (/^[a-z\-]{3,}$/i.test(name)) {
|
|
7393
|
-
const words = name.split(/-|[A-Z]/);
|
|
7394
|
-
for (const word of words) {
|
|
7395
|
-
if (word.length <= 2) {
|
|
7396
|
-
return false;
|
|
7397
|
-
}
|
|
7398
|
-
if (/[^aeiou]{4,}/i.test(word)) {
|
|
7399
|
-
return false;
|
|
7400
|
-
}
|
|
7401
|
-
}
|
|
7402
|
-
return true;
|
|
7403
|
-
}
|
|
7404
|
-
return false;
|
|
7405
|
-
}
|
|
7406
|
-
function tie(element, config) {
|
|
7407
|
-
const level = [];
|
|
7408
|
-
const elementId = element.getAttribute('id');
|
|
7409
|
-
if (elementId && config.idName(elementId)) {
|
|
7410
|
-
level.push({
|
|
7411
|
-
name: '#' + CSS.escape(elementId),
|
|
7412
|
-
penalty: 0,
|
|
7413
|
-
});
|
|
7414
|
-
}
|
|
7415
|
-
for (let i = 0; i < element.classList.length; i++) {
|
|
7416
|
-
const name = element.classList[i];
|
|
7417
|
-
if (config.className(name)) {
|
|
7418
|
-
level.push({
|
|
7419
|
-
name: '.' + CSS.escape(name),
|
|
7420
|
-
penalty: 1,
|
|
7421
|
-
});
|
|
7422
|
-
}
|
|
7423
|
-
}
|
|
7424
|
-
for (let i = 0; i < element.attributes.length; i++) {
|
|
7425
|
-
const attr = element.attributes[i];
|
|
7426
|
-
if (config.attr(attr.name, attr.value)) {
|
|
7427
|
-
level.push({
|
|
7428
|
-
name: `[${CSS.escape(attr.name)}="${CSS.escape(attr.value)}"]`,
|
|
7429
|
-
penalty: 2,
|
|
7430
|
-
});
|
|
7431
|
-
}
|
|
7432
|
-
}
|
|
7433
|
-
const tagName = element.tagName.toLowerCase();
|
|
7434
|
-
if (config.tagName(tagName)) {
|
|
7435
|
-
level.push({
|
|
7436
|
-
name: tagName,
|
|
7437
|
-
penalty: 5,
|
|
7438
|
-
});
|
|
7439
|
-
const index = indexOf(element, tagName);
|
|
7440
|
-
if (index !== undefined) {
|
|
7441
|
-
level.push({
|
|
7442
|
-
name: nthOfType(tagName, index),
|
|
7443
|
-
penalty: 10,
|
|
7444
|
-
});
|
|
7445
|
-
}
|
|
7446
|
-
}
|
|
7447
|
-
const nth = indexOf(element);
|
|
7448
|
-
if (nth !== undefined) {
|
|
7449
|
-
level.push({
|
|
7450
|
-
name: nthChild(tagName, nth),
|
|
7451
|
-
penalty: 50,
|
|
7452
|
-
});
|
|
7453
|
-
}
|
|
7454
|
-
return level;
|
|
7455
|
-
}
|
|
7456
|
-
function selector(path) {
|
|
7457
|
-
let node = path[0];
|
|
7458
|
-
let query = node.name;
|
|
7459
|
-
for (let i = 1; i < path.length; i++) {
|
|
7460
|
-
const level = path[i].level || 0;
|
|
7461
|
-
if (node.level === level - 1) {
|
|
7462
|
-
query = `${path[i].name} > ${query}`;
|
|
7463
|
-
}
|
|
7464
|
-
else {
|
|
7465
|
-
query = `${path[i].name} ${query}`;
|
|
7466
|
-
}
|
|
7467
|
-
node = path[i];
|
|
7468
|
-
}
|
|
7469
|
-
return query;
|
|
7470
|
-
}
|
|
7471
|
-
function penalty(path) {
|
|
7472
|
-
return path.map((node) => node.penalty).reduce((acc, i) => acc + i, 0);
|
|
7473
|
-
}
|
|
7474
|
-
function byPenalty(a, b) {
|
|
7475
|
-
return penalty(a) - penalty(b);
|
|
7476
|
-
}
|
|
7477
|
-
function indexOf(input, tagName) {
|
|
7478
|
-
const parent = input.parentNode;
|
|
7479
|
-
if (!parent) {
|
|
7480
|
-
return undefined;
|
|
7481
|
-
}
|
|
7482
|
-
let child = parent.firstChild;
|
|
7483
|
-
if (!child) {
|
|
7484
|
-
return undefined;
|
|
7485
|
-
}
|
|
7486
|
-
let i = 0;
|
|
7487
|
-
while (child) {
|
|
7488
|
-
if (child.nodeType === Node.ELEMENT_NODE &&
|
|
7489
|
-
(tagName === undefined ||
|
|
7490
|
-
child.tagName.toLowerCase() === tagName)) {
|
|
7491
|
-
i++;
|
|
7492
|
-
}
|
|
7493
|
-
if (child === input) {
|
|
7494
|
-
break;
|
|
7495
|
-
}
|
|
7496
|
-
child = child.nextSibling;
|
|
7497
|
-
}
|
|
7498
|
-
return i;
|
|
7499
|
-
}
|
|
7500
|
-
function fallback(input, rootDocument) {
|
|
7501
|
-
let i = 0;
|
|
7502
|
-
let current = input;
|
|
7503
|
-
const path = [];
|
|
7504
|
-
while (current && current !== rootDocument) {
|
|
7505
|
-
const tagName = current.tagName.toLowerCase();
|
|
7506
|
-
const index = indexOf(current, tagName);
|
|
7507
|
-
if (index === undefined) {
|
|
7508
|
-
return;
|
|
7509
|
-
}
|
|
7510
|
-
path.push({
|
|
7511
|
-
name: nthOfType(tagName, index),
|
|
7512
|
-
penalty: NaN,
|
|
7513
|
-
level: i,
|
|
7514
|
-
});
|
|
7515
|
-
current = current.parentElement;
|
|
7516
|
-
i++;
|
|
7517
|
-
}
|
|
7518
|
-
if (unique(path, rootDocument)) {
|
|
7519
|
-
return path;
|
|
7520
|
-
}
|
|
7521
|
-
}
|
|
7522
|
-
function nthChild(tagName, index) {
|
|
7523
|
-
if (tagName === 'html') {
|
|
7524
|
-
return 'html';
|
|
7525
|
-
}
|
|
7526
|
-
return `${tagName}:nth-child(${index})`;
|
|
7527
|
-
}
|
|
7528
|
-
function nthOfType(tagName, index) {
|
|
7529
|
-
if (tagName === 'html') {
|
|
7530
|
-
return 'html';
|
|
7531
|
-
}
|
|
7532
|
-
return `${tagName}:nth-of-type(${index})`;
|
|
7533
|
-
}
|
|
7534
|
-
function* combinations(stack, path = []) {
|
|
7535
|
-
if (stack.length > 0) {
|
|
7536
|
-
for (let node of stack[0]) {
|
|
7537
|
-
yield* combinations(stack.slice(1, stack.length), path.concat(node));
|
|
7538
|
-
}
|
|
7539
|
-
}
|
|
7540
|
-
else {
|
|
7541
|
-
yield path;
|
|
7542
|
-
}
|
|
7543
|
-
}
|
|
7544
|
-
function findRootDocument(rootNode, defaults) {
|
|
7545
|
-
if (rootNode.nodeType === Node.DOCUMENT_NODE) {
|
|
7546
|
-
return rootNode;
|
|
7547
|
-
}
|
|
7548
|
-
if (rootNode === defaults.root) {
|
|
7549
|
-
return rootNode.ownerDocument;
|
|
7550
|
-
}
|
|
7551
|
-
return rootNode;
|
|
7552
|
-
}
|
|
7553
|
-
function unique(path, rootDocument) {
|
|
7554
|
-
const css = selector(path);
|
|
7555
|
-
switch (rootDocument.querySelectorAll(css).length) {
|
|
7556
|
-
case 0:
|
|
7557
|
-
throw new Error(`Can't select any node with this selector: ${css}`);
|
|
7558
|
-
case 1:
|
|
7559
|
-
return true;
|
|
7560
|
-
default:
|
|
7561
|
-
return false;
|
|
7562
|
-
}
|
|
7563
|
-
}
|
|
7564
|
-
function* optimize(path, input, config, rootDocument, startTime) {
|
|
7565
|
-
if (path.length > 2 && path.length > config.optimizedMinLength) {
|
|
7566
|
-
for (let i = 1; i < path.length - 1; i++) {
|
|
7567
|
-
const elapsedTimeMs = new Date().getTime() - startTime.getTime();
|
|
7568
|
-
if (elapsedTimeMs > config.timeoutMs) {
|
|
7569
|
-
return;
|
|
7570
|
-
}
|
|
7571
|
-
const newPath = [...path];
|
|
7572
|
-
newPath.splice(i, 1);
|
|
7573
|
-
if (unique(newPath, rootDocument) &&
|
|
7574
|
-
rootDocument.querySelector(selector(newPath)) === input) {
|
|
7575
|
-
yield newPath;
|
|
7576
|
-
yield* optimize(newPath, input, config, rootDocument, startTime);
|
|
7577
|
-
}
|
|
7578
|
-
}
|
|
7579
|
-
}
|
|
7580
|
-
}
|
|
7581
|
-
|
|
7582
|
-
function _getSelector(target, document, options) {
|
|
7583
|
-
const selector = finder(target, {
|
|
7584
|
-
root: document.body,
|
|
7585
|
-
seedMinLength: 3,
|
|
7586
|
-
optimizedMinLength: options?.minSelectorDepth || 2,
|
|
7587
|
-
maxNumberOfPathChecks: options?.maxOptimiseTries || 10000,
|
|
7588
|
-
});
|
|
7589
|
-
return selector;
|
|
7302
|
+
const cssEscape = (typeof CSS !== 'undefined' && CSS.escape) || ((t) => t);
|
|
7303
|
+
const docClassCache = new WeakMap();
|
|
7304
|
+
function _getSelector(target) {
|
|
7305
|
+
const selector = getCSSPath(target);
|
|
7306
|
+
return selector || '';
|
|
7590
7307
|
}
|
|
7591
7308
|
function isClickable(element) {
|
|
7592
7309
|
const tag = element.tagName.toUpperCase();
|
|
@@ -7706,8 +7423,8 @@ function Mouse (app, options) {
|
|
|
7706
7423
|
}
|
|
7707
7424
|
};
|
|
7708
7425
|
const patchDocument = (document, topframe = false) => {
|
|
7709
|
-
function getSelector(id, target
|
|
7710
|
-
return (selectorMap[id] = selectorMap[id] || _getSelector(target
|
|
7426
|
+
function getSelector(id, target) {
|
|
7427
|
+
return (selectorMap[id] = selectorMap[id] || _getSelector(target));
|
|
7711
7428
|
}
|
|
7712
7429
|
const attachListener = topframe
|
|
7713
7430
|
? app.attachEventListener.bind(app) // attached/removed on start/stop
|
|
@@ -7746,7 +7463,7 @@ function Mouse (app, options) {
|
|
|
7746
7463
|
const normalizedY = roundNumber(clickY / contentHeight);
|
|
7747
7464
|
sendMouseMove();
|
|
7748
7465
|
const label = getTargetLabel(target);
|
|
7749
|
-
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
|
|
7466
|
+
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);
|
|
7750
7467
|
}
|
|
7751
7468
|
mouseTarget = null;
|
|
7752
7469
|
});
|
|
@@ -7766,6 +7483,88 @@ function Mouse (app, options) {
|
|
|
7766
7483
|
function roundNumber(num) {
|
|
7767
7484
|
return Math.round(num * 1e4);
|
|
7768
7485
|
}
|
|
7486
|
+
function isDocUniqueClass(cls, doc) {
|
|
7487
|
+
let cache = docClassCache.get(doc);
|
|
7488
|
+
if (!cache) {
|
|
7489
|
+
cache = Object.create(null);
|
|
7490
|
+
docClassCache.set(doc, cache);
|
|
7491
|
+
}
|
|
7492
|
+
if (cls in cache)
|
|
7493
|
+
return cache[cls];
|
|
7494
|
+
const unique = doc.querySelectorAll(`.${cssEscape(cls)}`).length === 1;
|
|
7495
|
+
cache[cls] = unique;
|
|
7496
|
+
return unique;
|
|
7497
|
+
}
|
|
7498
|
+
function wordLike(name) {
|
|
7499
|
+
if (/^[a-z\-]{3,}$/i.test(name)) {
|
|
7500
|
+
const words = name.split(/-|[A-Z]/);
|
|
7501
|
+
for (const word of words) {
|
|
7502
|
+
if (word.length <= 2) {
|
|
7503
|
+
return false;
|
|
7504
|
+
}
|
|
7505
|
+
if (/[^aeiou]{4,}/i.test(word)) {
|
|
7506
|
+
return false;
|
|
7507
|
+
}
|
|
7508
|
+
}
|
|
7509
|
+
return true;
|
|
7510
|
+
}
|
|
7511
|
+
return false;
|
|
7512
|
+
}
|
|
7513
|
+
function getCSSPath(el) {
|
|
7514
|
+
if (!el || el.nodeType !== 1)
|
|
7515
|
+
return false;
|
|
7516
|
+
if (el.id)
|
|
7517
|
+
return `#${cssEscape(el.id)}`;
|
|
7518
|
+
const parts = [];
|
|
7519
|
+
while (el && el.nodeType === 1 && el !== el.ownerDocument) {
|
|
7520
|
+
if (el.id) {
|
|
7521
|
+
parts.unshift(`#${cssEscape(el.id)}`);
|
|
7522
|
+
break;
|
|
7523
|
+
}
|
|
7524
|
+
const tag = el.tagName.toLowerCase();
|
|
7525
|
+
if (el.classList?.length) {
|
|
7526
|
+
for (const cls of el.classList) {
|
|
7527
|
+
if (wordLike(cls) && isDocUniqueClass(cls, el.ownerDocument)) {
|
|
7528
|
+
parts.unshift(`${tag}.${cssEscape(cls)}`);
|
|
7529
|
+
return parts.join(' > ');
|
|
7530
|
+
}
|
|
7531
|
+
}
|
|
7532
|
+
}
|
|
7533
|
+
const sibCls = getUniqueSiblingClass(el);
|
|
7534
|
+
if (sibCls) {
|
|
7535
|
+
parts.unshift(`${tag}.${cssEscape(sibCls)}`);
|
|
7536
|
+
}
|
|
7537
|
+
else if (el === el.ownerDocument.body ||
|
|
7538
|
+
el === el.ownerDocument.documentElement) {
|
|
7539
|
+
parts.unshift(tag);
|
|
7540
|
+
}
|
|
7541
|
+
else {
|
|
7542
|
+
let idx = 1;
|
|
7543
|
+
for (let sib = el.previousElementSibling; sib; sib = sib.previousElementSibling) {
|
|
7544
|
+
if (sib.tagName.toLowerCase() === tag)
|
|
7545
|
+
idx++;
|
|
7546
|
+
}
|
|
7547
|
+
parts.unshift(`${tag}:nth-of-type(${idx})`);
|
|
7548
|
+
}
|
|
7549
|
+
el = el.parentNode;
|
|
7550
|
+
}
|
|
7551
|
+
return parts.join(' > ');
|
|
7552
|
+
}
|
|
7553
|
+
function getUniqueSiblingClass(el) {
|
|
7554
|
+
if (!el.classList?.length || !el.parentNode)
|
|
7555
|
+
return null;
|
|
7556
|
+
const sibs = el.parentNode.children;
|
|
7557
|
+
outer: for (const cls of el.classList) {
|
|
7558
|
+
if (!wordLike(cls) || !isDocUniqueClass(cls, el.ownerDocument))
|
|
7559
|
+
continue;
|
|
7560
|
+
for (const sib of sibs) {
|
|
7561
|
+
if (sib !== el && sib.classList?.contains(cls))
|
|
7562
|
+
continue outer;
|
|
7563
|
+
}
|
|
7564
|
+
return cls;
|
|
7565
|
+
}
|
|
7566
|
+
return null;
|
|
7567
|
+
}
|
|
7769
7568
|
|
|
7770
7569
|
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);})));}));};
|
|
7771
7570
|
|
|
@@ -8477,6 +8276,152 @@ function isObject(thing) {
|
|
|
8477
8276
|
return thing !== null && typeof thing === 'object';
|
|
8478
8277
|
}
|
|
8479
8278
|
|
|
8279
|
+
const sensitiveParams = new Set([
|
|
8280
|
+
"password",
|
|
8281
|
+
"pass",
|
|
8282
|
+
"pwd",
|
|
8283
|
+
"mdp",
|
|
8284
|
+
"token",
|
|
8285
|
+
"bearer",
|
|
8286
|
+
"jwt",
|
|
8287
|
+
"api_key",
|
|
8288
|
+
"api-key",
|
|
8289
|
+
"apiKey",
|
|
8290
|
+
"secret",
|
|
8291
|
+
"ssn",
|
|
8292
|
+
"zip",
|
|
8293
|
+
"zipcode",
|
|
8294
|
+
"x-api-key",
|
|
8295
|
+
"www-authenticate",
|
|
8296
|
+
"x-csrf-token",
|
|
8297
|
+
"x-requested-with",
|
|
8298
|
+
"x-forwarded-for",
|
|
8299
|
+
"x-real-ip",
|
|
8300
|
+
"cookie",
|
|
8301
|
+
"authorization",
|
|
8302
|
+
"auth",
|
|
8303
|
+
"proxy-authorization",
|
|
8304
|
+
"set-cookie",
|
|
8305
|
+
"account_key",
|
|
8306
|
+
]);
|
|
8307
|
+
function numDigits(x) {
|
|
8308
|
+
return (Math.log10((x ^ (x >> 31)) - (x >> 31)) | 0) + 1;
|
|
8309
|
+
}
|
|
8310
|
+
function obscure(value) {
|
|
8311
|
+
if (typeof value === "number") {
|
|
8312
|
+
const digits = numDigits(value);
|
|
8313
|
+
return "9".repeat(digits);
|
|
8314
|
+
}
|
|
8315
|
+
if (typeof value === "string") {
|
|
8316
|
+
return value.replace(/[^\f\n\r\t\v\u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff\s]/g, '*');
|
|
8317
|
+
}
|
|
8318
|
+
return value;
|
|
8319
|
+
}
|
|
8320
|
+
function filterHeaders(headers) {
|
|
8321
|
+
const filteredHeaders = {};
|
|
8322
|
+
if (Array.isArray(headers)) {
|
|
8323
|
+
headers.forEach(({ name, value }) => {
|
|
8324
|
+
if (sensitiveParams.has(name.toLowerCase())) {
|
|
8325
|
+
filteredHeaders[name] = obscure(value);
|
|
8326
|
+
}
|
|
8327
|
+
else {
|
|
8328
|
+
filteredHeaders[name] = value;
|
|
8329
|
+
}
|
|
8330
|
+
});
|
|
8331
|
+
}
|
|
8332
|
+
else {
|
|
8333
|
+
for (const [key, value] of Object.entries(headers)) {
|
|
8334
|
+
if (sensitiveParams.has(key.toLowerCase())) {
|
|
8335
|
+
filteredHeaders[key] = obscure(value);
|
|
8336
|
+
}
|
|
8337
|
+
else {
|
|
8338
|
+
filteredHeaders[key] = value;
|
|
8339
|
+
}
|
|
8340
|
+
}
|
|
8341
|
+
}
|
|
8342
|
+
return filteredHeaders;
|
|
8343
|
+
}
|
|
8344
|
+
function filterBody(body) {
|
|
8345
|
+
if (!body) {
|
|
8346
|
+
return body;
|
|
8347
|
+
}
|
|
8348
|
+
let parsedBody;
|
|
8349
|
+
let isJSON = false;
|
|
8350
|
+
try {
|
|
8351
|
+
parsedBody = JSON.parse(body);
|
|
8352
|
+
isJSON = true;
|
|
8353
|
+
}
|
|
8354
|
+
catch (e) {
|
|
8355
|
+
// not json
|
|
8356
|
+
}
|
|
8357
|
+
if (isJSON) {
|
|
8358
|
+
obscureSensitiveData(parsedBody);
|
|
8359
|
+
return JSON.stringify(parsedBody);
|
|
8360
|
+
}
|
|
8361
|
+
else {
|
|
8362
|
+
const isUrlSearch = typeof body === "string" && body.includes("?") && body.includes("=");
|
|
8363
|
+
if (isUrlSearch) {
|
|
8364
|
+
try {
|
|
8365
|
+
const params = new URLSearchParams(body);
|
|
8366
|
+
for (const key of params.keys()) {
|
|
8367
|
+
if (sensitiveParams.has(key.toLowerCase())) {
|
|
8368
|
+
const value = obscure(params.get(key));
|
|
8369
|
+
params.set(key, value);
|
|
8370
|
+
}
|
|
8371
|
+
}
|
|
8372
|
+
return params.toString();
|
|
8373
|
+
}
|
|
8374
|
+
catch (e) {
|
|
8375
|
+
// not url query ?
|
|
8376
|
+
return body;
|
|
8377
|
+
}
|
|
8378
|
+
}
|
|
8379
|
+
else {
|
|
8380
|
+
// not json or url query
|
|
8381
|
+
return body;
|
|
8382
|
+
}
|
|
8383
|
+
}
|
|
8384
|
+
}
|
|
8385
|
+
function sanitizeObject(obj) {
|
|
8386
|
+
obscureSensitiveData(obj);
|
|
8387
|
+
return obj;
|
|
8388
|
+
}
|
|
8389
|
+
function obscureSensitiveData(obj) {
|
|
8390
|
+
if (Array.isArray(obj)) {
|
|
8391
|
+
obj.forEach(obscureSensitiveData);
|
|
8392
|
+
}
|
|
8393
|
+
else if (obj && typeof obj === "object") {
|
|
8394
|
+
for (const key in obj) {
|
|
8395
|
+
if (Object.hasOwn(obj, key)) {
|
|
8396
|
+
if (sensitiveParams.has(key.toLowerCase())) {
|
|
8397
|
+
obj[key] = obscure(obj[key]);
|
|
8398
|
+
}
|
|
8399
|
+
else if (obj[key] !== null && typeof obj[key] === "object") {
|
|
8400
|
+
obscureSensitiveData(obj[key]);
|
|
8401
|
+
}
|
|
8402
|
+
}
|
|
8403
|
+
}
|
|
8404
|
+
}
|
|
8405
|
+
}
|
|
8406
|
+
function tryFilterUrl(url) {
|
|
8407
|
+
if (!url)
|
|
8408
|
+
return "";
|
|
8409
|
+
try {
|
|
8410
|
+
const urlObj = new URL(url);
|
|
8411
|
+
if (urlObj.searchParams) {
|
|
8412
|
+
for (const key of urlObj.searchParams.keys()) {
|
|
8413
|
+
if (sensitiveParams.has(key.toLowerCase())) {
|
|
8414
|
+
urlObj.searchParams.set(key, "******");
|
|
8415
|
+
}
|
|
8416
|
+
}
|
|
8417
|
+
}
|
|
8418
|
+
return urlObj.toString();
|
|
8419
|
+
}
|
|
8420
|
+
catch (e) {
|
|
8421
|
+
return url;
|
|
8422
|
+
}
|
|
8423
|
+
}
|
|
8424
|
+
|
|
8480
8425
|
/**
|
|
8481
8426
|
* I know we're not using most of the information from this class
|
|
8482
8427
|
* but it can be useful in the future if we will decide to display more stuff in our ui
|
|
@@ -8508,13 +8453,18 @@ class NetworkMessage {
|
|
|
8508
8453
|
}
|
|
8509
8454
|
getMessage() {
|
|
8510
8455
|
const { reqHs, resHs } = this.writeHeaders();
|
|
8456
|
+
const reqBody = this.method === 'GET'
|
|
8457
|
+
? JSON.stringify(sanitizeObject(this.getData)) : filterBody(this.requestData);
|
|
8511
8458
|
const request = {
|
|
8512
|
-
headers: reqHs,
|
|
8513
|
-
body:
|
|
8459
|
+
headers: filterHeaders(reqHs),
|
|
8460
|
+
body: reqBody,
|
|
8461
|
+
};
|
|
8462
|
+
const response = {
|
|
8463
|
+
headers: filterHeaders(resHs),
|
|
8464
|
+
body: filterBody(this.response)
|
|
8514
8465
|
};
|
|
8515
|
-
const response = { headers: resHs, body: this.response };
|
|
8516
8466
|
const messageInfo = this.sanitize({
|
|
8517
|
-
url: this.url,
|
|
8467
|
+
url: tryFilterUrl(this.url),
|
|
8518
8468
|
method: this.method,
|
|
8519
8469
|
status: this.status,
|
|
8520
8470
|
request,
|
|
@@ -8830,9 +8780,10 @@ class ResponseProxyHandler {
|
|
|
8830
8780
|
if (typeof this.resp.body.getReader !== 'function') {
|
|
8831
8781
|
return;
|
|
8832
8782
|
}
|
|
8833
|
-
const
|
|
8783
|
+
const clonedResp = this.resp.clone();
|
|
8784
|
+
const _getReader = clonedResp.body.getReader;
|
|
8834
8785
|
// @ts-ignore
|
|
8835
|
-
|
|
8786
|
+
clonedResp.body.getReader = () => {
|
|
8836
8787
|
const reader = _getReader.apply(this.resp.body);
|
|
8837
8788
|
// when readyState is already 4,
|
|
8838
8789
|
// it's not a chunked stream, or it had already been read.
|
|
@@ -9674,7 +9625,7 @@ class API {
|
|
|
9674
9625
|
this.signalStartIssue = (reason, missingApi) => {
|
|
9675
9626
|
const doNotTrack = this.checkDoNotTrack();
|
|
9676
9627
|
console.log("Tracker couldn't start due to:", JSON.stringify({
|
|
9677
|
-
trackerVersion: '16.3.0
|
|
9628
|
+
trackerVersion: '16.3.0',
|
|
9678
9629
|
projectKey: this.options.projectKey,
|
|
9679
9630
|
doNotTrack,
|
|
9680
9631
|
reason: missingApi.length ? `missing api: ${missingApi.join(',')}` : reason,
|