@openreplay/tracker 16.1.0-beta.8 → 16.1.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/entry.js +227 -53
- package/dist/cjs/entry.js.map +1 -1
- package/dist/cjs/index.js +227 -53
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/main/app/index.d.ts +1 -0
- package/dist/cjs/main/app/sanitizer.d.ts +6 -1
- package/dist/lib/entry.js +227 -53
- package/dist/lib/entry.js.map +1 -1
- package/dist/lib/index.js +227 -53
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/main/app/index.d.ts +1 -0
- package/dist/lib/main/app/sanitizer.d.ts +6 -1
- package/dist/types/main/app/index.d.ts +1 -0
- package/dist/types/main/app/sanitizer.d.ts +6 -1
- package/package.json +2 -2
package/dist/lib/index.js
CHANGED
|
@@ -721,7 +721,9 @@ class StringDictionary {
|
|
|
721
721
|
this.backDict = {};
|
|
722
722
|
this.getKey = (str) => {
|
|
723
723
|
let isNew = false;
|
|
724
|
-
|
|
724
|
+
// avoiding potential native object properties
|
|
725
|
+
const safeKey = `__${str}`;
|
|
726
|
+
if (!this.backDict[safeKey]) {
|
|
725
727
|
isNew = true;
|
|
726
728
|
// shaving the first 2 digits of the timestamp (since they are irrelevant for next millennia)
|
|
727
729
|
const shavedTs = Date.now() % 10 ** (13 - 2);
|
|
@@ -733,20 +735,18 @@ class StringDictionary {
|
|
|
733
735
|
else {
|
|
734
736
|
this.lastSuffix = 1;
|
|
735
737
|
}
|
|
736
|
-
this.backDict[
|
|
738
|
+
this.backDict[safeKey] = id;
|
|
737
739
|
this.lastTs = shavedTs;
|
|
738
740
|
}
|
|
739
|
-
return [this.backDict[
|
|
741
|
+
return [this.backDict[safeKey], isNew];
|
|
740
742
|
};
|
|
741
743
|
}
|
|
742
744
|
}
|
|
743
745
|
class AttributeSender {
|
|
744
746
|
constructor(options) {
|
|
745
747
|
this.sendSetAttribute = (id, name, value) => {
|
|
746
|
-
// @ts-ignore
|
|
747
|
-
const attr = typeof value === 'string' ? value : (value.toString?.() ?? '');
|
|
748
748
|
if (this.isDictDisabled) {
|
|
749
|
-
const msg = [12 /* Type.SetNodeAttribute */, id, name,
|
|
749
|
+
const msg = [12 /* Type.SetNodeAttribute */, id, name, value];
|
|
750
750
|
return this.app.send(msg);
|
|
751
751
|
}
|
|
752
752
|
else {
|
|
@@ -754,7 +754,7 @@ class AttributeSender {
|
|
|
754
754
|
35 /* Type.SetNodeAttributeDictGlobal */,
|
|
755
755
|
id,
|
|
756
756
|
this.applyDict(name),
|
|
757
|
-
this.applyDict(
|
|
757
|
+
this.applyDict(value),
|
|
758
758
|
];
|
|
759
759
|
return this.app.send(message);
|
|
760
760
|
}
|
|
@@ -2200,7 +2200,7 @@ function Performance (app, opts) {
|
|
|
2200
2200
|
app.attachStopCallback(() => {
|
|
2201
2201
|
ticks = frames = undefined;
|
|
2202
2202
|
});
|
|
2203
|
-
app.ticker.attach(sendPerformanceTrack,
|
|
2203
|
+
app.ticker.attach(sendPerformanceTrack, 165, false);
|
|
2204
2204
|
if (document.hidden !== undefined) {
|
|
2205
2205
|
app.attachEventListener(document, 'visibilitychange', sendPerformanceTrack, false, false);
|
|
2206
2206
|
}
|
|
@@ -3707,9 +3707,26 @@ async function parseUseEl(useElement, mode, domParser) {
|
|
|
3707
3707
|
console.debug('Openreplay: xlink:href or href not found on <use>.');
|
|
3708
3708
|
return;
|
|
3709
3709
|
}
|
|
3710
|
-
|
|
3711
|
-
if
|
|
3712
|
-
|
|
3710
|
+
let [url, symbolId] = href.split('#');
|
|
3711
|
+
// happens if svg spritemap is local, fastest case for us
|
|
3712
|
+
if (!url && symbolId) {
|
|
3713
|
+
const symbol = document.querySelector(href);
|
|
3714
|
+
if (symbol) {
|
|
3715
|
+
const inlineSvg = `
|
|
3716
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="${symbol.getAttribute('viewBox') || '0 0 24 24'}">
|
|
3717
|
+
${symbol.innerHTML}
|
|
3718
|
+
</svg>
|
|
3719
|
+
`.trim();
|
|
3720
|
+
iconCache[symbolId] = inlineSvg;
|
|
3721
|
+
return inlineSvg;
|
|
3722
|
+
}
|
|
3723
|
+
else {
|
|
3724
|
+
console.warn('Openreplay: Sprite symbol not found in the document.');
|
|
3725
|
+
return;
|
|
3726
|
+
}
|
|
3727
|
+
}
|
|
3728
|
+
if (!url && !symbolId) {
|
|
3729
|
+
console.warn('Openreplay: Invalid xlink:href or href found on <use>.');
|
|
3713
3730
|
return;
|
|
3714
3731
|
}
|
|
3715
3732
|
if (iconCache[symbolId]) {
|
|
@@ -3960,6 +3977,9 @@ class Observer {
|
|
|
3960
3977
|
if (name === 'href' || value.length > 1e5) {
|
|
3961
3978
|
value = '';
|
|
3962
3979
|
}
|
|
3980
|
+
if (['alt', 'placeholder'].includes(name) && this.app.sanitizer.privateMode) {
|
|
3981
|
+
value = value.replaceAll(/./g, '*');
|
|
3982
|
+
}
|
|
3963
3983
|
this.app.attributeSender.sendSetAttribute(id, name, value);
|
|
3964
3984
|
}
|
|
3965
3985
|
sendNodeData(id, parentElement, data) {
|
|
@@ -3987,7 +4007,7 @@ class Observer {
|
|
|
3987
4007
|
const walker = document.createTreeWalker(node, NodeFilter.SHOW_ELEMENT + NodeFilter.SHOW_TEXT, {
|
|
3988
4008
|
acceptNode: (node) => {
|
|
3989
4009
|
if (this.app.nodes.getID(node) !== undefined) {
|
|
3990
|
-
this.app.debug.
|
|
4010
|
+
this.app.debug.info('! Node is already bound', node);
|
|
3991
4011
|
}
|
|
3992
4012
|
return isIgnored(node) || this.app.nodes.getID(node) !== undefined
|
|
3993
4013
|
? NodeFilter.FILTER_REJECT
|
|
@@ -4400,18 +4420,30 @@ var SanitizeLevel;
|
|
|
4400
4420
|
})(SanitizeLevel || (SanitizeLevel = {}));
|
|
4401
4421
|
const stringWiper = (input) => input
|
|
4402
4422
|
.trim()
|
|
4403
|
-
.replace(/[^\f\n\r\t\v\u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff]/g, '
|
|
4423
|
+
.replace(/[^\f\n\r\t\v\u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff\s]/g, '*');
|
|
4404
4424
|
class Sanitizer {
|
|
4405
4425
|
constructor(params) {
|
|
4406
4426
|
this.obscured = new Set();
|
|
4407
4427
|
this.hidden = new Set();
|
|
4408
4428
|
this.app = params.app;
|
|
4409
|
-
|
|
4429
|
+
const defaultOptions = {
|
|
4410
4430
|
obscureTextEmails: true,
|
|
4411
4431
|
obscureTextNumbers: false,
|
|
4412
|
-
|
|
4432
|
+
privateMode: false,
|
|
4433
|
+
domSanitizer: undefined,
|
|
4434
|
+
};
|
|
4435
|
+
this.privateMode = params.options?.privateMode ?? false;
|
|
4436
|
+
this.options = Object.assign(defaultOptions, params.options);
|
|
4413
4437
|
}
|
|
4414
4438
|
handleNode(id, parentID, node) {
|
|
4439
|
+
if (this.options.privateMode) {
|
|
4440
|
+
if (isElementNode(node) && !hasOpenreplayAttribute(node, 'unmask')) {
|
|
4441
|
+
return this.obscured.add(id);
|
|
4442
|
+
}
|
|
4443
|
+
if (isTextNode(node) && !hasOpenreplayAttribute(node.parentNode, 'unmask')) {
|
|
4444
|
+
return this.obscured.add(id);
|
|
4445
|
+
}
|
|
4446
|
+
}
|
|
4415
4447
|
if (this.obscured.has(parentID) ||
|
|
4416
4448
|
(isElementNode(node) &&
|
|
4417
4449
|
(hasOpenreplayAttribute(node, 'masked') || hasOpenreplayAttribute(node, 'obscured')))) {
|
|
@@ -4654,7 +4686,7 @@ class Ticker {
|
|
|
4654
4686
|
* this value is injected during build time via rollup
|
|
4655
4687
|
* */
|
|
4656
4688
|
// @ts-ignore
|
|
4657
|
-
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=[118,this.tabId];this.writeType(t),this.writeFields(t),this.writeWithSize(s),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";
|
|
4689
|
+
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";
|
|
4658
4690
|
const CANCELED = 'canceled';
|
|
4659
4691
|
const uxtStorageKey = 'or_uxt_active';
|
|
4660
4692
|
const bufferStorageKey = 'or_buffer_1';
|
|
@@ -4708,7 +4740,7 @@ class App {
|
|
|
4708
4740
|
this.stopCallbacks = [];
|
|
4709
4741
|
this.commitCallbacks = [];
|
|
4710
4742
|
this.activityState = ActivityState.NotActive;
|
|
4711
|
-
this.version = '16.1.0
|
|
4743
|
+
this.version = '16.1.0'; // TODO: version compatability check inside each plugin.
|
|
4712
4744
|
this.socketMode = false;
|
|
4713
4745
|
this.compressionThreshold = 24 * 1000;
|
|
4714
4746
|
this.bc = null;
|
|
@@ -4722,6 +4754,7 @@ class App {
|
|
|
4722
4754
|
'feature-flags': true,
|
|
4723
4755
|
'usability-test': true,
|
|
4724
4756
|
};
|
|
4757
|
+
this.emptyBatchCounter = 0;
|
|
4725
4758
|
/** used by child iframes for crossdomain only */
|
|
4726
4759
|
this.parentActive = false;
|
|
4727
4760
|
this.checkStatus = () => {
|
|
@@ -5321,8 +5354,7 @@ class App {
|
|
|
5321
5354
|
* */
|
|
5322
5355
|
_nCommit() {
|
|
5323
5356
|
if (this.socketMode) {
|
|
5324
|
-
this.messages.unshift(TabData(this.session.getTabId()));
|
|
5325
|
-
this.messages.unshift(Timestamp(this.timestamp()));
|
|
5357
|
+
this.messages.unshift(Timestamp(this.timestamp()), TabData(this.session.getTabId()));
|
|
5326
5358
|
this.commitCallbacks.forEach((cb) => cb(this.messages));
|
|
5327
5359
|
this.messages.length = 0;
|
|
5328
5360
|
return;
|
|
@@ -5339,25 +5371,19 @@ class App {
|
|
|
5339
5371
|
if (this.worker === undefined || !this.messages.length) {
|
|
5340
5372
|
return;
|
|
5341
5373
|
}
|
|
5374
|
+
if (!this.messages.length) {
|
|
5375
|
+
// Release empty batches every 30 secs (1000 * 30ms)
|
|
5376
|
+
if (this.emptyBatchCounter < 1000) {
|
|
5377
|
+
this.emptyBatchCounter++;
|
|
5378
|
+
return;
|
|
5379
|
+
}
|
|
5380
|
+
}
|
|
5381
|
+
this.emptyBatchCounter = 0;
|
|
5382
|
+
console.log('messages', this.messages.join(', '));
|
|
5342
5383
|
try {
|
|
5343
5384
|
requestIdleCb(() => {
|
|
5344
|
-
this.messages.unshift(TabData(this.session.getTabId()));
|
|
5345
|
-
this.
|
|
5346
|
-
try {
|
|
5347
|
-
this.worker?.postMessage(this.messages);
|
|
5348
|
-
}
|
|
5349
|
-
catch (e) {
|
|
5350
|
-
console.log(this.messages.join('$___$'));
|
|
5351
|
-
console.error(e);
|
|
5352
|
-
this.messages.forEach(m => {
|
|
5353
|
-
try {
|
|
5354
|
-
this.worker?.postMessage([m]);
|
|
5355
|
-
}
|
|
5356
|
-
catch (e) {
|
|
5357
|
-
console.error(m, e);
|
|
5358
|
-
}
|
|
5359
|
-
});
|
|
5360
|
-
}
|
|
5385
|
+
this.messages.unshift(Timestamp(this.timestamp()), TabData(this.session.getTabId()));
|
|
5386
|
+
this.worker?.postMessage(this.messages);
|
|
5361
5387
|
this.commitCallbacks.forEach((cb) => cb(this.messages));
|
|
5362
5388
|
this.messages.length = 0;
|
|
5363
5389
|
});
|
|
@@ -5379,10 +5405,9 @@ class App {
|
|
|
5379
5405
|
_cStartCommit() {
|
|
5380
5406
|
this.coldStartCommitN += 1;
|
|
5381
5407
|
if (this.coldStartCommitN === 2) {
|
|
5382
|
-
this.
|
|
5383
|
-
this.bufferedMessages1.push(
|
|
5384
|
-
this.bufferedMessages2.push(
|
|
5385
|
-
this.bufferedMessages2.push(TabData(this.session.getTabId()));
|
|
5408
|
+
const payload = [Timestamp(this.timestamp()), TabData(this.session.getTabId())];
|
|
5409
|
+
this.bufferedMessages1.push(...payload);
|
|
5410
|
+
this.bufferedMessages2.push(...payload);
|
|
5386
5411
|
this.coldStartCommitN = 0;
|
|
5387
5412
|
}
|
|
5388
5413
|
}
|
|
@@ -6188,7 +6213,13 @@ function Console (app, opts) {
|
|
|
6188
6213
|
if (!Array.isArray(options.consoleMethods) || options.consoleMethods.length === 0) {
|
|
6189
6214
|
return;
|
|
6190
6215
|
}
|
|
6191
|
-
const sendConsoleLog = app.safe((level, args) =>
|
|
6216
|
+
const sendConsoleLog = app.safe((level, args) => {
|
|
6217
|
+
let logMsg = printf(args);
|
|
6218
|
+
if (app.sanitizer.privateMode) {
|
|
6219
|
+
logMsg = logMsg.replaceAll(/./g, '*');
|
|
6220
|
+
}
|
|
6221
|
+
app.send(ConsoleLog(level, logMsg));
|
|
6222
|
+
});
|
|
6192
6223
|
let n = 0;
|
|
6193
6224
|
const reset = () => {
|
|
6194
6225
|
n = 0;
|
|
@@ -6712,7 +6743,10 @@ function Input (app, opts) {
|
|
|
6712
6743
|
}, 3);
|
|
6713
6744
|
function sendInputChange(id, node, hesitationTime, inputTime) {
|
|
6714
6745
|
const { value, mask } = getInputValue(id, node);
|
|
6715
|
-
|
|
6746
|
+
let label = getInputLabel(node);
|
|
6747
|
+
if (app.sanitizer.privateMode) {
|
|
6748
|
+
label = label.replaceAll(/./g, '*');
|
|
6749
|
+
}
|
|
6716
6750
|
app.send(InputChange(id, value, mask !== 0, label, hesitationTime, inputTime));
|
|
6717
6751
|
}
|
|
6718
6752
|
app.nodes.attachNodeCallback(app.safe((node) => {
|
|
@@ -7220,7 +7254,8 @@ function Mouse (app, options) {
|
|
|
7220
7254
|
const normalizedX = roundNumber(clickX / contentWidth);
|
|
7221
7255
|
const normalizedY = roundNumber(clickY / contentHeight);
|
|
7222
7256
|
sendMouseMove();
|
|
7223
|
-
|
|
7257
|
+
const label = getTargetLabel(target);
|
|
7258
|
+
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, options) : '', normalizedX, normalizedY), true);
|
|
7224
7259
|
}
|
|
7225
7260
|
mouseTarget = null;
|
|
7226
7261
|
});
|
|
@@ -7331,7 +7366,7 @@ function Timing (app, opts) {
|
|
|
7331
7366
|
if (failed) {
|
|
7332
7367
|
app.send(ResourceTiming(entry.startTime + getTimeOrigin(), 0, 0, 0, 0, 0, entry.name, entry.initiatorType, 0, true));
|
|
7333
7368
|
}
|
|
7334
|
-
app.send(ResourceTiming(entry.startTime + getTimeOrigin(), entry.duration, entry.responseStart && entry.startTime ? entry.responseStart - entry.startTime : 0, entry.transferSize > entry.encodedBodySize ? entry.transferSize - entry.encodedBodySize : 0, entry.encodedBodySize || 0, entry.decodedBodySize || 0, entry.name, entry.initiatorType, entry.transferSize,
|
|
7369
|
+
app.send(ResourceTiming(entry.startTime + getTimeOrigin(), entry.duration, entry.responseStart && entry.startTime ? entry.responseStart - entry.startTime : 0, entry.transferSize > entry.encodedBodySize ? entry.transferSize - entry.encodedBodySize : 0, entry.encodedBodySize || 0, entry.decodedBodySize || 0, app.sanitizer.privateMode ? entry.name.replaceAll(/./g, '*') : entry.name, entry.initiatorType, entry.transferSize,
|
|
7335
7370
|
// @ts-ignore
|
|
7336
7371
|
(entry.responseStatus && entry.responseStatus === 304) || entry.transferSize === 0));
|
|
7337
7372
|
}
|
|
@@ -7520,7 +7555,10 @@ function Viewport (app) {
|
|
|
7520
7555
|
const { URL } = document;
|
|
7521
7556
|
if (URL !== url) {
|
|
7522
7557
|
url = URL;
|
|
7523
|
-
app.
|
|
7558
|
+
const safeTitle = app.sanitizer.privateMode ? stringWiper(document.title) : document.title;
|
|
7559
|
+
const safeUrl = app.sanitizer.privateMode ? stringWiper(url) : url;
|
|
7560
|
+
const safeReferrer = app.sanitizer.privateMode ? stringWiper(referrer) : referrer;
|
|
7561
|
+
app.send(SetPageLocation(safeUrl, safeReferrer, navigationStart, safeTitle));
|
|
7524
7562
|
navigationStart = 0;
|
|
7525
7563
|
referrer = url;
|
|
7526
7564
|
}
|
|
@@ -7989,6 +8027,136 @@ function isObject(thing) {
|
|
|
7989
8027
|
return thing !== null && typeof thing === 'object';
|
|
7990
8028
|
}
|
|
7991
8029
|
|
|
8030
|
+
const sensitiveParams = new Set([
|
|
8031
|
+
"password",
|
|
8032
|
+
"pass",
|
|
8033
|
+
"pwd",
|
|
8034
|
+
"mdp",
|
|
8035
|
+
"token",
|
|
8036
|
+
"bearer",
|
|
8037
|
+
"jwt",
|
|
8038
|
+
"api_key",
|
|
8039
|
+
"api-key",
|
|
8040
|
+
"apiKey",
|
|
8041
|
+
"secret",
|
|
8042
|
+
"ssn",
|
|
8043
|
+
"zip",
|
|
8044
|
+
"zipcode",
|
|
8045
|
+
"x-api-key",
|
|
8046
|
+
"www-authenticate",
|
|
8047
|
+
"x-csrf-token",
|
|
8048
|
+
"x-requested-with",
|
|
8049
|
+
"x-forwarded-for",
|
|
8050
|
+
"x-real-ip",
|
|
8051
|
+
"cookie",
|
|
8052
|
+
"authorization",
|
|
8053
|
+
"auth",
|
|
8054
|
+
"proxy-authorization",
|
|
8055
|
+
"set-cookie",
|
|
8056
|
+
"account_key",
|
|
8057
|
+
]);
|
|
8058
|
+
function numDigits(x) {
|
|
8059
|
+
return (Math.log10((x ^ (x >> 31)) - (x >> 31)) | 0) + 1;
|
|
8060
|
+
}
|
|
8061
|
+
function obscure(value) {
|
|
8062
|
+
if (typeof value === "number") {
|
|
8063
|
+
const digits = numDigits(value);
|
|
8064
|
+
return "9".repeat(digits);
|
|
8065
|
+
}
|
|
8066
|
+
return value.replace(/[^\f\n\r\t\v\u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff\s]/g, '*');
|
|
8067
|
+
}
|
|
8068
|
+
function filterHeaders(headers) {
|
|
8069
|
+
const filteredHeaders = {};
|
|
8070
|
+
if (Array.isArray(headers)) {
|
|
8071
|
+
headers.forEach(({ name, value }) => {
|
|
8072
|
+
if (sensitiveParams.has(name.toLowerCase())) {
|
|
8073
|
+
filteredHeaders[name] = obscure(value);
|
|
8074
|
+
}
|
|
8075
|
+
else {
|
|
8076
|
+
filteredHeaders[name] = value;
|
|
8077
|
+
}
|
|
8078
|
+
});
|
|
8079
|
+
}
|
|
8080
|
+
else {
|
|
8081
|
+
for (const [key, value] of Object.entries(headers)) {
|
|
8082
|
+
if (sensitiveParams.has(key.toLowerCase())) {
|
|
8083
|
+
filteredHeaders[key] = obscure(value);
|
|
8084
|
+
}
|
|
8085
|
+
else {
|
|
8086
|
+
filteredHeaders[key] = value;
|
|
8087
|
+
}
|
|
8088
|
+
}
|
|
8089
|
+
}
|
|
8090
|
+
return filteredHeaders;
|
|
8091
|
+
}
|
|
8092
|
+
function filterBody(body) {
|
|
8093
|
+
if (!body) {
|
|
8094
|
+
return body;
|
|
8095
|
+
}
|
|
8096
|
+
let parsedBody;
|
|
8097
|
+
let isJSON = false;
|
|
8098
|
+
try {
|
|
8099
|
+
parsedBody = JSON.parse(body);
|
|
8100
|
+
isJSON = true;
|
|
8101
|
+
}
|
|
8102
|
+
catch (e) {
|
|
8103
|
+
// not json
|
|
8104
|
+
}
|
|
8105
|
+
if (isJSON) {
|
|
8106
|
+
obscureSensitiveData(parsedBody);
|
|
8107
|
+
return JSON.stringify(parsedBody);
|
|
8108
|
+
}
|
|
8109
|
+
else {
|
|
8110
|
+
const params = new URLSearchParams(body);
|
|
8111
|
+
for (const key of params.keys()) {
|
|
8112
|
+
if (sensitiveParams.has(key.toLowerCase())) {
|
|
8113
|
+
const value = obscure(params.get(key));
|
|
8114
|
+
params.set(key, value);
|
|
8115
|
+
}
|
|
8116
|
+
}
|
|
8117
|
+
return params.toString();
|
|
8118
|
+
}
|
|
8119
|
+
}
|
|
8120
|
+
function sanitizeObject(obj) {
|
|
8121
|
+
obscureSensitiveData(obj);
|
|
8122
|
+
return obj;
|
|
8123
|
+
}
|
|
8124
|
+
function obscureSensitiveData(obj) {
|
|
8125
|
+
if (Array.isArray(obj)) {
|
|
8126
|
+
obj.forEach(obscureSensitiveData);
|
|
8127
|
+
}
|
|
8128
|
+
else if (obj && typeof obj === "object") {
|
|
8129
|
+
for (const key in obj) {
|
|
8130
|
+
if (Object.hasOwn(obj, key)) {
|
|
8131
|
+
if (sensitiveParams.has(key.toLowerCase())) {
|
|
8132
|
+
obj[key] = obscure(obj[key]);
|
|
8133
|
+
}
|
|
8134
|
+
else if (obj[key] !== null && typeof obj[key] === "object") {
|
|
8135
|
+
obscureSensitiveData(obj[key]);
|
|
8136
|
+
}
|
|
8137
|
+
}
|
|
8138
|
+
}
|
|
8139
|
+
}
|
|
8140
|
+
}
|
|
8141
|
+
function tryFilterUrl(url) {
|
|
8142
|
+
if (!url)
|
|
8143
|
+
return "";
|
|
8144
|
+
try {
|
|
8145
|
+
const urlObj = new URL(url);
|
|
8146
|
+
if (urlObj.searchParams) {
|
|
8147
|
+
for (const key of urlObj.searchParams.keys()) {
|
|
8148
|
+
if (sensitiveParams.has(key.toLowerCase())) {
|
|
8149
|
+
urlObj.searchParams.set(key, "******");
|
|
8150
|
+
}
|
|
8151
|
+
}
|
|
8152
|
+
}
|
|
8153
|
+
return urlObj.toString();
|
|
8154
|
+
}
|
|
8155
|
+
catch (e) {
|
|
8156
|
+
return url;
|
|
8157
|
+
}
|
|
8158
|
+
}
|
|
8159
|
+
|
|
7992
8160
|
/**
|
|
7993
8161
|
* I know we're not using most of the information from this class
|
|
7994
8162
|
* but it can be useful in the future if we will decide to display more stuff in our ui
|
|
@@ -8020,13 +8188,18 @@ class NetworkMessage {
|
|
|
8020
8188
|
}
|
|
8021
8189
|
getMessage() {
|
|
8022
8190
|
const { reqHs, resHs } = this.writeHeaders();
|
|
8191
|
+
const reqBody = this.method === 'GET'
|
|
8192
|
+
? JSON.stringify(sanitizeObject(this.getData)) : filterBody(this.requestData);
|
|
8023
8193
|
const request = {
|
|
8024
|
-
headers: reqHs,
|
|
8025
|
-
body:
|
|
8194
|
+
headers: filterHeaders(reqHs),
|
|
8195
|
+
body: reqBody,
|
|
8196
|
+
};
|
|
8197
|
+
const response = {
|
|
8198
|
+
headers: filterHeaders(resHs),
|
|
8199
|
+
body: filterBody(this.response)
|
|
8026
8200
|
};
|
|
8027
|
-
const response = { headers: resHs, body: this.response };
|
|
8028
8201
|
const messageInfo = this.sanitize({
|
|
8029
|
-
url: this.url,
|
|
8202
|
+
url: tryFilterUrl(this.url),
|
|
8030
8203
|
method: this.method,
|
|
8031
8204
|
status: this.status,
|
|
8032
8205
|
request,
|
|
@@ -8891,7 +9064,7 @@ function Network (app, opts = {}) {
|
|
|
8891
9064
|
}
|
|
8892
9065
|
}
|
|
8893
9066
|
function sanitize(reqResInfo) {
|
|
8894
|
-
if (!options.capturePayload) {
|
|
9067
|
+
if (!options.capturePayload || app.sanitizer.privateMode) {
|
|
8895
9068
|
// @ts-ignore
|
|
8896
9069
|
delete reqResInfo.request.body;
|
|
8897
9070
|
delete reqResInfo.response.body;
|
|
@@ -8924,11 +9097,12 @@ function Network (app, opts = {}) {
|
|
|
8924
9097
|
const patchWindow = (context) => {
|
|
8925
9098
|
/* ====== modern way ====== */
|
|
8926
9099
|
if (options.useProxy) {
|
|
8927
|
-
return createNetworkProxy(context, options.ignoreHeaders, setSessionTokenHeader, sanitize, (message) => {
|
|
9100
|
+
return createNetworkProxy(context, app.sanitizer.privateMode ? true : options.ignoreHeaders, setSessionTokenHeader, sanitize, (message) => {
|
|
8928
9101
|
if (options.failuresOnly && message.status < 400) {
|
|
8929
9102
|
return;
|
|
8930
9103
|
}
|
|
8931
|
-
|
|
9104
|
+
const url = app.sanitizer.privateMode ? '************' : message.url;
|
|
9105
|
+
app.send(NetworkRequest(message.requestType, message.method, url, message.request, message.response, message.status, message.startTime + getTimeOrigin(), message.duration, message.responseSize));
|
|
8932
9106
|
}, (url) => app.isServiceURL(url), { xhr: true, fetch: true, beacon: true }, options.tokenUrlMatcher);
|
|
8933
9107
|
}
|
|
8934
9108
|
/* ====== Fetch ====== */
|
|
@@ -9185,7 +9359,7 @@ class API {
|
|
|
9185
9359
|
this.signalStartIssue = (reason, missingApi) => {
|
|
9186
9360
|
const doNotTrack = this.checkDoNotTrack();
|
|
9187
9361
|
console.log("Tracker couldn't start due to:", JSON.stringify({
|
|
9188
|
-
trackerVersion: '16.1.0
|
|
9362
|
+
trackerVersion: '16.1.0',
|
|
9189
9363
|
projectKey: this.options.projectKey,
|
|
9190
9364
|
doNotTrack,
|
|
9191
9365
|
reason: missingApi.length ? `missing api: ${missingApi.join(',')}` : reason,
|