@openreplay/tracker 17.2.6 → 17.2.8

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.
@@ -1,6 +1,7 @@
1
1
  import type { Options as WebworkerOptions } from '../../common/interaction.js';
2
2
  import AttributeSender from '../modules/attributeSender.js';
3
3
  import type { Options as NetworkOptions } from '../modules/network.js';
4
+ import type TagMatcher from '../modules/tagMatcher.js';
4
5
  import Logger, { ILogLevel } from './logger.js';
5
6
  import Message from './messages.gen.js';
6
7
  import Nodes from './nodes/index.js';
@@ -158,6 +159,7 @@ export default class App {
158
159
  private canvasRecorder;
159
160
  private conditionsManager;
160
161
  private readonly tagWatcher;
162
+ get tagMatcher(): TagMatcher;
161
163
  private canStart;
162
164
  private rootId;
163
165
  private pageFrames;
@@ -62,7 +62,6 @@ export declare function AdoptedSSRemoveOwner(sheetID: number, id: number): Messa
62
62
  export declare function JSException(name: string, message: string, payload: string, metadata: string): Messages.JSException;
63
63
  export declare function Zustand(mutation: string, state: string): Messages.Zustand;
64
64
  export declare function BatchMetadata(version: number, pageNo: number, firstIndex: number, timestamp: number, location: string): Messages.BatchMetadata;
65
- export declare function PartitionedMessage(partNo: number, partTotal: number): Messages.PartitionedMessage;
66
65
  export declare function NetworkRequest(type: string, method: string, url: string, request: string, response: string, status: number, timestamp: number, duration: number, transferredBodySize: number): Messages.NetworkRequest;
67
66
  export declare function WSChannel(chType: string, channelName: string, data: string, timestamp: number, dir: string, messageType: string): Messages.WSChannel;
68
67
  export declare function ResourceTiming(timestamp: number, duration: number, ttfb: number, headerSize: number, encodedBodySize: number, decodedBodySize: number, url: string, initiator: string, transferredSize: number, cached: boolean, queueing: number, dnsLookup: number, initialConnection: number, ssl: number, contentDownload: number, total: number, stalled: number): Messages.ResourceTiming;
@@ -0,0 +1,28 @@
1
+ export type Tag = {
2
+ id: number;
3
+ selector: string;
4
+ location?: string;
5
+ };
6
+ /**
7
+ * Two-tier tag matching:
8
+ * 1. Fast fingerprint lookup by id, data-attr,
9
+ * or class from the selector's last segment
10
+ * 2. Fallback iteration using native element.matches()
11
+ */
12
+ declare class TagMatcher {
13
+ private tags;
14
+ private byId;
15
+ private byDataAttr;
16
+ private byClass;
17
+ private fallback;
18
+ setTags(tags: Tag[]): void;
19
+ getTags(): Tag[];
20
+ /** Match element, its parent, or direct children against known tag selectors */
21
+ match(el: Element): Tag | null;
22
+ private matchExact;
23
+ clear(): void;
24
+ }
25
+ export declare function matchesLocation(tag: {
26
+ location?: string;
27
+ }): boolean;
28
+ export default TagMatcher;
@@ -1,10 +1,9 @@
1
+ import TagMatcher, { type Tag } from './tagMatcher.js';
1
2
  export declare const WATCHED_TAGS_KEY = "__or__watched_tags__";
2
3
  declare class TagWatcher {
3
4
  interval: ReturnType<typeof setInterval> | null;
4
- tags: {
5
- id: number;
6
- selector: string;
7
- }[];
5
+ tags: Tag[];
6
+ readonly matcher: TagMatcher;
8
7
  observer: IntersectionObserver;
9
8
  private readonly sessionStorage;
10
9
  private readonly errLog;
@@ -15,10 +14,7 @@ declare class TagWatcher {
15
14
  onTag: (tag: number) => void;
16
15
  });
17
16
  fetchTags(ingest: string, token: string): Promise<void>;
18
- setTags(tags: {
19
- id: number;
20
- selector: string;
21
- }[]): void;
17
+ setTags(tags: Tag[]): void;
22
18
  onTagRendered(tagId: number): void;
23
19
  clear(): void;
24
20
  }
@@ -61,7 +61,6 @@ export declare const enum Type {
61
61
  JSException = 78,
62
62
  Zustand = 79,
63
63
  BatchMetadata = 81,
64
- PartitionedMessage = 82,
65
64
  NetworkRequest = 83,
66
65
  WSChannel = 84,
67
66
  ResourceTiming = 85,
@@ -442,11 +441,6 @@ export type BatchMetadata = [
442
441
  number,
443
442
  string
444
443
  ];
445
- export type PartitionedMessage = [
446
- Type.PartitionedMessage,
447
- number,
448
- number
449
- ];
450
444
  export type NetworkRequest = [
451
445
  Type.NetworkRequest,
452
446
  string,
@@ -583,5 +577,5 @@ export type WebVitals = [
583
577
  string,
584
578
  string
585
579
  ];
586
- type Message = Timestamp | SetPageLocationDeprecated | SetViewportSize | SetViewportScroll | CreateDocument | CreateElementNode | CreateTextNode | MoveNode | RemoveNode | SetNodeAttribute | RemoveNodeAttribute | SetNodeData | SetNodeScroll | SetInputTarget | SetInputValue | SetInputChecked | MouseMove | NetworkRequestDeprecated | ConsoleLog | PageLoadTiming | PageRenderTiming | CustomEvent | UserID | UserAnonymousID | Metadata | StringDictGlobal | SetNodeAttributeDictGlobal | NodeAnimationResult | Profiler | OTable | StateAction | ReduxDeprecated | Vuex | MobX | NgRx | GraphQLDeprecated | PerformanceTrack | StringDictDeprecated | SetNodeAttributeDictDeprecated | StringDict | SetNodeAttributeDict | ResourceTimingDeprecatedDeprecated | ConnectionInformation | SetPageVisibility | LoadFontFace | SetNodeFocus | SetNodeAttributeURLBased | SetCSSDataURLBased | TechnicalInfo | CustomIssue | SetNodeSlot | MouseClick | MouseClickDeprecated | CreateIFrameDocument | AdoptedSSReplaceURLBased | AdoptedSSInsertRuleURLBased | AdoptedSSDeleteRule | AdoptedSSAddOwner | AdoptedSSRemoveOwner | JSException | Zustand | BatchMetadata | PartitionedMessage | NetworkRequest | WSChannel | ResourceTiming | Incident | LongAnimationTask | InputChange | SelectionChange | MouseThrashing | UnbindNodes | ResourceTimingDeprecated | TabChange | TabData | CanvasNode | TagTrigger | Redux | SetPageLocation | GraphQL | WebVitals;
580
+ type Message = Timestamp | SetPageLocationDeprecated | SetViewportSize | SetViewportScroll | CreateDocument | CreateElementNode | CreateTextNode | MoveNode | RemoveNode | SetNodeAttribute | RemoveNodeAttribute | SetNodeData | SetNodeScroll | SetInputTarget | SetInputValue | SetInputChecked | MouseMove | NetworkRequestDeprecated | ConsoleLog | PageLoadTiming | PageRenderTiming | CustomEvent | UserID | UserAnonymousID | Metadata | StringDictGlobal | SetNodeAttributeDictGlobal | NodeAnimationResult | Profiler | OTable | StateAction | ReduxDeprecated | Vuex | MobX | NgRx | GraphQLDeprecated | PerformanceTrack | StringDictDeprecated | SetNodeAttributeDictDeprecated | StringDict | SetNodeAttributeDict | ResourceTimingDeprecatedDeprecated | ConnectionInformation | SetPageVisibility | LoadFontFace | SetNodeFocus | SetNodeAttributeURLBased | SetCSSDataURLBased | TechnicalInfo | CustomIssue | SetNodeSlot | MouseClick | MouseClickDeprecated | CreateIFrameDocument | AdoptedSSReplaceURLBased | AdoptedSSInsertRuleURLBased | AdoptedSSDeleteRule | AdoptedSSAddOwner | AdoptedSSRemoveOwner | JSException | Zustand | BatchMetadata | NetworkRequest | WSChannel | ResourceTiming | Incident | LongAnimationTask | InputChange | SelectionChange | MouseThrashing | UnbindNodes | ResourceTimingDeprecated | TabChange | TabData | CanvasNode | TagTrigger | Redux | SetPageLocation | GraphQL | WebVitals;
587
581
  export default Message;
package/dist/lib/entry.js CHANGED
@@ -1207,13 +1207,6 @@ function BatchMetadata(version, pageNo, firstIndex, timestamp, location) {
1207
1207
  location,
1208
1208
  ];
1209
1209
  }
1210
- function PartitionedMessage(partNo, partTotal) {
1211
- return [
1212
- 82 /* Messages.Type.PartitionedMessage */,
1213
- partNo,
1214
- partTotal,
1215
- ];
1216
- }
1217
1210
  function NetworkRequest(type, method, url, request, response, status, timestamp, duration, transferredBodySize) {
1218
1211
  return [
1219
1212
  83 /* Messages.Type.NetworkRequest */,
@@ -1425,7 +1418,6 @@ var _Messages = /*#__PURE__*/Object.freeze({
1425
1418
  OTable: OTable,
1426
1419
  PageLoadTiming: PageLoadTiming,
1427
1420
  PageRenderTiming: PageRenderTiming,
1428
- PartitionedMessage: PartitionedMessage,
1429
1421
  PerformanceTrack: PerformanceTrack,
1430
1422
  Profiler: Profiler,
1431
1423
  Redux: Redux,
@@ -1520,11 +1512,157 @@ function Performance (app, opts) {
1520
1512
  }
1521
1513
  }
1522
1514
 
1515
+ /**
1516
+ * Two-tier tag matching:
1517
+ * 1. Fast fingerprint lookup by id, data-attr,
1518
+ * or class from the selector's last segment
1519
+ * 2. Fallback iteration using native element.matches()
1520
+ */
1521
+ class TagMatcher {
1522
+ constructor() {
1523
+ this.tags = [];
1524
+ this.byId = new Map();
1525
+ this.byDataAttr = new Map();
1526
+ this.byClass = new Map();
1527
+ this.fallback = [];
1528
+ }
1529
+ setTags(tags) {
1530
+ this.tags = tags;
1531
+ this.byId.clear();
1532
+ this.byDataAttr.clear();
1533
+ this.byClass.clear();
1534
+ this.fallback = [];
1535
+ for (const tag of tags) {
1536
+ const last = lastSegment(tag.selector);
1537
+ if (!last) {
1538
+ this.fallback.push(tag);
1539
+ continue;
1540
+ }
1541
+ if (last.startsWith('#')) {
1542
+ this.byId.set(last.slice(1), tag);
1543
+ }
1544
+ else if (last.startsWith('[data-')) {
1545
+ this.byDataAttr.set(last, tag);
1546
+ }
1547
+ else {
1548
+ const cls = extractClass(last);
1549
+ if (cls) {
1550
+ this.byClass.set(cls, tag);
1551
+ }
1552
+ else {
1553
+ this.fallback.push(tag);
1554
+ }
1555
+ }
1556
+ }
1557
+ }
1558
+ getTags() {
1559
+ return this.tags;
1560
+ }
1561
+ /** Match element, its parent, or direct children against known tag selectors */
1562
+ match(el) {
1563
+ const direct = this.matchExact(el);
1564
+ if (direct)
1565
+ return direct;
1566
+ if (el.parentElement) {
1567
+ const parent = this.matchExact(el.parentElement);
1568
+ if (parent)
1569
+ return parent;
1570
+ }
1571
+ const children = el.children;
1572
+ for (let i = 0; i < children.length; i++) {
1573
+ const child = this.matchExact(children[i]);
1574
+ if (child)
1575
+ return child;
1576
+ }
1577
+ return null;
1578
+ }
1579
+ matchExact(el) {
1580
+ if (el.id && this.byId.has(el.id)) {
1581
+ const tag = this.byId.get(el.id);
1582
+ if (safeMatches(el, tag.selector) && matchesLocation(tag))
1583
+ return tag;
1584
+ }
1585
+ if (this.byDataAttr.size > 0) {
1586
+ const attrs = el.attributes;
1587
+ for (let i = 0; i < attrs.length; i++) {
1588
+ const attr = attrs[i];
1589
+ if (attr.name.startsWith('data-')) {
1590
+ const key = `[${attr.name}="${attr.value}"]`;
1591
+ if (this.byDataAttr.has(key)) {
1592
+ const tag = this.byDataAttr.get(key);
1593
+ if (safeMatches(el, tag.selector) && matchesLocation(tag))
1594
+ return tag;
1595
+ }
1596
+ }
1597
+ }
1598
+ }
1599
+ if (this.byClass.size > 0 && el.classList) {
1600
+ for (let i = 0; i < el.classList.length; i++) {
1601
+ const cls = el.classList[i];
1602
+ if (this.byClass.has(cls)) {
1603
+ const tag = this.byClass.get(cls);
1604
+ if (safeMatches(el, tag.selector) && matchesLocation(tag))
1605
+ return tag;
1606
+ }
1607
+ }
1608
+ }
1609
+ for (const tag of this.fallback) {
1610
+ if (safeMatches(el, tag.selector) && matchesLocation(tag))
1611
+ return tag;
1612
+ }
1613
+ return null;
1614
+ }
1615
+ clear() {
1616
+ this.tags = [];
1617
+ this.byId.clear();
1618
+ this.byDataAttr.clear();
1619
+ this.byClass.clear();
1620
+ this.fallback = [];
1621
+ }
1622
+ }
1623
+ /** Last combinator-separated segment of a CSS selector */
1624
+ function lastSegment(selector) {
1625
+ const trimmed = selector.trim();
1626
+ if (!trimmed)
1627
+ return null;
1628
+ const parts = trimmed.split(/\s*[>+~ ]\s*/);
1629
+ const last = parts[parts.length - 1]?.trim();
1630
+ return last || null;
1631
+ }
1632
+ /** First class name from a selector segment, e.g. "div.my-class" -> "my-class" */
1633
+ function extractClass(segment) {
1634
+ const match = segment.match(/\.([a-zA-Z_-][\w-]*)/);
1635
+ return match ? match[1] : null;
1636
+ }
1637
+ function safeMatches(el, selector) {
1638
+ try {
1639
+ return el.matches(selector);
1640
+ }
1641
+ catch {
1642
+ return false;
1643
+ }
1644
+ }
1645
+ function matchesLocation(tag) {
1646
+ if (!tag.location)
1647
+ return true;
1648
+ try {
1649
+ const loc = tag.location;
1650
+ if (loc.startsWith('/')) {
1651
+ return window.location.pathname === loc;
1652
+ }
1653
+ return window.location.href === loc;
1654
+ }
1655
+ catch {
1656
+ return true;
1657
+ }
1658
+ }
1659
+
1523
1660
  const WATCHED_TAGS_KEY = '__or__watched_tags__';
1524
1661
  class TagWatcher {
1525
1662
  constructor(params) {
1526
1663
  this.interval = null;
1527
1664
  this.tags = [];
1665
+ this.matcher = new TagMatcher();
1528
1666
  this.sessionStorage = params.sessionStorage;
1529
1667
  this.errLog = params.errLog;
1530
1668
  this.onTag = params.onTag;
@@ -1565,12 +1703,15 @@ class TagWatcher {
1565
1703
  }
1566
1704
  setTags(tags) {
1567
1705
  this.tags = tags;
1706
+ this.matcher.setTags(tags);
1568
1707
  if (this.interval) {
1569
1708
  clearInterval(this.interval);
1570
1709
  this.interval = null;
1571
1710
  }
1572
1711
  this.interval = setInterval(() => {
1573
1712
  this.tags.forEach((tag) => {
1713
+ if (!matchesLocation(tag))
1714
+ return;
1574
1715
  const possibleEls = document.querySelectorAll(tag.selector);
1575
1716
  if (possibleEls.length > 0) {
1576
1717
  const el = possibleEls[0];
@@ -1582,13 +1723,17 @@ class TagWatcher {
1582
1723
  }, 500);
1583
1724
  }
1584
1725
  onTagRendered(tagId) {
1585
- if (this.tags.findIndex(t => t.id === tagId)) {
1586
- this.tags = this.tags.filter((tag) => tag.id !== tagId);
1726
+ const tag = this.tags.find(t => t.id === tagId);
1727
+ if (tag) {
1728
+ this.tags = this.tags.filter((t) => t.id !== tagId);
1729
+ if (!matchesLocation(tag))
1730
+ return;
1587
1731
  }
1588
1732
  this.onTag(tagId);
1589
1733
  }
1590
1734
  clear() {
1591
1735
  this.tags = [];
1736
+ this.matcher.clear();
1592
1737
  if (this.interval) {
1593
1738
  clearInterval(this.interval);
1594
1739
  this.interval = null;
@@ -2241,8 +2386,44 @@ function inlineRemoteCss(node, id, baseHref, getNextID, insertRule, addOwner, fo
2241
2386
  })
2242
2387
  .catch(error => {
2243
2388
  console.error(`OpenReplay: Failed to fetch CSS from ${node.href}:`, error);
2389
+ // Fetch failed (likely CORS) — retry via load event + sheet access
2390
+ retryViaLoadEvent();
2244
2391
  });
2245
2392
  }
2393
+ else {
2394
+ retryViaLoadEvent();
2395
+ }
2396
+ function retryViaLoadEvent() {
2397
+ const trySheet = () => {
2398
+ const loadedSheet = node.sheet;
2399
+ if (loadedSheet) {
2400
+ try {
2401
+ const cssText = stringifyStylesheet(loadedSheet);
2402
+ if (cssText) {
2403
+ if (sendPlain && onPlain) {
2404
+ onPlain(cssText, fakeIdHolder++);
2405
+ }
2406
+ else {
2407
+ processCssText(cssText);
2408
+ }
2409
+ return;
2410
+ }
2411
+ }
2412
+ catch (e) {
2413
+ // cross-origin sheet — nothing more we can do
2414
+ }
2415
+ }
2416
+ };
2417
+ if (node.sheet) {
2418
+ trySheet();
2419
+ }
2420
+ else {
2421
+ node.addEventListener('load', function onLoad() {
2422
+ node.removeEventListener('load', onLoad);
2423
+ trySheet();
2424
+ });
2425
+ }
2426
+ }
2246
2427
  function processCssText(cssText) {
2247
2428
  // Remove comments
2248
2429
  cssText = cssText.replace(/\/\*[\s\S]*?\*\//g, '');
@@ -2464,7 +2645,6 @@ function ConstructedStyleSheets (app) {
2464
2645
  if (!hasAdoptedSS(document)) {
2465
2646
  return;
2466
2647
  }
2467
- const styleSheetIDMap = new Map();
2468
2648
  const adoptedStyleSheetsOwnings = new Map();
2469
2649
  const sendAdoptedStyleSheetsUpdate = (root) => setTimeout(() => {
2470
2650
  let nodeID = app.nodes.getID(root);
@@ -2884,9 +3064,7 @@ class Observer {
2884
3064
  this.app.send(AdoptedSSAddOwner(sheetId, ownerId));
2885
3065
  }, this.inlinerOptions?.forceFetch, this.inlinerOptions?.forcePlain, (cssText, fakeTextId) => {
2886
3066
  this.app.send(CreateTextNode(fakeTextId, id, 0));
2887
- setTimeout(() => {
2888
- this.app.send(SetCSSDataURLBased(fakeTextId, cssText, this.app.getBaseHref()));
2889
- }, 10);
3067
+ this.app.send(SetCSSDataURLBased(fakeTextId, cssText, this.app.getBaseHref()));
2890
3068
  });
2891
3069
  }, 0);
2892
3070
  return;
@@ -3754,7 +3932,7 @@ class Ticker {
3754
3932
  * this value is injected during build time via rollup
3755
3933
  * */
3756
3934
  // @ts-ignore
3757
- 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 65: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 36:case 50:case 54:return this.uint(t[1])&&this.string(t[2]);case 16:return this.uint(t[1])&&this.int(t[2])&&this.int(t[3]);case 18:return this.uint(t[1])&&this.string(t[2])&&this.int(t[3]);case 19:return this.uint(t[1])&&this.boolean(t[2]);case 21:return this.string(t[1])&&this.string(t[2])&&this.string(t[3])&&this.string(t[4])&&this.string(t[5])&&this.uint(t[6])&&this.uint(t[7])&&this.uint(t[8]);case 22:case 27:case 30:case 41:case 45:case 46:case 43:case 63:case 64:case 79:case 124:return this.string(t[1])&&this.string(t[2]);case 23:return this.uint(t[1])&&this.uint(t[2])&&this.uint(t[3])&&this.uint(t[4])&&this.uint(t[5])&&this.uint(t[6])&&this.uint(t[7])&&this.uint(t[8])&&this.uint(t[9]);case 28:case 29:case 42:case 117:case 118:return this.string(t[1]);case 40:return this.string(t[1])&&this.uint(t[2])&&this.string(t[3])&&this.string(t[4]);case 48:return this.string(t[1])&&this.string(t[2])&&this.string(t[3])&&this.string(t[4])&&this.int(t[5]);case 49:return this.int(t[1])&&this.int(t[2])&&this.uint(t[3])&&this.uint(t[4]);case 53:return this.uint(t[1])&&this.uint(t[2])&&this.uint(t[3])&&this.uint(t[4])&&this.uint(t[5])&&this.uint(t[6])&&this.string(t[7])&&this.string(t[8]);case 55:return this.boolean(t[1]);case 57:case 60:return this.uint(t[1])&&this.string(t[2])&&this.string(t[3])&&this.string(t[4]);case 58:case 120:return this.int(t[1]);case 68:return this.uint(t[1])&&this.uint(t[2])&&this.string(t[3])&&this.string(t[4])&&this.uint(t[5])&&this.uint(t[6]);case 69:return this.uint(t[1])&&this.uint(t[2])&&this.string(t[3])&&this.string(t[4]);case 73:return this.uint(t[1])&&this.string(t[2])&&this.uint(t[3])&&this.string(t[4]);case 78:return this.string(t[1])&&this.string(t[2])&&this.string(t[3])&&this.string(t[4]);case 81:return this.uint(t[1])&&this.uint(t[2])&&this.uint(t[3])&&this.int(t[4])&&this.string(t[5]);case 83:return this.string(t[1])&&this.string(t[2])&&this.string(t[3])&&this.string(t[4])&&this.string(t[5])&&this.uint(t[6])&&this.uint(t[7])&&this.uint(t[8])&&this.uint(t[9]);case 84:return this.string(t[1])&&this.string(t[2])&&this.string(t[3])&&this.uint(t[4])&&this.string(t[5])&&this.string(t[6]);case 85:return this.uint(t[1])&&this.uint(t[2])&&this.uint(t[3])&&this.uint(t[4])&&this.uint(t[5])&&this.uint(t[6])&&this.string(t[7])&&this.string(t[8])&&this.uint(t[9])&&this.boolean(t[10])&&this.uint(t[11])&&this.uint(t[12])&&this.uint(t[13])&&this.uint(t[14])&&this.uint(t[15])&&this.uint(t[16])&&this.uint(t[17]);case 87:return this.string(t[1])&&this.int(t[2])&&this.int(t[3]);case 89:return this.string(t[1])&&this.int(t[2])&&this.int(t[3])&&this.int(t[4])&&this.int(t[5])&&this.string(t[6]);case 112:return this.uint(t[1])&&this.string(t[2])&&this.boolean(t[3])&&this.string(t[4])&&this.int(t[5])&&this.int(t[6]);case 113:return this.uint(t[1])&&this.uint(t[2])&&this.string(t[3]);case 116:return this.uint(t[1])&&this.uint(t[2])&&this.uint(t[3])&&this.uint(t[4])&&this.uint(t[5])&&this.uint(t[6])&&this.string(t[7])&&this.string(t[8])&&this.uint(t[9])&&this.boolean(t[10]);case 119:return this.string(t[1])&&this.uint(t[2]);case 121:return this.string(t[1])&&this.string(t[2])&&this.uint(t[3])&&this.uint(t[4]);case 122:return this.string(t[1])&&this.string(t[2])&&this.uint(t[3])&&this.string(t[4]);case 123:return this.string(t[1])&&this.string(t[2])&&this.string(t[3])&&this.string(t[4])&&this.uint(t[5])}}}class 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.checkpoints=[],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;this.checkpoints.length=0;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.checkpoints.push(s.getCurrentOffset()),this.isEmpty=this.isEmpty&&0===t[0],this.nextIndex++}return e}setBeaconSizeLimit(t){this.beaconSizeLimit=t}writeMessage(t){if(-1===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(t=!1){if(this.isEmpty)return;const s=this.encoder.flush();this.onBatch(s,t),this.prepare()}clean(){this.encoder.reset(),this.checkpoints.length=0}}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,u=null,a=h.NotActive;function o(t){u&&u.finaliseBatch(t)}function c(){return new Promise((t=>{a=h.Stopping,null!==p&&(clearInterval(p),p=null),u&&(u.clean(),u=null),r&&(r.clean(),setTimeout((()=>{r=null}),20)),setTimeout((()=>{a=h.NotActive,t(null)}),100)}))}function g(){[h.Stopped,h.Stopping].includes(a)||(postMessage(\"a_stop\"),c().then((()=>{postMessage(\"a_start\")})))}let l,p=null;self.onmessage=({data:s})=>{if(\"stop\"===s)return o(),void c().then((()=>{a=h.Stopped}));if(\"forceFlushBatch\"!==s)if(\"closing\"!==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?(a=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),u=new n(s.pageNo,s.timestamp,s.url,((t,s)=>{r&&(s?r.sendUncompressed(t):r.push(t))}),s.tabId,(()=>postMessage({type:\"queue_empty\"}))),null===p&&(p=setInterval(o,3e4)),a=h.Active):\"auth\"===s.type?r?u?(r.authorise(s.token),void(s.beaconSizeLimit&&u.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(u){const t=u;s.forEach((s=>{55===s[0]&&(s[1]?l=setTimeout((()=>g()),18e5):clearTimeout(l)),t.writeMessage(s)}))}else postMessage(\"not_init\"),g()}else o(!0);else o()}}();\n";
3935
+ 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 65:case 70:case 75:case 76:case 77:return this.uint(t[1])&&this.uint(t[2]);case 6:return this.int(t[1])&&this.int(t[2]);case 7:return!0;case 8:return this.uint(t[1])&&this.uint(t[2])&&this.uint(t[3])&&this.string(t[4])&&this.boolean(t[5]);case 9:case 10:case 24:case 35:case 51:return this.uint(t[1])&&this.uint(t[2])&&this.uint(t[3]);case 12:case 52:case 61:case 71:return this.uint(t[1])&&this.string(t[2])&&this.string(t[3]);case 13:case 14:case 17:case 34:case 36:case 50:case 54:return this.uint(t[1])&&this.string(t[2]);case 16:return this.uint(t[1])&&this.int(t[2])&&this.int(t[3]);case 18:return this.uint(t[1])&&this.string(t[2])&&this.int(t[3]);case 19:return this.uint(t[1])&&this.boolean(t[2]);case 21:return this.string(t[1])&&this.string(t[2])&&this.string(t[3])&&this.string(t[4])&&this.string(t[5])&&this.uint(t[6])&&this.uint(t[7])&&this.uint(t[8]);case 22:case 27:case 30:case 41:case 45:case 46:case 43:case 63:case 64:case 79:case 124:return this.string(t[1])&&this.string(t[2]);case 23:return this.uint(t[1])&&this.uint(t[2])&&this.uint(t[3])&&this.uint(t[4])&&this.uint(t[5])&&this.uint(t[6])&&this.uint(t[7])&&this.uint(t[8])&&this.uint(t[9]);case 28:case 29:case 42:case 117:case 118:return this.string(t[1]);case 40:return this.string(t[1])&&this.uint(t[2])&&this.string(t[3])&&this.string(t[4]);case 48:return this.string(t[1])&&this.string(t[2])&&this.string(t[3])&&this.string(t[4])&&this.int(t[5]);case 49:return this.int(t[1])&&this.int(t[2])&&this.uint(t[3])&&this.uint(t[4]);case 53:return this.uint(t[1])&&this.uint(t[2])&&this.uint(t[3])&&this.uint(t[4])&&this.uint(t[5])&&this.uint(t[6])&&this.string(t[7])&&this.string(t[8]);case 55:return this.boolean(t[1]);case 57:case 60:return this.uint(t[1])&&this.string(t[2])&&this.string(t[3])&&this.string(t[4]);case 58:case 120:return this.int(t[1]);case 68:return this.uint(t[1])&&this.uint(t[2])&&this.string(t[3])&&this.string(t[4])&&this.uint(t[5])&&this.uint(t[6]);case 69:return this.uint(t[1])&&this.uint(t[2])&&this.string(t[3])&&this.string(t[4]);case 73:return this.uint(t[1])&&this.string(t[2])&&this.uint(t[3])&&this.string(t[4]);case 78:return this.string(t[1])&&this.string(t[2])&&this.string(t[3])&&this.string(t[4]);case 81:return this.uint(t[1])&&this.uint(t[2])&&this.uint(t[3])&&this.int(t[4])&&this.string(t[5]);case 83:return this.string(t[1])&&this.string(t[2])&&this.string(t[3])&&this.string(t[4])&&this.string(t[5])&&this.uint(t[6])&&this.uint(t[7])&&this.uint(t[8])&&this.uint(t[9]);case 84:return this.string(t[1])&&this.string(t[2])&&this.string(t[3])&&this.uint(t[4])&&this.string(t[5])&&this.string(t[6]);case 85:return this.uint(t[1])&&this.uint(t[2])&&this.uint(t[3])&&this.uint(t[4])&&this.uint(t[5])&&this.uint(t[6])&&this.string(t[7])&&this.string(t[8])&&this.uint(t[9])&&this.boolean(t[10])&&this.uint(t[11])&&this.uint(t[12])&&this.uint(t[13])&&this.uint(t[14])&&this.uint(t[15])&&this.uint(t[16])&&this.uint(t[17]);case 87:return this.string(t[1])&&this.int(t[2])&&this.int(t[3]);case 89:return this.string(t[1])&&this.int(t[2])&&this.int(t[3])&&this.int(t[4])&&this.int(t[5])&&this.string(t[6]);case 112:return this.uint(t[1])&&this.string(t[2])&&this.boolean(t[3])&&this.string(t[4])&&this.int(t[5])&&this.int(t[6]);case 113:return this.uint(t[1])&&this.uint(t[2])&&this.string(t[3]);case 116:return this.uint(t[1])&&this.uint(t[2])&&this.uint(t[3])&&this.uint(t[4])&&this.uint(t[5])&&this.uint(t[6])&&this.string(t[7])&&this.string(t[8])&&this.uint(t[9])&&this.boolean(t[10]);case 119:return this.string(t[1])&&this.uint(t[2]);case 121:return this.string(t[1])&&this.string(t[2])&&this.uint(t[3])&&this.uint(t[4]);case 122:return this.string(t[1])&&this.string(t[2])&&this.uint(t[3])&&this.string(t[4]);case 123:return this.string(t[1])&&this.string(t[2])&&this.string(t[3])&&this.string(t[4])&&this.uint(t[5])}}}class 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.checkpoints=[],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;this.checkpoints.length=0;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.checkpoints.push(s.getCurrentOffset()),this.isEmpty=this.isEmpty&&0===t[0],this.nextIndex++}return e}setBeaconSizeLimit(t){this.beaconSizeLimit=t}writeMessage(t){if(-1===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(t=!1){if(this.isEmpty)return;const s=this.encoder.flush();this.onBatch(s,t),this.prepare()}clean(){this.encoder.reset(),this.checkpoints.length=0}}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,u=null,a=h.NotActive;function o(t){u&&u.finaliseBatch(t)}function c(){return new Promise((t=>{a=h.Stopping,null!==p&&(clearInterval(p),p=null),u&&(u.clean(),u=null),r&&(r.clean(),setTimeout((()=>{r=null}),20)),setTimeout((()=>{a=h.NotActive,t(null)}),100)}))}function g(){[h.Stopped,h.Stopping].includes(a)||(postMessage(\"a_stop\"),c().then((()=>{postMessage(\"a_start\")})))}let l,p=null;self.onmessage=({data:s})=>{if(\"stop\"===s)return o(),void c().then((()=>{a=h.Stopped}));if(\"forceFlushBatch\"!==s)if(\"closing\"!==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?(a=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),u=new n(s.pageNo,s.timestamp,s.url,((t,s)=>{r&&(s?r.sendUncompressed(t):r.push(t))}),s.tabId,(()=>postMessage({type:\"queue_empty\"}))),null===p&&(p=setInterval(o,3e4)),a=h.Active):\"auth\"===s.type?r?u?(r.authorise(s.token),void(s.beaconSizeLimit&&u.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(u){const t=u;s.forEach((s=>{55===s[0]&&(s[1]?l=setTimeout((()=>g()),18e5):clearTimeout(l)),t.writeMessage(s)}))}else postMessage(\"not_init\"),g()}else o(!0);else o()}}();\n";
3758
3936
  const CANCELED = 'canceled';
3759
3937
  const bufferStorageKey = 'or_buffer_1';
3760
3938
  const UnsuccessfulStart = (reason) => ({ reason, success: false });
@@ -3796,6 +3974,9 @@ const proto = {
3796
3974
  reset: 'reset-your-session-please',
3797
3975
  };
3798
3976
  class App {
3977
+ get tagMatcher() {
3978
+ return this.tagWatcher.matcher;
3979
+ }
3799
3980
  constructor(projectKey, sessionToken, options, signalError, insideIframe) {
3800
3981
  this.signalError = signalError;
3801
3982
  this.insideIframe = insideIframe;
@@ -3810,7 +3991,7 @@ class App {
3810
3991
  this.stopCallbacks = [];
3811
3992
  this.commitCallbacks = [];
3812
3993
  this.activityState = ActivityState.NotActive;
3813
- this.version = '17.2.6'; // TODO: version compatability check inside each plugin.
3994
+ this.version = '17.2.8'; // TODO: version compatability check inside each plugin.
3814
3995
  this.socketMode = false;
3815
3996
  this.compressionThreshold = 24 * 1000;
3816
3997
  this.bc = null;
@@ -3838,6 +4019,9 @@ class App {
3838
4019
  if (data.token) {
3839
4020
  this.session.setSessionToken(data.token, this.projectKey);
3840
4021
  }
4022
+ if (data.id !== undefined) {
4023
+ this.rootId = data.id;
4024
+ }
3841
4025
  this.allowAppStart();
3842
4026
  void this.start();
3843
4027
  }
@@ -3981,6 +4165,14 @@ class App {
3981
4165
  const message = { line: nextCommand };
3982
4166
  if (nextCommand === proto.startIframe) {
3983
4167
  message.token = this.session.getSessionToken(this.projectKey);
4168
+ const targetFrame = this.pageFrames.find((f) => f.contentWindow === event.source)
4169
+ || Array.from(document.querySelectorAll('iframe')).find((f) => f.contentWindow === event.source);
4170
+ if (targetFrame) {
4171
+ const nodeId = targetFrame[this.options.node_id];
4172
+ if (nodeId !== undefined) {
4173
+ message.id = nodeId;
4174
+ }
4175
+ }
3984
4176
  }
3985
4177
  // @ts-ignore
3986
4178
  event.source?.postMessage(message, '*');
@@ -5744,6 +5936,18 @@ function Input (app, opts) {
5744
5936
  defaultInputMode: InputMode.Obscured,
5745
5937
  obscureInputDates: false,
5746
5938
  }, opts);
5939
+ const tagSelectorMap = new Map();
5940
+ function getTagSelector(id, node) {
5941
+ const cached = tagSelectorMap.get(id);
5942
+ if (cached !== undefined)
5943
+ return cached;
5944
+ const tagMatch = app.tagMatcher.match(node);
5945
+ if (tagMatch) {
5946
+ tagSelectorMap.set(id, tagMatch.selector);
5947
+ return tagMatch.selector;
5948
+ }
5949
+ return null;
5950
+ }
5747
5951
  function getInputValue(id, node) {
5748
5952
  let value = node.value;
5749
5953
  let inputMode = options.defaultInputMode;
@@ -5779,6 +5983,7 @@ function Input (app, opts) {
5779
5983
  app.attachStopCallback(() => {
5780
5984
  inputValues.clear();
5781
5985
  checkboxValues.clear();
5986
+ tagSelectorMap.clear();
5782
5987
  });
5783
5988
  function trackInputValue(id, node) {
5784
5989
  if (inputValues.get(id) === node.value) {
@@ -5811,7 +6016,7 @@ function Input (app, opts) {
5811
6016
  }, 3);
5812
6017
  function sendInputChange(id, node, hesitationTime, inputTime) {
5813
6018
  const { value, mask } = getInputValue(id, node);
5814
- let label = getInputLabel(node, options.customAttributes);
6019
+ let label = getTagSelector(id, node) || getInputLabel(node, options.customAttributes);
5815
6020
  if (app.sanitizer.privateMode) {
5816
6021
  label = label.replaceAll(/./g, '*');
5817
6022
  }
@@ -5994,7 +6199,13 @@ function Mouse (app, options) {
5994
6199
  };
5995
6200
  const patchDocument = (document, topframe = false) => {
5996
6201
  function getSelector(id, target) {
5997
- return (selectorMap[id] = selectorMap[id] || _getSelector(target));
6202
+ if (selectorMap[id])
6203
+ return selectorMap[id];
6204
+ const tagMatch = app.tagMatcher.match(target);
6205
+ if (tagMatch) {
6206
+ return (selectorMap[id] = tagMatch.selector);
6207
+ }
6208
+ return (selectorMap[id] = _getSelector(target));
5998
6209
  }
5999
6210
  const attachListener = topframe
6000
6211
  ? app.attachEventListener.bind(app) // attached/removed on start/stop
@@ -8672,7 +8883,7 @@ class ConstantProperties {
8672
8883
  user_id: this.user_id,
8673
8884
  distinct_id: this.deviceId,
8674
8885
  sdk_edition: 'web',
8675
- sdk_version: '17.2.6',
8886
+ sdk_version: '17.2.8',
8676
8887
  timezone: getUTCOffsetString(),
8677
8888
  search_engine: this.searchEngine,
8678
8889
  };
@@ -9374,7 +9585,7 @@ class API {
9374
9585
  this.signalStartIssue = (reason, missingApi) => {
9375
9586
  const doNotTrack = this.checkDoNotTrack();
9376
9587
  console.log("Tracker couldn't start due to:", JSON.stringify({
9377
- trackerVersion: '17.2.6',
9588
+ trackerVersion: '17.2.8',
9378
9589
  projectKey: this.options.projectKey,
9379
9590
  doNotTrack,
9380
9591
  reason: missingApi.length ? `missing api: ${missingApi.join(',')}` : reason,