@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
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
function isSVGElement(node) {
|
|
6
|
-
return node.namespaceURI === 'http://www.w3.org/2000/svg';
|
|
7
|
-
}
|
|
3
|
+
const messages_js_1 = require("../../common/messages.js");
|
|
4
|
+
const guards_js_1 = require("../guards.js");
|
|
8
5
|
function isIgnored(node) {
|
|
9
|
-
if ((0,
|
|
6
|
+
if ((0, guards_js_1.isTextNode)(node)) {
|
|
10
7
|
return false;
|
|
11
8
|
}
|
|
12
|
-
if (!(0,
|
|
9
|
+
if (!(0, guards_js_1.isElementNode)(node)) {
|
|
13
10
|
return true;
|
|
14
11
|
}
|
|
15
12
|
const tag = node.tagName.toUpperCase();
|
|
@@ -24,11 +21,8 @@ function isIgnored(node) {
|
|
|
24
21
|
tag === 'TITLE' ||
|
|
25
22
|
tag === 'BASE');
|
|
26
23
|
}
|
|
27
|
-
function isRootNode(node) {
|
|
28
|
-
return (0, context_js_1.isInstance)(node, Document) || (0, context_js_1.isInstance)(node, ShadowRoot);
|
|
29
|
-
}
|
|
30
24
|
function isObservable(node) {
|
|
31
|
-
if (isRootNode(node)) {
|
|
25
|
+
if ((0, guards_js_1.isRootNode)(node)) {
|
|
32
26
|
return true;
|
|
33
27
|
}
|
|
34
28
|
return !isIgnored(node);
|
|
@@ -38,20 +32,23 @@ class Observer {
|
|
|
38
32
|
this.app = app;
|
|
39
33
|
this.isTopContext = isTopContext;
|
|
40
34
|
this.commited = [];
|
|
41
|
-
this.recents = [];
|
|
42
|
-
this.myNodes = [];
|
|
43
35
|
this.indexes = [];
|
|
44
36
|
this.attributesList = [];
|
|
45
37
|
this.textSet = new Set();
|
|
38
|
+
this.newSet = new Set();
|
|
39
|
+
this.affectedSet = new Set();
|
|
46
40
|
this.observer = new MutationObserver(this.app.safe((mutations) => {
|
|
47
41
|
for (const mutation of mutations) {
|
|
48
42
|
const target = mutation.target;
|
|
49
43
|
const type = mutation.type;
|
|
50
|
-
if (!isObservable(target)
|
|
44
|
+
if (!isObservable(target) /*|| !inDocument() */) {
|
|
51
45
|
continue;
|
|
52
46
|
}
|
|
53
47
|
if (type === 'childList') {
|
|
54
48
|
for (let i = 0; i < mutation.removedNodes.length; i++) {
|
|
49
|
+
// TODO: handle node removal separately from binding.
|
|
50
|
+
// Node removals should go first in the commit.
|
|
51
|
+
// To check: MoveNode and other possible unbinding behaviours
|
|
55
52
|
this.bindTree(mutation.removedNodes[i]);
|
|
56
53
|
}
|
|
57
54
|
for (let i = 0; i < mutation.addedNodes.length; i++) {
|
|
@@ -63,9 +60,6 @@ class Observer {
|
|
|
63
60
|
if (id === undefined) {
|
|
64
61
|
continue;
|
|
65
62
|
}
|
|
66
|
-
if (id >= this.recents.length) { // TODO: something more convinient
|
|
67
|
-
this.recents[id] = undefined;
|
|
68
|
-
}
|
|
69
63
|
if (type === 'attributes') {
|
|
70
64
|
const name = mutation.attributeName;
|
|
71
65
|
if (name === null) {
|
|
@@ -76,10 +70,12 @@ class Observer {
|
|
|
76
70
|
this.attributesList[id] = attr = new Set();
|
|
77
71
|
}
|
|
78
72
|
attr.add(name);
|
|
73
|
+
this.affectedSet.add(id);
|
|
79
74
|
continue;
|
|
80
75
|
}
|
|
81
76
|
if (type === 'characterData') {
|
|
82
77
|
this.textSet.add(id);
|
|
78
|
+
this.affectedSet.add(id);
|
|
83
79
|
continue;
|
|
84
80
|
}
|
|
85
81
|
}
|
|
@@ -88,27 +84,28 @@ class Observer {
|
|
|
88
84
|
}
|
|
89
85
|
clear() {
|
|
90
86
|
this.commited.length = 0;
|
|
91
|
-
this.recents.length = 0;
|
|
92
87
|
this.indexes.length = 1;
|
|
93
88
|
this.attributesList.length = 0;
|
|
94
89
|
this.textSet.clear();
|
|
90
|
+
this.newSet.clear();
|
|
91
|
+
this.affectedSet.clear();
|
|
95
92
|
}
|
|
96
93
|
sendNodeAttribute(id, node, name, value) {
|
|
97
|
-
if (isSVGElement(node)) {
|
|
94
|
+
if ((0, guards_js_1.isSVGElement)(node)) {
|
|
98
95
|
if (name.substr(0, 6) === 'xlink:') {
|
|
99
96
|
name = name.substr(6);
|
|
100
97
|
}
|
|
101
98
|
if (value === null) {
|
|
102
|
-
this.app.send(new
|
|
99
|
+
this.app.send(new messages_js_1.RemoveNodeAttribute(id, name));
|
|
103
100
|
}
|
|
104
101
|
else if (name === 'href') {
|
|
105
102
|
if (value.length > 1e5) {
|
|
106
103
|
value = '';
|
|
107
104
|
}
|
|
108
|
-
this.app.send(new
|
|
105
|
+
this.app.send(new messages_js_1.SetNodeAttributeURLBased(id, name, value, this.app.getBaseHref()));
|
|
109
106
|
}
|
|
110
107
|
else {
|
|
111
|
-
this.app.send(new
|
|
108
|
+
this.app.send(new messages_js_1.SetNodeAttribute(id, name, value));
|
|
112
109
|
}
|
|
113
110
|
return;
|
|
114
111
|
}
|
|
@@ -121,38 +118,39 @@ class Observer {
|
|
|
121
118
|
return;
|
|
122
119
|
}
|
|
123
120
|
if (name === 'value' &&
|
|
124
|
-
(0,
|
|
121
|
+
(0, guards_js_1.hasTag)(node, "INPUT") &&
|
|
125
122
|
node.type !== 'button' &&
|
|
126
123
|
node.type !== 'reset' &&
|
|
127
124
|
node.type !== 'submit') {
|
|
128
125
|
return;
|
|
129
126
|
}
|
|
130
127
|
if (value === null) {
|
|
131
|
-
this.app.send(new
|
|
128
|
+
this.app.send(new messages_js_1.RemoveNodeAttribute(id, name));
|
|
132
129
|
return;
|
|
133
130
|
}
|
|
134
|
-
if (name === 'style' || name === 'href' && (0,
|
|
135
|
-
this.app.send(new
|
|
131
|
+
if (name === 'style' || name === 'href' && (0, guards_js_1.hasTag)(node, "LINK")) {
|
|
132
|
+
this.app.send(new messages_js_1.SetNodeAttributeURLBased(id, name, value, this.app.getBaseHref()));
|
|
136
133
|
return;
|
|
137
134
|
}
|
|
138
135
|
if (name === 'href' || value.length > 1e5) {
|
|
139
136
|
value = '';
|
|
140
137
|
}
|
|
141
|
-
this.app.send(new
|
|
138
|
+
this.app.send(new messages_js_1.SetNodeAttribute(id, name, value));
|
|
142
139
|
}
|
|
143
140
|
sendNodeData(id, parentElement, data) {
|
|
144
|
-
if ((0,
|
|
145
|
-
this.app.send(new
|
|
141
|
+
if ((0, guards_js_1.hasTag)(parentElement, "STYLE")) {
|
|
142
|
+
this.app.send(new messages_js_1.SetCSSDataURLBased(id, data, this.app.getBaseHref()));
|
|
146
143
|
return;
|
|
147
144
|
}
|
|
148
145
|
data = this.app.sanitizer.sanitize(id, data);
|
|
149
|
-
this.app.send(new
|
|
146
|
+
this.app.send(new messages_js_1.SetNodeData(id, data));
|
|
150
147
|
}
|
|
151
148
|
bindNode(node) {
|
|
152
|
-
const
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
149
|
+
const [id, isNew] = this.app.nodes.registerNode(node);
|
|
150
|
+
if (isNew) {
|
|
151
|
+
this.newSet.add(id);
|
|
152
|
+
}
|
|
153
|
+
this.affectedSet.add(id);
|
|
156
154
|
}
|
|
157
155
|
bindTree(node) {
|
|
158
156
|
if (!isObservable(node)) {
|
|
@@ -172,12 +170,13 @@ class Observer {
|
|
|
172
170
|
}
|
|
173
171
|
unbindNode(node) {
|
|
174
172
|
const id = this.app.nodes.unregisterNode(node);
|
|
175
|
-
if (id !== undefined && this.recents[id] === false) {
|
|
176
|
-
|
|
173
|
+
// if (id !== undefined && this.recents[id] === false) { // In the old version it === flase when bindNode() was called on node but it was not new
|
|
174
|
+
if (id !== undefined && !this.newSet.has(id) && this.affectedSet.has(id)) { // Unbinding logic should be simplified. Node removals should go first.
|
|
175
|
+
this.app.send(new messages_js_1.RemoveNode(id));
|
|
177
176
|
}
|
|
178
177
|
}
|
|
179
178
|
_commitNode(id, node) {
|
|
180
|
-
if (isRootNode(node)) {
|
|
179
|
+
if ((0, guards_js_1.isRootNode)(node)) {
|
|
181
180
|
return true;
|
|
182
181
|
}
|
|
183
182
|
const parent = node.parentNode;
|
|
@@ -185,7 +184,7 @@ class Observer {
|
|
|
185
184
|
// Disable parent check for the upper context HTMLHtmlElement, because it is root there... (before)
|
|
186
185
|
// TODO: get rid of "special" cases (there is an issue with CreateDocument altered behaviour though)
|
|
187
186
|
// TODO: Clean the logic (though now it workd fine)
|
|
188
|
-
if (!(0,
|
|
187
|
+
if (!(0, guards_js_1.hasTag)(node, "HTML") || !this.isTopContext) {
|
|
189
188
|
if (parent === null) {
|
|
190
189
|
this.unbindNode(node);
|
|
191
190
|
return false;
|
|
@@ -212,36 +211,37 @@ class Observer {
|
|
|
212
211
|
sibling = sibling.previousSibling;
|
|
213
212
|
}
|
|
214
213
|
if (sibling === null) {
|
|
215
|
-
this.indexes[id] = 0;
|
|
214
|
+
this.indexes[id] = 0;
|
|
216
215
|
}
|
|
217
|
-
const isNew = this.
|
|
216
|
+
const isNew = this.newSet.has(id);
|
|
218
217
|
const index = this.indexes[id];
|
|
219
218
|
if (index === undefined) {
|
|
220
219
|
throw 'commitNode: missing node index';
|
|
221
220
|
}
|
|
222
221
|
if (isNew === true) {
|
|
223
|
-
if ((0,
|
|
222
|
+
if ((0, guards_js_1.isElementNode)(node)) {
|
|
224
223
|
if (parentID !== undefined) {
|
|
225
|
-
this.app.send(new
|
|
224
|
+
this.app.send(new messages_js_1.CreateElementNode(id, parentID, index, node.tagName, (0, guards_js_1.isSVGElement)(node)));
|
|
226
225
|
}
|
|
227
226
|
for (let i = 0; i < node.attributes.length; i++) {
|
|
228
227
|
const attr = node.attributes[i];
|
|
229
228
|
this.sendNodeAttribute(id, node, attr.nodeName, attr.value);
|
|
230
229
|
}
|
|
231
230
|
}
|
|
232
|
-
else if ((0,
|
|
231
|
+
else if ((0, guards_js_1.isTextNode)(node)) {
|
|
233
232
|
// for text node id != 0, hence parentID !== undefined and parent is Element
|
|
234
|
-
this.app.send(new
|
|
233
|
+
this.app.send(new messages_js_1.CreateTextNode(id, parentID, index));
|
|
235
234
|
this.sendNodeData(id, parent, node.data);
|
|
236
235
|
}
|
|
237
236
|
return true;
|
|
238
237
|
}
|
|
239
238
|
if (isNew === false && parentID !== undefined) {
|
|
240
|
-
this
|
|
239
|
+
// does this happen a lot?
|
|
240
|
+
this.app.send(new messages_js_1.MoveNode(id, parentID, index));
|
|
241
241
|
}
|
|
242
242
|
const attr = this.attributesList[id];
|
|
243
243
|
if (attr !== undefined) {
|
|
244
|
-
if (!(0,
|
|
244
|
+
if (!(0, guards_js_1.isElementNode)(node)) {
|
|
245
245
|
throw 'commitNode: node is not an element';
|
|
246
246
|
}
|
|
247
247
|
for (const name of attr) {
|
|
@@ -249,7 +249,7 @@ class Observer {
|
|
|
249
249
|
}
|
|
250
250
|
}
|
|
251
251
|
if (this.textSet.has(id)) {
|
|
252
|
-
if (!(0,
|
|
252
|
+
if (!(0, guards_js_1.isTextNode)(node)) {
|
|
253
253
|
throw 'commitNode: node is not a text';
|
|
254
254
|
}
|
|
255
255
|
// for text node id != 0, hence parent is Element
|
|
@@ -270,19 +270,12 @@ class Observer {
|
|
|
270
270
|
}
|
|
271
271
|
commitNodes() {
|
|
272
272
|
let node;
|
|
273
|
-
|
|
274
|
-
// TODO: make things/logic nice here.
|
|
275
|
-
// commit required in any case if recents[id] true or false (in case of unbinding) or undefined (in case of attr change).
|
|
276
|
-
// Possible solution: separate new node commit (recents) and new attribute/move node commit
|
|
277
|
-
// Otherwise commitNode is called on each node, which might be a lot
|
|
278
|
-
if (!this.myNodes[id]) {
|
|
279
|
-
continue;
|
|
280
|
-
}
|
|
273
|
+
this.affectedSet.forEach(id => {
|
|
281
274
|
this.commitNode(id);
|
|
282
|
-
if (this.
|
|
275
|
+
if (this.newSet.has(id) && (node = this.app.nodes.getNode(id))) {
|
|
283
276
|
this.app.nodes.callNodeCallbacks(node);
|
|
284
277
|
}
|
|
285
|
-
}
|
|
278
|
+
});
|
|
286
279
|
this.clear();
|
|
287
280
|
}
|
|
288
281
|
// ISSSUE
|
|
@@ -302,7 +295,6 @@ class Observer {
|
|
|
302
295
|
disconnect() {
|
|
303
296
|
this.observer.disconnect();
|
|
304
297
|
this.clear();
|
|
305
|
-
this.myNodes.length = 0;
|
|
306
298
|
}
|
|
307
299
|
}
|
|
308
300
|
exports.default = Observer;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const observer_js_1 = require("./observer.js");
|
|
4
|
-
const
|
|
4
|
+
const messages_js_1 = require("../../common/messages.js");
|
|
5
5
|
class ShadowRootObserver extends observer_js_1.default {
|
|
6
6
|
observe(el) {
|
|
7
7
|
const shRoot = el.shadowRoot;
|
|
@@ -14,7 +14,7 @@ class ShadowRootObserver extends observer_js_1.default {
|
|
|
14
14
|
console.log("OpenReplay: Shadow Root was not bound");
|
|
15
15
|
return;
|
|
16
16
|
}
|
|
17
|
-
this.app.send((0,
|
|
17
|
+
this.app.send((0, messages_js_1.CreateIFrameDocument)(hostID, rootID));
|
|
18
18
|
});
|
|
19
19
|
}
|
|
20
20
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const observer_js_1 = require("./observer.js");
|
|
4
|
-
const
|
|
4
|
+
const guards_js_1 = require("../guards.js");
|
|
5
5
|
const iframe_observer_js_1 = require("./iframe_observer.js");
|
|
6
6
|
const shadow_root_observer_js_1 = require("./shadow_root_observer.js");
|
|
7
|
-
const
|
|
7
|
+
const messages_js_1 = require("../../common/messages.js");
|
|
8
8
|
const utils_js_1 = require("../../utils.js");
|
|
9
9
|
const attachShadowNativeFn = utils_js_1.IN_BROWSER ? Element.prototype.attachShadow : () => new ShadowRoot();
|
|
10
10
|
class TopObserver extends observer_js_1.default {
|
|
@@ -17,7 +17,7 @@ class TopObserver extends observer_js_1.default {
|
|
|
17
17
|
}, options);
|
|
18
18
|
// IFrames
|
|
19
19
|
this.app.nodes.attachNodeCallback(node => {
|
|
20
|
-
if ((0,
|
|
20
|
+
if ((0, guards_js_1.hasTag)(node, "IFRAME") &&
|
|
21
21
|
((this.options.captureIFrames && !(0, utils_js_1.hasOpenreplayAttribute)(node, "obscured"))
|
|
22
22
|
|| (0, utils_js_1.hasOpenreplayAttribute)(node, "capture"))) {
|
|
23
23
|
this.handleIframe(node);
|
|
@@ -25,7 +25,7 @@ class TopObserver extends observer_js_1.default {
|
|
|
25
25
|
});
|
|
26
26
|
// ShadowDOM
|
|
27
27
|
this.app.nodes.attachNodeCallback(node => {
|
|
28
|
-
if ((0,
|
|
28
|
+
if ((0, guards_js_1.isElementNode)(node) && node.shadowRoot !== null) {
|
|
29
29
|
this.handleShadowRoot(node.shadowRoot);
|
|
30
30
|
}
|
|
31
31
|
});
|
|
@@ -71,7 +71,7 @@ class TopObserver extends observer_js_1.default {
|
|
|
71
71
|
// the 0-node ("fRoot") will become #document rather than documentElement as it is now.
|
|
72
72
|
// Alternatively - observe(#document) then bindNode(documentElement)
|
|
73
73
|
this.observeRoot(window.document, () => {
|
|
74
|
-
this.app.send(new
|
|
74
|
+
this.app.send(new messages_js_1.CreateDocument());
|
|
75
75
|
}, window.document.documentElement);
|
|
76
76
|
}
|
|
77
77
|
disconnect() {
|
package/cjs/app/sanitizer.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
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 guards_js_1 = require("./guards.js");
|
|
5
5
|
class Sanitizer {
|
|
6
6
|
constructor(app, options) {
|
|
7
7
|
this.app = app;
|
|
@@ -13,7 +13,7 @@ class Sanitizer {
|
|
|
13
13
|
}
|
|
14
14
|
handleNode(id, parentID, node) {
|
|
15
15
|
if (this.masked.has(parentID) ||
|
|
16
|
-
((0,
|
|
16
|
+
((0, guards_js_1.isElementNode)(node) && (0, utils_js_1.hasOpenreplayAttribute)(node, 'masked'))) {
|
|
17
17
|
this.masked.add(id);
|
|
18
18
|
}
|
|
19
19
|
}
|
package/cjs/app/session.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
|
var ActivityState;
|
|
5
5
|
(function (ActivityState) {
|
|
6
6
|
ActivityState[ActivityState["NotActive"] = 0] = "NotActive";
|
|
@@ -42,11 +42,11 @@ class Session {
|
|
|
42
42
|
this.handleUpdate();
|
|
43
43
|
}
|
|
44
44
|
_setMetadata(key, value) {
|
|
45
|
-
this.app.send(new
|
|
45
|
+
this.app.send(new messages_js_1.Metadata(key, value));
|
|
46
46
|
this.metadata[key] = value;
|
|
47
47
|
}
|
|
48
48
|
_setUserID(userID) {
|
|
49
|
-
this.app.send(new
|
|
49
|
+
this.app.send(new messages_js_1.UserID(userID));
|
|
50
50
|
this.userID = userID;
|
|
51
51
|
}
|
|
52
52
|
setMetadata(key, value) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import Message from "./
|
|
2
|
-
|
|
1
|
+
import type { Writer, Message } from "./types.js";
|
|
2
|
+
export default Message;
|
|
3
3
|
export declare const classes: Map<number, Function>;
|
|
4
4
|
declare class _BatchMeta implements Message {
|
|
5
5
|
pageNo: number;
|
|
@@ -442,4 +442,3 @@ declare class _CreateIFrameDocument implements Message {
|
|
|
442
442
|
encode(writer: Writer): boolean;
|
|
443
443
|
}
|
|
444
444
|
export declare const CreateIFrameDocument: typeof _CreateIFrameDocument & ((frameID: number, id: number) => _CreateIFrameDocument);
|
|
445
|
-
export {};
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export interface Options {
|
|
2
|
+
connAttemptCount?: number;
|
|
3
|
+
connAttemptGap?: number;
|
|
4
|
+
}
|
|
5
|
+
declare type Start = {
|
|
6
|
+
type: "start";
|
|
7
|
+
ingestPoint: string;
|
|
8
|
+
pageNo: number;
|
|
9
|
+
timestamp: number;
|
|
10
|
+
} & Options;
|
|
11
|
+
declare type Auth = {
|
|
12
|
+
type: "auth";
|
|
13
|
+
token: string;
|
|
14
|
+
beaconSizeLimit?: number;
|
|
15
|
+
};
|
|
16
|
+
export declare type WorkerMessageData = null | "stop" | Start | Auth | Array<{
|
|
17
|
+
_id: number;
|
|
18
|
+
}>;
|
|
19
|
+
export {};
|
package/cjs/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import App from "./app/index.js";
|
|
2
2
|
export { default as App } from './app/index.js';
|
|
3
|
-
import * as _Messages from "./messages
|
|
3
|
+
import * as _Messages from "./common/messages.js";
|
|
4
4
|
export declare const Messages: typeof _Messages;
|
|
5
5
|
import type { Options as AppOptions } from "./app/index.js";
|
|
6
6
|
import type { Options as ConsoleOptions } from "./modules/console.js";
|
|
@@ -9,7 +9,7 @@ import type { Options as InputOptions } from "./modules/input.js";
|
|
|
9
9
|
import type { Options as PerformanceOptions } from "./modules/performance.js";
|
|
10
10
|
import type { Options as TimingOptions } from "./modules/timing.js";
|
|
11
11
|
import type { StartOptions } from './app/index.js';
|
|
12
|
-
import type {
|
|
12
|
+
import type { StartPromiseReturn } from './app/index.js';
|
|
13
13
|
export declare type Options = Partial<AppOptions & ConsoleOptions & ExceptionOptions & InputOptions & PerformanceOptions & TimingOptions> & {
|
|
14
14
|
projectID?: number;
|
|
15
15
|
projectKey: string;
|
|
@@ -24,7 +24,7 @@ export default class API {
|
|
|
24
24
|
constructor(options: Options);
|
|
25
25
|
use<T>(fn: (app: App | null, options?: Options) => T): T;
|
|
26
26
|
isActive(): boolean;
|
|
27
|
-
start(startOpts?: Partial<StartOptions>): Promise<
|
|
27
|
+
start(startOpts?: Partial<StartOptions>): Promise<StartPromiseReturn>;
|
|
28
28
|
stop(): void;
|
|
29
29
|
getSessionToken(): string | null | undefined;
|
|
30
30
|
getSessionID(): string | null | undefined;
|
package/cjs/index.js
CHANGED
|
@@ -4,8 +4,8 @@ exports.Messages = exports.App = void 0;
|
|
|
4
4
|
const index_js_1 = require("./app/index.js");
|
|
5
5
|
var index_js_2 = require("./app/index.js");
|
|
6
6
|
Object.defineProperty(exports, "App", { enumerable: true, get: function () { return index_js_2.default; } });
|
|
7
|
-
const
|
|
8
|
-
const _Messages = require("./messages
|
|
7
|
+
const messages_js_1 = require("./common/messages.js");
|
|
8
|
+
const _Messages = require("./common/messages.js");
|
|
9
9
|
exports.Messages = _Messages;
|
|
10
10
|
const connection_js_1 = require("./modules/connection.js");
|
|
11
11
|
const console_js_1 = require("./modules/console.js");
|
|
@@ -127,7 +127,7 @@ class API {
|
|
|
127
127
|
// no-cors issue only with text/plain or not-set Content-Type
|
|
128
128
|
// req.setRequestHeader("Content-Type", "application/json;charset=UTF-8");
|
|
129
129
|
req.send(JSON.stringify({
|
|
130
|
-
trackerVersion: '3.5.
|
|
130
|
+
trackerVersion: '3.5.13-beta.0',
|
|
131
131
|
projectKey: options.projectKey,
|
|
132
132
|
doNotTrack,
|
|
133
133
|
// TODO: add precise reason (an exact API missing)
|
|
@@ -187,7 +187,7 @@ class API {
|
|
|
187
187
|
}
|
|
188
188
|
setUserAnonymousID(id) {
|
|
189
189
|
if (typeof id === 'string' && this.app !== null) {
|
|
190
|
-
this.app.send(new
|
|
190
|
+
this.app.send(new messages_js_1.UserAnonymousID(id));
|
|
191
191
|
}
|
|
192
192
|
}
|
|
193
193
|
userAnonymousID(id) {
|
|
@@ -217,7 +217,7 @@ class API {
|
|
|
217
217
|
catch (e) {
|
|
218
218
|
return;
|
|
219
219
|
}
|
|
220
|
-
this.app.send(new
|
|
220
|
+
this.app.send(new messages_js_1.RawCustomEvent(key, payload));
|
|
221
221
|
}
|
|
222
222
|
}
|
|
223
223
|
}
|
|
@@ -229,7 +229,7 @@ class API {
|
|
|
229
229
|
catch (e) {
|
|
230
230
|
return;
|
|
231
231
|
}
|
|
232
|
-
this.app.send(new
|
|
232
|
+
this.app.send(new messages_js_1.CustomIssue(key, payload));
|
|
233
233
|
}
|
|
234
234
|
}
|
|
235
235
|
}
|
|
@@ -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
|
const connection = navigator.connection ||
|
|
6
6
|
navigator.mozConnection ||
|
|
@@ -8,7 +8,7 @@ function default_1(app) {
|
|
|
8
8
|
if (connection === undefined) {
|
|
9
9
|
return;
|
|
10
10
|
}
|
|
11
|
-
const sendConnectionInformation = () => app.send(new
|
|
11
|
+
const sendConnectionInformation = () => app.send(new messages_js_1.ConnectionInformation(Math.round(connection.downlink * 1000), connection.type || 'unknown'));
|
|
12
12
|
sendConnectionInformation();
|
|
13
13
|
connection.addEventListener('change', sendConnectionInformation);
|
|
14
14
|
}
|
package/cjs/modules/console.d.ts
CHANGED
package/cjs/modules/console.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 printError = utils_js_1.IN_BROWSER && 'InstallTrigger' in window // detect Firefox
|
|
6
7
|
? (e) => e.message + '\n' + e.stack
|
|
7
8
|
: (e) => e.stack || e.message;
|
|
@@ -92,7 +93,7 @@ function default_1(app, opts) {
|
|
|
92
93
|
options.consoleMethods.length === 0) {
|
|
93
94
|
return;
|
|
94
95
|
}
|
|
95
|
-
const sendConsoleLog = app.safe((level, args) => app.send(new
|
|
96
|
+
const sendConsoleLog = app.safe((level, args) => app.send(new messages_js_1.ConsoleLog(level, printf(args))));
|
|
96
97
|
let n;
|
|
97
98
|
const reset = () => {
|
|
98
99
|
n = 0;
|
|
@@ -115,7 +116,7 @@ function default_1(app, opts) {
|
|
|
115
116
|
});
|
|
116
117
|
patchConsole(window.console);
|
|
117
118
|
app.nodes.attachNodeCallback(app.safe(node => {
|
|
118
|
-
if (node
|
|
119
|
+
if ((0, guards_js_1.hasTag)(node, "IFRAME")) { // TODO: newContextCallback
|
|
119
120
|
let context = node.contentWindow;
|
|
120
121
|
if (context) {
|
|
121
122
|
patchConsole(context.console);
|
|
@@ -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 | null): void;
|
package/cjs/modules/cssrules.js
CHANGED
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const
|
|
3
|
+
const messages_js_1 = require("../common/messages.js");
|
|
4
|
+
const guards_js_1 = require("../app/guards.js");
|
|
4
5
|
function default_1(app) {
|
|
5
6
|
if (app === null) {
|
|
6
7
|
return;
|
|
7
8
|
}
|
|
8
9
|
if (!window.CSSStyleSheet) {
|
|
9
|
-
app.send(new
|
|
10
|
+
app.send(new messages_js_1.TechnicalInfo("no_stylesheet_prototype_in_window", ""));
|
|
10
11
|
return;
|
|
11
12
|
}
|
|
12
13
|
const processOperation = app.safe((stylesheet, index, rule) => {
|
|
13
14
|
const sendMessage = typeof rule === 'string'
|
|
14
|
-
? (nodeID) => app.send(new
|
|
15
|
-
: (nodeID) => app.send(new
|
|
15
|
+
? (nodeID) => app.send(new messages_js_1.CSSInsertRuleURLBased(nodeID, rule, index, app.getBaseHref()))
|
|
16
|
+
: (nodeID) => app.send(new messages_js_1.CSSDeleteRule(nodeID, index));
|
|
16
17
|
// TODO: Extend messages to maintain nested rules (CSSGroupingRule prototype, as well as CSSKeyframesRule)
|
|
17
18
|
if (stylesheet.ownerNode == null) {
|
|
18
19
|
throw new Error("Owner Node not found");
|
|
@@ -32,10 +33,7 @@ function default_1(app) {
|
|
|
32
33
|
return deleteRule.call(this, index);
|
|
33
34
|
};
|
|
34
35
|
app.nodes.attachNodeCallback((node) => {
|
|
35
|
-
if (!(node
|
|
36
|
-
return;
|
|
37
|
-
}
|
|
38
|
-
if (!(node.sheet instanceof CSSStyleSheet)) {
|
|
36
|
+
if (!(0, guards_js_1.hasTag)(node, "STYLE") || !node.sheet) {
|
|
39
37
|
return;
|
|
40
38
|
}
|
|
41
39
|
if (node.textContent !== null && node.textContent.trim().length > 0) {
|
package/cjs/modules/exception.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getExceptionMessageFromEvent = exports.getExceptionMessage = void 0;
|
|
4
|
-
const
|
|
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
7
|
return [{
|
|
@@ -19,7 +19,7 @@ function getExceptionMessage(error, fallbackStack) {
|
|
|
19
19
|
}
|
|
20
20
|
catch (e) {
|
|
21
21
|
}
|
|
22
|
-
return new
|
|
22
|
+
return new messages_js_1.JSException(error.name, error.message, JSON.stringify(stack));
|
|
23
23
|
}
|
|
24
24
|
exports.getExceptionMessage = getExceptionMessage;
|
|
25
25
|
function getExceptionMessageFromEvent(e) {
|
|
@@ -33,7 +33,7 @@ function getExceptionMessageFromEvent(e) {
|
|
|
33
33
|
name = 'Error';
|
|
34
34
|
message = e.message;
|
|
35
35
|
}
|
|
36
|
-
return new
|
|
36
|
+
return new messages_js_1.JSException(name, message, JSON.stringify(getDefaultStack(e)));
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
39
|
else if ('PromiseRejectionEvent' in window && e instanceof PromiseRejectionEvent) {
|
|
@@ -48,7 +48,7 @@ function getExceptionMessageFromEvent(e) {
|
|
|
48
48
|
catch (_) {
|
|
49
49
|
message = String(e.reason);
|
|
50
50
|
}
|
|
51
|
-
return new
|
|
51
|
+
return new messages_js_1.JSException('Unhandled Promise Rejection', message, '[]');
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
54
|
return null;
|
package/cjs/modules/img.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;
|