@openreplay/tracker 11.0.4 → 11.0.5

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 (83) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/cjs/app/canvas.d.ts +3 -0
  3. package/cjs/app/canvas.js +19 -7
  4. package/cjs/app/index.d.ts +2 -0
  5. package/cjs/app/index.js +15 -6
  6. package/cjs/app/nodes.d.ts +1 -0
  7. package/cjs/app/nodes.js +3 -0
  8. package/cjs/index.d.ts +1 -0
  9. package/cjs/index.js +7 -1
  10. package/coverage/clover.xml +890 -527
  11. package/coverage/coverage-final.json +10 -9
  12. package/coverage/lcov-report/index.html +30 -30
  13. package/coverage/lcov-report/main/app/canvas.ts.html +21 -6
  14. package/coverage/lcov-report/main/app/guards.ts.html +1 -1
  15. package/coverage/lcov-report/main/app/index.html +13 -13
  16. package/coverage/lcov-report/main/app/index.ts.html +1236 -114
  17. package/coverage/lcov-report/main/app/logger.ts.html +25 -91
  18. package/coverage/lcov-report/main/app/messages.gen.ts.html +1 -1
  19. package/coverage/lcov-report/main/app/nodes.ts.html +1 -1
  20. package/coverage/lcov-report/main/app/observer/iframe_observer.ts.html +1 -1
  21. package/coverage/lcov-report/main/app/observer/iframe_offsets.ts.html +1 -1
  22. package/coverage/lcov-report/main/app/observer/index.html +1 -1
  23. package/coverage/lcov-report/main/app/observer/shadow_root_observer.ts.html +1 -1
  24. package/coverage/lcov-report/main/app/observer/top_observer.ts.html +1 -1
  25. package/coverage/lcov-report/main/app/sanitizer.ts.html +1 -1
  26. package/coverage/lcov-report/main/app/session.ts.html +1 -1
  27. package/coverage/lcov-report/main/app/ticker.ts.html +1 -1
  28. package/coverage/lcov-report/main/index.html +9 -9
  29. package/coverage/lcov-report/main/index.ts.html +376 -100
  30. package/coverage/lcov-report/main/modules/Network/beaconProxy.ts.html +1 -1
  31. package/coverage/lcov-report/main/modules/Network/fetchProxy.ts.html +1 -1
  32. package/coverage/lcov-report/main/modules/Network/index.html +1 -1
  33. package/coverage/lcov-report/main/modules/Network/index.ts.html +1 -1
  34. package/coverage/lcov-report/main/modules/Network/networkMessage.ts.html +1 -1
  35. package/coverage/lcov-report/main/modules/Network/utils.ts.html +1 -1
  36. package/coverage/lcov-report/main/modules/Network/xhrProxy.ts.html +1 -1
  37. package/coverage/lcov-report/main/modules/attributeSender.ts.html +1 -1
  38. package/coverage/lcov-report/main/modules/axiosSpy.ts.html +1 -1
  39. package/coverage/lcov-report/main/modules/conditionsManager.ts.html +112 -67
  40. package/coverage/lcov-report/main/modules/connection.ts.html +1 -1
  41. package/coverage/lcov-report/main/modules/console.ts.html +1 -1
  42. package/coverage/lcov-report/main/modules/constructedStyleSheets.ts.html +1 -1
  43. package/coverage/lcov-report/main/modules/cssrules.ts.html +1 -1
  44. package/coverage/lcov-report/main/modules/exception.ts.html +1 -1
  45. package/coverage/lcov-report/main/modules/featureFlags.ts.html +10 -7
  46. package/coverage/lcov-report/main/modules/focus.ts.html +1 -1
  47. package/coverage/lcov-report/main/modules/fonts.ts.html +1 -1
  48. package/coverage/lcov-report/main/modules/img.ts.html +1 -1
  49. package/coverage/lcov-report/main/modules/index.html +37 -22
  50. package/coverage/lcov-report/main/modules/input.ts.html +1 -1
  51. package/coverage/lcov-report/main/modules/mouse.ts.html +1 -1
  52. package/coverage/lcov-report/main/modules/network.ts.html +1 -1
  53. package/coverage/lcov-report/main/modules/performance.ts.html +1 -1
  54. package/coverage/lcov-report/main/modules/scroll.ts.html +1 -1
  55. package/coverage/lcov-report/main/modules/selection.ts.html +1 -1
  56. package/coverage/lcov-report/main/modules/tabs.ts.html +1 -1
  57. package/coverage/lcov-report/main/modules/tagWatcher.ts.html +72 -15
  58. package/coverage/lcov-report/main/modules/timing.ts.html +1 -1
  59. package/coverage/lcov-report/main/modules/userTesting/SignalManager.ts.html +1 -1
  60. package/coverage/lcov-report/main/modules/userTesting/dnd.ts.html +1 -1
  61. package/coverage/lcov-report/main/modules/userTesting/index.html +1 -1
  62. package/coverage/lcov-report/main/modules/userTesting/index.ts.html +1 -1
  63. package/coverage/lcov-report/main/modules/userTesting/recorder.ts.html +1 -1
  64. package/coverage/lcov-report/main/modules/userTesting/styles.ts.html +1 -1
  65. package/coverage/lcov-report/main/modules/userTesting/utils.ts.html +1 -1
  66. package/coverage/lcov-report/main/modules/viewport.ts.html +1 -1
  67. package/coverage/lcov-report/main/utils.ts.html +1 -1
  68. package/coverage/lcov-report/webworker/BatchWriter.ts.html +23 -5
  69. package/coverage/lcov-report/webworker/MessageEncoder.gen.ts.html +1 -1
  70. package/coverage/lcov-report/webworker/PrimitiveEncoder.ts.html +1 -1
  71. package/coverage/lcov-report/webworker/QueueSender.ts.html +18 -6
  72. package/coverage/lcov-report/webworker/index.html +13 -13
  73. package/coverage/lcov-report/webworker/index.ts.html +17 -8
  74. package/coverage/lcov.info +1629 -942
  75. package/lib/app/canvas.d.ts +3 -0
  76. package/lib/app/canvas.js +19 -7
  77. package/lib/app/index.d.ts +2 -0
  78. package/lib/app/index.js +15 -6
  79. package/lib/app/nodes.d.ts +1 -0
  80. package/lib/app/nodes.js +3 -0
  81. package/lib/index.d.ts +1 -0
  82. package/lib/index.js +7 -1
  83. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -1,3 +1,12 @@
1
+ # 11.0.5
2
+
3
+ - add method to restart canvas tracking (in case of context recreation)
4
+ - scan dom tree for canvas els on tracker start
5
+
6
+ # 11.0.4
7
+
8
+ - some additional security for canvas capture (check if canvas el itself is obscured/ignored)
9
+
1
10
  # 11.0.3
2
11
 
3
12
  - move all logs under internal debugger
@@ -2,6 +2,7 @@ import App from '../app/index.js';
2
2
  interface Options {
3
3
  fps: number;
4
4
  quality: 'low' | 'medium' | 'high';
5
+ isDebug?: boolean;
5
6
  }
6
7
  declare class CanvasRecorder {
7
8
  private readonly app;
@@ -11,6 +12,8 @@ declare class CanvasRecorder {
11
12
  private readonly interval;
12
13
  constructor(app: App, options: Options);
13
14
  startTracking(): void;
15
+ restartTracking: () => void;
16
+ handleCanvasEl: (node: Node) => void;
14
17
  sendSnaps(images: {
15
18
  data: string;
16
19
  id: number;
package/cjs/app/canvas.js CHANGED
@@ -8,12 +8,13 @@ class CanvasRecorder {
8
8
  this.options = options;
9
9
  this.snapshots = {};
10
10
  this.intervals = [];
11
- this.interval = 1000 / options.fps;
12
- }
13
- startTracking() {
14
- this.app.nodes.attachNodeCallback((node) => {
11
+ this.restartTracking = () => {
12
+ this.clear();
13
+ this.app.nodes.scanTree(this.handleCanvasEl);
14
+ };
15
+ this.handleCanvasEl = (node) => {
15
16
  const id = this.app.nodes.getID(node);
16
- if (!id) {
17
+ if (!id || !(0, guards_js_1.hasTag)(node, 'canvas')) {
17
18
  return;
18
19
  }
19
20
  const isIgnored = this.app.sanitizer.isObscured(id) || this.app.sanitizer.isHidden(id);
@@ -44,7 +45,16 @@ class CanvasRecorder {
44
45
  }
45
46
  }, this.interval);
46
47
  this.intervals.push(int);
47
- });
48
+ };
49
+ this.interval = 1000 / options.fps;
50
+ }
51
+ startTracking() {
52
+ setTimeout(() => {
53
+ this.app.nodes.scanTree(this.handleCanvasEl);
54
+ this.app.nodes.attachNodeCallback((node) => {
55
+ this.handleCanvasEl(node);
56
+ });
57
+ }, 500);
48
58
  }
49
59
  sendSnaps(images, canvasId, createdAt) {
50
60
  var _a;
@@ -55,7 +65,9 @@ class CanvasRecorder {
55
65
  images.forEach((snapshot) => {
56
66
  const blob = dataUrlToBlob(snapshot.data)[0];
57
67
  formData.append('snapshot', blob, `${createdAt}_${canvasId}_${snapshot.id}.jpeg`);
58
- // saveImageData(snapshot.data, `${createdAt}_${canvasId}_${snapshot.id}.jpeg`)
68
+ if (this.options.isDebug) {
69
+ saveImageData(snapshot.data, `${createdAt}_${canvasId}_${snapshot.id}.jpeg`);
70
+ }
59
71
  });
60
72
  fetch(this.app.options.ingestPoint + '/v1/web/images', {
61
73
  method: 'POST',
@@ -50,6 +50,7 @@ type AppOptions = {
50
50
  __is_snippet: boolean;
51
51
  __debug_report_edp: string | null;
52
52
  __debug__?: LoggerOptions;
53
+ __save_canvas_locally?: boolean;
53
54
  localStorage: Storage | null;
54
55
  sessionStorage: Storage | null;
55
56
  forceSingleTab?: boolean;
@@ -127,6 +128,7 @@ export default class App {
127
128
  active(): boolean;
128
129
  resetNextPageSession(flag: boolean): void;
129
130
  private _start;
131
+ restartCanvasTracking: () => void;
130
132
  onUxtCb: never[];
131
133
  addOnUxtCb(cb: (id: number) => void): void;
132
134
  getUxtId(): number | null;
package/cjs/app/index.js CHANGED
@@ -42,13 +42,17 @@ class App {
42
42
  this.stopCallbacks = [];
43
43
  this.commitCallbacks = [];
44
44
  this.activityState = ActivityState.NotActive;
45
- this.version = '11.0.4'; // TODO: version compatability check inside each plugin.
45
+ this.version = '11.0.5'; // TODO: version compatability check inside each plugin.
46
46
  this.compressionThreshold = 24 * 1000;
47
47
  this.restartAttempts = 0;
48
48
  this.bc = null;
49
49
  this.canvasRecorder = null;
50
50
  this._usingOldFetchPlugin = false;
51
51
  this.delay = 0;
52
+ this.restartCanvasTracking = () => {
53
+ var _a;
54
+ (_a = this.canvasRecorder) === null || _a === void 0 ? void 0 : _a.restartTracking();
55
+ };
52
56
  this.onUxtCb = [];
53
57
  // if (options.onStart !== undefined) {
54
58
  // deprecationWarn("'onStart' option", "tracker.start().then(/* handle session info */)")
@@ -69,6 +73,7 @@ class App {
69
73
  verbose: false,
70
74
  __is_snippet: false,
71
75
  __debug_report_edp: null,
76
+ __save_canvas_locally: false,
72
77
  localStorage: null,
73
78
  sessionStorage: null,
74
79
  disableStringDict: false,
@@ -498,15 +503,19 @@ class App {
498
503
  });
499
504
  this.compressionThreshold = compressionThreshold;
500
505
  const onStartInfo = { sessionToken: token, userUUID, sessionID };
501
- // TODO: start as early as possible (before receiving the token)
502
- this.startCallbacks.forEach((cb) => cb(onStartInfo)); // MBTODO: callbacks after DOM "mounted" (observed)
503
- this.observer.observe();
504
- this.ticker.start();
505
506
  if (canvasEnabled) {
506
507
  this.canvasRecorder =
507
- (_a = this.canvasRecorder) !== null && _a !== void 0 ? _a : new canvas_js_1.default(this, { fps: canvasFPS, quality: canvasQuality });
508
+ (_a = this.canvasRecorder) !== null && _a !== void 0 ? _a : new canvas_js_1.default(this, {
509
+ fps: canvasFPS,
510
+ quality: canvasQuality,
511
+ isDebug: this.options.__save_canvas_locally,
512
+ });
508
513
  this.canvasRecorder.startTracking();
509
514
  }
515
+ // TODO: start as early as possible (before receiving the token)
516
+ this.startCallbacks.forEach((cb) => cb(onStartInfo)); // MBTODO: callbacks after DOM "mounted" (observed)
517
+ this.observer.observe();
518
+ this.ticker.start();
510
519
  this.activityState = ActivityState.Active;
511
520
  this.notify.log('OpenReplay tracking started.');
512
521
  // get rid of onStart ?
@@ -7,6 +7,7 @@ export default class Nodes {
7
7
  private readonly elementListeners;
8
8
  constructor(node_id: string);
9
9
  attachNodeCallback(nodeCallback: NodeCallback): void;
10
+ scanTree: (cb: (node: Node | void) => void) => void;
10
11
  attachNodeListener(node: Node, type: string, listener: EventListener, useCapture?: boolean): void;
11
12
  registerNode(node: Node): [/*id:*/ number, /*isNew:*/ boolean];
12
13
  unregisterNode(node: Node): number | undefined;
package/cjs/app/nodes.js CHANGED
@@ -8,6 +8,9 @@ class Nodes {
8
8
  this.totalNodeAmount = 0;
9
9
  this.nodeCallbacks = [];
10
10
  this.elementListeners = new Map();
11
+ this.scanTree = (cb) => {
12
+ this.nodes.forEach((node) => cb(node));
13
+ };
11
14
  }
12
15
  // Attached once per Tracker instance
13
16
  attachNodeCallback(nodeCallback) {
package/cjs/index.d.ts CHANGED
@@ -39,6 +39,7 @@ export default class API {
39
39
  reloadFlags(): Promise<void>;
40
40
  getFeatureFlag(flagName: string): IFeatureFlag | undefined;
41
41
  getAllFeatureFlags(): IFeatureFlag[];
42
+ restartCanvasTracking: () => void;
42
43
  use<T>(fn: (app: App | null, options?: Options) => T): T;
43
44
  isActive(): boolean;
44
45
  start(startOpts?: Partial<StartOptions>): Promise<StartPromiseReturn>;
package/cjs/index.js CHANGED
@@ -60,6 +60,12 @@ class API {
60
60
  constructor(options) {
61
61
  this.options = options;
62
62
  this.app = null;
63
+ this.restartCanvasTracking = () => {
64
+ if (this.app === null) {
65
+ return;
66
+ }
67
+ this.app.restartCanvasTracking();
68
+ };
63
69
  this.handleError = (e, metadata = {}) => {
64
70
  if (this.app === null) {
65
71
  return;
@@ -162,7 +168,7 @@ class API {
162
168
  // no-cors issue only with text/plain or not-set Content-Type
163
169
  // req.setRequestHeader("Content-Type", "application/json;charset=UTF-8");
164
170
  req.send(JSON.stringify({
165
- trackerVersion: '11.0.4',
171
+ trackerVersion: '11.0.5',
166
172
  projectKey: options.projectKey,
167
173
  doNotTrack,
168
174
  // TODO: add precise reason (an exact API missing)