@openreplay/tracker 13.0.0 → 13.0.1

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.
Files changed (77) hide show
  1. package/CHANGELOG.md +5 -0
  2. package/cjs/app/canvas.d.ts +2 -1
  3. package/cjs/app/canvas.js +27 -13
  4. package/cjs/app/index.d.ts +6 -0
  5. package/cjs/app/index.js +23 -4
  6. package/cjs/index.js +1 -1
  7. package/coverage/clover.xml +1054 -964
  8. package/coverage/coverage-final.json +21 -21
  9. package/coverage/lcov-report/index.html +43 -43
  10. package/coverage/lcov-report/main/app/canvas.ts.html +224 -47
  11. package/coverage/lcov-report/main/app/guards.ts.html +26 -26
  12. package/coverage/lcov-report/main/app/index.html +42 -42
  13. package/coverage/lcov-report/main/app/index.ts.html +157 -37
  14. package/coverage/lcov-report/main/app/logger.ts.html +1 -1
  15. package/coverage/lcov-report/main/app/messages.gen.ts.html +244 -154
  16. package/coverage/lcov-report/main/app/nodes.ts.html +7 -4
  17. package/coverage/lcov-report/main/app/observer/iframe_observer.ts.html +1 -1
  18. package/coverage/lcov-report/main/app/observer/iframe_offsets.ts.html +1 -1
  19. package/coverage/lcov-report/main/app/observer/index.html +5 -5
  20. package/coverage/lcov-report/main/app/observer/shadow_root_observer.ts.html +1 -1
  21. package/coverage/lcov-report/main/app/observer/top_observer.ts.html +7 -4
  22. package/coverage/lcov-report/main/app/sanitizer.ts.html +2 -2
  23. package/coverage/lcov-report/main/app/session.ts.html +2 -2
  24. package/coverage/lcov-report/main/app/ticker.ts.html +1 -1
  25. package/coverage/lcov-report/main/index.html +13 -13
  26. package/coverage/lcov-report/main/index.ts.html +32 -14
  27. package/coverage/lcov-report/main/modules/Network/beaconProxy.ts.html +17 -8
  28. package/coverage/lcov-report/main/modules/Network/fetchProxy.ts.html +40 -13
  29. package/coverage/lcov-report/main/modules/Network/index.html +21 -21
  30. package/coverage/lcov-report/main/modules/Network/index.ts.html +2 -2
  31. package/coverage/lcov-report/main/modules/Network/networkMessage.ts.html +12 -6
  32. package/coverage/lcov-report/main/modules/Network/utils.ts.html +17 -8
  33. package/coverage/lcov-report/main/modules/Network/xhrProxy.ts.html +39 -12
  34. package/coverage/lcov-report/main/modules/attributeSender.ts.html +1 -1
  35. package/coverage/lcov-report/main/modules/axiosSpy.ts.html +1 -1
  36. package/coverage/lcov-report/main/modules/conditionsManager.ts.html +4 -22
  37. package/coverage/lcov-report/main/modules/connection.ts.html +1 -1
  38. package/coverage/lcov-report/main/modules/console.ts.html +1 -1
  39. package/coverage/lcov-report/main/modules/constructedStyleSheets.ts.html +3 -3
  40. package/coverage/lcov-report/main/modules/cssrules.ts.html +1 -1
  41. package/coverage/lcov-report/main/modules/exception.ts.html +1 -1
  42. package/coverage/lcov-report/main/modules/featureFlags.ts.html +1 -1
  43. package/coverage/lcov-report/main/modules/focus.ts.html +1 -1
  44. package/coverage/lcov-report/main/modules/fonts.ts.html +1 -1
  45. package/coverage/lcov-report/main/modules/img.ts.html +4 -4
  46. package/coverage/lcov-report/main/modules/index.html +24 -24
  47. package/coverage/lcov-report/main/modules/input.ts.html +1 -1
  48. package/coverage/lcov-report/main/modules/mouse.ts.html +1 -1
  49. package/coverage/lcov-report/main/modules/network.ts.html +2 -2
  50. package/coverage/lcov-report/main/modules/performance.ts.html +1 -1
  51. package/coverage/lcov-report/main/modules/scroll.ts.html +1 -1
  52. package/coverage/lcov-report/main/modules/selection.ts.html +1 -1
  53. package/coverage/lcov-report/main/modules/tabs.ts.html +1 -1
  54. package/coverage/lcov-report/main/modules/tagWatcher.ts.html +95 -92
  55. package/coverage/lcov-report/main/modules/timing.ts.html +1 -1
  56. package/coverage/lcov-report/main/modules/userTesting/SignalManager.ts.html +1 -1
  57. package/coverage/lcov-report/main/modules/userTesting/dnd.ts.html +1 -1
  58. package/coverage/lcov-report/main/modules/userTesting/index.html +1 -1
  59. package/coverage/lcov-report/main/modules/userTesting/index.ts.html +1 -1
  60. package/coverage/lcov-report/main/modules/userTesting/recorder.ts.html +1 -1
  61. package/coverage/lcov-report/main/modules/userTesting/styles.ts.html +1 -1
  62. package/coverage/lcov-report/main/modules/userTesting/utils.ts.html +1 -1
  63. package/coverage/lcov-report/main/modules/viewport.ts.html +4 -4
  64. package/coverage/lcov-report/main/utils.ts.html +181 -31
  65. package/coverage/lcov-report/webworker/BatchWriter.ts.html +1 -1
  66. package/coverage/lcov-report/webworker/MessageEncoder.gen.ts.html +31 -7
  67. package/coverage/lcov-report/webworker/PrimitiveEncoder.ts.html +1 -1
  68. package/coverage/lcov-report/webworker/QueueSender.ts.html +48 -18
  69. package/coverage/lcov-report/webworker/index.html +14 -14
  70. package/coverage/lcov-report/webworker/index.ts.html +51 -21
  71. package/coverage/lcov.info +1882 -1653
  72. package/lib/app/canvas.d.ts +2 -1
  73. package/lib/app/canvas.js +27 -13
  74. package/lib/app/index.d.ts +6 -0
  75. package/lib/app/index.js +23 -4
  76. package/lib/index.js +1 -1
  77. package/package.json +1 -1
@@ -4,6 +4,7 @@ interface Options {
4
4
  quality: 'low' | 'medium' | 'high';
5
5
  isDebug?: boolean;
6
6
  fixedScaling?: boolean;
7
+ useAnimationFrame?: boolean;
7
8
  }
8
9
  declare class CanvasRecorder {
9
10
  private readonly app;
@@ -17,7 +18,7 @@ declare class CanvasRecorder {
17
18
  captureCanvas: (node: Node) => void;
18
19
  recordCanvas: (node: Node, id: number) => void;
19
20
  sendSnaps(images: {
20
- data: string;
21
+ data: Blob;
21
22
  id: number;
22
23
  }[], canvasId: number, createdAt: number): void;
23
24
  clear(): void;
package/lib/app/canvas.js CHANGED
@@ -56,6 +56,17 @@ class CanvasRecorder {
56
56
  };
57
57
  const canvasMsg = CanvasNode(id.toString(), ts);
58
58
  this.app.send(canvasMsg);
59
+ const captureFn = (canvas) => {
60
+ captureSnapshot(canvas, this.options.quality, this.snapshots[id].dummy, this.options.fixedScaling, (blob) => {
61
+ if (!blob)
62
+ return;
63
+ this.snapshots[id].images.push({ id: this.app.timestamp(), data: blob });
64
+ if (this.snapshots[id].images.length > 9) {
65
+ this.sendSnaps(this.snapshots[id].images, id, this.snapshots[id].createdAt);
66
+ this.snapshots[id].images = [];
67
+ }
68
+ });
69
+ };
59
70
  const int = setInterval(() => {
60
71
  const cid = this.app.nodes.getID(node);
61
72
  const canvas = cid ? this.app.nodes.getNode(cid) : undefined;
@@ -65,11 +76,13 @@ class CanvasRecorder {
65
76
  }
66
77
  else {
67
78
  if (!this.snapshots[id].paused) {
68
- const snapshot = captureSnapshot(canvas, this.options.quality, this.snapshots[id].dummy, this.options.fixedScaling);
69
- this.snapshots[id].images.push({ id: this.app.timestamp(), data: snapshot });
70
- if (this.snapshots[id].images.length > 9) {
71
- this.sendSnaps(this.snapshots[id].images, id, this.snapshots[id].createdAt);
72
- this.snapshots[id].images = [];
79
+ if (this.options.useAnimationFrame) {
80
+ requestAnimationFrame(() => {
81
+ captureFn(canvas);
82
+ });
83
+ }
84
+ else {
85
+ captureFn(canvas);
73
86
  }
74
87
  }
75
88
  }
@@ -92,12 +105,12 @@ class CanvasRecorder {
92
105
  }
93
106
  const formData = new FormData();
94
107
  images.forEach((snapshot) => {
95
- const blob = dataUrlToBlob(snapshot.data);
108
+ const blob = snapshot.data;
96
109
  if (!blob)
97
110
  return;
98
- formData.append('snapshot', blob[0], `${createdAt}_${canvasId}_${snapshot.id}.jpeg`);
111
+ formData.append('snapshot', blob, `${createdAt}_${canvasId}_${snapshot.id}.webp`);
99
112
  if (this.options.isDebug) {
100
- saveImageData(snapshot.data, `${createdAt}_${canvasId}_${snapshot.id}.jpeg`);
113
+ saveImageData(blob, `${createdAt}_${canvasId}_${snapshot.id}.webp`);
101
114
  }
102
115
  });
103
116
  fetch(this.app.options.ingestPoint + '/v1/web/images', {
@@ -124,8 +137,8 @@ const qualityInt = {
124
137
  medium: 0.55,
125
138
  high: 0.8,
126
139
  };
127
- function captureSnapshot(canvas, quality = 'medium', dummy, fixedScaling = false) {
128
- const imageFormat = 'image/jpeg'; // or /png'
140
+ function captureSnapshot(canvas, quality = 'medium', dummy, fixedScaling = false, onBlob) {
141
+ const imageFormat = 'image/webp';
129
142
  if (fixedScaling) {
130
143
  const canvasScaleRatio = window.devicePixelRatio || 1;
131
144
  dummy.width = canvas.width / canvasScaleRatio;
@@ -135,10 +148,10 @@ function captureSnapshot(canvas, quality = 'medium', dummy, fixedScaling = false
135
148
  return '';
136
149
  }
137
150
  ctx.drawImage(canvas, 0, 0, dummy.width, dummy.height);
138
- return dummy.toDataURL(imageFormat, qualityInt[quality]);
151
+ dummy.toBlob(onBlob, imageFormat, qualityInt[quality]);
139
152
  }
140
153
  else {
141
- return canvas.toDataURL(imageFormat, qualityInt[quality]);
154
+ canvas.toBlob(onBlob, imageFormat, qualityInt[quality]);
142
155
  }
143
156
  }
144
157
  function dataUrlToBlob(dataUrl) {
@@ -157,7 +170,8 @@ function dataUrlToBlob(dataUrl) {
157
170
  }
158
171
  return [new Blob([u8arr], { type: mime }), u8arr];
159
172
  }
160
- function saveImageData(imageDataUrl, name) {
173
+ function saveImageData(imageDataBlob, name) {
174
+ const imageDataUrl = URL.createObjectURL(imageDataBlob);
161
175
  const link = document.createElement('a');
162
176
  link.href = imageDataUrl;
163
177
  link.download = name;
@@ -58,6 +58,12 @@ type AppOptions = {
58
58
  disableStringDict?: boolean;
59
59
  assistSocketHost?: string;
60
60
  disableCanvas?: boolean;
61
+ canvas: {
62
+ disableCanvas?: boolean;
63
+ fixedCanvasScaling?: boolean;
64
+ __save_canvas_locally?: boolean;
65
+ useAnimationFrame?: boolean;
66
+ };
61
67
  /** @deprecated */
62
68
  onStart?: StartCallback;
63
69
  network?: NetworkOptions;
package/lib/app/index.js CHANGED
@@ -51,7 +51,7 @@ export default class App {
51
51
  this.stopCallbacks = [];
52
52
  this.commitCallbacks = [];
53
53
  this.activityState = ActivityState.NotActive;
54
- this.version = '13.0.0'; // TODO: version compatability check inside each plugin.
54
+ this.version = '13.0.1'; // TODO: version compatability check inside each plugin.
55
55
  this.socketMode = false;
56
56
  this.compressionThreshold = 24 * 1000;
57
57
  this.restartAttempts = 0;
@@ -89,6 +89,18 @@ export default class App {
89
89
  });
90
90
  };
91
91
  this.onUxtCb = [];
92
+ if (Object.keys(options).findIndex((k) => ['fixedCanvasScaling', 'disableCanvas'].includes(k)) !==
93
+ -1) {
94
+ console.warn('Openreplay: canvas options are moving to separate key "canvas" in next update. Please update your configuration.');
95
+ options = {
96
+ ...options,
97
+ canvas: {
98
+ __save_canvas_locally: options.__save_canvas_locally,
99
+ fixedCanvasScaling: options.fixedCanvasScaling,
100
+ disableCanvas: options.disableCanvas,
101
+ },
102
+ };
103
+ }
92
104
  this.contextId = Math.random().toString(36).slice(2);
93
105
  this.projectKey = projectKey;
94
106
  this.networkOptions = options.network;
@@ -114,6 +126,12 @@ export default class App {
114
126
  fixedCanvasScaling: false,
115
127
  disableCanvas: false,
116
128
  assistOnly: false,
129
+ canvas: {
130
+ disableCanvas: false,
131
+ fixedCanvasScaling: false,
132
+ __save_canvas_locally: false,
133
+ useAnimationFrame: false,
134
+ },
117
135
  }, options);
118
136
  if (!this.options.forceSingleTab && globalThis && 'BroadcastChannel' in globalThis) {
119
137
  const host = location.hostname.split('.').slice(-2).join('_');
@@ -858,14 +876,15 @@ export default class App {
858
876
  void this.featureFlags.reloadFlags();
859
877
  await this.tagWatcher.fetchTags(this.options.ingestPoint, token);
860
878
  this.activityState = ActivityState.Active;
861
- if (canvasEnabled && !this.options.disableCanvas) {
879
+ if (canvasEnabled && !this.options.canvas.disableCanvas) {
862
880
  this.canvasRecorder =
863
881
  this.canvasRecorder ??
864
882
  new CanvasRecorder(this, {
865
883
  fps: canvasFPS,
866
884
  quality: canvasQuality,
867
- isDebug: this.options.__save_canvas_locally,
868
- fixedScaling: this.options.fixedCanvasScaling,
885
+ isDebug: this.options.canvas.__save_canvas_locally,
886
+ fixedScaling: this.options.canvas.fixedCanvasScaling,
887
+ useAnimationFrame: this.options.canvas.useAnimationFrame,
869
888
  });
870
889
  this.canvasRecorder.startTracking();
871
890
  }
package/lib/index.js CHANGED
@@ -66,7 +66,7 @@ export default class API {
66
66
  const orig = this.options.ingestPoint || DEFAULT_INGEST_POINT;
67
67
  req.open('POST', orig + '/v1/web/not-started');
68
68
  req.send(JSON.stringify({
69
- trackerVersion: '13.0.0',
69
+ trackerVersion: '13.0.1',
70
70
  projectKey: this.options.projectKey,
71
71
  doNotTrack,
72
72
  reason: missingApi.length ? `missing api: ${missingApi.join(',')}` : reason,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@openreplay/tracker",
3
3
  "description": "The OpenReplay tracker main package",
4
- "version": "13.0.0",
4
+ "version": "13.0.1",
5
5
  "keywords": [
6
6
  "logging",
7
7
  "replay"