@openreplay/tracker 3.5.10 → 3.5.13-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -1
- package/cjs/app/guards.d.ts +17 -0
- package/cjs/app/guards.js +24 -0
- package/cjs/app/index.d.ts +19 -5
- package/cjs/app/index.js +37 -30
- package/cjs/app/nodes.d.ts +1 -1
- package/cjs/app/observer/iframe_observer.js +2 -2
- package/cjs/app/observer/observer.d.ts +2 -2
- package/cjs/app/observer/observer.js +50 -58
- package/cjs/app/observer/shadow_root_observer.js +2 -2
- package/cjs/app/observer/top_observer.js +5 -5
- package/cjs/app/sanitizer.js +2 -2
- package/cjs/app/session.js +3 -3
- package/{lib/messages/index.d.ts → cjs/common/messages.d.ts} +2 -3
- package/cjs/{messages/index.js → common/messages.js} +0 -0
- package/cjs/common/types.d.ts +9 -0
- package/cjs/{messages/message.js → common/types.js} +0 -0
- package/cjs/common/webworker.d.ts +19 -0
- package/cjs/common/webworker.js +2 -0
- package/cjs/index.d.ts +3 -3
- package/cjs/index.js +6 -6
- package/cjs/modules/connection.js +2 -2
- package/cjs/modules/console.d.ts +1 -1
- package/cjs/modules/console.js +4 -3
- package/cjs/modules/cssrules.d.ts +1 -1
- package/cjs/modules/cssrules.js +6 -8
- package/cjs/modules/exception.d.ts +2 -2
- package/cjs/modules/exception.js +4 -4
- package/cjs/modules/img.d.ts +1 -1
- package/cjs/modules/img.js +9 -8
- package/cjs/modules/input.d.ts +1 -1
- package/cjs/modules/input.js +18 -17
- package/cjs/modules/longtasks.d.ts +1 -1
- package/cjs/modules/longtasks.js +2 -2
- package/cjs/modules/mouse.d.ts +1 -1
- package/cjs/modules/mouse.js +6 -5
- 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 +8 -8
- package/cjs/modules/timing.d.ts +1 -1
- package/cjs/modules/timing.js +6 -5
- package/cjs/modules/viewport.d.ts +1 -1
- package/cjs/modules/viewport.js +4 -4
- package/lib/app/guards.d.ts +17 -0
- package/lib/app/guards.js +16 -0
- package/lib/app/index.d.ts +19 -5
- package/lib/app/index.js +33 -26
- package/lib/app/nodes.d.ts +1 -1
- package/lib/app/observer/iframe_observer.js +1 -1
- package/lib/app/observer/observer.d.ts +2 -2
- package/lib/app/observer/observer.js +35 -43
- package/lib/app/observer/shadow_root_observer.js +1 -1
- package/lib/app/observer/top_observer.js +4 -4
- package/lib/app/sanitizer.js +2 -2
- package/lib/app/session.js +1 -1
- package/{cjs/messages/index.d.ts → lib/common/messages.d.ts} +2 -3
- package/lib/{messages/index.js → common/messages.js} +0 -0
- package/lib/common/tsconfig.tsbuildinfo +1 -0
- package/lib/common/types.d.ts +9 -0
- package/lib/{messages/message.js → common/types.js} +0 -0
- package/lib/common/webworker.d.ts +19 -0
- package/lib/common/webworker.js +1 -0
- package/lib/index.d.ts +3 -3
- package/lib/index.js +3 -3
- package/lib/modules/connection.js +1 -1
- package/lib/modules/console.d.ts +1 -1
- package/lib/modules/console.js +3 -2
- package/lib/modules/cssrules.d.ts +1 -1
- package/lib/modules/cssrules.js +3 -5
- package/lib/modules/exception.d.ts +2 -2
- package/lib/modules/exception.js +1 -1
- package/lib/modules/img.d.ts +1 -1
- package/lib/modules/img.js +3 -2
- package/lib/modules/input.d.ts +1 -1
- package/lib/modules/input.js +14 -13
- package/lib/modules/longtasks.d.ts +1 -1
- package/lib/modules/longtasks.js +1 -1
- package/lib/modules/mouse.d.ts +1 -1
- package/lib/modules/mouse.js +4 -3
- package/lib/modules/performance.d.ts +1 -1
- package/lib/modules/performance.js +1 -1
- package/lib/modules/scroll.d.ts +1 -1
- package/lib/modules/scroll.js +6 -6
- package/lib/modules/timing.d.ts +1 -1
- package/lib/modules/timing.js +3 -2
- package/lib/modules/viewport.d.ts +1 -1
- package/lib/modules/viewport.js +1 -1
- package/package.json +1 -1
- package/cjs/app/context.d.ts +0 -18
- package/cjs/app/context.js +0 -73
- package/cjs/messages/message.d.ts +0 -4
- package/cjs/messages/writer.d.ts +0 -15
- package/cjs/messages/writer.js +0 -115
- package/lib/app/context.d.ts +0 -18
- package/lib/app/context.js +0 -68
- package/lib/messages/message.d.ts +0 -4
- package/lib/messages/tsconfig.tsbuildinfo +0 -1
- package/lib/messages/writer.d.ts +0 -15
- package/lib/messages/writer.js +0 -112
package/cjs/modules/img.js
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const utils_js_1 = require("../utils.js");
|
|
4
|
-
const
|
|
4
|
+
const messages_js_1 = require("../common/messages.js");
|
|
5
|
+
const guards_js_1 = require("../app/guards.js");
|
|
5
6
|
const PLACEHOLDER_SRC = "https://static.openreplay.com/tracker/placeholder.jpeg";
|
|
6
7
|
function default_1(app) {
|
|
7
8
|
function sendPlaceholder(id, node) {
|
|
8
|
-
app.send(new
|
|
9
|
+
app.send(new messages_js_1.SetNodeAttribute(id, "src", PLACEHOLDER_SRC));
|
|
9
10
|
const { width, height } = node.getBoundingClientRect();
|
|
10
11
|
if (!node.hasAttribute("width")) {
|
|
11
|
-
app.send(new
|
|
12
|
+
app.send(new messages_js_1.SetNodeAttribute(id, "width", String(width)));
|
|
12
13
|
}
|
|
13
14
|
if (!node.hasAttribute("height")) {
|
|
14
|
-
app.send(new
|
|
15
|
+
app.send(new messages_js_1.SetNodeAttribute(id, "height", String(height)));
|
|
15
16
|
}
|
|
16
17
|
}
|
|
17
18
|
const sendImgSrc = app.safe(function () {
|
|
@@ -25,14 +26,14 @@ function default_1(app) {
|
|
|
25
26
|
}
|
|
26
27
|
if (naturalWidth === 0 && naturalHeight === 0) {
|
|
27
28
|
if (src != null && (0, utils_js_1.isURL)(src)) { // TODO: How about relative urls ? Src type is null sometimes.
|
|
28
|
-
app.send(new
|
|
29
|
+
app.send(new messages_js_1.ResourceTiming((0, utils_js_1.timestamp)(), 0, 0, 0, 0, 0, src, 'img'));
|
|
29
30
|
}
|
|
30
31
|
}
|
|
31
32
|
else if (src.length >= 1e5 || app.sanitizer.isMasked(id)) {
|
|
32
33
|
sendPlaceholder(id, this);
|
|
33
34
|
}
|
|
34
35
|
else {
|
|
35
|
-
app.send(new
|
|
36
|
+
app.send(new messages_js_1.SetNodeAttributeURLBased(id, 'src', src, app.getBaseHref()));
|
|
36
37
|
}
|
|
37
38
|
});
|
|
38
39
|
const observer = new MutationObserver((mutations) => {
|
|
@@ -44,12 +45,12 @@ function default_1(app) {
|
|
|
44
45
|
return;
|
|
45
46
|
}
|
|
46
47
|
const src = target.src;
|
|
47
|
-
app.send(new
|
|
48
|
+
app.send(new messages_js_1.SetNodeAttributeURLBased(id, 'src', src, app.getBaseHref()));
|
|
48
49
|
}
|
|
49
50
|
}
|
|
50
51
|
});
|
|
51
52
|
app.nodes.attachNodeCallback((node) => {
|
|
52
|
-
if (!(node
|
|
53
|
+
if (!(0, guards_js_1.hasTag)(node, "IMG")) {
|
|
53
54
|
return;
|
|
54
55
|
}
|
|
55
56
|
app.nodes.attachElementListener('error', node, sendImgSrc);
|
package/cjs/modules/input.d.ts
CHANGED
package/cjs/modules/input.js
CHANGED
|
@@ -2,12 +2,13 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getInputLabel = void 0;
|
|
4
4
|
const utils_js_1 = require("../utils.js");
|
|
5
|
-
const
|
|
5
|
+
const guards_js_1 = require("../app/guards.js");
|
|
6
|
+
const messages_js_1 = require("../common/messages.js");
|
|
6
7
|
function isTextEditable(node) {
|
|
7
|
-
if (node
|
|
8
|
+
if ((0, guards_js_1.hasTag)(node, "TEXTAREA")) {
|
|
8
9
|
return true;
|
|
9
10
|
}
|
|
10
|
-
if (!(node
|
|
11
|
+
if (!(0, guards_js_1.hasTag)(node, "INPUT")) {
|
|
11
12
|
return false;
|
|
12
13
|
}
|
|
13
14
|
const type = node.type;
|
|
@@ -19,7 +20,7 @@ function isTextEditable(node) {
|
|
|
19
20
|
type === 'range');
|
|
20
21
|
}
|
|
21
22
|
function isCheckable(node) {
|
|
22
|
-
if (!(node
|
|
23
|
+
if (!(0, guards_js_1.hasTag)(node, "INPUT")) {
|
|
23
24
|
return false;
|
|
24
25
|
}
|
|
25
26
|
const type = node.type;
|
|
@@ -29,7 +30,7 @@ const labelElementFor = utils_js_1.IN_BROWSER && 'labels' in HTMLInputElement.pr
|
|
|
29
30
|
? (node) => {
|
|
30
31
|
let p = node;
|
|
31
32
|
while ((p = p.parentNode) !== null) {
|
|
32
|
-
if (p
|
|
33
|
+
if ((0, guards_js_1.hasTag)(p, "LABEL")) {
|
|
33
34
|
return p;
|
|
34
35
|
}
|
|
35
36
|
}
|
|
@@ -41,7 +42,7 @@ const labelElementFor = utils_js_1.IN_BROWSER && 'labels' in HTMLInputElement.pr
|
|
|
41
42
|
: (node) => {
|
|
42
43
|
let p = node;
|
|
43
44
|
while ((p = p.parentNode) !== null) {
|
|
44
|
-
if (p
|
|
45
|
+
if ((0, guards_js_1.hasTag)(p, "LABEL")) {
|
|
45
46
|
return p;
|
|
46
47
|
}
|
|
47
48
|
}
|
|
@@ -71,39 +72,39 @@ function default_1(app, opts) {
|
|
|
71
72
|
const options = Object.assign({
|
|
72
73
|
obscureInputNumbers: true,
|
|
73
74
|
obscureInputEmails: true,
|
|
74
|
-
defaultInputMode: 0 /* Plain */,
|
|
75
|
+
defaultInputMode: 0 /* InputMode.Plain */,
|
|
75
76
|
}, opts);
|
|
76
77
|
function sendInputTarget(id, node) {
|
|
77
78
|
const label = getInputLabel(node);
|
|
78
79
|
if (label !== '') {
|
|
79
|
-
app.send(new
|
|
80
|
+
app.send(new messages_js_1.SetInputTarget(id, label));
|
|
80
81
|
}
|
|
81
82
|
}
|
|
82
83
|
function sendInputValue(id, node) {
|
|
83
84
|
let value = node.value;
|
|
84
85
|
let inputMode = options.defaultInputMode;
|
|
85
86
|
if (node.type === 'password' || (0, utils_js_1.hasOpenreplayAttribute)(node, 'hidden')) {
|
|
86
|
-
inputMode = 2 /* Hidden */;
|
|
87
|
+
inputMode = 2 /* InputMode.Hidden */;
|
|
87
88
|
}
|
|
88
89
|
else if ((0, utils_js_1.hasOpenreplayAttribute)(node, 'obscured') ||
|
|
89
|
-
(inputMode === 0 /* Plain */ &&
|
|
90
|
+
(inputMode === 0 /* InputMode.Plain */ &&
|
|
90
91
|
((options.obscureInputNumbers && /\d\d\d\d/.test(value)) ||
|
|
91
92
|
(options.obscureInputEmails &&
|
|
92
93
|
(node.type === 'email' || !!~value.indexOf('@')))))) {
|
|
93
|
-
inputMode = 1 /* Obscured */;
|
|
94
|
+
inputMode = 1 /* InputMode.Obscured */;
|
|
94
95
|
}
|
|
95
96
|
let mask = 0;
|
|
96
97
|
switch (inputMode) {
|
|
97
|
-
case 2 /* Hidden */:
|
|
98
|
+
case 2 /* InputMode.Hidden */:
|
|
98
99
|
mask = -1;
|
|
99
100
|
value = '';
|
|
100
101
|
break;
|
|
101
|
-
case 1 /* Obscured */:
|
|
102
|
+
case 1 /* InputMode.Obscured */:
|
|
102
103
|
mask = value.length;
|
|
103
104
|
value = '';
|
|
104
105
|
break;
|
|
105
106
|
}
|
|
106
|
-
app.send(new
|
|
107
|
+
app.send(new messages_js_1.SetInputValue(id, value, mask));
|
|
107
108
|
}
|
|
108
109
|
const inputValues = new Map();
|
|
109
110
|
const checkableValues = new Map();
|
|
@@ -137,7 +138,7 @@ function default_1(app, opts) {
|
|
|
137
138
|
}
|
|
138
139
|
if (checked !== node.checked) {
|
|
139
140
|
checkableValues.set(id, node.checked);
|
|
140
|
-
app.send(new
|
|
141
|
+
app.send(new messages_js_1.SetInputChecked(id, node.checked));
|
|
141
142
|
}
|
|
142
143
|
});
|
|
143
144
|
});
|
|
@@ -148,7 +149,7 @@ function default_1(app, opts) {
|
|
|
148
149
|
return;
|
|
149
150
|
}
|
|
150
151
|
// TODO: support multiple select (?): use selectedOptions; Need send target?
|
|
151
|
-
if (node
|
|
152
|
+
if ((0, guards_js_1.hasTag)(node, "SELECT")) {
|
|
152
153
|
sendInputValue(id, node);
|
|
153
154
|
app.attachEventListener(node, "change", () => {
|
|
154
155
|
sendInputValue(id, node);
|
|
@@ -161,7 +162,7 @@ function default_1(app, opts) {
|
|
|
161
162
|
}
|
|
162
163
|
if (isCheckable(node)) {
|
|
163
164
|
checkableValues.set(id, node.checked);
|
|
164
|
-
app.send(new
|
|
165
|
+
app.send(new messages_js_1.SetInputChecked(id, node.checked));
|
|
165
166
|
return;
|
|
166
167
|
}
|
|
167
168
|
}));
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import App from "../app/index.js";
|
|
1
|
+
import type App from "../app/index.js";
|
|
2
2
|
export default function (app: App): void;
|
package/cjs/modules/longtasks.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const
|
|
3
|
+
const messages_js_1 = require("../common/messages.js");
|
|
4
4
|
;
|
|
5
5
|
;
|
|
6
6
|
function default_1(app) {
|
|
@@ -18,7 +18,7 @@ function default_1(app) {
|
|
|
18
18
|
id = container.containerId;
|
|
19
19
|
src = container.containerSrc;
|
|
20
20
|
}
|
|
21
|
-
app.send(new
|
|
21
|
+
app.send(new messages_js_1.LongTask(entry.startTime + performance.timing.navigationStart, entry.duration, Math.max(contexts.indexOf(entry.name), 0), Math.max(containerTypes.indexOf(type), 0), name, id, src));
|
|
22
22
|
}
|
|
23
23
|
const observer = new PerformanceObserver((list) => list.getEntries().forEach(longTask));
|
|
24
24
|
observer.observe({ entryTypes: ['longtask'] });
|
package/cjs/modules/mouse.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import App from "../app/index.js";
|
|
1
|
+
import type App from "../app/index.js";
|
|
2
2
|
export default function (app: App): void;
|
package/cjs/modules/mouse.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const guards_js_1 = require("../app/guards.js");
|
|
3
4
|
const utils_js_1 = require("../utils.js");
|
|
4
|
-
const
|
|
5
|
+
const messages_js_1 = require("../common/messages.js");
|
|
5
6
|
const input_js_1 = require("./input.js");
|
|
6
7
|
function _getSelector(target) {
|
|
7
8
|
let el = target;
|
|
@@ -49,7 +50,7 @@ function _getTarget(target) {
|
|
|
49
50
|
}
|
|
50
51
|
element = element.parentElement;
|
|
51
52
|
}
|
|
52
|
-
if (
|
|
53
|
+
if ((0, guards_js_1.isSVGElement)(target)) {
|
|
53
54
|
let owner = target.ownerSVGElement;
|
|
54
55
|
while (owner !== null) {
|
|
55
56
|
target = owner;
|
|
@@ -79,7 +80,7 @@ function default_1(app) {
|
|
|
79
80
|
if (dl !== null) {
|
|
80
81
|
return dl;
|
|
81
82
|
}
|
|
82
|
-
if (target
|
|
83
|
+
if ((0, guards_js_1.hasTag)(target, "INPUT")) {
|
|
83
84
|
return (0, input_js_1.getInputLabel)(target);
|
|
84
85
|
}
|
|
85
86
|
if (isClickable(target)) {
|
|
@@ -105,7 +106,7 @@ function default_1(app) {
|
|
|
105
106
|
});
|
|
106
107
|
const sendMouseMove = () => {
|
|
107
108
|
if (mousePositionChanged) {
|
|
108
|
-
app.send(new
|
|
109
|
+
app.send(new messages_js_1.MouseMove(mousePositionX, mousePositionY));
|
|
109
110
|
mousePositionChanged = false;
|
|
110
111
|
}
|
|
111
112
|
};
|
|
@@ -133,7 +134,7 @@ function default_1(app) {
|
|
|
133
134
|
const id = app.nodes.getID(target);
|
|
134
135
|
if (id !== undefined) {
|
|
135
136
|
sendMouseMove();
|
|
136
|
-
app.send(new
|
|
137
|
+
app.send(new messages_js_1.MouseClick(id, mouseTarget === target
|
|
137
138
|
? Math.round(performance.now() - mouseTargetTime)
|
|
138
139
|
: 0, getTargetLabel(target), getSelector(id, target)), true);
|
|
139
140
|
}
|
|
@@ -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_js_1 = require("../common/messages.js");
|
|
6
6
|
const perf = utils_js_1.IN_BROWSER && 'performance' in window && 'memory' in performance // works in Chrome only
|
|
7
7
|
? performance
|
|
8
8
|
: { memory: {} };
|
|
@@ -34,7 +34,7 @@ function default_1(app, opts) {
|
|
|
34
34
|
if (frames === undefined || ticks === undefined) {
|
|
35
35
|
return;
|
|
36
36
|
}
|
|
37
|
-
app.send(new
|
|
37
|
+
app.send(new messages_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 App from "../app/index.js";
|
|
1
|
+
import type App from "../app/index.js";
|
|
2
2
|
export default function (app: App): void;
|
package/cjs/modules/scroll.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const
|
|
3
|
+
const messages_js_1 = require("../common/messages.js");
|
|
4
4
|
function default_1(app) {
|
|
5
5
|
let documentScroll = false;
|
|
6
6
|
const nodeScroll = new Map();
|
|
7
|
-
const sendSetViewportScroll = app.safe(() => app.send(new
|
|
7
|
+
const sendSetViewportScroll = app.safe(() => app.send(new messages_js_1.SetViewportScroll(window.pageXOffset ||
|
|
8
8
|
(document.documentElement && document.documentElement.scrollLeft) ||
|
|
9
9
|
(document.body && document.body.scrollLeft) ||
|
|
10
10
|
0, window.pageYOffset ||
|
|
@@ -14,7 +14,7 @@ function default_1(app) {
|
|
|
14
14
|
const sendSetNodeScroll = app.safe((s, node) => {
|
|
15
15
|
const id = app.nodes.getID(node);
|
|
16
16
|
if (id !== undefined) {
|
|
17
|
-
app.send(new
|
|
17
|
+
app.send(new messages_js_1.SetNodeScroll(id, s[0], s[1]));
|
|
18
18
|
}
|
|
19
19
|
});
|
|
20
20
|
app.attachStartCallback(sendSetViewportScroll);
|
|
@@ -22,11 +22,11 @@ function default_1(app) {
|
|
|
22
22
|
documentScroll = false;
|
|
23
23
|
nodeScroll.clear();
|
|
24
24
|
});
|
|
25
|
-
app.nodes.attachNodeCallback(node => {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
})
|
|
25
|
+
// app.nodes.attachNodeCallback(node => {
|
|
26
|
+
// if (isElementNode(node) && node.scrollLeft + node.scrollTop > 0) {
|
|
27
|
+
// nodeScroll.set(node, [node.scrollLeft, node.scrollTop]);
|
|
28
|
+
// }
|
|
29
|
+
// })
|
|
30
30
|
app.attachEventListener(window, 'scroll', (e) => {
|
|
31
31
|
const target = e.target;
|
|
32
32
|
if (target === document) {
|
package/cjs/modules/timing.d.ts
CHANGED
package/cjs/modules/timing.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const guards_js_1 = require("../app/guards.js");
|
|
3
4
|
const utils_js_1 = require("../utils.js");
|
|
4
|
-
const
|
|
5
|
+
const messages_js_1 = require("../common/messages.js");
|
|
5
6
|
function getPaintBlocks(resources) {
|
|
6
7
|
const paintBlocks = [];
|
|
7
8
|
const elements = document.getElementsByTagName('*');
|
|
@@ -9,7 +10,7 @@ function getPaintBlocks(resources) {
|
|
|
9
10
|
for (let i = 0; i < elements.length; i++) {
|
|
10
11
|
const element = elements[i];
|
|
11
12
|
let src = '';
|
|
12
|
-
if (element
|
|
13
|
+
if ((0, guards_js_1.hasTag)(element, "IMG")) {
|
|
13
14
|
src = element.currentSrc || element.src;
|
|
14
15
|
}
|
|
15
16
|
if (!src) {
|
|
@@ -77,7 +78,7 @@ function default_1(app, opts) {
|
|
|
77
78
|
if (resources !== null) {
|
|
78
79
|
resources[entry.name] = entry.startTime + entry.duration;
|
|
79
80
|
}
|
|
80
|
-
app.send(new
|
|
81
|
+
app.send(new messages_js_1.ResourceTiming(entry.startTime + performance.timing.navigationStart, entry.duration, entry.responseStart && entry.startTime
|
|
81
82
|
? entry.responseStart - entry.startTime
|
|
82
83
|
: 0, entry.transferSize > entry.encodedBodySize
|
|
83
84
|
? entry.transferSize - entry.encodedBodySize
|
|
@@ -120,7 +121,7 @@ function default_1(app, opts) {
|
|
|
120
121
|
if (performance.timing.loadEventEnd || performance.now() > 30000) {
|
|
121
122
|
pageLoadTimingSent = true;
|
|
122
123
|
const { navigationStart, requestStart, responseStart, responseEnd, domContentLoadedEventStart, domContentLoadedEventEnd, loadEventStart, loadEventEnd, } = performance.timing;
|
|
123
|
-
app.send(new
|
|
124
|
+
app.send(new messages_js_1.PageLoadTiming(requestStart - navigationStart || 0, responseStart - navigationStart || 0, responseEnd - navigationStart || 0, domContentLoadedEventStart - navigationStart || 0, domContentLoadedEventEnd - navigationStart || 0, loadEventStart - navigationStart || 0, loadEventEnd - navigationStart || 0, firstPaint, firstContentfulPaint));
|
|
124
125
|
}
|
|
125
126
|
}, 30);
|
|
126
127
|
}
|
|
@@ -157,7 +158,7 @@ function default_1(app, opts) {
|
|
|
157
158
|
? Math.max(interactiveWindowStartTime, firstContentfulPaint, performance.timing.domContentLoadedEventEnd -
|
|
158
159
|
performance.timing.navigationStart || 0)
|
|
159
160
|
: 0;
|
|
160
|
-
app.send(new
|
|
161
|
+
app.send(new messages_js_1.PageRenderTiming(speedIndex, firstContentfulPaint > visuallyComplete
|
|
161
162
|
? firstContentfulPaint
|
|
162
163
|
: visuallyComplete, timeToInteractive));
|
|
163
164
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import App from "../app/index.js";
|
|
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_js_1 = require("../common/messages.js");
|
|
4
4
|
function default_1(app) {
|
|
5
5
|
let url, width, height;
|
|
6
6
|
let navigationStart = performance.timing.navigationStart;
|
|
@@ -8,7 +8,7 @@ function default_1(app) {
|
|
|
8
8
|
const { URL } = document;
|
|
9
9
|
if (URL !== url) {
|
|
10
10
|
url = URL;
|
|
11
|
-
app.send(new
|
|
11
|
+
app.send(new messages_js_1.SetPageLocation(url, document.referrer, navigationStart));
|
|
12
12
|
navigationStart = 0;
|
|
13
13
|
}
|
|
14
14
|
});
|
|
@@ -17,12 +17,12 @@ function default_1(app) {
|
|
|
17
17
|
if (innerWidth !== width || innerHeight !== height) {
|
|
18
18
|
width = innerWidth;
|
|
19
19
|
height = innerHeight;
|
|
20
|
-
app.send(new
|
|
20
|
+
app.send(new messages_js_1.SetViewportSize(width, height));
|
|
21
21
|
}
|
|
22
22
|
});
|
|
23
23
|
const sendSetPageVisibility = document.hidden === undefined
|
|
24
24
|
? Function.prototype
|
|
25
|
-
: app.safe(() => app.send(new
|
|
25
|
+
: app.safe(() => app.send(new messages_js_1.SetPageVisibility(document.hidden)));
|
|
26
26
|
app.attachStartCallback(() => {
|
|
27
27
|
url = '';
|
|
28
28
|
width = height = -1;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export declare function isSVGElement(node: Element): node is SVGElement;
|
|
2
|
+
export declare function isElementNode(node: Node): node is Element;
|
|
3
|
+
export declare function isTextNode(node: Node): node is Text;
|
|
4
|
+
export declare function isRootNode(node: Node): boolean;
|
|
5
|
+
declare type TagTypeMap = {
|
|
6
|
+
HTML: HTMLHtmlElement;
|
|
7
|
+
IMG: HTMLImageElement;
|
|
8
|
+
INPUT: HTMLInputElement;
|
|
9
|
+
TEXTAREA: HTMLTextAreaElement;
|
|
10
|
+
SELECT: HTMLSelectElement;
|
|
11
|
+
LABEL: HTMLLabelElement;
|
|
12
|
+
IFRAME: HTMLIFrameElement;
|
|
13
|
+
STYLE: HTMLStyleElement | SVGStyleElement;
|
|
14
|
+
LINK: HTMLLinkElement;
|
|
15
|
+
};
|
|
16
|
+
export declare function hasTag<T extends keyof TagTypeMap>(el: Node, tagName: T): el is TagTypeMap[typeof tagName];
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export function isSVGElement(node) {
|
|
2
|
+
return node.namespaceURI === 'http://www.w3.org/2000/svg';
|
|
3
|
+
}
|
|
4
|
+
export function isElementNode(node) {
|
|
5
|
+
return node.nodeType === Node.ELEMENT_NODE;
|
|
6
|
+
}
|
|
7
|
+
export function isTextNode(node) {
|
|
8
|
+
return node.nodeType === Node.TEXT_NODE;
|
|
9
|
+
}
|
|
10
|
+
export function isRootNode(node) {
|
|
11
|
+
return node.nodeType === Node.DOCUMENT_NODE ||
|
|
12
|
+
node.nodeType === Node.DOCUMENT_FRAGMENT_NODE;
|
|
13
|
+
}
|
|
14
|
+
export function hasTag(el, tagName) {
|
|
15
|
+
return el.nodeName.toUpperCase() === tagName;
|
|
16
|
+
}
|
package/lib/app/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import Message from "../messages
|
|
1
|
+
import type Message from "../common/messages.js";
|
|
2
2
|
import Nodes from "./nodes.js";
|
|
3
3
|
import Sanitizer from "./sanitizer.js";
|
|
4
4
|
import Ticker from "./ticker.js";
|
|
@@ -7,17 +7,28 @@ import Session from "./session.js";
|
|
|
7
7
|
import type { Options as ObserverOptions } from "./observer/top_observer.js";
|
|
8
8
|
import type { Options as SanitizerOptions } from "./sanitizer.js";
|
|
9
9
|
import type { Options as LoggerOptions } from "./logger.js";
|
|
10
|
-
import type { Options as WebworkerOptions } from "
|
|
10
|
+
import type { Options as WebworkerOptions } from "../common/webworker.js";
|
|
11
11
|
export interface StartOptions {
|
|
12
12
|
userID?: string;
|
|
13
13
|
metadata?: Record<string, string>;
|
|
14
14
|
forceNew?: boolean;
|
|
15
15
|
}
|
|
16
|
-
|
|
16
|
+
interface OnStartInfo {
|
|
17
17
|
sessionID: string;
|
|
18
18
|
sessionToken: string;
|
|
19
19
|
userUUID: string;
|
|
20
20
|
}
|
|
21
|
+
declare const CANCELED: "canceled";
|
|
22
|
+
declare type SuccessfulStart = OnStartInfo & {
|
|
23
|
+
success: true;
|
|
24
|
+
};
|
|
25
|
+
declare type UnsuccessfulStart = {
|
|
26
|
+
reason: typeof CANCELED | string;
|
|
27
|
+
success: false;
|
|
28
|
+
};
|
|
29
|
+
declare const UnsuccessfulStart: (reason: string) => UnsuccessfulStart;
|
|
30
|
+
declare const SuccessfulStart: (body: OnStartInfo) => SuccessfulStart;
|
|
31
|
+
export declare type StartPromiseReturn = SuccessfulStart | UnsuccessfulStart;
|
|
21
32
|
declare type StartCallback = (i: OnStartInfo) => void;
|
|
22
33
|
declare type CommitCallback = (messages: Array<Message>) => void;
|
|
23
34
|
declare type AppOptions = {
|
|
@@ -33,10 +44,11 @@ declare type AppOptions = {
|
|
|
33
44
|
__is_snippet: boolean;
|
|
34
45
|
__debug_report_edp: string | null;
|
|
35
46
|
__debug__?: LoggerOptions;
|
|
47
|
+
localStorage: Storage;
|
|
48
|
+
sessionStorage: Storage;
|
|
36
49
|
onStart?: StartCallback;
|
|
37
50
|
} & WebworkerOptions;
|
|
38
51
|
export declare type Options = AppOptions & ObserverOptions & SanitizerOptions;
|
|
39
|
-
export declare const CANCELED = "canceled";
|
|
40
52
|
export declare const DEFAULT_INGEST_POINT = "https://api.openreplay.com/ingest";
|
|
41
53
|
export default class App {
|
|
42
54
|
readonly nodes: Nodes;
|
|
@@ -46,6 +58,8 @@ export default class App {
|
|
|
46
58
|
readonly debug: Logger;
|
|
47
59
|
readonly notify: Logger;
|
|
48
60
|
readonly session: Session;
|
|
61
|
+
readonly localStorage: Storage;
|
|
62
|
+
readonly sessionStorage: Storage;
|
|
49
63
|
private readonly messages;
|
|
50
64
|
private readonly observer;
|
|
51
65
|
private readonly startCallbacks;
|
|
@@ -88,7 +102,7 @@ export default class App {
|
|
|
88
102
|
active(): boolean;
|
|
89
103
|
resetNextPageSession(flag: boolean): void;
|
|
90
104
|
private _start;
|
|
91
|
-
start(options?: StartOptions): Promise<
|
|
105
|
+
start(options?: StartOptions): Promise<StartPromiseReturn>;
|
|
92
106
|
stop(): void;
|
|
93
107
|
}
|
|
94
108
|
export {};
|