@openreplay/tracker 3.6.3 → 3.6.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.
Files changed (95) hide show
  1. package/.eslintignore +8 -0
  2. package/cjs/app/guards.js +1 -2
  3. package/cjs/app/index.d.ts +15 -13
  4. package/cjs/app/index.js +58 -42
  5. package/cjs/app/logger.js +6 -3
  6. package/cjs/app/observer/iframe_observer.d.ts +1 -1
  7. package/cjs/app/observer/iframe_observer.js +1 -1
  8. package/cjs/app/observer/observer.d.ts +2 -3
  9. package/cjs/app/observer/observer.js +38 -40
  10. package/cjs/app/observer/shadow_root_observer.d.ts +1 -1
  11. package/cjs/app/observer/shadow_root_observer.js +1 -1
  12. package/cjs/app/observer/top_observer.d.ts +2 -2
  13. package/cjs/app/observer/top_observer.js +12 -11
  14. package/cjs/app/sanitizer.d.ts +1 -1
  15. package/cjs/app/sanitizer.js +5 -5
  16. package/cjs/app/session.d.ts +14 -2
  17. package/cjs/app/session.js +19 -6
  18. package/cjs/app/ticker.d.ts +1 -1
  19. package/cjs/common/messages.d.ts +1 -1
  20. package/cjs/common/messages.js +69 -120
  21. package/cjs/common/webworker.d.ts +3 -3
  22. package/cjs/index.d.ts +9 -8
  23. package/cjs/index.js +34 -28
  24. package/cjs/modules/connection.d.ts +1 -1
  25. package/cjs/modules/console.d.ts +1 -1
  26. package/cjs/modules/console.js +5 -5
  27. package/cjs/modules/cssrules.d.ts +1 -1
  28. package/cjs/modules/cssrules.js +3 -3
  29. package/cjs/modules/exception.d.ts +2 -2
  30. package/cjs/modules/exception.js +7 -6
  31. package/cjs/modules/img.d.ts +1 -1
  32. package/cjs/modules/img.js +15 -12
  33. package/cjs/modules/input.d.ts +1 -1
  34. package/cjs/modules/input.js +15 -15
  35. package/cjs/modules/longtasks.d.ts +1 -1
  36. package/cjs/modules/longtasks.js +13 -5
  37. package/cjs/modules/mouse.d.ts +1 -1
  38. package/cjs/modules/mouse.js +10 -12
  39. package/cjs/modules/performance.d.ts +1 -1
  40. package/cjs/modules/scroll.d.ts +1 -1
  41. package/cjs/modules/timing.d.ts +1 -1
  42. package/cjs/modules/timing.js +12 -24
  43. package/cjs/modules/viewport.d.ts +1 -1
  44. package/cjs/utils.js +7 -7
  45. package/cjs/vendors/finder/finder.js +53 -48
  46. package/lib/app/guards.js +1 -2
  47. package/lib/app/index.d.ts +15 -13
  48. package/lib/app/index.js +67 -51
  49. package/lib/app/logger.js +6 -3
  50. package/lib/app/observer/iframe_observer.d.ts +1 -1
  51. package/lib/app/observer/iframe_observer.js +3 -3
  52. package/lib/app/observer/observer.d.ts +2 -3
  53. package/lib/app/observer/observer.js +40 -42
  54. package/lib/app/observer/shadow_root_observer.d.ts +1 -1
  55. package/lib/app/observer/shadow_root_observer.js +3 -3
  56. package/lib/app/observer/top_observer.d.ts +2 -2
  57. package/lib/app/observer/top_observer.js +17 -16
  58. package/lib/app/sanitizer.d.ts +1 -1
  59. package/lib/app/sanitizer.js +7 -7
  60. package/lib/app/session.d.ts +14 -2
  61. package/lib/app/session.js +19 -6
  62. package/lib/app/ticker.d.ts +1 -1
  63. package/lib/common/messages.d.ts +1 -1
  64. package/lib/common/messages.js +69 -120
  65. package/lib/common/tsconfig.tsbuildinfo +1 -1
  66. package/lib/common/webworker.d.ts +3 -3
  67. package/lib/index.d.ts +9 -8
  68. package/lib/index.js +49 -43
  69. package/lib/modules/connection.d.ts +1 -1
  70. package/lib/modules/connection.js +1 -1
  71. package/lib/modules/console.d.ts +1 -1
  72. package/lib/modules/console.js +8 -8
  73. package/lib/modules/cssrules.d.ts +1 -1
  74. package/lib/modules/cssrules.js +5 -5
  75. package/lib/modules/exception.d.ts +2 -2
  76. package/lib/modules/exception.js +8 -7
  77. package/lib/modules/img.d.ts +1 -1
  78. package/lib/modules/img.js +18 -15
  79. package/lib/modules/input.d.ts +1 -1
  80. package/lib/modules/input.js +18 -18
  81. package/lib/modules/longtasks.d.ts +1 -1
  82. package/lib/modules/longtasks.js +14 -6
  83. package/lib/modules/mouse.d.ts +1 -1
  84. package/lib/modules/mouse.js +14 -16
  85. package/lib/modules/performance.d.ts +1 -1
  86. package/lib/modules/performance.js +2 -2
  87. package/lib/modules/scroll.d.ts +1 -1
  88. package/lib/modules/scroll.js +2 -2
  89. package/lib/modules/timing.d.ts +1 -1
  90. package/lib/modules/timing.js +15 -27
  91. package/lib/modules/viewport.d.ts +1 -1
  92. package/lib/modules/viewport.js +1 -1
  93. package/lib/utils.js +7 -7
  94. package/lib/vendors/finder/finder.js +53 -48
  95. package/package.json +28 -10
@@ -1,8 +1,8 @@
1
- import Observer from "./observer.js";
2
- import { isElementNode, hasTag, } from "../guards.js";
3
- import IFrameObserver from "./iframe_observer.js";
4
- import ShadowRootObserver from "./shadow_root_observer.js";
5
- import { CreateDocument } from "../../common/messages.js";
1
+ import Observer from './observer.js';
2
+ import { isElementNode, hasTag } from '../guards.js';
3
+ import IFrameObserver from './iframe_observer.js';
4
+ import ShadowRootObserver from './shadow_root_observer.js';
5
+ import { CreateDocument } from '../../common/messages.js';
6
6
  import { IN_BROWSER, hasOpenreplayAttribute } from '../../utils.js';
7
7
  const attachShadowNativeFn = IN_BROWSER ? Element.prototype.attachShadow : () => new ShadowRoot();
8
8
  export default class TopObserver extends Observer {
@@ -11,18 +11,18 @@ export default class TopObserver extends Observer {
11
11
  this.iframeObservers = [];
12
12
  this.shadowRootObservers = [];
13
13
  this.options = Object.assign({
14
- captureIFrames: true
14
+ captureIFrames: true,
15
15
  }, options);
16
16
  // IFrames
17
- this.app.nodes.attachNodeCallback(node => {
18
- if (hasTag(node, "IFRAME") &&
19
- ((this.options.captureIFrames && !hasOpenreplayAttribute(node, "obscured"))
20
- || hasOpenreplayAttribute(node, "capture"))) {
17
+ this.app.nodes.attachNodeCallback((node) => {
18
+ if (hasTag(node, 'IFRAME') &&
19
+ ((this.options.captureIFrames && !hasOpenreplayAttribute(node, 'obscured')) ||
20
+ hasOpenreplayAttribute(node, 'capture'))) {
21
21
  this.handleIframe(node);
22
22
  }
23
23
  });
24
24
  // ShadowDOM
25
- this.app.nodes.attachNodeCallback(node => {
25
+ this.app.nodes.attachNodeCallback((node) => {
26
26
  if (isElementNode(node) && node.shadowRoot !== null) {
27
27
  this.handleShadowRoot(node.shadowRoot);
28
28
  }
@@ -46,7 +46,7 @@ export default class TopObserver extends Observer {
46
46
  this.iframeObservers.push(observer);
47
47
  observer.observe(iframe);
48
48
  });
49
- iframe.addEventListener("load", handle); // why app.attachEventListener not working?
49
+ iframe.addEventListener('load', handle); // why app.attachEventListener not working?
50
50
  handle();
51
51
  }
52
52
  handleShadowRoot(shRoot) {
@@ -58,14 +58,15 @@ export default class TopObserver extends Observer {
58
58
  // Protection from several subsequent calls?
59
59
  const observer = this;
60
60
  Element.prototype.attachShadow = function () {
61
+ // eslint-disable-next-line
61
62
  const shadow = attachShadowNativeFn.apply(this, arguments);
62
63
  observer.handleShadowRoot(shadow);
63
64
  return shadow;
64
65
  };
65
66
  // Can observe documentElement (<html>) here, because it is not supposed to be changing.
66
67
  // However, it is possible in some exotic cases and may cause an ignorance of the newly created <html>
67
- // In this case context.document have to be observed, but this will cause
68
- // the change in the re-player behaviour caused by CreateDocument message:
68
+ // In this case context.document have to be observed, but this will cause
69
+ // the change in the re-player behaviour caused by CreateDocument message:
69
70
  // the 0-node ("fRoot") will become #document rather than documentElement as it is now.
70
71
  // Alternatively - observe(#document) then bindNode(documentElement)
71
72
  this.observeRoot(window.document, () => {
@@ -74,9 +75,9 @@ export default class TopObserver extends Observer {
74
75
  }
75
76
  disconnect() {
76
77
  Element.prototype.attachShadow = attachShadowNativeFn;
77
- this.iframeObservers.forEach(o => o.disconnect());
78
+ this.iframeObservers.forEach((o) => o.disconnect());
78
79
  this.iframeObservers = [];
79
- this.shadowRootObservers.forEach(o => o.disconnect());
80
+ this.shadowRootObservers.forEach((o) => o.disconnect());
80
81
  this.shadowRootObservers = [];
81
82
  super.disconnect();
82
83
  }
@@ -1,4 +1,4 @@
1
- import type App from "./index.js";
1
+ import type App from './index.js';
2
2
  export interface Options {
3
3
  obscureTextEmails: boolean;
4
4
  obscureTextNumbers: boolean;
@@ -1,5 +1,5 @@
1
- import { stars, hasOpenreplayAttribute } from "../utils.js";
2
- import { isElementNode } from "./guards.js";
1
+ import { stars, hasOpenreplayAttribute } from '../utils.js';
2
+ import { isElementNode } from './guards.js';
3
3
  export default class Sanitizer {
4
4
  constructor(app, options) {
5
5
  this.app = app;
@@ -12,20 +12,20 @@ export default class Sanitizer {
12
12
  }
13
13
  handleNode(id, parentID, node) {
14
14
  if (this.masked.has(parentID) ||
15
- (isElementNode(node) &&
16
- hasOpenreplayAttribute(node, 'masked'))) {
15
+ (isElementNode(node) && hasOpenreplayAttribute(node, 'masked'))) {
17
16
  this.masked.add(id);
18
17
  }
19
18
  if (this.maskedContainers.has(parentID) ||
20
- (isElementNode(node) &&
21
- hasOpenreplayAttribute(node, 'htmlmasked'))) {
19
+ (isElementNode(node) && hasOpenreplayAttribute(node, 'htmlmasked'))) {
22
20
  this.maskedContainers.add(id);
23
21
  }
24
22
  }
25
23
  sanitize(id, data) {
26
24
  if (this.masked.has(id)) {
27
25
  // TODO: is it the best place to put trim() ? Might trimmed spaces be considered in layout in certain cases?
28
- return data.trim().replace(/[^\f\n\r\t\v\u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff]/g, '█');
26
+ return data
27
+ .trim()
28
+ .replace(/[^\f\n\r\t\v\u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff]/g, '█');
29
29
  }
30
30
  if (this.options.obscureTextNumbers) {
31
31
  data = data.replace(/\d/g, '0');
@@ -1,14 +1,26 @@
1
+ import type App from './index.js';
1
2
  interface SessionInfo {
2
- sessionID: string | null;
3
+ sessionID: string | undefined;
3
4
  metadata: Record<string, string>;
4
5
  userID: string | null;
6
+ timestamp: number;
7
+ projectID?: string;
5
8
  }
6
9
  declare type OnUpdateCallback = (i: Partial<SessionInfo>) => void;
10
+ export declare type Options = {
11
+ session_token_key: string;
12
+ session_pageno_key: string;
13
+ };
7
14
  export default class Session {
15
+ private readonly app;
16
+ private readonly options;
8
17
  private metadata;
9
18
  private userID;
10
19
  private sessionID;
11
- private callbacks;
20
+ private readonly callbacks;
21
+ private timestamp;
22
+ private projectID;
23
+ constructor(app: App, options: Options);
12
24
  attachUpdateCallback(cb: OnUpdateCallback): void;
13
25
  private handleUpdate;
14
26
  update(newInfo: Partial<SessionInfo>): void;
@@ -1,9 +1,11 @@
1
1
  export default class Session {
2
- constructor() {
2
+ constructor(app, options) {
3
+ this.app = app;
4
+ this.options = options;
3
5
  this.metadata = {};
4
6
  this.userID = null;
5
- this.sessionID = null;
6
7
  this.callbacks = [];
8
+ this.timestamp = 0;
7
9
  }
8
10
  attachUpdateCallback(cb) {
9
11
  this.callbacks.push(cb);
@@ -15,18 +17,25 @@ export default class Session {
15
17
  if (newInfo.sessionID == null) {
16
18
  delete newInfo.sessionID;
17
19
  }
18
- this.callbacks.forEach(cb => cb(newInfo));
20
+ this.callbacks.forEach((cb) => cb(newInfo));
19
21
  }
20
22
  update(newInfo) {
21
- if (newInfo.userID !== undefined) { // TODO clear nullable/undefinable types
23
+ if (newInfo.userID !== undefined) {
24
+ // TODO clear nullable/undefinable types
22
25
  this.userID = newInfo.userID;
23
26
  }
24
27
  if (newInfo.metadata !== undefined) {
25
- Object.entries(newInfo.metadata).forEach(([k, v]) => this.metadata[k] = v);
28
+ Object.entries(newInfo.metadata).forEach(([k, v]) => (this.metadata[k] = v));
26
29
  }
27
30
  if (newInfo.sessionID !== undefined) {
28
31
  this.sessionID = newInfo.sessionID;
29
32
  }
33
+ if (newInfo.timestamp !== undefined) {
34
+ this.timestamp = newInfo.timestamp;
35
+ }
36
+ if (newInfo.projectID !== undefined) {
37
+ this.projectID = newInfo.projectID;
38
+ }
30
39
  this.handleUpdate(newInfo);
31
40
  }
32
41
  setMetadata(key, value) {
@@ -42,11 +51,15 @@ export default class Session {
42
51
  sessionID: this.sessionID,
43
52
  metadata: this.metadata,
44
53
  userID: this.userID,
54
+ timestamp: this.timestamp,
55
+ projectID: this.projectID,
45
56
  };
46
57
  }
47
58
  reset() {
59
+ this.app.sessionStorage.removeItem(this.options.session_token_key);
48
60
  this.metadata = {};
49
61
  this.userID = null;
50
- this.sessionID = null;
62
+ this.sessionID = undefined;
63
+ this.timestamp = 0;
51
64
  }
52
65
  }
@@ -1,4 +1,4 @@
1
- import App from "./index.js";
1
+ import App from './index.js';
2
2
  declare type Callback = () => void;
3
3
  export default class Ticker {
4
4
  private readonly app;
@@ -1,4 +1,4 @@
1
- import type { Writer, Message } from "./types.js";
1
+ import type { Writer, Message } from './types.js';
2
2
  export default Message;
3
3
  export declare const classes: Map<number, Function>;
4
4
  declare class _BatchMeta implements Message {