@openreplay/tracker 3.6.3 → 4.0.0

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 (128) hide show
  1. package/.eslintignore +8 -0
  2. package/.prettierignore +1 -0
  3. package/LICENSE +1 -1
  4. package/cjs/app/guards.d.ts +2 -1
  5. package/cjs/app/guards.js +6 -3
  6. package/cjs/app/index.d.ts +28 -23
  7. package/cjs/app/index.js +101 -83
  8. package/cjs/app/logger.js +6 -3
  9. package/cjs/app/messages.d.ts +52 -0
  10. package/cjs/app/messages.gen.d.ts +57 -0
  11. package/cjs/app/messages.gen.js +493 -0
  12. package/cjs/app/messages.js +234 -0
  13. package/cjs/app/nodes.d.ts +1 -1
  14. package/cjs/app/nodes.js +2 -0
  15. package/cjs/app/observer/iframe_observer.d.ts +1 -1
  16. package/cjs/app/observer/iframe_observer.js +3 -3
  17. package/cjs/app/observer/observer.d.ts +2 -3
  18. package/cjs/app/observer/observer.js +50 -52
  19. package/cjs/app/observer/shadow_root_observer.d.ts +1 -1
  20. package/cjs/app/observer/shadow_root_observer.js +3 -3
  21. package/cjs/app/observer/top_observer.d.ts +13 -2
  22. package/cjs/app/observer/top_observer.js +58 -23
  23. package/cjs/app/sanitizer.d.ts +1 -1
  24. package/cjs/app/sanitizer.js +5 -5
  25. package/cjs/app/session.d.ts +20 -2
  26. package/cjs/app/session.js +65 -6
  27. package/cjs/app/ticker.d.ts +1 -1
  28. package/cjs/common/{webworker.d.ts → interaction.d.ts} +5 -5
  29. package/cjs/common/{types.js → interaction.js} +0 -0
  30. package/cjs/common/messages.gen.d.ts +382 -0
  31. package/cjs/common/{webworker.js → messages.gen.js} +1 -0
  32. package/cjs/index.d.ts +10 -9
  33. package/cjs/index.js +47 -36
  34. package/cjs/modules/adoptedStyleSheets.d.ts +2 -0
  35. package/cjs/modules/adoptedStyleSheets.js +127 -0
  36. package/cjs/modules/connection.d.ts +1 -1
  37. package/cjs/modules/connection.js +2 -2
  38. package/cjs/modules/console.d.ts +1 -1
  39. package/cjs/modules/console.js +7 -21
  40. package/cjs/modules/cssrules.d.ts +1 -1
  41. package/cjs/modules/cssrules.js +18 -14
  42. package/cjs/modules/exception.d.ts +3 -3
  43. package/cjs/modules/exception.js +23 -18
  44. package/cjs/modules/img.d.ts +1 -1
  45. package/cjs/modules/img.js +39 -26
  46. package/cjs/modules/input.d.ts +1 -1
  47. package/cjs/modules/input.js +21 -21
  48. package/cjs/modules/mouse.d.ts +1 -1
  49. package/cjs/modules/mouse.js +50 -43
  50. package/cjs/modules/performance.d.ts +1 -1
  51. package/cjs/modules/performance.js +2 -2
  52. package/cjs/modules/scroll.d.ts +1 -1
  53. package/cjs/modules/scroll.js +16 -7
  54. package/cjs/modules/timing.d.ts +1 -1
  55. package/cjs/modules/timing.js +14 -26
  56. package/cjs/modules/viewport.d.ts +1 -1
  57. package/cjs/modules/viewport.js +4 -4
  58. package/cjs/utils.js +7 -7
  59. package/cjs/vendors/finder/finder.js +53 -48
  60. package/lib/app/guards.d.ts +2 -1
  61. package/lib/app/guards.js +4 -2
  62. package/lib/app/index.d.ts +28 -23
  63. package/lib/app/index.js +109 -91
  64. package/lib/app/logger.js +6 -3
  65. package/lib/app/messages.d.ts +52 -0
  66. package/lib/app/messages.gen.d.ts +57 -0
  67. package/lib/app/messages.gen.js +434 -0
  68. package/lib/app/messages.js +181 -0
  69. package/lib/app/nodes.d.ts +1 -1
  70. package/lib/app/nodes.js +2 -0
  71. package/lib/app/observer/iframe_observer.d.ts +1 -1
  72. package/lib/app/observer/iframe_observer.js +3 -3
  73. package/lib/app/observer/observer.d.ts +2 -3
  74. package/lib/app/observer/observer.js +51 -53
  75. package/lib/app/observer/shadow_root_observer.d.ts +1 -1
  76. package/lib/app/observer/shadow_root_observer.js +3 -3
  77. package/lib/app/observer/top_observer.d.ts +13 -2
  78. package/lib/app/observer/top_observer.js +62 -27
  79. package/lib/app/sanitizer.d.ts +1 -1
  80. package/lib/app/sanitizer.js +7 -7
  81. package/lib/app/session.d.ts +20 -2
  82. package/lib/app/session.js +65 -6
  83. package/lib/app/ticker.d.ts +1 -1
  84. package/lib/common/{webworker.d.ts → interaction.d.ts} +5 -5
  85. package/lib/common/{types.js → interaction.js} +0 -0
  86. package/lib/common/messages.gen.d.ts +382 -0
  87. package/lib/common/messages.gen.js +2 -0
  88. package/lib/common/tsconfig.tsbuildinfo +1 -1
  89. package/lib/index.d.ts +10 -9
  90. package/lib/index.js +60 -49
  91. package/lib/modules/adoptedStyleSheets.d.ts +2 -0
  92. package/lib/modules/adoptedStyleSheets.js +124 -0
  93. package/lib/modules/connection.d.ts +1 -1
  94. package/lib/modules/connection.js +2 -2
  95. package/lib/modules/console.d.ts +1 -1
  96. package/lib/modules/console.js +8 -22
  97. package/lib/modules/cssrules.d.ts +1 -1
  98. package/lib/modules/cssrules.js +19 -15
  99. package/lib/modules/exception.d.ts +3 -3
  100. package/lib/modules/exception.js +23 -18
  101. package/lib/modules/img.d.ts +1 -1
  102. package/lib/modules/img.js +41 -28
  103. package/lib/modules/input.d.ts +1 -1
  104. package/lib/modules/input.js +23 -23
  105. package/lib/modules/mouse.d.ts +1 -1
  106. package/lib/modules/mouse.js +53 -46
  107. package/lib/modules/performance.d.ts +1 -1
  108. package/lib/modules/performance.js +3 -3
  109. package/lib/modules/scroll.d.ts +1 -1
  110. package/lib/modules/scroll.js +17 -8
  111. package/lib/modules/timing.d.ts +1 -1
  112. package/lib/modules/timing.js +16 -28
  113. package/lib/modules/viewport.d.ts +1 -1
  114. package/lib/modules/viewport.js +4 -4
  115. package/lib/utils.js +7 -7
  116. package/lib/vendors/finder/finder.js +53 -48
  117. package/package.json +27 -10
  118. package/cjs/common/messages.d.ts +0 -444
  119. package/cjs/common/messages.js +0 -794
  120. package/cjs/common/types.d.ts +0 -9
  121. package/cjs/modules/longtasks.d.ts +0 -2
  122. package/cjs/modules/longtasks.js +0 -26
  123. package/lib/common/messages.d.ts +0 -444
  124. package/lib/common/messages.js +0 -790
  125. package/lib/common/types.d.ts +0 -9
  126. package/lib/common/webworker.js +0 -1
  127. package/lib/modules/longtasks.d.ts +0 -2
  128. package/lib/modules/longtasks.js +0 -23
@@ -2,9 +2,9 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const guards_js_1 = require("../app/guards.js");
4
4
  const utils_js_1 = require("../utils.js");
5
- const messages_js_1 = require("../common/messages.js");
5
+ const messages_gen_js_1 = require("../app/messages.gen.js");
6
6
  const input_js_1 = require("./input.js");
7
- function _getSelector(target) {
7
+ function _getSelector(target, document) {
8
8
  let el = target;
9
9
  let selector = null;
10
10
  do {
@@ -12,9 +12,10 @@ function _getSelector(target) {
12
12
  return `#${el.id}` + (selector ? ` > ${selector}` : '');
13
13
  }
14
14
  selector =
15
- el.className.split(' ')
16
- .map(cn => cn.trim())
17
- .filter(cn => cn !== '')
15
+ el.className
16
+ .split(' ')
17
+ .map((cn) => cn.trim())
18
+ .filter((cn) => cn !== '')
18
19
  .reduce((sel, cn) => `${sel}.${cn}`, el.tagName.toLowerCase()) +
19
20
  (selector ? ` > ${selector}` : '');
20
21
  if (el === document.body) {
@@ -26,23 +27,23 @@ function _getSelector(target) {
26
27
  }
27
28
  function isClickable(element) {
28
29
  const tag = element.tagName.toUpperCase();
29
- return tag === 'BUTTON' ||
30
+ return (tag === 'BUTTON' ||
30
31
  tag === 'A' ||
31
32
  tag === 'LI' ||
32
33
  tag === 'SELECT' ||
33
34
  element.onclick != null ||
34
- element.getAttribute('role') === 'button';
35
+ element.getAttribute('role') === 'button');
35
36
  //|| element.className.includes("btn")
36
- // MBTODO: intersect addEventListener
37
+ // MBTODO: intersept addEventListener
37
38
  }
38
- //TODO: fix (typescript doesn't allow work when the guard is inside the function)
39
- function getTarget(target) {
39
+ //TODO: fix (typescript is not sure about target variable after assignation of svg)
40
+ function getTarget(target, document) {
40
41
  if (target instanceof Element) {
41
- return _getTarget(target);
42
+ return _getTarget(target, document);
42
43
  }
43
44
  return null;
44
45
  }
45
- function _getTarget(target) {
46
+ function _getTarget(target, document) {
46
47
  let element = target;
47
48
  while (element !== null && element !== document.documentElement) {
48
49
  if ((0, utils_js_1.hasOpenreplayAttribute)(element, 'masked')) {
@@ -66,8 +67,7 @@ function _getTarget(target) {
66
67
  if (tag === 'INPUT') {
67
68
  return element;
68
69
  }
69
- if (isClickable(element) ||
70
- (0, utils_js_1.getLabelAttribute)(element) !== null) {
70
+ if (isClickable(element) || (0, utils_js_1.getLabelAttribute)(element) !== null) {
71
71
  return element;
72
72
  }
73
73
  element = element.parentElement;
@@ -80,7 +80,7 @@ function default_1(app) {
80
80
  if (dl !== null) {
81
81
  return dl;
82
82
  }
83
- if ((0, guards_js_1.hasTag)(target, "INPUT")) {
83
+ if ((0, guards_js_1.hasTag)(target, 'INPUT')) {
84
84
  return (0, input_js_1.getInputLabel)(target);
85
85
  }
86
86
  if (isClickable(target)) {
@@ -106,40 +106,47 @@ function default_1(app) {
106
106
  });
107
107
  const sendMouseMove = () => {
108
108
  if (mousePositionChanged) {
109
- app.send(new messages_js_1.MouseMove(mousePositionX, mousePositionY));
109
+ app.send((0, messages_gen_js_1.MouseMove)(mousePositionX, mousePositionY));
110
110
  mousePositionChanged = false;
111
111
  }
112
112
  };
113
- const selectorMap = {};
114
- function getSelector(id, target) {
115
- return selectorMap[id] = selectorMap[id] || _getSelector(target);
116
- }
117
- app.attachEventListener(document.documentElement, 'mouseover', (e) => {
118
- const target = getTarget(e.target);
119
- if (target !== mouseTarget) {
120
- mouseTarget = target;
121
- mouseTargetTime = performance.now();
122
- }
123
- });
124
- app.attachEventListener(document, 'mousemove', (e) => {
125
- mousePositionX = e.clientX;
126
- mousePositionY = e.clientY;
127
- mousePositionChanged = true;
128
- }, false);
129
- app.attachEventListener(document, 'click', (e) => {
130
- const target = getTarget(e.target);
131
- if ((!e.clientX && !e.clientY) || target === null) {
132
- return;
113
+ const patchDocument = (document) => {
114
+ const selectorMap = {};
115
+ function getSelector(id, target) {
116
+ return (selectorMap[id] = selectorMap[id] || _getSelector(target, document));
133
117
  }
134
- const id = app.nodes.getID(target);
135
- if (id !== undefined) {
136
- sendMouseMove();
137
- app.send(new messages_js_1.MouseClick(id, mouseTarget === target
138
- ? Math.round(performance.now() - mouseTargetTime)
139
- : 0, getTargetLabel(target), getSelector(id, target)), true);
118
+ app.attachEventListener(document.documentElement, 'mouseover', (e) => {
119
+ const target = getTarget(e.target, document);
120
+ if (target !== mouseTarget) {
121
+ mouseTarget = target;
122
+ mouseTargetTime = performance.now();
123
+ }
124
+ });
125
+ app.attachEventListener(document, 'mousemove', (e) => {
126
+ const { top, left } = app.observer.getDocumentOffset(document);
127
+ mousePositionX = e.clientX + left;
128
+ mousePositionY = e.clientY + top;
129
+ mousePositionChanged = true;
130
+ }, false);
131
+ app.attachEventListener(document, 'click', (e) => {
132
+ const target = getTarget(e.target, document);
133
+ if ((!e.clientX && !e.clientY) || target === null) {
134
+ return;
135
+ }
136
+ const id = app.nodes.getID(target);
137
+ if (id !== undefined) {
138
+ sendMouseMove();
139
+ app.send((0, messages_gen_js_1.MouseClick)(id, mouseTarget === target ? Math.round(performance.now() - mouseTargetTime) : 0, getTargetLabel(target), getSelector(id, target)), true);
140
+ }
141
+ mouseTarget = null;
142
+ });
143
+ };
144
+ app.nodes.attachNodeCallback((node) => {
145
+ if ((0, guards_js_1.isDocument)(node)) {
146
+ patchDocument(node);
140
147
  }
141
- mouseTarget = null;
142
148
  });
149
+ patchDocument(document);
143
150
  app.ticker.attach(sendMouseMove, 10);
144
151
  }
145
152
  exports.default = default_1;
@@ -1,4 +1,4 @@
1
- import type App from "../app/index.js";
1
+ import type App from '../app/index.js';
2
2
  export declare const deviceMemory: number;
3
3
  export declare const jsHeapSizeLimit: number;
4
4
  export interface Options {
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.jsHeapSizeLimit = exports.deviceMemory = void 0;
4
4
  const utils_js_1 = require("../utils.js");
5
- const messages_js_1 = require("../common/messages.js");
5
+ const messages_gen_js_1 = require("../app/messages.gen.js");
6
6
  const perf = utils_js_1.IN_BROWSER && 'performance' in window && 'memory' in performance // works in Chrome only
7
7
  ? performance
8
8
  : { memory: {} };
@@ -34,7 +34,7 @@ function default_1(app, opts) {
34
34
  if (frames === undefined || ticks === undefined) {
35
35
  return;
36
36
  }
37
- app.send(new messages_js_1.PerformanceTrack(frames, ticks, perf.memory.totalJSHeapSize || 0, perf.memory.usedJSHeapSize || 0));
37
+ app.send((0, messages_gen_js_1.PerformanceTrack)(frames, ticks, perf.memory.totalJSHeapSize || 0, perf.memory.usedJSHeapSize || 0));
38
38
  ticks = frames = document.hidden ? -1 : 0;
39
39
  };
40
40
  app.attachStartCallback(() => {
@@ -1,2 +1,2 @@
1
- import type App from "../app/index.js";
1
+ import type App from '../app/index.js';
2
2
  export default function (app: App): void;
@@ -1,11 +1,16 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const messages_js_1 = require("../common/messages.js");
3
+ const messages_gen_js_1 = require("../app/messages.gen.js");
4
4
  const guards_js_1 = require("../app/guards.js");
5
5
  function default_1(app) {
6
6
  let documentScroll = false;
7
7
  const nodeScroll = new Map();
8
- const sendSetViewportScroll = app.safe(() => app.send(new messages_js_1.SetViewportScroll(window.pageXOffset ||
8
+ function setNodeScroll(target) {
9
+ if (target instanceof Element) {
10
+ nodeScroll.set(target, [target.scrollLeft, target.scrollTop]);
11
+ }
12
+ }
13
+ const sendSetViewportScroll = app.safe(() => app.send((0, messages_gen_js_1.SetViewportScroll)(window.pageXOffset ||
9
14
  (document.documentElement && document.documentElement.scrollLeft) ||
10
15
  (document.body && document.body.scrollLeft) ||
11
16
  0, window.pageYOffset ||
@@ -15,7 +20,7 @@ function default_1(app) {
15
20
  const sendSetNodeScroll = app.safe((s, node) => {
16
21
  const id = app.nodes.getID(node);
17
22
  if (id !== undefined) {
18
- app.send(new messages_js_1.SetNodeScroll(id, s[0], s[1]));
23
+ app.send((0, messages_gen_js_1.SetNodeScroll)(id, s[0], s[1]));
19
24
  }
20
25
  });
21
26
  app.attachStartCallback(sendSetViewportScroll);
@@ -27,16 +32,20 @@ function default_1(app) {
27
32
  if (isStart && (0, guards_js_1.isElementNode)(node) && node.scrollLeft + node.scrollTop > 0) {
28
33
  nodeScroll.set(node, [node.scrollLeft, node.scrollTop]);
29
34
  }
35
+ else if ((0, guards_js_1.isRootNode)(node)) {
36
+ // scroll is not-composed event (https://javascript.info/shadow-dom-events)
37
+ app.attachEventListener(node, 'scroll', (e) => {
38
+ setNodeScroll(e.target);
39
+ });
40
+ }
30
41
  });
31
- app.attachEventListener(window, 'scroll', (e) => {
42
+ app.attachEventListener(document, 'scroll', (e) => {
32
43
  const target = e.target;
33
44
  if (target === document) {
34
45
  documentScroll = true;
35
46
  return;
36
47
  }
37
- if (target instanceof Element) {
38
- nodeScroll.set(target, [target.scrollLeft, target.scrollTop]);
39
- }
48
+ setNodeScroll(target);
40
49
  });
41
50
  app.ticker.attach(() => {
42
51
  if (documentScroll) {
@@ -1,4 +1,4 @@
1
- import type App from "../app/index.js";
1
+ import type App from '../app/index.js';
2
2
  export interface Options {
3
3
  captureResourceTimings: boolean;
4
4
  capturePageLoadTimings: boolean;
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const guards_js_1 = require("../app/guards.js");
4
4
  const utils_js_1 = require("../utils.js");
5
- const messages_js_1 = require("../common/messages.js");
5
+ const messages_gen_js_1 = require("../app/messages.gen.js");
6
6
  function getPaintBlocks(resources) {
7
7
  const paintBlocks = [];
8
8
  const elements = document.getElementsByTagName('*');
@@ -10,7 +10,7 @@ function getPaintBlocks(resources) {
10
10
  for (let i = 0; i < elements.length; i++) {
11
11
  const element = elements[i];
12
12
  let src = '';
13
- if ((0, guards_js_1.hasTag)(element, "IMG")) {
13
+ if ((0, guards_js_1.hasTag)(element, 'IMG')) {
14
14
  src = element.currentSrc || element.src;
15
15
  }
16
16
  if (!src) {
@@ -36,9 +36,7 @@ function getPaintBlocks(resources) {
36
36
  const bottom = Math.min(rect.bottom, window.innerHeight ||
37
37
  (document.documentElement && document.documentElement.clientHeight) ||
38
38
  0);
39
- const right = Math.min(rect.right, window.innerWidth ||
40
- (document.documentElement && document.documentElement.clientWidth) ||
41
- 0);
39
+ const right = Math.min(rect.right, window.innerWidth || (document.documentElement && document.documentElement.clientWidth) || 0);
42
40
  if (bottom <= top || right <= left)
43
41
  continue;
44
42
  const area = (bottom - top) * (right - left);
@@ -48,8 +46,7 @@ function getPaintBlocks(resources) {
48
46
  }
49
47
  function calculateSpeedIndex(firstContentfulPaint, paintBlocks) {
50
48
  let a = (Math.max((document.documentElement && document.documentElement.clientWidth) || 0, window.innerWidth || 0) *
51
- Math.max((document.documentElement && document.documentElement.clientHeight) ||
52
- 0, window.innerHeight || 0)) /
49
+ Math.max((document.documentElement && document.documentElement.clientHeight) || 0, window.innerHeight || 0)) /
53
50
  10;
54
51
  let s = a * firstContentfulPaint;
55
52
  for (let i = 0; i < paintBlocks.length; i++) {
@@ -78,16 +75,13 @@ function default_1(app, opts) {
78
75
  if (resources !== null) {
79
76
  resources[entry.name] = entry.startTime + entry.duration;
80
77
  }
81
- app.send(new messages_js_1.ResourceTiming(entry.startTime + performance.timing.navigationStart, entry.duration, entry.responseStart && entry.startTime
82
- ? entry.responseStart - entry.startTime
83
- : 0, entry.transferSize > entry.encodedBodySize
84
- ? entry.transferSize - entry.encodedBodySize
85
- : 0, entry.encodedBodySize || 0, entry.decodedBodySize || 0, entry.name, entry.initiatorType));
78
+ app.send((0, messages_gen_js_1.ResourceTiming)(entry.startTime + performance.timing.navigationStart, entry.duration, entry.responseStart && entry.startTime ? entry.responseStart - entry.startTime : 0, entry.transferSize > entry.encodedBodySize ? entry.transferSize - entry.encodedBodySize : 0, entry.encodedBodySize || 0, entry.decodedBodySize || 0, entry.name, entry.initiatorType));
86
79
  }
87
80
  const observer = new PerformanceObserver((list) => list.getEntries().forEach(resourceTiming));
88
81
  let prevSessionID;
89
82
  app.attachStartCallback(function ({ sessionID }) {
90
- if (sessionID !== prevSessionID) { // Send past page resources on a newly started session
83
+ if (sessionID !== prevSessionID) {
84
+ // Send past page resources on a newly started session
91
85
  performance.getEntriesByType('resource').forEach(resourceTiming);
92
86
  prevSessionID = sessionID;
93
87
  }
@@ -104,9 +98,7 @@ function default_1(app, opts) {
104
98
  return;
105
99
  }
106
100
  if (firstPaint === 0 || firstContentfulPaint === 0) {
107
- performance
108
- .getEntriesByType('paint')
109
- .forEach((entry) => {
101
+ performance.getEntriesByType('paint').forEach((entry) => {
110
102
  const { name, startTime } = entry;
111
103
  switch (name) {
112
104
  case 'first-paint':
@@ -121,7 +113,7 @@ function default_1(app, opts) {
121
113
  if (performance.timing.loadEventEnd || performance.now() > 30000) {
122
114
  pageLoadTimingSent = true;
123
115
  const { navigationStart, requestStart, responseStart, responseEnd, domContentLoadedEventStart, domContentLoadedEventEnd, loadEventStart, loadEventEnd, } = performance.timing;
124
- app.send(new messages_js_1.PageLoadTiming(requestStart - navigationStart || 0, responseStart - navigationStart || 0, responseEnd - navigationStart || 0, domContentLoadedEventStart - navigationStart || 0, domContentLoadedEventEnd - navigationStart || 0, loadEventStart - navigationStart || 0, loadEventEnd - navigationStart || 0, firstPaint, firstContentfulPaint));
116
+ app.send((0, messages_gen_js_1.PageLoadTiming)(requestStart - navigationStart || 0, responseStart - navigationStart || 0, responseEnd - navigationStart || 0, domContentLoadedEventStart - navigationStart || 0, domContentLoadedEventEnd - navigationStart || 0, loadEventStart - navigationStart || 0, loadEventEnd - navigationStart || 0, firstPaint, firstContentfulPaint));
125
117
  }
126
118
  }, 30);
127
119
  }
@@ -144,23 +136,19 @@ function default_1(app, opts) {
144
136
  if (time - interactiveWindowTickTime > 50) {
145
137
  interactiveWindowStartTime = time;
146
138
  }
147
- interactiveWindowTickTime =
148
- time - interactiveWindowStartTime > 5000 ? null : time;
139
+ interactiveWindowTickTime = time - interactiveWindowStartTime > 5000 ? null : time;
149
140
  }
150
- if ((paintBlocks !== null && interactiveWindowTickTime === null) ||
151
- time > 30000) {
141
+ if ((paintBlocks !== null && interactiveWindowTickTime === null) || time > 30000) {
152
142
  pageRenderTimingSent = true;
153
143
  resources = null;
154
144
  const speedIndex = paintBlocks === null
155
145
  ? 0
156
146
  : calculateSpeedIndex(firstContentfulPaint || firstPaint, paintBlocks);
157
147
  const timeToInteractive = interactiveWindowTickTime === null
158
- ? Math.max(interactiveWindowStartTime, firstContentfulPaint, performance.timing.domContentLoadedEventEnd -
159
- performance.timing.navigationStart || 0)
148
+ ? Math.max(interactiveWindowStartTime, firstContentfulPaint, performance.timing.domContentLoadedEventEnd - performance.timing.navigationStart ||
149
+ 0)
160
150
  : 0;
161
- app.send(new messages_js_1.PageRenderTiming(speedIndex, firstContentfulPaint > visuallyComplete
162
- ? firstContentfulPaint
163
- : visuallyComplete, timeToInteractive));
151
+ app.send((0, messages_gen_js_1.PageRenderTiming)(speedIndex, firstContentfulPaint > visuallyComplete ? firstContentfulPaint : visuallyComplete, timeToInteractive));
164
152
  }
165
153
  });
166
154
  }
@@ -1,2 +1,2 @@
1
- import type App from "../app/index.js";
1
+ import type App from '../app/index.js';
2
2
  export default function (app: App): void;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const messages_js_1 = require("../common/messages.js");
3
+ const messages_gen_js_1 = require("../app/messages.gen.js");
4
4
  function default_1(app) {
5
5
  let url, width, height;
6
6
  let navigationStart = performance.timing.navigationStart;
@@ -8,7 +8,7 @@ function default_1(app) {
8
8
  const { URL } = document;
9
9
  if (URL !== url) {
10
10
  url = URL;
11
- app.send(new messages_js_1.SetPageLocation(url, document.referrer, navigationStart));
11
+ app.send((0, messages_gen_js_1.SetPageLocation)(url, document.referrer, navigationStart));
12
12
  navigationStart = 0;
13
13
  }
14
14
  });
@@ -17,12 +17,12 @@ function default_1(app) {
17
17
  if (innerWidth !== width || innerHeight !== height) {
18
18
  width = innerWidth;
19
19
  height = innerHeight;
20
- app.send(new messages_js_1.SetViewportSize(width, height));
20
+ app.send((0, messages_gen_js_1.SetViewportSize)(width, height));
21
21
  }
22
22
  });
23
23
  const sendSetPageVisibility = document.hidden === undefined
24
24
  ? Function.prototype
25
- : app.safe(() => app.send(new messages_js_1.SetPageVisibility(document.hidden)));
25
+ : app.safe(() => app.send((0, messages_gen_js_1.SetPageVisibility)(document.hidden)));
26
26
  app.attachStartCallback(() => {
27
27
  url = '';
28
28
  width = height = -1;
package/cjs/utils.js CHANGED
@@ -17,26 +17,26 @@ function isURL(s) {
17
17
  return s.startsWith('https://') || s.startsWith('http://');
18
18
  }
19
19
  exports.isURL = isURL;
20
- exports.IN_BROWSER = !(typeof window === "undefined");
20
+ exports.IN_BROWSER = !(typeof window === 'undefined');
21
21
  // TODO: JOIN IT WITH LOGGER somehow (use logging decorators?); Don't forget about index.js loggin when there is no logger instance.
22
22
  exports.DOCS_HOST = 'https://docs.openreplay.com';
23
23
  const warnedFeatures = {};
24
- function deprecationWarn(nameOfFeature, useInstead, docsPath = "/") {
24
+ function deprecationWarn(nameOfFeature, useInstead, docsPath = '/') {
25
25
  if (warnedFeatures[nameOfFeature]) {
26
26
  return;
27
27
  }
28
- console.warn(`OpenReplay: ${nameOfFeature} is deprecated. ${useInstead ? `Please, use ${useInstead} instead.` : ""} Visit ${exports.DOCS_HOST}${docsPath} for more information.`);
28
+ console.warn(`OpenReplay: ${nameOfFeature} is deprecated. ${useInstead ? `Please, use ${useInstead} instead.` : ''} Visit ${exports.DOCS_HOST}${docsPath} for more information.`);
29
29
  warnedFeatures[nameOfFeature] = true;
30
30
  }
31
31
  exports.deprecationWarn = deprecationWarn;
32
32
  function getLabelAttribute(e) {
33
- let value = e.getAttribute("data-openreplay-label");
33
+ let value = e.getAttribute('data-openreplay-label');
34
34
  if (value !== null) {
35
35
  return value;
36
36
  }
37
- value = e.getAttribute("data-asayer-label");
37
+ value = e.getAttribute('data-asayer-label');
38
38
  if (value !== null) {
39
- deprecationWarn(`"data-asayer-label" attribute`, `"data-openreplay-label" attribute`, "/");
39
+ deprecationWarn('"data-asayer-label" attribute', '"data-openreplay-label" attribute', '/');
40
40
  }
41
41
  return value;
42
42
  }
@@ -48,7 +48,7 @@ function hasOpenreplayAttribute(e, name) {
48
48
  }
49
49
  const oldName = `data-asayer-${name}`;
50
50
  if (e.hasAttribute(oldName)) {
51
- deprecationWarn(`"${oldName}" attribute`, `"${newName}" attribute`, "/installation/sanitize-data");
51
+ deprecationWarn(`"${oldName}" attribute`, `"${newName}" attribute`, '/installation/sanitize-data');
52
52
  return true;
53
53
  }
54
54
  return false;