@openreplay/tracker 17.1.4 → 17.1.6

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.
@@ -12,8 +12,14 @@ declare class CanvasRecorder {
12
12
  private readonly options;
13
13
  private snapshots;
14
14
  private readonly intervals;
15
+ private readonly observers;
15
16
  private readonly interval;
16
17
  private readonly fileExt;
18
+ private uploadQueue;
19
+ private readonly MAX_CONCURRENT_UPLOADS;
20
+ private readonly MAX_QUEUE_SIZE;
21
+ private readonly pendingBatches;
22
+ private isProcessingQueue;
17
23
  constructor(app: App, options: Options);
18
24
  startTracking(): void;
19
25
  restartTracking: () => void;
@@ -23,6 +29,9 @@ declare class CanvasRecorder {
23
29
  data: Blob;
24
30
  id: number;
25
31
  }[], canvasId: number, createdAt: number): void;
32
+ private processUploadQueue;
33
+ private uploadBatch;
34
+ private cleanupCanvas;
26
35
  clear(): void;
27
36
  }
28
37
  export default CanvasRecorder;
@@ -28,9 +28,6 @@ export declare function Metadata(key: string, value: string): Messages.Metadata;
28
28
  export declare function StringDictGlobal(key: number, value: string): Messages.StringDictGlobal;
29
29
  export declare function SetNodeAttributeDictGlobal(id: number, name: number, value: number): Messages.SetNodeAttributeDictGlobal;
30
30
  export declare function NodeAnimationResult(id: number, styles: string): Messages.NodeAnimationResult;
31
- export declare function CSSInsertRule(id: number, rule: string, index: number): Messages.CSSInsertRule;
32
- export declare function CSSDeleteRule(id: number, index: number): Messages.CSSDeleteRule;
33
- export declare function Fetch(method: string, url: string, request: string, response: string, status: number, timestamp: number, duration: number): Messages.Fetch;
34
31
  export declare function Profiler(name: string, duration: number, args: string, result: string): Messages.Profiler;
35
32
  export declare function OTable(key: string, value: string): Messages.OTable;
36
33
  export declare function StateAction(type: string): Messages.StateAction;
@@ -49,13 +46,11 @@ export declare function ConnectionInformation(downlink: number, type: string): M
49
46
  export declare function SetPageVisibility(hidden: boolean): Messages.SetPageVisibility;
50
47
  export declare function LoadFontFace(parentID: number, family: string, source: string, descriptors: string): Messages.LoadFontFace;
51
48
  export declare function SetNodeFocus(id: number): Messages.SetNodeFocus;
52
- export declare function LongTask(timestamp: number, duration: number, context: number, containerType: number, containerSrc: string, containerId: string, containerName: string): Messages.LongTask;
53
49
  export declare function SetNodeAttributeURLBased(id: number, name: string, value: string, baseURL: string): Messages.SetNodeAttributeURLBased;
54
50
  export declare function SetCSSDataURLBased(id: number, data: string, baseURL: string): Messages.SetCSSDataURLBased;
55
51
  export declare function TechnicalInfo(type: string, value: string): Messages.TechnicalInfo;
56
52
  export declare function CustomIssue(name: string, payload: string): Messages.CustomIssue;
57
53
  export declare function SetNodeSlot(id: number, slotID: number): Messages.SetNodeSlot;
58
- export declare function CSSInsertRuleURLBased(id: number, rule: string, index: number, baseURL: string): Messages.CSSInsertRuleURLBased;
59
54
  export declare function MouseClick(id: number, hesitationTime: number, label: string, selector: string, normalizedX: number, normalizedY: number): Messages.MouseClick;
60
55
  export declare function MouseClickDeprecated(id: number, hesitationTime: number, label: string, selector: string): Messages.MouseClickDeprecated;
61
56
  export declare function CreateIFrameDocument(frameID: number, id: number): Messages.CreateIFrameDocument;
@@ -17,6 +17,7 @@ declare class TrackerSingleton {
17
17
  * */
18
18
  stop(): string | undefined;
19
19
  setUserID(id: string): void;
20
+ get analytics(): import("./entry.js").Analytics | null;
20
21
  identify: (id: string) => void;
21
22
  track: (eventName: string, properties?: Record<string, any>, options?: {
22
23
  send_immediately: boolean;
@@ -27,9 +27,6 @@ export declare const enum Type {
27
27
  StringDictGlobal = 34,
28
28
  SetNodeAttributeDictGlobal = 35,
29
29
  NodeAnimationResult = 36,
30
- CSSInsertRule = 37,
31
- CSSDeleteRule = 38,
32
- Fetch = 39,
33
30
  Profiler = 40,
34
31
  OTable = 41,
35
32
  StateAction = 42,
@@ -48,13 +45,11 @@ export declare const enum Type {
48
45
  SetPageVisibility = 55,
49
46
  LoadFontFace = 57,
50
47
  SetNodeFocus = 58,
51
- LongTask = 59,
52
48
  SetNodeAttributeURLBased = 60,
53
49
  SetCSSDataURLBased = 61,
54
50
  TechnicalInfo = 63,
55
51
  CustomIssue = 64,
56
52
  SetNodeSlot = 65,
57
- CSSInsertRuleURLBased = 67,
58
53
  MouseClick = 68,
59
54
  MouseClickDeprecated = 69,
60
55
  CreateIFrameDocument = 70,
@@ -244,27 +239,6 @@ export type NodeAnimationResult = [
244
239
  number,
245
240
  string
246
241
  ];
247
- export type CSSInsertRule = [
248
- Type.CSSInsertRule,
249
- number,
250
- string,
251
- number
252
- ];
253
- export type CSSDeleteRule = [
254
- Type.CSSDeleteRule,
255
- number,
256
- number
257
- ];
258
- export type Fetch = [
259
- Type.Fetch,
260
- string,
261
- string,
262
- string,
263
- string,
264
- number,
265
- number,
266
- number
267
- ];
268
242
  export type Profiler = [
269
243
  Type.Profiler,
270
244
  string,
@@ -371,16 +345,6 @@ export type SetNodeFocus = [
371
345
  Type.SetNodeFocus,
372
346
  number
373
347
  ];
374
- export type LongTask = [
375
- Type.LongTask,
376
- number,
377
- number,
378
- number,
379
- number,
380
- string,
381
- string,
382
- string
383
- ];
384
348
  export type SetNodeAttributeURLBased = [
385
349
  Type.SetNodeAttributeURLBased,
386
350
  number,
@@ -409,13 +373,6 @@ export type SetNodeSlot = [
409
373
  number,
410
374
  number
411
375
  ];
412
- export type CSSInsertRuleURLBased = [
413
- Type.CSSInsertRuleURLBased,
414
- number,
415
- string,
416
- number,
417
- string
418
- ];
419
376
  export type MouseClick = [
420
377
  Type.MouseClick,
421
378
  number,
@@ -626,5 +583,5 @@ export type WebVitals = [
626
583
  string,
627
584
  string
628
585
  ];
629
- 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 | CSSInsertRule | CSSDeleteRule | Fetch | Profiler | OTable | StateAction | ReduxDeprecated | Vuex | MobX | NgRx | GraphQLDeprecated | PerformanceTrack | StringDictDeprecated | SetNodeAttributeDictDeprecated | StringDict | SetNodeAttributeDict | ResourceTimingDeprecatedDeprecated | ConnectionInformation | SetPageVisibility | LoadFontFace | SetNodeFocus | LongTask | SetNodeAttributeURLBased | SetCSSDataURLBased | TechnicalInfo | CustomIssue | SetNodeSlot | CSSInsertRuleURLBased | 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;
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;
630
587
  export default Message;
package/dist/lib/entry.js CHANGED
@@ -1131,7 +1131,7 @@ const stars = 'repeat' in String.prototype
1131
1131
  ? (str) => '*'.repeat(str.length)
1132
1132
  : (str) => str.replace(/./g, '*');
1133
1133
  function normSpaces(str) {
1134
- return str.trim().replace(/\s+/g, ' ');
1134
+ return str ? str.trim().replace(/\s+/g, ' ') : '';
1135
1135
  }
1136
1136
  // isAbsoluteUrl regexp: /^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(url)
1137
1137
  function isURL(s) {
@@ -1632,33 +1632,6 @@ function NodeAnimationResult(id, styles) {
1632
1632
  styles,
1633
1633
  ];
1634
1634
  }
1635
- function CSSInsertRule(id, rule, index) {
1636
- return [
1637
- 37 /* Messages.Type.CSSInsertRule */,
1638
- id,
1639
- rule,
1640
- index,
1641
- ];
1642
- }
1643
- function CSSDeleteRule(id, index) {
1644
- return [
1645
- 38 /* Messages.Type.CSSDeleteRule */,
1646
- id,
1647
- index,
1648
- ];
1649
- }
1650
- function Fetch(method, url, request, response, status, timestamp, duration) {
1651
- return [
1652
- 39 /* Messages.Type.Fetch */,
1653
- method,
1654
- url,
1655
- request,
1656
- response,
1657
- status,
1658
- timestamp,
1659
- duration,
1660
- ];
1661
- }
1662
1635
  function Profiler(name, duration, args, result) {
1663
1636
  return [
1664
1637
  40 /* Messages.Type.Profiler */,
@@ -1801,18 +1774,6 @@ function SetNodeFocus(id) {
1801
1774
  id,
1802
1775
  ];
1803
1776
  }
1804
- function LongTask(timestamp, duration, context, containerType, containerSrc, containerId, containerName) {
1805
- return [
1806
- 59 /* Messages.Type.LongTask */,
1807
- timestamp,
1808
- duration,
1809
- context,
1810
- containerType,
1811
- containerSrc,
1812
- containerId,
1813
- containerName,
1814
- ];
1815
- }
1816
1777
  function SetNodeAttributeURLBased(id, name, value, baseURL) {
1817
1778
  return [
1818
1779
  60 /* Messages.Type.SetNodeAttributeURLBased */,
@@ -1851,15 +1812,6 @@ function SetNodeSlot(id, slotID) {
1851
1812
  slotID,
1852
1813
  ];
1853
1814
  }
1854
- function CSSInsertRuleURLBased(id, rule, index, baseURL) {
1855
- return [
1856
- 67 /* Messages.Type.CSSInsertRuleURLBased */,
1857
- id,
1858
- rule,
1859
- index,
1860
- baseURL,
1861
- ];
1862
- }
1863
1815
  function MouseClick(id, hesitationTime, label, selector, normalizedX, normalizedY) {
1864
1816
  return [
1865
1817
  68 /* Messages.Type.MouseClick */,
@@ -2139,9 +2091,6 @@ var _Messages = /*#__PURE__*/Object.freeze({
2139
2091
  AdoptedSSRemoveOwner: AdoptedSSRemoveOwner,
2140
2092
  AdoptedSSReplaceURLBased: AdoptedSSReplaceURLBased,
2141
2093
  BatchMetadata: BatchMetadata,
2142
- CSSDeleteRule: CSSDeleteRule,
2143
- CSSInsertRule: CSSInsertRule,
2144
- CSSInsertRuleURLBased: CSSInsertRuleURLBased,
2145
2094
  CanvasNode: CanvasNode,
2146
2095
  ConnectionInformation: ConnectionInformation,
2147
2096
  ConsoleLog: ConsoleLog,
@@ -2151,7 +2100,6 @@ var _Messages = /*#__PURE__*/Object.freeze({
2151
2100
  CreateTextNode: CreateTextNode,
2152
2101
  CustomEvent: CustomEvent,
2153
2102
  CustomIssue: CustomIssue,
2154
- Fetch: Fetch,
2155
2103
  GraphQL: GraphQL,
2156
2104
  GraphQLDeprecated: GraphQLDeprecated,
2157
2105
  Incident: Incident,
@@ -2159,7 +2107,6 @@ var _Messages = /*#__PURE__*/Object.freeze({
2159
2107
  JSException: JSException,
2160
2108
  LoadFontFace: LoadFontFace,
2161
2109
  LongAnimationTask: LongAnimationTask$1,
2162
- LongTask: LongTask,
2163
2110
  Metadata: Metadata,
2164
2111
  MobX: MobX,
2165
2112
  MouseClick: MouseClick,
@@ -2381,7 +2328,13 @@ class CanvasRecorder {
2381
2328
  this.app = app;
2382
2329
  this.options = options;
2383
2330
  this.snapshots = {};
2384
- this.intervals = [];
2331
+ this.intervals = new Map();
2332
+ this.observers = new Map();
2333
+ this.uploadQueue = 0;
2334
+ this.MAX_CONCURRENT_UPLOADS = 2;
2335
+ this.MAX_QUEUE_SIZE = 50; // ~500 images max (50 batches × 10 images)
2336
+ this.pendingBatches = [];
2337
+ this.isProcessingQueue = false;
2385
2338
  this.restartTracking = () => {
2386
2339
  this.clear();
2387
2340
  this.app.nodes.scanTree(this.captureCanvas);
@@ -2392,34 +2345,33 @@ class CanvasRecorder {
2392
2345
  return;
2393
2346
  }
2394
2347
  const isIgnored = this.app.sanitizer.isObscured(id) || this.app.sanitizer.isHidden(id);
2395
- if (isIgnored || !hasTag(node, 'canvas') || this.snapshots[id]) {
2348
+ if (isIgnored || this.snapshots[id]) {
2396
2349
  return;
2397
2350
  }
2398
2351
  const observer = new IntersectionObserver((entries) => {
2399
2352
  entries.forEach((entry) => {
2400
2353
  if (entry.isIntersecting) {
2401
- if (entry.target) {
2402
- if (this.snapshots[id] && this.snapshots[id].createdAt) {
2403
- this.snapshots[id].paused = false;
2404
- }
2405
- else {
2406
- this.recordCanvas(entry.target, id);
2407
- }
2408
- /**
2409
- * We can switch this to start observing when element is in the view
2410
- * but otherwise right now we're just pausing when it's not
2411
- * just to save some bandwidth and space on backend
2412
- * */
2413
- // observer.unobserve(entry.target)
2354
+ if (this.snapshots[id] && this.snapshots[id].createdAt) {
2355
+ this.snapshots[id].paused = false;
2414
2356
  }
2415
2357
  else {
2416
- if (this.snapshots[id]) {
2417
- this.snapshots[id].paused = true;
2418
- }
2358
+ this.recordCanvas(entry.target, id);
2359
+ }
2360
+ /**
2361
+ * We can switch this to start observing when element is in the view
2362
+ * but otherwise right now we're just pausing when it's not
2363
+ * just to save some bandwidth and space on backend
2364
+ * */
2365
+ // observer.unobserve(entry.target)
2366
+ }
2367
+ else {
2368
+ if (this.snapshots[id]) {
2369
+ this.snapshots[id].paused = true;
2419
2370
  }
2420
2371
  }
2421
2372
  });
2422
2373
  });
2374
+ this.observers.set(id, observer);
2423
2375
  observer.observe(node);
2424
2376
  };
2425
2377
  this.recordCanvas = (node, id) => {
@@ -2429,15 +2381,23 @@ class CanvasRecorder {
2429
2381
  createdAt: ts,
2430
2382
  paused: false,
2431
2383
  dummy: document.createElement('canvas'),
2384
+ isCapturing: false,
2385
+ isStopped: false,
2432
2386
  };
2433
2387
  const canvasMsg = CanvasNode(id.toString(), ts);
2434
2388
  this.app.send(canvasMsg);
2389
+ const cachedCanvas = node;
2435
2390
  const captureFn = (canvas) => {
2391
+ if (!this.snapshots[id] || this.snapshots[id].isCapturing || this.snapshots[id].isStopped) {
2392
+ return;
2393
+ }
2394
+ this.snapshots[id].isCapturing = true;
2436
2395
  captureSnapshot(canvas, this.options.quality, this.snapshots[id].dummy, this.options.fixedScaling, this.fileExt, (blob) => {
2437
- if (!blob)
2396
+ if (this.snapshots[id]) {
2397
+ this.snapshots[id].isCapturing = false;
2398
+ }
2399
+ if (!blob || !this.snapshots[id] || this.snapshots[id].isStopped) {
2438
2400
  return;
2439
- if (!this.snapshots[id]) {
2440
- return this.app.debug.warn('Canvas not present in snapshots after capture:', this.snapshots, id);
2441
2401
  }
2442
2402
  this.snapshots[id].images.push({ id: this.app.timestamp(), data: blob });
2443
2403
  if (this.snapshots[id].images.length > 9) {
@@ -2447,32 +2407,29 @@ class CanvasRecorder {
2447
2407
  });
2448
2408
  };
2449
2409
  const int = setInterval(() => {
2450
- const cid = this.app.nodes.getID(node);
2451
- const canvas = cid ? this.app.nodes.getNode(cid) : undefined;
2452
- if (!this.snapshots[id]) {
2410
+ const snapshot = this.snapshots[id];
2411
+ if (!snapshot || snapshot.isStopped) {
2453
2412
  this.app.debug.log('Canvas is not present in {snapshots}');
2454
- clearInterval(int);
2413
+ this.cleanupCanvas(id);
2455
2414
  return;
2456
2415
  }
2457
- if (!canvas || !hasTag(canvas, 'canvas') || canvas !== node) {
2458
- this.app.debug.log('Canvas element not in sync', canvas, node);
2459
- clearInterval(int);
2416
+ if (!document.contains(cachedCanvas)) {
2417
+ this.app.debug.log('Canvas element not in sync', cachedCanvas, node);
2418
+ this.cleanupCanvas(id);
2460
2419
  return;
2461
2420
  }
2462
- else {
2463
- if (!this.snapshots[id].paused) {
2464
- if (this.options.useAnimationFrame) {
2465
- requestAnimationFrame(() => {
2466
- captureFn(canvas);
2467
- });
2468
- }
2469
- else {
2470
- captureFn(canvas);
2471
- }
2421
+ if (!snapshot.paused) {
2422
+ if (this.options.useAnimationFrame) {
2423
+ requestAnimationFrame(() => {
2424
+ captureFn(cachedCanvas);
2425
+ });
2426
+ }
2427
+ else {
2428
+ captureFn(cachedCanvas);
2472
2429
  }
2473
2430
  }
2474
2431
  }, this.interval);
2475
- this.intervals.push(int);
2432
+ this.intervals.set(id, int);
2476
2433
  };
2477
2434
  this.fileExt = options.fileExt ?? 'webp';
2478
2435
  this.interval = 1000 / options.fps;
@@ -2487,6 +2444,30 @@ class CanvasRecorder {
2487
2444
  if (Object.keys(this.snapshots).length === 0) {
2488
2445
  return;
2489
2446
  }
2447
+ if (this.pendingBatches.length >= this.MAX_QUEUE_SIZE) {
2448
+ this.app.debug.warn('Upload queue full, dropping canvas batch');
2449
+ return;
2450
+ }
2451
+ this.pendingBatches.push({ images, canvasId, createdAt });
2452
+ if (!this.isProcessingQueue) {
2453
+ this.processUploadQueue();
2454
+ }
2455
+ }
2456
+ async processUploadQueue() {
2457
+ this.isProcessingQueue = true;
2458
+ while (this.pendingBatches.length > 0) {
2459
+ if (this.uploadQueue >= this.MAX_CONCURRENT_UPLOADS) {
2460
+ await new Promise((resolve) => setTimeout(resolve, 100));
2461
+ continue;
2462
+ }
2463
+ const batch = this.pendingBatches.shift();
2464
+ if (!batch)
2465
+ break;
2466
+ this.uploadBatch(batch.images, batch.canvasId, batch.createdAt);
2467
+ }
2468
+ this.isProcessingQueue = false;
2469
+ }
2470
+ uploadBatch(images, canvasId, createdAt) {
2490
2471
  const formData = new FormData();
2491
2472
  images.forEach((snapshot) => {
2492
2473
  const blob = snapshot.data;
@@ -2504,6 +2485,7 @@ class CanvasRecorder {
2504
2485
  void this.app.start({}, true);
2505
2486
  }, 250);
2506
2487
  };
2488
+ this.uploadQueue++;
2507
2489
  fetch(this.app.options.ingestPoint + '/v1/web/images', {
2508
2490
  method: 'POST',
2509
2491
  headers: {
@@ -2519,10 +2501,50 @@ class CanvasRecorder {
2519
2501
  })
2520
2502
  .catch((e) => {
2521
2503
  this.app.debug.error('error saving canvas', e);
2504
+ })
2505
+ .finally(() => {
2506
+ this.uploadQueue--;
2522
2507
  });
2523
2508
  }
2509
+ cleanupCanvas(id) {
2510
+ if (this.snapshots[id]) {
2511
+ this.snapshots[id].isStopped = true;
2512
+ }
2513
+ const interval = this.intervals.get(id);
2514
+ if (interval) {
2515
+ clearInterval(interval);
2516
+ this.intervals.delete(id);
2517
+ }
2518
+ const observer = this.observers.get(id);
2519
+ if (observer) {
2520
+ observer.disconnect();
2521
+ this.observers.delete(id);
2522
+ }
2523
+ if (this.snapshots[id]?.dummy) {
2524
+ const dummy = this.snapshots[id].dummy;
2525
+ dummy.width = 0;
2526
+ dummy.height = 0;
2527
+ }
2528
+ delete this.snapshots[id];
2529
+ }
2524
2530
  clear() {
2525
- this.intervals.forEach((int) => clearInterval(int));
2531
+ // Flush remaining images before cleanup
2532
+ Object.keys(this.snapshots).forEach((idStr) => {
2533
+ const id = parseInt(idStr, 10);
2534
+ const snapshot = this.snapshots[id];
2535
+ if (snapshot && snapshot.images.length > 0) {
2536
+ this.sendSnaps(snapshot.images, id, snapshot.createdAt);
2537
+ snapshot.images = [];
2538
+ }
2539
+ });
2540
+ Object.keys(this.snapshots).forEach((idStr) => {
2541
+ const id = parseInt(idStr, 10);
2542
+ this.cleanupCanvas(id);
2543
+ });
2544
+ // don't clear pendingBatches or stop queue processing
2545
+ // to allow flushed images to finish uploading in the background
2546
+ this.intervals.clear();
2547
+ this.observers.clear();
2526
2548
  this.snapshots = {};
2527
2549
  }
2528
2550
  }
@@ -4342,7 +4364,7 @@ class Ticker {
4342
4364
  * this value is injected during build time via rollup
4343
4365
  * */
4344
4366
  // @ts-ignore
4345
- 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 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 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 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";
4367
+ 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";
4346
4368
  const CANCELED = 'canceled';
4347
4369
  const bufferStorageKey = 'or_buffer_1';
4348
4370
  const UnsuccessfulStart = (reason) => ({ reason, success: false });
@@ -4398,7 +4420,7 @@ class App {
4398
4420
  this.stopCallbacks = [];
4399
4421
  this.commitCallbacks = [];
4400
4422
  this.activityState = ActivityState.NotActive;
4401
- this.version = '17.1.4'; // TODO: version compatability check inside each plugin.
4423
+ this.version = '17.1.6'; // TODO: version compatability check inside each plugin.
4402
4424
  this.socketMode = false;
4403
4425
  this.compressionThreshold = 24 * 1000;
4404
4426
  this.bc = null;
@@ -8822,6 +8844,8 @@ function webAnimations(app, options = {}) {
8822
8844
  handled.add(anim);
8823
8845
  anim.addEventListener('finish', () => {
8824
8846
  const lastKF = anim.effect.getKeyframes().at(-1);
8847
+ if (!lastKF)
8848
+ return;
8825
8849
  const computedStyle = getComputedStyle(el);
8826
8850
  const keys = Object.keys(lastKF).filter((p) => !toIgnore.includes(p));
8827
8851
  // @ts-ignore
@@ -9233,7 +9257,7 @@ class ConstantProperties {
9233
9257
  user_id: this.user_id,
9234
9258
  distinct_id: this.deviceId,
9235
9259
  sdk_edition: 'web',
9236
- sdk_version: '17.1.4',
9260
+ sdk_version: '17.1.6',
9237
9261
  timezone: getUTCOffsetString(),
9238
9262
  search_engine: this.searchEngine,
9239
9263
  };
@@ -9877,7 +9901,7 @@ class API {
9877
9901
  this.signalStartIssue = (reason, missingApi) => {
9878
9902
  const doNotTrack = this.checkDoNotTrack();
9879
9903
  console.log("Tracker couldn't start due to:", JSON.stringify({
9880
- trackerVersion: '17.1.4',
9904
+ trackerVersion: '17.1.6',
9881
9905
  projectKey: this.options.projectKey,
9882
9906
  doNotTrack,
9883
9907
  reason: missingApi.length ? `missing api: ${missingApi.join(',')}` : reason,
@@ -10336,6 +10360,15 @@ class TrackerSingleton {
10336
10360
  }
10337
10361
  this.instance.setUserID(id);
10338
10362
  }
10363
+ get analytics() {
10364
+ if (this.instance?.analytics) {
10365
+ return this.instance.analytics;
10366
+ }
10367
+ else {
10368
+ return null;
10369
+ }
10370
+ }
10371
+ ;
10339
10372
  /**
10340
10373
  * Set metadata for the current session
10341
10374
  *