@openreplay/tracker 11.0.3 → 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 +23 -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 +840 -739
  11. package/coverage/coverage-final.json +13 -12
  12. package/coverage/lcov-report/index.html +33 -33
  13. package/coverage/lcov-report/main/app/canvas.ts.html +23 -14
  14. package/coverage/lcov-report/main/app/guards.ts.html +1 -1
  15. package/coverage/lcov-report/main/app/index.html +16 -16
  16. package/coverage/lcov-report/main/app/index.ts.html +478 -82
  17. package/coverage/lcov-report/main/app/logger.ts.html +25 -91
  18. package/coverage/lcov-report/main/app/messages.gen.ts.html +62 -5
  19. package/coverage/lcov-report/main/app/nodes.ts.html +1 -1
  20. package/coverage/lcov-report/main/app/observer/iframe_observer.ts.html +2 -2
  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 +2 -2
  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 +182 -11
  30. package/coverage/lcov-report/main/modules/Network/beaconProxy.ts.html +1 -1
  31. package/coverage/lcov-report/main/modules/Network/fetchProxy.ts.html +21 -6
  32. package/coverage/lcov-report/main/modules/Network/index.html +6 -6
  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 +3 -3
  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 +1 -1
  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 +34 -19
  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 +307 -0
  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 +17 -5
  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 +19 -19
  73. package/coverage/lcov-report/webworker/index.ts.html +15 -12
  74. package/coverage/lcov.info +1576 -1355
  75. package/lib/app/canvas.d.ts +3 -0
  76. package/lib/app/canvas.js +23 -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
@@ -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/lib/app/canvas.js CHANGED
@@ -6,12 +6,17 @@ class CanvasRecorder {
6
6
  this.options = options;
7
7
  this.snapshots = {};
8
8
  this.intervals = [];
9
- this.interval = 1000 / options.fps;
10
- }
11
- startTracking() {
12
- this.app.nodes.attachNodeCallback((node) => {
9
+ this.restartTracking = () => {
10
+ this.clear();
11
+ this.app.nodes.scanTree(this.handleCanvasEl);
12
+ };
13
+ this.handleCanvasEl = (node) => {
13
14
  const id = this.app.nodes.getID(node);
14
- if (!id || !hasTag(node, 'canvas') || this.snapshots[id]) {
15
+ if (!id || !hasTag(node, 'canvas')) {
16
+ return;
17
+ }
18
+ const isIgnored = this.app.sanitizer.isObscured(id) || this.app.sanitizer.isHidden(id);
19
+ if (isIgnored || !hasTag(node, 'canvas') || this.snapshots[id]) {
15
20
  return;
16
21
  }
17
22
  const ts = this.app.timestamp();
@@ -38,7 +43,16 @@ class CanvasRecorder {
38
43
  }
39
44
  }, this.interval);
40
45
  this.intervals.push(int);
41
- });
46
+ };
47
+ this.interval = 1000 / options.fps;
48
+ }
49
+ startTracking() {
50
+ setTimeout(() => {
51
+ this.app.nodes.scanTree(this.handleCanvasEl);
52
+ this.app.nodes.attachNodeCallback((node) => {
53
+ this.handleCanvasEl(node);
54
+ });
55
+ }, 500);
42
56
  }
43
57
  sendSnaps(images, canvasId, createdAt) {
44
58
  var _a;
@@ -49,7 +63,9 @@ class CanvasRecorder {
49
63
  images.forEach((snapshot) => {
50
64
  const blob = dataUrlToBlob(snapshot.data)[0];
51
65
  formData.append('snapshot', blob, `${createdAt}_${canvasId}_${snapshot.id}.jpeg`);
52
- // saveImageData(snapshot.data, `${createdAt}_${canvasId}_${snapshot.id}.jpeg`)
66
+ if (this.options.isDebug) {
67
+ saveImageData(snapshot.data, `${createdAt}_${canvasId}_${snapshot.id}.jpeg`);
68
+ }
53
69
  });
54
70
  fetch(this.app.options.ingestPoint + '/v1/web/images', {
55
71
  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/lib/app/index.js CHANGED
@@ -39,13 +39,17 @@ export default class App {
39
39
  this.stopCallbacks = [];
40
40
  this.commitCallbacks = [];
41
41
  this.activityState = ActivityState.NotActive;
42
- this.version = '11.0.3'; // TODO: version compatability check inside each plugin.
42
+ this.version = '11.0.5'; // TODO: version compatability check inside each plugin.
43
43
  this.compressionThreshold = 24 * 1000;
44
44
  this.restartAttempts = 0;
45
45
  this.bc = null;
46
46
  this.canvasRecorder = null;
47
47
  this._usingOldFetchPlugin = false;
48
48
  this.delay = 0;
49
+ this.restartCanvasTracking = () => {
50
+ var _a;
51
+ (_a = this.canvasRecorder) === null || _a === void 0 ? void 0 : _a.restartTracking();
52
+ };
49
53
  this.onUxtCb = [];
50
54
  // if (options.onStart !== undefined) {
51
55
  // deprecationWarn("'onStart' option", "tracker.start().then(/* handle session info */)")
@@ -66,6 +70,7 @@ export default class App {
66
70
  verbose: false,
67
71
  __is_snippet: false,
68
72
  __debug_report_edp: null,
73
+ __save_canvas_locally: false,
69
74
  localStorage: null,
70
75
  sessionStorage: null,
71
76
  disableStringDict: false,
@@ -495,15 +500,19 @@ export default class App {
495
500
  });
496
501
  this.compressionThreshold = compressionThreshold;
497
502
  const onStartInfo = { sessionToken: token, userUUID, sessionID };
498
- // TODO: start as early as possible (before receiving the token)
499
- this.startCallbacks.forEach((cb) => cb(onStartInfo)); // MBTODO: callbacks after DOM "mounted" (observed)
500
- this.observer.observe();
501
- this.ticker.start();
502
503
  if (canvasEnabled) {
503
504
  this.canvasRecorder =
504
- (_a = this.canvasRecorder) !== null && _a !== void 0 ? _a : new CanvasRecorder(this, { fps: canvasFPS, quality: canvasQuality });
505
+ (_a = this.canvasRecorder) !== null && _a !== void 0 ? _a : new CanvasRecorder(this, {
506
+ fps: canvasFPS,
507
+ quality: canvasQuality,
508
+ isDebug: this.options.__save_canvas_locally,
509
+ });
505
510
  this.canvasRecorder.startTracking();
506
511
  }
512
+ // TODO: start as early as possible (before receiving the token)
513
+ this.startCallbacks.forEach((cb) => cb(onStartInfo)); // MBTODO: callbacks after DOM "mounted" (observed)
514
+ this.observer.observe();
515
+ this.ticker.start();
507
516
  this.activityState = ActivityState.Active;
508
517
  this.notify.log('OpenReplay tracking started.');
509
518
  // 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/lib/app/nodes.js CHANGED
@@ -6,6 +6,9 @@ export default class Nodes {
6
6
  this.totalNodeAmount = 0;
7
7
  this.nodeCallbacks = [];
8
8
  this.elementListeners = new Map();
9
+ this.scanTree = (cb) => {
10
+ this.nodes.forEach((node) => cb(node));
11
+ };
9
12
  }
10
13
  // Attached once per Tracker instance
11
14
  attachNodeCallback(nodeCallback) {
package/lib/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/lib/index.js CHANGED
@@ -55,6 +55,12 @@ export default class API {
55
55
  constructor(options) {
56
56
  this.options = options;
57
57
  this.app = null;
58
+ this.restartCanvasTracking = () => {
59
+ if (this.app === null) {
60
+ return;
61
+ }
62
+ this.app.restartCanvasTracking();
63
+ };
58
64
  this.handleError = (e, metadata = {}) => {
59
65
  if (this.app === null) {
60
66
  return;
@@ -157,7 +163,7 @@ export default class API {
157
163
  // no-cors issue only with text/plain or not-set Content-Type
158
164
  // req.setRequestHeader("Content-Type", "application/json;charset=UTF-8");
159
165
  req.send(JSON.stringify({
160
- trackerVersion: '11.0.3',
166
+ trackerVersion: '11.0.5',
161
167
  projectKey: options.projectKey,
162
168
  doNotTrack,
163
169
  // TODO: add precise reason (an exact API missing)
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": "11.0.3",
4
+ "version": "11.0.5",
5
5
  "keywords": [
6
6
  "logging",
7
7
  "replay"