@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
package/cjs/index.js CHANGED
@@ -27,17 +27,18 @@ function processOptions(obj) {
27
27
  }
28
28
  if (typeof obj.projectKey !== 'string') {
29
29
  if (typeof obj.projectKey !== 'number') {
30
- if (typeof obj.projectID !== 'number') { // Back compatability
30
+ if (typeof obj.projectID !== 'number') {
31
+ // Back compatability
31
32
  console.error(`OpenReplay: projectKey is missing or wrong type (string is expected). Please, check ${utils_js_1.DOCS_HOST}${DOCS_SETUP} for more information.`);
32
33
  return false;
33
34
  }
34
35
  else {
35
36
  obj.projectKey = obj.projectID.toString();
36
- (0, utils_js_1.deprecationWarn)("`projectID` option", "`projectKey` option", DOCS_SETUP);
37
+ (0, utils_js_1.deprecationWarn)('`projectID` option', '`projectKey` option', DOCS_SETUP);
37
38
  }
38
39
  }
39
40
  else {
40
- console.warn("OpenReplay: projectKey is expected to have a string type.");
41
+ console.warn('OpenReplay: projectKey is expected to have a string type.');
41
42
  obj.projectKey = obj.projectKey.toString();
42
43
  }
43
44
  }
@@ -69,28 +70,29 @@ class API {
69
70
  return;
70
71
  }
71
72
  if (window.__OPENREPLAY__) {
72
- console.error("OpenReplay: one tracker instance has been initialised already");
73
+ console.error('OpenReplay: one tracker instance has been initialised already');
73
74
  return;
74
75
  }
75
76
  if (!options.__DISABLE_SECURE_MODE && location.protocol !== 'https:') {
76
- console.error("OpenReplay: Your website must be publicly accessible and running on SSL in order for OpenReplay to properly capture and replay the user session. You can disable this check by setting `__DISABLE_SECURE_MODE` option to `true` if you are testing in localhost. Keep in mind, that asset files on a local machine are not available to the outside world. This might affect tracking if you use css files.");
77
+ console.error('OpenReplay: Your website must be publicly accessible and running on SSL in order for OpenReplay to properly capture and replay the user session. You can disable this check by setting `__DISABLE_SECURE_MODE` option to `true` if you are testing in localhost. Keep in mind, that asset files on a local machine are not available to the outside world. This might affect tracking if you use css files.');
77
78
  return;
78
79
  }
79
80
  const doNotTrack = options.respectDoNotTrack &&
80
- (navigator.doNotTrack == '1'
81
+ (navigator.doNotTrack == '1' ||
81
82
  // @ts-ignore
82
- || window.doNotTrack == '1');
83
- const app = this.app = doNotTrack ||
84
- !('Map' in window) ||
85
- !('Set' in window) ||
86
- !('MutationObserver' in window) ||
87
- !('performance' in window) ||
88
- !('timing' in performance) ||
89
- !('startsWith' in String.prototype) ||
90
- !('Blob' in window) ||
91
- !('Worker' in window)
92
- ? null
93
- : new index_js_1.default(options.projectKey, options.sessionToken, options);
83
+ window.doNotTrack == '1');
84
+ const app = (this.app =
85
+ doNotTrack ||
86
+ !('Map' in window) ||
87
+ !('Set' in window) ||
88
+ !('MutationObserver' in window) ||
89
+ !('performance' in window) ||
90
+ !('timing' in performance) ||
91
+ !('startsWith' in String.prototype) ||
92
+ !('Blob' in window) ||
93
+ !('Worker' in window)
94
+ ? null
95
+ : new index_js_1.default(options.projectKey, options.sessionToken, options));
94
96
  if (app !== null) {
95
97
  (0, viewport_js_1.default)(app);
96
98
  (0, cssrules_js_1.default)(app);
@@ -123,11 +125,11 @@ class API {
123
125
  console.log("OpenReplay: browser doesn't support API required for tracking or doNotTrack is set to 1.");
124
126
  const req = new XMLHttpRequest();
125
127
  const orig = options.ingestPoint || index_js_1.DEFAULT_INGEST_POINT;
126
- req.open("POST", orig + "/v1/web/not-started");
128
+ req.open('POST', orig + '/v1/web/not-started');
127
129
  // no-cors issue only with text/plain or not-set Content-Type
128
130
  // req.setRequestHeader("Content-Type", "application/json;charset=UTF-8");
129
131
  req.send(JSON.stringify({
130
- trackerVersion: '3.6.3',
132
+ trackerVersion: '3.6.6',
131
133
  projectKey: options.projectKey,
132
134
  doNotTrack,
133
135
  // TODO: add precise reason (an exact API missing)
@@ -146,7 +148,7 @@ class API {
146
148
  start(startOpts) {
147
149
  if (!utils_js_1.IN_BROWSER) {
148
150
  console.error(`OpenReplay: you are trying to start Tracker on a node.js environment. If you want to use OpenReplay with SSR, please, use componentDidMount or useEffect API for placing the \`tracker.start()\` line. Check documentation on ${utils_js_1.DOCS_HOST}${DOCS_SETUP}`);
149
- return Promise.reject("Trying to start not in browser.");
151
+ return Promise.reject('Trying to start not in browser.');
150
152
  }
151
153
  if (this.app === null) {
152
154
  return Promise.reject("Browser doesn't support required api, or doNotTrack is active.");
@@ -173,16 +175,22 @@ class API {
173
175
  return this.app.getSessionID();
174
176
  }
175
177
  sessionID() {
176
- (0, utils_js_1.deprecationWarn)("'sessionID' method", "'getSessionID' method", "/");
178
+ (0, utils_js_1.deprecationWarn)("'sessionID' method", "'getSessionID' method", '/');
177
179
  return this.getSessionID();
178
180
  }
181
+ getSessionURL() {
182
+ if (this.app === null) {
183
+ return undefined;
184
+ }
185
+ return this.app.getSessionURL();
186
+ }
179
187
  setUserID(id) {
180
188
  if (typeof id === 'string' && this.app !== null) {
181
189
  this.app.session.setUserID(id);
182
190
  }
183
191
  }
184
192
  userID(id) {
185
- (0, utils_js_1.deprecationWarn)("'userID' method", "'setUserID' method", "/");
193
+ (0, utils_js_1.deprecationWarn)("'userID' method", "'setUserID' method", '/');
186
194
  this.setUserID(id);
187
195
  }
188
196
  setUserAnonymousID(id) {
@@ -191,18 +199,16 @@ class API {
191
199
  }
192
200
  }
193
201
  userAnonymousID(id) {
194
- (0, utils_js_1.deprecationWarn)("'userAnonymousID' method", "'setUserAnonymousID' method", "/");
202
+ (0, utils_js_1.deprecationWarn)("'userAnonymousID' method", "'setUserAnonymousID' method", '/');
195
203
  this.setUserAnonymousID(id);
196
204
  }
197
205
  setMetadata(key, value) {
198
- if (typeof key === 'string' &&
199
- typeof value === 'string' &&
200
- this.app !== null) {
206
+ if (typeof key === 'string' && typeof value === 'string' && this.app !== null) {
201
207
  this.app.session.setMetadata(key, value);
202
208
  }
203
209
  }
204
210
  metadata(key, value) {
205
- (0, utils_js_1.deprecationWarn)("'metadata' method", "'setMetadata' method", "/");
211
+ (0, utils_js_1.deprecationWarn)("'metadata' method", "'setMetadata' method", '/');
206
212
  this.setMetadata(key, value);
207
213
  }
208
214
  event(key, payload, issue = false) {
@@ -1,2 +1,2 @@
1
- import App from "../app/index.js";
1
+ import App from '../app/index.js';
2
2
  export default function (app: App): void;
@@ -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
  consoleMethods: Array<string> | null;
4
4
  consoleThrottling: number;
@@ -89,8 +89,7 @@ function default_1(app, opts) {
89
89
  consoleMethods,
90
90
  consoleThrottling: 30,
91
91
  }, opts);
92
- if (!Array.isArray(options.consoleMethods) ||
93
- options.consoleMethods.length === 0) {
92
+ if (!Array.isArray(options.consoleMethods) || options.consoleMethods.length === 0) {
94
93
  return;
95
94
  }
96
95
  const sendConsoleLog = app.safe((level, args) => app.send(new messages_js_1.ConsoleLog(level, printf(args))));
@@ -115,13 +114,14 @@ function default_1(app, opts) {
115
114
  };
116
115
  });
117
116
  patchConsole(window.console);
118
- app.nodes.attachNodeCallback(app.safe(node => {
119
- if ((0, guards_js_1.hasTag)(node, "IFRAME")) { // TODO: newContextCallback
117
+ app.nodes.attachNodeCallback(app.safe((node) => {
118
+ if ((0, guards_js_1.hasTag)(node, 'IFRAME')) {
119
+ // TODO: newContextCallback
120
120
  let context = node.contentWindow;
121
121
  if (context) {
122
122
  patchConsole(context.console);
123
123
  }
124
- app.attachEventListener(node, "load", () => {
124
+ app.attachEventListener(node, 'load', () => {
125
125
  if (node.contentWindow !== context) {
126
126
  context = node.contentWindow;
127
127
  patchConsole(context.console);
@@ -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 | null): void;
@@ -7,7 +7,7 @@ function default_1(app) {
7
7
  return;
8
8
  }
9
9
  if (!window.CSSStyleSheet) {
10
- app.send(new messages_js_1.TechnicalInfo("no_stylesheet_prototype_in_window", ""));
10
+ app.send(new messages_js_1.TechnicalInfo('no_stylesheet_prototype_in_window', ''));
11
11
  return;
12
12
  }
13
13
  const processOperation = app.safe((stylesheet, index, rule) => {
@@ -16,7 +16,7 @@ function default_1(app) {
16
16
  : (nodeID) => app.send(new messages_js_1.CSSDeleteRule(nodeID, index));
17
17
  // TODO: Extend messages to maintain nested rules (CSSGroupingRule prototype, as well as CSSKeyframesRule)
18
18
  if (stylesheet.ownerNode == null) {
19
- throw new Error("Owner Node not found");
19
+ throw new Error('Owner Node not found');
20
20
  }
21
21
  const nodeID = app.nodes.getID(stylesheet.ownerNode);
22
22
  if (nodeID !== undefined) {
@@ -33,7 +33,7 @@ function default_1(app) {
33
33
  return deleteRule.call(this, index);
34
34
  };
35
35
  app.nodes.attachNodeCallback((node) => {
36
- if (!(0, guards_js_1.hasTag)(node, "STYLE") || !node.sheet) {
36
+ if (!(0, guards_js_1.hasTag)(node, 'STYLE') || !node.sheet) {
37
37
  return;
38
38
  }
39
39
  if (node.textContent !== null && node.textContent.trim().length > 0) {
@@ -1,5 +1,5 @@
1
- import type App from "../app/index.js";
2
- import type Message from "../common/messages.js";
1
+ import type App from '../app/index.js';
2
+ import type Message from '../common/messages.js';
3
3
  export interface Options {
4
4
  captureExceptions: boolean;
5
5
  }
@@ -4,21 +4,22 @@ exports.getExceptionMessageFromEvent = exports.getExceptionMessage = void 0;
4
4
  const messages_js_1 = require("../common/messages.js");
5
5
  const error_stack_parser_1 = require("error-stack-parser");
6
6
  function getDefaultStack(e) {
7
- return [{
7
+ return [
8
+ {
8
9
  columnNumber: e.colno,
9
10
  lineNumber: e.lineno,
10
11
  fileName: e.filename,
11
- functionName: "",
12
- source: "",
13
- }];
12
+ functionName: '',
13
+ source: '',
14
+ },
15
+ ];
14
16
  }
15
17
  function getExceptionMessage(error, fallbackStack) {
16
18
  let stack = fallbackStack;
17
19
  try {
18
20
  stack = error_stack_parser_1.default.parse(error);
19
21
  }
20
- catch (e) {
21
- }
22
+ catch (e) { }
22
23
  return new messages_js_1.JSException(error.name, error.message, JSON.stringify(stack));
23
24
  }
24
25
  exports.getExceptionMessage = getExceptionMessage;
@@ -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;
@@ -18,16 +18,16 @@ function resolveURL(url, location = document.location) {
18
18
  return location.origin + location.pathname + url;
19
19
  }
20
20
  }
21
- const PLACEHOLDER_SRC = "https://static.openreplay.com/tracker/placeholder.jpeg";
21
+ const PLACEHOLDER_SRC = 'https://static.openreplay.com/tracker/placeholder.jpeg';
22
22
  function default_1(app) {
23
23
  function sendPlaceholder(id, node) {
24
- app.send(new messages_js_1.SetNodeAttribute(id, "src", PLACEHOLDER_SRC));
24
+ app.send(new messages_js_1.SetNodeAttribute(id, 'src', PLACEHOLDER_SRC));
25
25
  const { width, height } = node.getBoundingClientRect();
26
- if (!node.hasAttribute("width")) {
27
- app.send(new messages_js_1.SetNodeAttribute(id, "width", String(width)));
26
+ if (!node.hasAttribute('width')) {
27
+ app.send(new messages_js_1.SetNodeAttribute(id, 'width', String(width)));
28
28
  }
29
- if (!node.hasAttribute("height")) {
30
- app.send(new messages_js_1.SetNodeAttribute(id, "height", String(height)));
29
+ if (!node.hasAttribute('height')) {
30
+ app.send(new messages_js_1.SetNodeAttribute(id, 'height', String(height)));
31
31
  }
32
32
  }
33
33
  const sendImgSrc = app.safe(function () {
@@ -51,24 +51,27 @@ function default_1(app) {
51
51
  else {
52
52
  app.send(new messages_js_1.SetNodeAttribute(id, 'src', resolvedSrc));
53
53
  if (srcset) {
54
- const resolvedSrcset = srcset.split(',').map(str => resolveURL(str)).join(',');
54
+ const resolvedSrcset = srcset
55
+ .split(',')
56
+ .map((str) => resolveURL(str))
57
+ .join(',');
55
58
  app.send(new messages_js_1.SetNodeAttribute(id, 'srcset', resolvedSrcset));
56
59
  }
57
60
  }
58
61
  });
59
62
  const observer = new MutationObserver((mutations) => {
60
63
  for (const mutation of mutations) {
61
- if (mutation.type === "attributes") {
64
+ if (mutation.type === 'attributes') {
62
65
  const target = mutation.target;
63
66
  const id = app.nodes.getID(target);
64
67
  if (id === undefined) {
65
68
  return;
66
69
  }
67
- if (mutation.attributeName === "src") {
70
+ if (mutation.attributeName === 'src') {
68
71
  const src = target.src;
69
72
  app.send(new messages_js_1.SetNodeAttributeURLBased(id, 'src', src, app.getBaseHref()));
70
73
  }
71
- if (mutation.attributeName === "srcset") {
74
+ if (mutation.attributeName === 'srcset') {
72
75
  const srcset = target.srcset;
73
76
  app.send(new messages_js_1.SetNodeAttribute(id, 'srcset', srcset));
74
77
  }
@@ -76,13 +79,13 @@ function default_1(app) {
76
79
  }
77
80
  });
78
81
  app.nodes.attachNodeCallback((node) => {
79
- if (!(0, guards_js_1.hasTag)(node, "IMG")) {
82
+ if (!(0, guards_js_1.hasTag)(node, 'IMG')) {
80
83
  return;
81
84
  }
82
85
  app.nodes.attachElementListener('error', node, sendImgSrc);
83
86
  app.nodes.attachElementListener('load', node, sendImgSrc);
84
87
  sendImgSrc.call(node);
85
- observer.observe(node, { attributes: true, attributeFilter: ["src", "srcset"] });
88
+ observer.observe(node, { attributes: true, attributeFilter: ['src', 'srcset'] });
86
89
  });
87
90
  }
88
91
  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
  declare type TextEditableElement = HTMLInputElement | HTMLTextAreaElement;
3
3
  export declare function getInputLabel(node: TextEditableElement): string;
4
4
  export declare const enum InputMode {
@@ -6,16 +6,16 @@ const guards_js_1 = require("../app/guards.js");
6
6
  const messages_js_1 = require("../common/messages.js");
7
7
  const INPUT_TYPES = ['text', 'password', 'email', 'search', 'number', 'range', 'date'];
8
8
  function isTextEditable(node) {
9
- if ((0, guards_js_1.hasTag)(node, "TEXTAREA")) {
9
+ if ((0, guards_js_1.hasTag)(node, 'TEXTAREA')) {
10
10
  return true;
11
11
  }
12
- if (!(0, guards_js_1.hasTag)(node, "INPUT")) {
12
+ if (!(0, guards_js_1.hasTag)(node, 'INPUT')) {
13
13
  return false;
14
14
  }
15
15
  return INPUT_TYPES.includes(node.type);
16
16
  }
17
17
  function isCheckable(node) {
18
- if (!(0, guards_js_1.hasTag)(node, "INPUT")) {
18
+ if (!(0, guards_js_1.hasTag)(node, 'INPUT')) {
19
19
  return false;
20
20
  }
21
21
  const type = node.type;
@@ -25,7 +25,7 @@ const labelElementFor = utils_js_1.IN_BROWSER && 'labels' in HTMLInputElement.pr
25
25
  ? (node) => {
26
26
  let p = node;
27
27
  while ((p = p.parentNode) !== null) {
28
- if ((0, guards_js_1.hasTag)(p, "LABEL")) {
28
+ if ((0, guards_js_1.hasTag)(p, 'LABEL')) {
29
29
  return p;
30
30
  }
31
31
  }
@@ -37,7 +37,7 @@ const labelElementFor = utils_js_1.IN_BROWSER && 'labels' in HTMLInputElement.pr
37
37
  : (node) => {
38
38
  let p = node;
39
39
  while ((p = p.parentNode) !== null) {
40
- if ((0, guards_js_1.hasTag)(p, "LABEL")) {
40
+ if ((0, guards_js_1.hasTag)(p, 'LABEL')) {
41
41
  return p;
42
42
  }
43
43
  }
@@ -53,12 +53,13 @@ function getInputLabel(node) {
53
53
  let label = (0, utils_js_1.getLabelAttribute)(node);
54
54
  if (label === null) {
55
55
  const labelElement = labelElementFor(node);
56
- label = (labelElement && labelElement.innerText)
57
- || node.placeholder
58
- || node.name
59
- || node.id
60
- || node.className
61
- || node.type;
56
+ label =
57
+ (labelElement && labelElement.innerText) ||
58
+ node.placeholder ||
59
+ node.name ||
60
+ node.id ||
61
+ node.className ||
62
+ node.type;
62
63
  }
63
64
  return (0, utils_js_1.normSpaces)(label).slice(0, 100);
64
65
  }
@@ -86,8 +87,7 @@ function default_1(app, opts) {
86
87
  (inputMode === 0 /* Plain */ &&
87
88
  ((options.obscureInputNumbers && node.type !== 'date' && /\d\d\d\d/.test(value)) ||
88
89
  (options.obscureInputDates && node.type === 'date') ||
89
- (options.obscureInputEmails &&
90
- (node.type === 'email' || !!~value.indexOf('@')))))) {
90
+ (options.obscureInputEmails && (node.type === 'email' || !!~value.indexOf('@')))))) {
91
91
  inputMode = 1 /* Obscured */;
92
92
  }
93
93
  let mask = 0;
@@ -150,9 +150,9 @@ function default_1(app, opts) {
150
150
  return;
151
151
  }
152
152
  // TODO: support multiple select (?): use selectedOptions; Need send target?
153
- if ((0, guards_js_1.hasTag)(node, "SELECT")) {
153
+ if ((0, guards_js_1.hasTag)(node, 'SELECT')) {
154
154
  sendInputValue(id, node);
155
- app.attachEventListener(node, "change", () => {
155
+ app.attachEventListener(node, 'change', () => {
156
156
  sendInputValue(id, node);
157
157
  });
158
158
  }
@@ -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,16 +1,24 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const messages_js_1 = require("../common/messages.js");
4
- ;
5
- ;
6
4
  function default_1(app) {
7
5
  if (!('PerformanceObserver' in window) || !('PerformanceLongTaskTiming' in window)) {
8
6
  return;
9
7
  }
10
- const contexts = ["unknown", "self", "same-origin-ancestor", "same-origin-descendant", "same-origin", "cross-origin-ancestor", "cross-origin-descendant", "cross-origin-unreachable", "multiple-contexts"];
11
- const containerTypes = ["window", "iframe", "embed", "object"];
8
+ const contexts = [
9
+ 'unknown',
10
+ 'self',
11
+ 'same-origin-ancestor',
12
+ 'same-origin-descendant',
13
+ 'same-origin',
14
+ 'cross-origin-ancestor',
15
+ 'cross-origin-descendant',
16
+ 'cross-origin-unreachable',
17
+ 'multiple-contexts',
18
+ ];
19
+ const containerTypes = ['window', 'iframe', 'embed', 'object'];
12
20
  function longTask(entry) {
13
- let type = "", src = "", id = "", name = "";
21
+ let type = '', src = '', id = '', name = '';
14
22
  const container = entry.attribution[0];
15
23
  if (container != null) {
16
24
  type = container.containerType;
@@ -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;
@@ -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,12 +27,12 @@ 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
37
  // MBTODO: intersect addEventListener
37
38
  }
@@ -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)) {
@@ -112,7 +112,7 @@ function default_1(app) {
112
112
  };
113
113
  const selectorMap = {};
114
114
  function getSelector(id, target) {
115
- return selectorMap[id] = selectorMap[id] || _getSelector(target);
115
+ return (selectorMap[id] = selectorMap[id] || _getSelector(target));
116
116
  }
117
117
  app.attachEventListener(document.documentElement, 'mouseover', (e) => {
118
118
  const target = getTarget(e.target);
@@ -134,9 +134,7 @@ function default_1(app) {
134
134
  const id = app.nodes.getID(target);
135
135
  if (id !== undefined) {
136
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);
137
+ app.send(new messages_js_1.MouseClick(id, mouseTarget === target ? Math.round(performance.now() - mouseTargetTime) : 0, getTargetLabel(target), getSelector(id, target)), true);
140
138
  }
141
139
  mouseTarget = null;
142
140
  });
@@ -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 {
@@ -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 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;
@@ -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(new messages_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':
@@ -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(new messages_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;