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