@openreplay/tracker 3.6.0-beta.0 → 3.6.2

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 (126) hide show
  1. package/cjs/app/guards.d.ts +1 -2
  2. package/cjs/app/guards.js +3 -6
  3. package/cjs/app/index.d.ts +22 -24
  4. package/cjs/app/index.js +84 -85
  5. package/cjs/app/logger.js +3 -6
  6. package/cjs/app/nodes.js +0 -2
  7. package/cjs/app/observer/iframe_observer.d.ts +1 -1
  8. package/cjs/app/observer/iframe_observer.js +3 -3
  9. package/cjs/app/observer/observer.d.ts +3 -2
  10. package/cjs/app/observer/observer.js +52 -50
  11. package/cjs/app/observer/shadow_root_observer.d.ts +1 -1
  12. package/cjs/app/observer/shadow_root_observer.js +3 -3
  13. package/cjs/app/observer/top_observer.d.ts +2 -11
  14. package/cjs/app/observer/top_observer.js +23 -52
  15. package/cjs/app/sanitizer.d.ts +1 -1
  16. package/cjs/app/sanitizer.js +5 -5
  17. package/cjs/app/session.d.ts +2 -18
  18. package/cjs/app/session.js +6 -55
  19. package/cjs/app/ticker.d.ts +1 -1
  20. package/cjs/common/messages.d.ts +444 -0
  21. package/cjs/common/messages.js +794 -0
  22. package/cjs/common/types.d.ts +9 -0
  23. package/cjs/common/{interaction.js → types.js} +0 -0
  24. package/cjs/common/{interaction.d.ts → webworker.d.ts} +5 -5
  25. package/cjs/common/webworker.js +2 -0
  26. package/cjs/index.d.ts +10 -10
  27. package/cjs/index.js +37 -42
  28. package/cjs/modules/connection.d.ts +1 -1
  29. package/cjs/modules/connection.js +2 -2
  30. package/cjs/modules/console.d.ts +1 -1
  31. package/cjs/modules/console.js +21 -7
  32. package/cjs/modules/cssrules.d.ts +1 -1
  33. package/cjs/modules/cssrules.js +14 -18
  34. package/cjs/modules/exception.d.ts +3 -3
  35. package/cjs/modules/exception.js +20 -25
  36. package/cjs/modules/img.d.ts +1 -1
  37. package/cjs/modules/img.js +26 -39
  38. package/cjs/modules/input.d.ts +1 -1
  39. package/cjs/modules/input.js +21 -21
  40. package/cjs/modules/longtasks.d.ts +2 -0
  41. package/cjs/modules/longtasks.js +26 -0
  42. package/cjs/modules/mouse.d.ts +1 -1
  43. package/cjs/modules/mouse.js +43 -50
  44. package/cjs/modules/performance.d.ts +1 -1
  45. package/cjs/modules/performance.js +2 -2
  46. package/cjs/modules/scroll.d.ts +1 -1
  47. package/cjs/modules/scroll.js +7 -16
  48. package/cjs/modules/timing.d.ts +1 -1
  49. package/cjs/modules/timing.js +26 -14
  50. package/cjs/modules/viewport.d.ts +1 -1
  51. package/cjs/modules/viewport.js +4 -4
  52. package/cjs/utils.js +7 -7
  53. package/cjs/vendors/finder/finder.js +48 -53
  54. package/lib/app/guards.d.ts +1 -2
  55. package/lib/app/guards.js +2 -4
  56. package/lib/app/index.d.ts +22 -24
  57. package/lib/app/index.js +92 -93
  58. package/lib/app/logger.js +3 -6
  59. package/lib/app/nodes.js +0 -2
  60. package/lib/app/observer/iframe_observer.d.ts +1 -1
  61. package/lib/app/observer/iframe_observer.js +3 -3
  62. package/lib/app/observer/observer.d.ts +3 -2
  63. package/lib/app/observer/observer.js +53 -51
  64. package/lib/app/observer/shadow_root_observer.d.ts +1 -1
  65. package/lib/app/observer/shadow_root_observer.js +3 -3
  66. package/lib/app/observer/top_observer.d.ts +2 -11
  67. package/lib/app/observer/top_observer.js +27 -56
  68. package/lib/app/sanitizer.d.ts +1 -1
  69. package/lib/app/sanitizer.js +7 -7
  70. package/lib/app/session.d.ts +2 -18
  71. package/lib/app/session.js +6 -55
  72. package/lib/app/ticker.d.ts +1 -1
  73. package/lib/common/messages.d.ts +444 -0
  74. package/lib/common/messages.js +790 -0
  75. package/lib/common/tsconfig.tsbuildinfo +1 -1
  76. package/lib/common/types.d.ts +9 -0
  77. package/lib/common/{interaction.js → types.js} +0 -0
  78. package/lib/common/{interaction.d.ts → webworker.d.ts} +5 -5
  79. package/lib/common/webworker.js +1 -0
  80. package/lib/index.d.ts +10 -10
  81. package/lib/index.js +50 -55
  82. package/lib/modules/connection.d.ts +1 -1
  83. package/lib/modules/connection.js +2 -2
  84. package/lib/modules/console.d.ts +1 -1
  85. package/lib/modules/console.js +22 -8
  86. package/lib/modules/cssrules.d.ts +1 -1
  87. package/lib/modules/cssrules.js +15 -19
  88. package/lib/modules/exception.d.ts +3 -3
  89. package/lib/modules/exception.js +20 -25
  90. package/lib/modules/img.d.ts +1 -1
  91. package/lib/modules/img.js +28 -41
  92. package/lib/modules/input.d.ts +1 -1
  93. package/lib/modules/input.js +23 -23
  94. package/lib/modules/longtasks.d.ts +2 -0
  95. package/lib/modules/longtasks.js +23 -0
  96. package/lib/modules/mouse.d.ts +1 -1
  97. package/lib/modules/mouse.js +46 -53
  98. package/lib/modules/performance.d.ts +1 -1
  99. package/lib/modules/performance.js +3 -3
  100. package/lib/modules/scroll.d.ts +1 -1
  101. package/lib/modules/scroll.js +8 -17
  102. package/lib/modules/timing.d.ts +1 -1
  103. package/lib/modules/timing.js +28 -16
  104. package/lib/modules/viewport.d.ts +1 -1
  105. package/lib/modules/viewport.js +4 -4
  106. package/lib/utils.js +7 -7
  107. package/lib/vendors/finder/finder.js +48 -53
  108. package/package.json +10 -27
  109. package/.eslintignore +0 -8
  110. package/.prettierignore +0 -1
  111. package/cjs/app/messages.d.ts +0 -52
  112. package/cjs/app/messages.gen.d.ts +0 -57
  113. package/cjs/app/messages.gen.js +0 -494
  114. package/cjs/app/messages.js +0 -235
  115. package/cjs/common/messages.gen.d.ts +0 -382
  116. package/cjs/common/messages.gen.js +0 -62
  117. package/cjs/modules/adoptedStyleSheets.d.ts +0 -2
  118. package/cjs/modules/adoptedStyleSheets.js +0 -127
  119. package/lib/app/messages.d.ts +0 -52
  120. package/lib/app/messages.gen.d.ts +0 -57
  121. package/lib/app/messages.gen.js +0 -435
  122. package/lib/app/messages.js +0 -182
  123. package/lib/common/messages.gen.d.ts +0 -382
  124. package/lib/common/messages.gen.js +0 -59
  125. package/lib/modules/adoptedStyleSheets.d.ts +0 -2
  126. package/lib/modules/adoptedStyleSheets.js +0 -124
@@ -1,6 +1,6 @@
1
- import { hasTag } from '../app/guards.js';
2
- import { isURL } from '../utils.js';
3
- import { ResourceTiming, PageLoadTiming, PageRenderTiming } from '../app/messages.gen.js';
1
+ import { hasTag } from "../app/guards.js";
2
+ import { isURL } from "../utils.js";
3
+ import { ResourceTiming, PageLoadTiming, PageRenderTiming } from "../common/messages.js";
4
4
  function getPaintBlocks(resources) {
5
5
  const paintBlocks = [];
6
6
  const elements = document.getElementsByTagName('*');
@@ -8,7 +8,7 @@ function getPaintBlocks(resources) {
8
8
  for (let i = 0; i < elements.length; i++) {
9
9
  const element = elements[i];
10
10
  let src = '';
11
- if (hasTag(element, 'IMG')) {
11
+ if (hasTag(element, "IMG")) {
12
12
  src = element.currentSrc || element.src;
13
13
  }
14
14
  if (!src) {
@@ -34,7 +34,9 @@ function getPaintBlocks(resources) {
34
34
  const bottom = Math.min(rect.bottom, window.innerHeight ||
35
35
  (document.documentElement && document.documentElement.clientHeight) ||
36
36
  0);
37
- const right = Math.min(rect.right, window.innerWidth || (document.documentElement && document.documentElement.clientWidth) || 0);
37
+ const right = Math.min(rect.right, window.innerWidth ||
38
+ (document.documentElement && document.documentElement.clientWidth) ||
39
+ 0);
38
40
  if (bottom <= top || right <= left)
39
41
  continue;
40
42
  const area = (bottom - top) * (right - left);
@@ -44,7 +46,8 @@ function getPaintBlocks(resources) {
44
46
  }
45
47
  function calculateSpeedIndex(firstContentfulPaint, paintBlocks) {
46
48
  let a = (Math.max((document.documentElement && document.documentElement.clientWidth) || 0, window.innerWidth || 0) *
47
- Math.max((document.documentElement && document.documentElement.clientHeight) || 0, window.innerHeight || 0)) /
49
+ Math.max((document.documentElement && document.documentElement.clientHeight) ||
50
+ 0, window.innerHeight || 0)) /
48
51
  10;
49
52
  let s = a * firstContentfulPaint;
50
53
  for (let i = 0; i < paintBlocks.length; i++) {
@@ -73,13 +76,16 @@ export default function (app, opts) {
73
76
  if (resources !== null) {
74
77
  resources[entry.name] = entry.startTime + entry.duration;
75
78
  }
76
- app.send(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));
79
+ app.send(new ResourceTiming(entry.startTime + performance.timing.navigationStart, entry.duration, entry.responseStart && entry.startTime
80
+ ? entry.responseStart - entry.startTime
81
+ : 0, entry.transferSize > entry.encodedBodySize
82
+ ? entry.transferSize - entry.encodedBodySize
83
+ : 0, entry.encodedBodySize || 0, entry.decodedBodySize || 0, entry.name, entry.initiatorType));
77
84
  }
78
85
  const observer = new PerformanceObserver((list) => list.getEntries().forEach(resourceTiming));
79
86
  let prevSessionID;
80
87
  app.attachStartCallback(function ({ sessionID }) {
81
- if (sessionID !== prevSessionID) {
82
- // Send past page resources on a newly started session
88
+ if (sessionID !== prevSessionID) { // Send past page resources on a newly started session
83
89
  performance.getEntriesByType('resource').forEach(resourceTiming);
84
90
  prevSessionID = sessionID;
85
91
  }
@@ -96,7 +102,9 @@ export default function (app, opts) {
96
102
  return;
97
103
  }
98
104
  if (firstPaint === 0 || firstContentfulPaint === 0) {
99
- performance.getEntriesByType('paint').forEach((entry) => {
105
+ performance
106
+ .getEntriesByType('paint')
107
+ .forEach((entry) => {
100
108
  const { name, startTime } = entry;
101
109
  switch (name) {
102
110
  case 'first-paint':
@@ -111,7 +119,7 @@ export default function (app, opts) {
111
119
  if (performance.timing.loadEventEnd || performance.now() > 30000) {
112
120
  pageLoadTimingSent = true;
113
121
  const { navigationStart, requestStart, responseStart, responseEnd, domContentLoadedEventStart, domContentLoadedEventEnd, loadEventStart, loadEventEnd, } = performance.timing;
114
- app.send(PageLoadTiming(requestStart - navigationStart || 0, responseStart - navigationStart || 0, responseEnd - navigationStart || 0, domContentLoadedEventStart - navigationStart || 0, domContentLoadedEventEnd - navigationStart || 0, loadEventStart - navigationStart || 0, loadEventEnd - navigationStart || 0, firstPaint, firstContentfulPaint));
122
+ app.send(new PageLoadTiming(requestStart - navigationStart || 0, responseStart - navigationStart || 0, responseEnd - navigationStart || 0, domContentLoadedEventStart - navigationStart || 0, domContentLoadedEventEnd - navigationStart || 0, loadEventStart - navigationStart || 0, loadEventEnd - navigationStart || 0, firstPaint, firstContentfulPaint));
115
123
  }
116
124
  }, 30);
117
125
  }
@@ -134,19 +142,23 @@ export default function (app, opts) {
134
142
  if (time - interactiveWindowTickTime > 50) {
135
143
  interactiveWindowStartTime = time;
136
144
  }
137
- interactiveWindowTickTime = time - interactiveWindowStartTime > 5000 ? null : time;
145
+ interactiveWindowTickTime =
146
+ time - interactiveWindowStartTime > 5000 ? null : time;
138
147
  }
139
- if ((paintBlocks !== null && interactiveWindowTickTime === null) || time > 30000) {
148
+ if ((paintBlocks !== null && interactiveWindowTickTime === null) ||
149
+ time > 30000) {
140
150
  pageRenderTimingSent = true;
141
151
  resources = null;
142
152
  const speedIndex = paintBlocks === null
143
153
  ? 0
144
154
  : calculateSpeedIndex(firstContentfulPaint || firstPaint, paintBlocks);
145
155
  const timeToInteractive = interactiveWindowTickTime === null
146
- ? Math.max(interactiveWindowStartTime, firstContentfulPaint, performance.timing.domContentLoadedEventEnd - performance.timing.navigationStart ||
147
- 0)
156
+ ? Math.max(interactiveWindowStartTime, firstContentfulPaint, performance.timing.domContentLoadedEventEnd -
157
+ performance.timing.navigationStart || 0)
148
158
  : 0;
149
- app.send(PageRenderTiming(speedIndex, firstContentfulPaint > visuallyComplete ? firstContentfulPaint : visuallyComplete, timeToInteractive));
159
+ app.send(new PageRenderTiming(speedIndex, firstContentfulPaint > visuallyComplete
160
+ ? firstContentfulPaint
161
+ : visuallyComplete, timeToInteractive));
150
162
  }
151
163
  });
152
164
  }
@@ -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,4 +1,4 @@
1
- import { SetPageLocation, SetViewportSize, SetPageVisibility } from '../app/messages.gen.js';
1
+ import { SetPageLocation, SetViewportSize, SetPageVisibility, } from "../common/messages.js";
2
2
  export default function (app) {
3
3
  let url, width, height;
4
4
  let navigationStart = performance.timing.navigationStart;
@@ -6,7 +6,7 @@ export default function (app) {
6
6
  const { URL } = document;
7
7
  if (URL !== url) {
8
8
  url = URL;
9
- app.send(SetPageLocation(url, document.referrer, navigationStart));
9
+ app.send(new SetPageLocation(url, document.referrer, navigationStart));
10
10
  navigationStart = 0;
11
11
  }
12
12
  });
@@ -15,12 +15,12 @@ export default function (app) {
15
15
  if (innerWidth !== width || innerHeight !== height) {
16
16
  width = innerWidth;
17
17
  height = innerHeight;
18
- app.send(SetViewportSize(width, height));
18
+ app.send(new SetViewportSize(width, height));
19
19
  }
20
20
  });
21
21
  const sendSetPageVisibility = document.hidden === undefined
22
22
  ? Function.prototype
23
- : app.safe(() => app.send(SetPageVisibility(document.hidden)));
23
+ : app.safe(() => app.send(new SetPageVisibility(document.hidden)));
24
24
  app.attachStartCallback(() => {
25
25
  url = '';
26
26
  width = height = -1;
package/lib/utils.js CHANGED
@@ -11,25 +11,25 @@ export function normSpaces(str) {
11
11
  export function isURL(s) {
12
12
  return s.startsWith('https://') || s.startsWith('http://');
13
13
  }
14
- export const IN_BROWSER = !(typeof window === 'undefined');
14
+ export const IN_BROWSER = !(typeof window === "undefined");
15
15
  // TODO: JOIN IT WITH LOGGER somehow (use logging decorators?); Don't forget about index.js loggin when there is no logger instance.
16
16
  export const DOCS_HOST = 'https://docs.openreplay.com';
17
17
  const warnedFeatures = {};
18
- export function deprecationWarn(nameOfFeature, useInstead, docsPath = '/') {
18
+ export function deprecationWarn(nameOfFeature, useInstead, docsPath = "/") {
19
19
  if (warnedFeatures[nameOfFeature]) {
20
20
  return;
21
21
  }
22
- console.warn(`OpenReplay: ${nameOfFeature} is deprecated. ${useInstead ? `Please, use ${useInstead} instead.` : ''} Visit ${DOCS_HOST}${docsPath} for more information.`);
22
+ console.warn(`OpenReplay: ${nameOfFeature} is deprecated. ${useInstead ? `Please, use ${useInstead} instead.` : ""} Visit ${DOCS_HOST}${docsPath} for more information.`);
23
23
  warnedFeatures[nameOfFeature] = true;
24
24
  }
25
25
  export function getLabelAttribute(e) {
26
- let value = e.getAttribute('data-openreplay-label');
26
+ let value = e.getAttribute("data-openreplay-label");
27
27
  if (value !== null) {
28
28
  return value;
29
29
  }
30
- value = e.getAttribute('data-asayer-label');
30
+ value = e.getAttribute("data-asayer-label");
31
31
  if (value !== null) {
32
- deprecationWarn('"data-asayer-label" attribute', '"data-openreplay-label" attribute', '/');
32
+ deprecationWarn(`"data-asayer-label" attribute`, `"data-openreplay-label" attribute`, "/");
33
33
  }
34
34
  return value;
35
35
  }
@@ -40,7 +40,7 @@ export function hasOpenreplayAttribute(e, name) {
40
40
  }
41
41
  const oldName = `data-asayer-${name}`;
42
42
  if (e.hasAttribute(oldName)) {
43
- deprecationWarn(`"${oldName}" attribute`, `"${newName}" attribute`, '/installation/sanitize-data');
43
+ deprecationWarn(`"${oldName}" attribute`, `"${newName}" attribute`, "/installation/sanitize-data");
44
44
  return true;
45
45
  }
46
46
  return false;
@@ -8,10 +8,10 @@ let config;
8
8
  let rootDocument;
9
9
  export function finder(input, options) {
10
10
  if (input.nodeType !== Node.ELEMENT_NODE) {
11
- throw new Error("Can't generate CSS selector for non-element node type.");
11
+ throw new Error(`Can't generate CSS selector for non-element node type.`);
12
12
  }
13
- if ('html' === input.tagName.toLowerCase()) {
14
- return 'html';
13
+ if ("html" === input.tagName.toLowerCase()) {
14
+ return "html";
15
15
  }
16
16
  const defaults = {
17
17
  root: document.body,
@@ -35,7 +35,7 @@ export function finder(input, options) {
35
35
  return selector(path);
36
36
  }
37
37
  else {
38
- throw new Error('Selector was not found.');
38
+ throw new Error(`Selector was not found.`);
39
39
  }
40
40
  }
41
41
  function findRootDocument(rootNode, defaults) {
@@ -49,33 +49,30 @@ function findRootDocument(rootNode, defaults) {
49
49
  }
50
50
  function bottomUpSearch(input, limit, fallback) {
51
51
  let path = null;
52
- const stack = [];
52
+ let stack = [];
53
53
  let current = input;
54
54
  let i = 0;
55
55
  while (current && current !== config.root.parentElement) {
56
- let level = maybe(id(current)) ||
57
- maybe(...attr(current)) ||
58
- maybe(...classNames(current)) ||
59
- maybe(tagName(current)) || [any()];
56
+ let level = maybe(id(current)) || maybe(...attr(current)) || maybe(...classNames(current)) || maybe(tagName(current)) || [any()];
60
57
  const nth = index(current);
61
58
  if (limit === Limit.All) {
62
59
  if (nth) {
63
- level = level.concat(level.filter(dispensableNth).map((node) => nthChild(node, nth)));
60
+ level = level.concat(level.filter(dispensableNth).map(node => nthChild(node, nth)));
64
61
  }
65
62
  }
66
63
  else if (limit === Limit.Two) {
67
64
  level = level.slice(0, 1);
68
65
  if (nth) {
69
- level = level.concat(level.filter(dispensableNth).map((node) => nthChild(node, nth)));
66
+ level = level.concat(level.filter(dispensableNth).map(node => nthChild(node, nth)));
70
67
  }
71
68
  }
72
69
  else if (limit === Limit.One) {
73
- const [node] = (level = level.slice(0, 1));
70
+ const [node] = level = level.slice(0, 1);
74
71
  if (nth && dispensableNth(node)) {
75
72
  level = [nthChild(node, nth)];
76
73
  }
77
74
  }
78
- for (const node of level) {
75
+ for (let node of level) {
79
76
  node.level = i;
80
77
  }
81
78
  stack.push(level);
@@ -98,7 +95,7 @@ function findUniquePath(stack, fallback) {
98
95
  if (paths.length > config.threshold) {
99
96
  return fallback ? fallback() : null;
100
97
  }
101
- for (const candidate of paths) {
98
+ for (let candidate of paths) {
102
99
  if (unique(candidate)) {
103
100
  return candidate;
104
101
  }
@@ -121,7 +118,7 @@ function selector(path) {
121
118
  return query;
122
119
  }
123
120
  function penalty(path) {
124
- return path.map((node) => node.penalty).reduce((acc, i) => acc + i, 0);
121
+ return path.map(node => node.penalty).reduce((acc, i) => acc + i, 0);
125
122
  }
126
123
  function unique(path) {
127
124
  switch (rootDocument.querySelectorAll(selector(path)).length) {
@@ -134,10 +131,10 @@ function unique(path) {
134
131
  }
135
132
  }
136
133
  function id(input) {
137
- const elementId = input.getAttribute('id');
134
+ const elementId = input.getAttribute("id");
138
135
  if (elementId && config.idName(elementId)) {
139
136
  return {
140
- name: '#' + cssesc(elementId, { isIdentifier: true }),
137
+ name: "#" + cssesc(elementId, { isIdentifier: true }),
141
138
  penalty: 0,
142
139
  };
143
140
  }
@@ -146,15 +143,16 @@ function id(input) {
146
143
  function attr(input) {
147
144
  const attrs = Array.from(input.attributes).filter((attr) => config.attr(attr.name, attr.value));
148
145
  return attrs.map((attr) => ({
149
- name: '[' + cssesc(attr.name, { isIdentifier: true }) + '="' + cssesc(attr.value) + '"]',
150
- penalty: 0.5,
146
+ name: "[" + cssesc(attr.name, { isIdentifier: true }) + "=\"" + cssesc(attr.value) + "\"]",
147
+ penalty: 0.5
151
148
  }));
152
149
  }
153
150
  function classNames(input) {
154
- const names = Array.from(input.classList).filter(config.className);
151
+ const names = Array.from(input.classList)
152
+ .filter(config.className);
155
153
  return names.map((name) => ({
156
- name: '.' + cssesc(name, { isIdentifier: true }),
157
- penalty: 1,
154
+ name: "." + cssesc(name, { isIdentifier: true }),
155
+ penalty: 1
158
156
  }));
159
157
  }
160
158
  function tagName(input) {
@@ -162,15 +160,15 @@ function tagName(input) {
162
160
  if (config.tagName(name)) {
163
161
  return {
164
162
  name,
165
- penalty: 2,
163
+ penalty: 2
166
164
  };
167
165
  }
168
166
  return null;
169
167
  }
170
168
  function any() {
171
169
  return {
172
- name: '*',
173
- penalty: 3,
170
+ name: "*",
171
+ penalty: 3
174
172
  };
175
173
  }
176
174
  function index(input) {
@@ -197,11 +195,11 @@ function index(input) {
197
195
  function nthChild(node, i) {
198
196
  return {
199
197
  name: node.name + `:nth-child(${i})`,
200
- penalty: node.penalty + 1,
198
+ penalty: node.penalty + 1
201
199
  };
202
200
  }
203
201
  function dispensableNth(node) {
204
- return node.name !== 'html' && !node.name.startsWith('#');
202
+ return node.name !== "html" && !node.name.startsWith("#");
205
203
  }
206
204
  function maybe(...level) {
207
205
  const list = level.filter(notEmpty);
@@ -216,7 +214,7 @@ function notEmpty(value) {
216
214
  function combinations(stack, path = []) {
217
215
  const paths = [];
218
216
  if (stack.length > 0) {
219
- for (const node of stack[0]) {
217
+ for (let node of stack[0]) {
220
218
  paths.push(...combinations(stack.slice(1, stack.length), path.concat(node)));
221
219
  }
222
220
  }
@@ -230,7 +228,7 @@ function sort(paths) {
230
228
  }
231
229
  function optimize(path, input, scope = {
232
230
  counter: 0,
233
- visited: new Map(),
231
+ visited: new Map()
234
232
  }) {
235
233
  const paths = [];
236
234
  if (path.length > 2 && path.length > config.optimizedMinLength) {
@@ -261,20 +259,20 @@ const regexAnySingleEscape = /[ -,\.\/:-@\[-\^`\{-~]/;
261
259
  const regexSingleEscape = /[ -,\.\/:-@\[\]\^`\{-~]/;
262
260
  const regexExcessiveSpaces = /(^|\\+)?(\\[A-F0-9]{1,6})\x20(?![a-fA-F0-9\x20])/g;
263
261
  const defaultOptions = {
264
- escapeEverything: false,
265
- isIdentifier: false,
266
- quotes: 'single',
267
- wrap: false,
262
+ "escapeEverything": false,
263
+ "isIdentifier": false,
264
+ "quotes": "single",
265
+ "wrap": false
268
266
  };
269
267
  function cssesc(string, opt = {}) {
270
268
  const options = Object.assign(Object.assign({}, defaultOptions), opt);
271
- if (options.quotes != 'single' && options.quotes != 'double') {
272
- options.quotes = 'single';
269
+ if (options.quotes != "single" && options.quotes != "double") {
270
+ options.quotes = "single";
273
271
  }
274
- const quote = options.quotes == 'double' ? '"' : "'";
272
+ const quote = options.quotes == "double" ? "\"" : "'";
275
273
  const isIdentifier = options.isIdentifier;
276
274
  const firstChar = string.charAt(0);
277
- let output = '';
275
+ let output = "";
278
276
  let counter = 0;
279
277
  const length = string.length;
280
278
  while (counter < length) {
@@ -282,13 +280,13 @@ function cssesc(string, opt = {}) {
282
280
  let codePoint = character.charCodeAt(0);
283
281
  let value = void 0;
284
282
  // If it’s not a printable ASCII character…
285
- if (codePoint < 0x20 || codePoint > 0x7e) {
286
- if (codePoint >= 0xd800 && codePoint <= 0xdbff && counter < length) {
283
+ if (codePoint < 0x20 || codePoint > 0x7E) {
284
+ if (codePoint >= 0xD800 && codePoint <= 0xDBFF && counter < length) {
287
285
  // It’s a high surrogate, and there is a next character.
288
286
  const extra = string.charCodeAt(counter++);
289
- if ((extra & 0xfc00) == 0xdc00) {
287
+ if ((extra & 0xFC00) == 0xDC00) {
290
288
  // next character is low surrogate
291
- codePoint = ((codePoint & 0x3ff) << 10) + (extra & 0x3ff) + 0x10000;
289
+ codePoint = ((codePoint & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000;
292
290
  }
293
291
  else {
294
292
  // It’s an unmatched surrogate; only append this code unit, in case
@@ -296,25 +294,22 @@ function cssesc(string, opt = {}) {
296
294
  counter--;
297
295
  }
298
296
  }
299
- value = '\\' + codePoint.toString(16).toUpperCase() + ' ';
297
+ value = "\\" + codePoint.toString(16).toUpperCase() + " ";
300
298
  }
301
299
  else {
302
300
  if (options.escapeEverything) {
303
301
  if (regexAnySingleEscape.test(character)) {
304
- value = '\\' + character;
302
+ value = "\\" + character;
305
303
  }
306
304
  else {
307
- value = '\\' + codePoint.toString(16).toUpperCase() + ' ';
305
+ value = "\\" + codePoint.toString(16).toUpperCase() + " ";
308
306
  }
309
307
  }
310
308
  else if (/[\t\n\f\r\x0B]/.test(character)) {
311
- value = '\\' + codePoint.toString(16).toUpperCase() + ' ';
309
+ value = "\\" + codePoint.toString(16).toUpperCase() + " ";
312
310
  }
313
- else if (character == '\\' ||
314
- (!isIdentifier &&
315
- ((character == '"' && quote == character) || (character == "'" && quote == character))) ||
316
- (isIdentifier && regexSingleEscape.test(character))) {
317
- value = '\\' + character;
311
+ else if (character == "\\" || !isIdentifier && (character == "\"" && quote == character || character == "'" && quote == character) || isIdentifier && regexSingleEscape.test(character)) {
312
+ value = "\\" + character;
318
313
  }
319
314
  else {
320
315
  value = character;
@@ -324,10 +319,10 @@ function cssesc(string, opt = {}) {
324
319
  }
325
320
  if (isIdentifier) {
326
321
  if (/^-[-\d]/.test(output)) {
327
- output = '\\-' + output.slice(1);
322
+ output = "\\-" + output.slice(1);
328
323
  }
329
324
  else if (/\d/.test(firstChar)) {
330
- output = '\\3' + firstChar + ' ' + output.slice(1);
325
+ output = "\\3" + firstChar + " " + output.slice(1);
331
326
  }
332
327
  }
333
328
  // Remove spaces after `\HEX` escapes that are not followed by a hex digit,
@@ -339,7 +334,7 @@ function cssesc(string, opt = {}) {
339
334
  return $0;
340
335
  }
341
336
  // Strip the space.
342
- return ($1 || '') + $2;
337
+ return ($1 || "") + $2;
343
338
  });
344
339
  if (!isIdentifier && options.wrap) {
345
340
  return quote + output + quote;
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": "3.6.0-beta.0",
4
+ "version": "3.6.2",
5
5
  "keywords": [
6
6
  "logging",
7
7
  "replay"
@@ -14,50 +14,33 @@
14
14
  "type": "module",
15
15
  "main": "./lib/index.js",
16
16
  "scripts": {
17
- "lint": "eslint src --ext .ts,.js --fix --quiet",
17
+ "lint": "eslint src --ext .ts,.js --fix && tsc --noEmit",
18
18
  "clean": "rm -Rf build && rm -Rf lib && rm -Rf cjs",
19
- "tscRun": "tsc -b src/main && tsc -b src/webworker && tsc --project src/main/tsconfig-cjs.json",
19
+ "tsc": "tsc -b src/main && tsc -b src/webworker && tsc --project src/main/tsconfig-cjs.json",
20
20
  "rollup": "rollup --config rollup.config.js",
21
21
  "compile": "node --experimental-modules --experimental-json-modules scripts/compile.cjs",
22
- "build": "npm run clean && npm run tscRun && npm run rollup && npm run compile",
23
- "prepare": "cd ../../ && husky install tracker/.husky/",
24
- "lint-front": "lint-staged"
22
+ "build": "npm run clean && npm run tsc && npm run rollup && npm run compile",
23
+ "prepare": "node scripts/checkver.cjs && npm run build"
25
24
  },
26
25
  "devDependencies": {
27
26
  "@babel/core": "^7.10.2",
28
27
  "@rollup/plugin-babel": "^5.0.3",
29
28
  "@rollup/plugin-node-resolve": "^10.0.0",
30
- "@typescript-eslint/eslint-plugin": "^5.30.0",
31
- "@typescript-eslint/parser": "^5.30.0",
29
+ "@typescript-eslint/eslint-plugin": "^4.33.0",
30
+ "@typescript-eslint/parser": "^4.33.0",
32
31
  "eslint": "^7.8.0",
33
- "eslint-config-prettier": "^8.5.0",
34
- "eslint-plugin-prettier": "^4.2.1",
35
- "husky": "^8.0.1",
36
- "lint-staged": "^13.0.3",
37
- "prettier": "^2.7.1",
32
+ "eslint-plugin-prettier": "^4.1.4",
33
+ "prettier": "^2.0.0",
38
34
  "replace-in-files": "^2.0.3",
39
35
  "rollup": "^2.17.0",
40
36
  "rollup-plugin-terser": "^6.1.0",
41
37
  "semver": "^6.3.0",
42
- "typescript": "4.6.0-dev.20211126"
38
+ "typescript": "^4.6.0-dev.20211126"
43
39
  },
44
40
  "dependencies": {
45
41
  "error-stack-parser": "^2.0.6"
46
42
  },
47
43
  "engines": {
48
44
  "node": ">=14.0"
49
- },
50
- "husky": {
51
- "hooks": {
52
- "pre-commit": "sh lint.sh"
53
- }
54
- },
55
- "lint-staged": {
56
- "*.{js,mjs,jsx,ts,tsx}": [
57
- "eslint --fix --quiet"
58
- ],
59
- "*.{json,md,html,js,jsx,ts,tsx}": [
60
- "prettier --write"
61
- ]
62
45
  }
63
46
  }
package/.eslintignore DELETED
@@ -1,8 +0,0 @@
1
- node_modules
2
- npm-debug.log
3
- lib
4
- cjs
5
- build
6
- .cache
7
- .eslintrc.cjs
8
- *.gen.ts
package/.prettierignore DELETED
@@ -1 +0,0 @@
1
- *.gen.ts
@@ -1,52 +0,0 @@
1
- import * as Messages from '../common/messages.gen.js';
2
- export { default } from '../common/messages.gen.js';
3
- export declare function BatchMetadata(version: number, pageNo: number, firstIndex: number, timestamp: number, location: string): Messages.BatchMetadata;
4
- export declare function PartitionedMessage(partNo: number, partTotal: number): Messages.PartitionedMessage;
5
- export declare function Timestamp(timestamp: number): Messages.Timestamp;
6
- export declare function SetPageLocation(url: string, referrer: string, navigationStart: number): Messages.SetPageLocation;
7
- export declare function SetViewportSize(width: number, height: number): Messages.SetViewportSize;
8
- export declare function SetViewportScroll(x: number, y: number): Messages.SetViewportScroll;
9
- export declare function CreateDocument(): Messages.CreateDocument;
10
- export declare function CreateElementNode(id: number, parentID: number, index: number, tag: string, svg: boolean): Messages.CreateElementNode;
11
- export declare function CreateTextNode(id: number, parentID: number, index: number): Messages.CreateTextNode;
12
- export declare function MoveNode(id: number, parentID: number, index: number): Messages.MoveNode;
13
- export declare function RemoveNode(id: number): Messages.RemoveNode;
14
- export declare function SetNodeAttribute(id: number, name: string, value: string): Messages.SetNodeAttribute;
15
- export declare function RemoveNodeAttribute(id: number, name: string): Messages.RemoveNodeAttribute;
16
- export declare function SetNodeData(id: number, data: string): Messages.SetNodeData;
17
- export declare function SetNodeScroll(id: number, x: number, y: number): Messages.SetNodeScroll;
18
- export declare function SetInputTarget(id: number, label: string): Messages.SetInputTarget;
19
- export declare function SetInputValue(id: number, value: string, mask: number): Messages.SetInputValue;
20
- export declare function SetInputChecked(id: number, checked: boolean): Messages.SetInputChecked;
21
- export declare function MouseMove(x: number, y: number): Messages.MouseMove;
22
- export declare function ConsoleLog(level: string, value: string): Messages.ConsoleLog;
23
- export declare function PageLoadTiming(requestStart: number, responseStart: number, responseEnd: number, domContentLoadedEventStart: number, domContentLoadedEventEnd: number, loadEventStart: number, loadEventEnd: number, firstPaint: number, firstContentfulPaint: number): Messages.PageLoadTiming;
24
- export declare function PageRenderTiming(speedIndex: number, visuallyComplete: number, timeToInteractive: number): Messages.PageRenderTiming;
25
- export declare function JSException(name: string, message: string, payload: string): Messages.JSException;
26
- export declare function RawCustomEvent(name: string, payload: string): Messages.RawCustomEvent;
27
- export declare function UserID(id: string): Messages.UserID;
28
- export declare function UserAnonymousID(id: string): Messages.UserAnonymousID;
29
- export declare function Metadata(key: string, value: string): Messages.Metadata;
30
- export declare function CSSInsertRule(id: number, rule: string, index: number): Messages.CSSInsertRule;
31
- export declare function CSSDeleteRule(id: number, index: number): Messages.CSSDeleteRule;
32
- export declare function Fetch(method: string, url: string, request: string, response: string, status: number, timestamp: number, duration: number): Messages.Fetch;
33
- export declare function Profiler(name: string, duration: number, args: string, result: string): Messages.Profiler;
34
- export declare function OTable(key: string, value: string): Messages.OTable;
35
- export declare function StateAction(type: string): Messages.StateAction;
36
- export declare function Redux(action: string, state: string, duration: number): Messages.Redux;
37
- export declare function Vuex(mutation: string, state: string): Messages.Vuex;
38
- export declare function MobX(type: string, payload: string): Messages.MobX;
39
- export declare function NgRx(action: string, state: string, duration: number): Messages.NgRx;
40
- export declare function GraphQL(operationKind: string, operationName: string, variables: string, response: string): Messages.GraphQL;
41
- export declare function PerformanceTrack(frames: number, ticks: number, totalJSHeapSize: number, usedJSHeapSize: number): Messages.PerformanceTrack;
42
- export declare function ResourceTiming(timestamp: number, duration: number, ttfb: number, headerSize: number, encodedBodySize: number, decodedBodySize: number, url: string, initiator: string): Messages.ResourceTiming;
43
- export declare function ConnectionInformation(downlink: number, type: string): Messages.ConnectionInformation;
44
- export declare function SetPageVisibility(hidden: boolean): Messages.SetPageVisibility;
45
- export declare function LongTask(timestamp: number, duration: number, context: number, containerType: number, containerSrc: string, containerId: string, containerName: string): Messages.LongTask;
46
- export declare function SetNodeAttributeURLBased(id: number, name: string, value: string, baseURL: string): Messages.SetNodeAttributeURLBased;
47
- export declare function SetCSSDataURLBased(id: number, data: string, baseURL: string): Messages.SetCSSDataURLBased;
48
- export declare function TechnicalInfo(type: string, value: string): Messages.TechnicalInfo;
49
- export declare function CustomIssue(name: string, payload: string): Messages.CustomIssue;
50
- export declare function CSSInsertRuleURLBased(id: number, rule: string, index: number, baseURL: string): Messages.CSSInsertRuleURLBased;
51
- export declare function MouseClick(id: number, hesitationTime: number, label: string, selector: string): Messages.MouseClick;
52
- export declare function CreateIFrameDocument(frameID: number, id: number): Messages.CreateIFrameDocument;
@@ -1,57 +0,0 @@
1
- import * as Messages from '../common/messages.gen.js';
2
- export { default } from '../common/messages.gen.js';
3
- export declare function BatchMetadata(version: number, pageNo: number, firstIndex: number, timestamp: number, location: string): Messages.BatchMetadata;
4
- export declare function PartitionedMessage(partNo: number, partTotal: number): Messages.PartitionedMessage;
5
- export declare function Timestamp(timestamp: number): Messages.Timestamp;
6
- export declare function SetPageLocation(url: string, referrer: string, navigationStart: number): Messages.SetPageLocation;
7
- export declare function SetViewportSize(width: number, height: number): Messages.SetViewportSize;
8
- export declare function SetViewportScroll(x: number, y: number): Messages.SetViewportScroll;
9
- export declare function CreateDocument(): Messages.CreateDocument;
10
- export declare function CreateElementNode(id: number, parentID: number, index: number, tag: string, svg: boolean): Messages.CreateElementNode;
11
- export declare function CreateTextNode(id: number, parentID: number, index: number): Messages.CreateTextNode;
12
- export declare function MoveNode(id: number, parentID: number, index: number): Messages.MoveNode;
13
- export declare function RemoveNode(id: number): Messages.RemoveNode;
14
- export declare function SetNodeAttribute(id: number, name: string, value: string): Messages.SetNodeAttribute;
15
- export declare function RemoveNodeAttribute(id: number, name: string): Messages.RemoveNodeAttribute;
16
- export declare function SetNodeData(id: number, data: string): Messages.SetNodeData;
17
- export declare function SetNodeScroll(id: number, x: number, y: number): Messages.SetNodeScroll;
18
- export declare function SetInputTarget(id: number, label: string): Messages.SetInputTarget;
19
- export declare function SetInputValue(id: number, value: string, mask: number): Messages.SetInputValue;
20
- export declare function SetInputChecked(id: number, checked: boolean): Messages.SetInputChecked;
21
- export declare function MouseMove(x: number, y: number): Messages.MouseMove;
22
- export declare function ConsoleLog(level: string, value: string): Messages.ConsoleLog;
23
- export declare function PageLoadTiming(requestStart: number, responseStart: number, responseEnd: number, domContentLoadedEventStart: number, domContentLoadedEventEnd: number, loadEventStart: number, loadEventEnd: number, firstPaint: number, firstContentfulPaint: number): Messages.PageLoadTiming;
24
- export declare function PageRenderTiming(speedIndex: number, visuallyComplete: number, timeToInteractive: number): Messages.PageRenderTiming;
25
- export declare function JSException(name: string, message: string, payload: string): Messages.JSException;
26
- export declare function RawCustomEvent(name: string, payload: string): Messages.RawCustomEvent;
27
- export declare function UserID(id: string): Messages.UserID;
28
- export declare function UserAnonymousID(id: string): Messages.UserAnonymousID;
29
- export declare function Metadata(key: string, value: string): Messages.Metadata;
30
- export declare function CSSInsertRule(id: number, rule: string, index: number): Messages.CSSInsertRule;
31
- export declare function CSSDeleteRule(id: number, index: number): Messages.CSSDeleteRule;
32
- export declare function Fetch(method: string, url: string, request: string, response: string, status: number, timestamp: number, duration: number): Messages.Fetch;
33
- export declare function Profiler(name: string, duration: number, args: string, result: string): Messages.Profiler;
34
- export declare function OTable(key: string, value: string): Messages.OTable;
35
- export declare function StateAction(type: string): Messages.StateAction;
36
- export declare function Redux(action: string, state: string, duration: number): Messages.Redux;
37
- export declare function Vuex(mutation: string, state: string): Messages.Vuex;
38
- export declare function MobX(type: string, payload: string): Messages.MobX;
39
- export declare function NgRx(action: string, state: string, duration: number): Messages.NgRx;
40
- export declare function GraphQL(operationKind: string, operationName: string, variables: string, response: string): Messages.GraphQL;
41
- export declare function PerformanceTrack(frames: number, ticks: number, totalJSHeapSize: number, usedJSHeapSize: number): Messages.PerformanceTrack;
42
- export declare function ResourceTiming(timestamp: number, duration: number, ttfb: number, headerSize: number, encodedBodySize: number, decodedBodySize: number, url: string, initiator: string): Messages.ResourceTiming;
43
- export declare function ConnectionInformation(downlink: number, type: string): Messages.ConnectionInformation;
44
- export declare function SetPageVisibility(hidden: boolean): Messages.SetPageVisibility;
45
- export declare function LongTask(timestamp: number, duration: number, context: number, containerType: number, containerSrc: string, containerId: string, containerName: string): Messages.LongTask;
46
- export declare function SetNodeAttributeURLBased(id: number, name: string, value: string, baseURL: string): Messages.SetNodeAttributeURLBased;
47
- export declare function SetCSSDataURLBased(id: number, data: string, baseURL: string): Messages.SetCSSDataURLBased;
48
- export declare function TechnicalInfo(type: string, value: string): Messages.TechnicalInfo;
49
- export declare function CustomIssue(name: string, payload: string): Messages.CustomIssue;
50
- export declare function CSSInsertRuleURLBased(id: number, rule: string, index: number, baseURL: string): Messages.CSSInsertRuleURLBased;
51
- export declare function MouseClick(id: number, hesitationTime: number, label: string, selector: string): Messages.MouseClick;
52
- export declare function CreateIFrameDocument(frameID: number, id: number): Messages.CreateIFrameDocument;
53
- export declare function AdoptedSSReplaceURLBased(sheetID: number, text: string, baseURL: string): Messages.AdoptedSSReplaceURLBased;
54
- export declare function AdoptedSSInsertRuleURLBased(sheetID: number, rule: string, index: number, baseURL: string): Messages.AdoptedSSInsertRuleURLBased;
55
- export declare function AdoptedSSDeleteRule(sheetID: number, index: number): Messages.AdoptedSSDeleteRule;
56
- export declare function AdoptedSSAddOwner(sheetID: number, id: number): Messages.AdoptedSSAddOwner;
57
- export declare function AdoptedSSRemoveOwner(sheetID: number, id: number): Messages.AdoptedSSRemoveOwner;