@openreplay/tracker 3.6.2 → 4.0.1
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.
- package/.eslintignore +8 -0
- package/.prettierignore +1 -0
- package/LICENSE +1 -1
- package/cjs/app/guards.d.ts +2 -1
- package/cjs/app/guards.js +6 -3
- package/cjs/app/index.d.ts +28 -23
- package/cjs/app/index.js +107 -86
- package/cjs/app/logger.js +6 -3
- package/cjs/app/messages.d.ts +52 -0
- package/cjs/app/messages.gen.d.ts +58 -0
- package/cjs/app/messages.gen.js +501 -0
- package/cjs/app/messages.js +234 -0
- package/cjs/app/nodes.d.ts +1 -1
- package/cjs/app/nodes.js +2 -0
- package/cjs/app/observer/iframe_observer.d.ts +1 -1
- package/cjs/app/observer/iframe_observer.js +3 -3
- package/cjs/app/observer/observer.d.ts +2 -3
- package/cjs/app/observer/observer.js +50 -52
- package/cjs/app/observer/shadow_root_observer.d.ts +1 -1
- package/cjs/app/observer/shadow_root_observer.js +3 -3
- package/cjs/app/observer/top_observer.d.ts +13 -2
- package/cjs/app/observer/top_observer.js +58 -23
- package/cjs/app/sanitizer.d.ts +1 -1
- package/cjs/app/sanitizer.js +5 -5
- package/cjs/app/session.d.ts +20 -2
- package/cjs/app/session.js +65 -6
- package/cjs/app/ticker.d.ts +1 -1
- package/cjs/common/{webworker.d.ts → interaction.d.ts} +5 -5
- package/cjs/common/{types.js → interaction.js} +0 -0
- package/cjs/common/messages.gen.d.ts +388 -0
- package/cjs/common/{webworker.js → messages.gen.js} +1 -0
- package/cjs/index.d.ts +10 -9
- package/cjs/index.js +47 -36
- package/cjs/modules/adoptedStyleSheets.d.ts +2 -0
- package/cjs/modules/adoptedStyleSheets.js +127 -0
- package/cjs/modules/connection.d.ts +1 -1
- package/cjs/modules/connection.js +2 -2
- package/cjs/modules/console.d.ts +1 -1
- package/cjs/modules/console.js +7 -21
- package/cjs/modules/cssrules.d.ts +1 -1
- package/cjs/modules/cssrules.js +18 -14
- package/cjs/modules/exception.d.ts +3 -3
- package/cjs/modules/exception.js +23 -18
- package/cjs/modules/img.d.ts +1 -1
- package/cjs/modules/img.js +39 -26
- package/cjs/modules/input.d.ts +1 -1
- package/cjs/modules/input.js +21 -21
- package/cjs/modules/mouse.d.ts +1 -1
- package/cjs/modules/mouse.js +50 -43
- package/cjs/modules/performance.d.ts +1 -1
- package/cjs/modules/performance.js +2 -2
- package/cjs/modules/scroll.d.ts +1 -1
- package/cjs/modules/scroll.js +16 -7
- package/cjs/modules/timing.d.ts +1 -1
- package/cjs/modules/timing.js +14 -26
- package/cjs/modules/viewport.d.ts +1 -1
- package/cjs/modules/viewport.js +4 -4
- package/cjs/utils.js +7 -7
- package/cjs/vendors/finder/finder.js +53 -48
- package/lib/app/guards.d.ts +2 -1
- package/lib/app/guards.js +4 -2
- package/lib/app/index.d.ts +28 -23
- package/lib/app/index.js +115 -94
- package/lib/app/logger.js +6 -3
- package/lib/app/messages.d.ts +52 -0
- package/lib/app/messages.gen.d.ts +58 -0
- package/lib/app/messages.gen.js +441 -0
- package/lib/app/messages.js +181 -0
- package/lib/app/nodes.d.ts +1 -1
- package/lib/app/nodes.js +2 -0
- package/lib/app/observer/iframe_observer.d.ts +1 -1
- package/lib/app/observer/iframe_observer.js +3 -3
- package/lib/app/observer/observer.d.ts +2 -3
- package/lib/app/observer/observer.js +51 -53
- package/lib/app/observer/shadow_root_observer.d.ts +1 -1
- package/lib/app/observer/shadow_root_observer.js +3 -3
- package/lib/app/observer/top_observer.d.ts +13 -2
- package/lib/app/observer/top_observer.js +62 -27
- package/lib/app/sanitizer.d.ts +1 -1
- package/lib/app/sanitizer.js +7 -7
- package/lib/app/session.d.ts +20 -2
- package/lib/app/session.js +65 -6
- package/lib/app/ticker.d.ts +1 -1
- package/lib/common/{webworker.d.ts → interaction.d.ts} +5 -5
- package/lib/common/{types.js → interaction.js} +0 -0
- package/lib/common/messages.gen.d.ts +388 -0
- package/lib/common/messages.gen.js +2 -0
- package/lib/common/tsconfig.tsbuildinfo +1 -1
- package/lib/index.d.ts +10 -9
- package/lib/index.js +60 -49
- package/lib/modules/adoptedStyleSheets.d.ts +2 -0
- package/lib/modules/adoptedStyleSheets.js +124 -0
- package/lib/modules/connection.d.ts +1 -1
- package/lib/modules/connection.js +2 -2
- package/lib/modules/console.d.ts +1 -1
- package/lib/modules/console.js +8 -22
- package/lib/modules/cssrules.d.ts +1 -1
- package/lib/modules/cssrules.js +19 -15
- package/lib/modules/exception.d.ts +3 -3
- package/lib/modules/exception.js +23 -18
- package/lib/modules/img.d.ts +1 -1
- package/lib/modules/img.js +41 -28
- package/lib/modules/input.d.ts +1 -1
- package/lib/modules/input.js +23 -23
- package/lib/modules/mouse.d.ts +1 -1
- package/lib/modules/mouse.js +53 -46
- package/lib/modules/performance.d.ts +1 -1
- package/lib/modules/performance.js +3 -3
- package/lib/modules/scroll.d.ts +1 -1
- package/lib/modules/scroll.js +17 -8
- package/lib/modules/timing.d.ts +1 -1
- package/lib/modules/timing.js +16 -28
- package/lib/modules/viewport.d.ts +1 -1
- package/lib/modules/viewport.js +4 -4
- package/lib/utils.js +7 -7
- package/lib/vendors/finder/finder.js +53 -48
- package/package.json +27 -10
- package/cjs/common/messages.d.ts +0 -444
- package/cjs/common/messages.js +0 -794
- package/cjs/common/types.d.ts +0 -9
- package/cjs/modules/longtasks.d.ts +0 -2
- package/cjs/modules/longtasks.js +0 -26
- package/lib/common/messages.d.ts +0 -444
- package/lib/common/messages.js +0 -790
- package/lib/common/types.d.ts +0 -9
- package/lib/common/webworker.js +0 -1
- package/lib/modules/longtasks.d.ts +0 -2
- package/lib/modules/longtasks.js +0 -23
package/cjs/modules/mouse.js
CHANGED
|
@@ -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
|
|
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
|
|
16
|
-
.
|
|
17
|
-
.
|
|
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:
|
|
37
|
+
// MBTODO: intersept addEventListener
|
|
37
38
|
}
|
|
38
|
-
//TODO: fix (typescript
|
|
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,
|
|
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(
|
|
109
|
+
app.send((0, messages_gen_js_1.MouseMove)(mousePositionX, mousePositionY));
|
|
110
110
|
mousePositionChanged = false;
|
|
111
111
|
}
|
|
112
112
|
};
|
|
113
|
-
const
|
|
114
|
-
|
|
115
|
-
|
|
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
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
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;
|
|
@@ -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
|
|
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(
|
|
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(() => {
|
package/cjs/modules/scroll.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type App from
|
|
1
|
+
import type App from '../app/index.js';
|
|
2
2
|
export default function (app: App): void;
|
package/cjs/modules/scroll.js
CHANGED
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const
|
|
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
|
-
|
|
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(
|
|
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(
|
|
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
|
-
|
|
38
|
-
nodeScroll.set(target, [target.scrollLeft, target.scrollTop]);
|
|
39
|
-
}
|
|
48
|
+
setNodeScroll(target);
|
|
40
49
|
});
|
|
41
50
|
app.ticker.attach(() => {
|
|
42
51
|
if (documentScroll) {
|
package/cjs/modules/timing.d.ts
CHANGED
package/cjs/modules/timing.js
CHANGED
|
@@ -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
|
|
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,
|
|
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(
|
|
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) {
|
|
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(
|
|
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
|
-
|
|
148
|
+
? Math.max(interactiveWindowStartTime, firstContentfulPaint, performance.timing.domContentLoadedEventEnd - performance.timing.navigationStart ||
|
|
149
|
+
0)
|
|
160
150
|
: 0;
|
|
161
|
-
app.send(
|
|
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
|
|
1
|
+
import type App from '../app/index.js';
|
|
2
2
|
export default function (app: App): void;
|
package/cjs/modules/viewport.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const
|
|
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(
|
|
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(
|
|
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(
|
|
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 ===
|
|
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.` :
|
|
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(
|
|
33
|
+
let value = e.getAttribute('data-openreplay-label');
|
|
34
34
|
if (value !== null) {
|
|
35
35
|
return value;
|
|
36
36
|
}
|
|
37
|
-
value = e.getAttribute(
|
|
37
|
+
value = e.getAttribute('data-asayer-label');
|
|
38
38
|
if (value !== null) {
|
|
39
|
-
deprecationWarn(
|
|
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`,
|
|
51
|
+
deprecationWarn(`"${oldName}" attribute`, `"${newName}" attribute`, '/installation/sanitize-data');
|
|
52
52
|
return true;
|
|
53
53
|
}
|
|
54
54
|
return false;
|