@openreplay/tracker 3.6.1 → 3.6.5
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 +1 -1
- package/LICENSE +1 -1
- package/cjs/app/guards.d.ts +1 -2
- package/cjs/app/guards.js +1 -5
- package/cjs/app/index.d.ts +13 -16
- package/cjs/app/index.js +45 -47
- package/cjs/app/nodes.d.ts +1 -1
- package/cjs/app/nodes.js +0 -2
- package/cjs/app/observer/iframe_observer.js +2 -2
- package/cjs/app/observer/observer.js +13 -13
- package/cjs/app/observer/shadow_root_observer.js +2 -2
- package/cjs/app/observer/top_observer.d.ts +0 -11
- package/cjs/app/observer/top_observer.js +12 -46
- package/cjs/app/session.d.ts +0 -6
- package/cjs/app/session.js +0 -46
- package/cjs/common/messages.d.ts +444 -0
- package/cjs/common/messages.js +743 -0
- package/cjs/common/types.d.ts +9 -0
- package/cjs/common/{interaction.js → types.js} +0 -0
- package/cjs/common/{interaction.d.ts → webworker.d.ts} +3 -3
- package/cjs/common/{messages.gen.js → webworker.js} +0 -1
- package/cjs/index.d.ts +2 -2
- package/cjs/index.js +9 -14
- package/cjs/modules/connection.js +2 -2
- package/cjs/modules/console.js +20 -6
- package/cjs/modules/cssrules.js +12 -16
- package/cjs/modules/exception.d.ts +2 -2
- package/cjs/modules/exception.js +12 -16
- package/cjs/modules/img.js +21 -31
- package/cjs/modules/input.js +6 -6
- package/cjs/modules/longtasks.d.ts +2 -0
- package/cjs/modules/longtasks.js +34 -0
- package/cjs/modules/mouse.js +33 -42
- package/cjs/modules/performance.js +2 -2
- package/cjs/modules/scroll.js +7 -16
- package/cjs/modules/timing.js +4 -4
- package/cjs/modules/viewport.js +4 -4
- package/lib/app/guards.d.ts +1 -2
- package/lib/app/guards.js +0 -3
- package/lib/app/index.d.ts +13 -16
- package/lib/app/index.js +46 -48
- package/lib/app/nodes.d.ts +1 -1
- package/lib/app/nodes.js +0 -2
- package/lib/app/observer/iframe_observer.js +1 -1
- package/lib/app/observer/observer.js +12 -12
- package/lib/app/observer/shadow_root_observer.js +1 -1
- package/lib/app/observer/top_observer.d.ts +0 -11
- package/lib/app/observer/top_observer.js +12 -46
- package/lib/app/session.d.ts +0 -6
- package/lib/app/session.js +0 -46
- package/lib/common/messages.d.ts +444 -0
- package/lib/common/messages.js +739 -0
- package/lib/common/tsconfig.tsbuildinfo +1 -1
- package/lib/common/types.d.ts +9 -0
- package/lib/common/{interaction.js → types.js} +0 -0
- package/lib/common/{interaction.d.ts → webworker.d.ts} +3 -3
- package/lib/common/webworker.js +1 -0
- package/lib/index.d.ts +2 -2
- package/lib/index.js +9 -14
- package/lib/modules/connection.js +2 -2
- package/lib/modules/console.js +20 -6
- package/lib/modules/cssrules.js +12 -16
- package/lib/modules/exception.d.ts +2 -2
- package/lib/modules/exception.js +12 -16
- package/lib/modules/img.js +21 -31
- package/lib/modules/input.js +6 -6
- package/lib/modules/longtasks.d.ts +2 -0
- package/lib/modules/longtasks.js +31 -0
- package/lib/modules/mouse.js +34 -43
- package/lib/modules/performance.js +2 -2
- package/lib/modules/scroll.js +8 -17
- package/lib/modules/timing.js +4 -4
- package/lib/modules/viewport.js +4 -4
- package/package.json +4 -3
- package/.prettierignore +0 -1
- package/cjs/app/messages.d.ts +0 -52
- package/cjs/app/messages.gen.d.ts +0 -57
- package/cjs/app/messages.gen.js +0 -493
- package/cjs/app/messages.js +0 -234
- package/cjs/common/messages.gen.d.ts +0 -382
- package/cjs/modules/adoptedStyleSheets.d.ts +0 -2
- package/cjs/modules/adoptedStyleSheets.js +0 -127
- package/lib/app/messages.d.ts +0 -52
- package/lib/app/messages.gen.d.ts +0 -57
- package/lib/app/messages.gen.js +0 -434
- package/lib/app/messages.js +0 -181
- package/lib/common/messages.gen.d.ts +0 -382
- package/lib/common/messages.gen.js +0 -2
- package/lib/modules/adoptedStyleSheets.d.ts +0 -2
- package/lib/modules/adoptedStyleSheets.js +0 -124
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { RemoveNodeAttribute, SetNodeAttribute, SetNodeAttributeURLBased, SetCSSDataURLBased, SetNodeData, CreateTextNode, CreateElementNode, MoveNode, RemoveNode, } from '
|
|
1
|
+
import { RemoveNodeAttribute, SetNodeAttribute, SetNodeAttributeURLBased, SetCSSDataURLBased, SetNodeData, CreateTextNode, CreateElementNode, MoveNode, RemoveNode, } from '../../common/messages.js';
|
|
2
2
|
import { isRootNode, isTextNode, isElementNode, isSVGElement, hasTag } from '../guards.js';
|
|
3
3
|
function isIgnored(node) {
|
|
4
4
|
if (isTextNode(node)) {
|
|
@@ -101,16 +101,16 @@ export default class Observer {
|
|
|
101
101
|
name = name.substr(6);
|
|
102
102
|
}
|
|
103
103
|
if (value === null) {
|
|
104
|
-
this.app.send(RemoveNodeAttribute(id, name));
|
|
104
|
+
this.app.send(new RemoveNodeAttribute(id, name));
|
|
105
105
|
}
|
|
106
106
|
else if (name === 'href') {
|
|
107
107
|
if (value.length > 1e5) {
|
|
108
108
|
value = '';
|
|
109
109
|
}
|
|
110
|
-
this.app.send(SetNodeAttributeURLBased(id, name, value, this.app.getBaseHref()));
|
|
110
|
+
this.app.send(new SetNodeAttributeURLBased(id, name, value, this.app.getBaseHref()));
|
|
111
111
|
}
|
|
112
112
|
else {
|
|
113
|
-
this.app.send(SetNodeAttribute(id, name, value));
|
|
113
|
+
this.app.send(new SetNodeAttribute(id, name, value));
|
|
114
114
|
}
|
|
115
115
|
return;
|
|
116
116
|
}
|
|
@@ -130,25 +130,25 @@ export default class Observer {
|
|
|
130
130
|
return;
|
|
131
131
|
}
|
|
132
132
|
if (value === null) {
|
|
133
|
-
this.app.send(RemoveNodeAttribute(id, name));
|
|
133
|
+
this.app.send(new RemoveNodeAttribute(id, name));
|
|
134
134
|
return;
|
|
135
135
|
}
|
|
136
136
|
if (name === 'style' || (name === 'href' && hasTag(node, 'LINK'))) {
|
|
137
|
-
this.app.send(SetNodeAttributeURLBased(id, name, value, this.app.getBaseHref()));
|
|
137
|
+
this.app.send(new SetNodeAttributeURLBased(id, name, value, this.app.getBaseHref()));
|
|
138
138
|
return;
|
|
139
139
|
}
|
|
140
140
|
if (name === 'href' || value.length > 1e5) {
|
|
141
141
|
value = '';
|
|
142
142
|
}
|
|
143
|
-
this.app.send(SetNodeAttribute(id, name, value));
|
|
143
|
+
this.app.send(new SetNodeAttribute(id, name, value));
|
|
144
144
|
}
|
|
145
145
|
sendNodeData(id, parentElement, data) {
|
|
146
146
|
if (hasTag(parentElement, 'STYLE') || hasTag(parentElement, 'style')) {
|
|
147
|
-
this.app.send(SetCSSDataURLBased(id, data, this.app.getBaseHref()));
|
|
147
|
+
this.app.send(new SetCSSDataURLBased(id, data, this.app.getBaseHref()));
|
|
148
148
|
return;
|
|
149
149
|
}
|
|
150
150
|
data = this.app.sanitizer.sanitize(id, data);
|
|
151
|
-
this.app.send(SetNodeData(id, data));
|
|
151
|
+
this.app.send(new SetNodeData(id, data));
|
|
152
152
|
}
|
|
153
153
|
bindNode(node) {
|
|
154
154
|
const [id, isNew] = this.app.nodes.registerNode(node);
|
|
@@ -256,7 +256,7 @@ export default class Observer {
|
|
|
256
256
|
el.style.width = width + 'px';
|
|
257
257
|
el.style.height = height + 'px';
|
|
258
258
|
}
|
|
259
|
-
this.app.send(CreateElementNode(id, parentID, index, el.tagName, isSVGElement(node)));
|
|
259
|
+
this.app.send(new CreateElementNode(id, parentID, index, el.tagName, isSVGElement(node)));
|
|
260
260
|
}
|
|
261
261
|
for (let i = 0; i < el.attributes.length; i++) {
|
|
262
262
|
const attr = el.attributes[i];
|
|
@@ -265,13 +265,13 @@ export default class Observer {
|
|
|
265
265
|
}
|
|
266
266
|
else if (isTextNode(node)) {
|
|
267
267
|
// for text node id != 0, hence parentID !== undefined and parent is Element
|
|
268
|
-
this.app.send(CreateTextNode(id, parentID, index));
|
|
268
|
+
this.app.send(new CreateTextNode(id, parentID, index));
|
|
269
269
|
this.sendNodeData(id, parent, node.data);
|
|
270
270
|
}
|
|
271
271
|
return true;
|
|
272
272
|
}
|
|
273
273
|
if (recentsType === RecentsType.Removed && parentID !== undefined) {
|
|
274
|
-
this.app.send(MoveNode(id, parentID, index));
|
|
274
|
+
this.app.send(new MoveNode(id, parentID, index));
|
|
275
275
|
}
|
|
276
276
|
const attr = this.attributesMap.get(id);
|
|
277
277
|
if (attr !== undefined) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import Observer from './observer.js';
|
|
2
|
-
import { CreateIFrameDocument } from '
|
|
2
|
+
import { CreateIFrameDocument } from '../../common/messages.js';
|
|
3
3
|
export default class ShadowRootObserver extends Observer {
|
|
4
4
|
observe(el) {
|
|
5
5
|
const shRoot = el.shadowRoot;
|
|
@@ -3,19 +3,9 @@ import App from '../index.js';
|
|
|
3
3
|
export interface Options {
|
|
4
4
|
captureIFrames: boolean;
|
|
5
5
|
}
|
|
6
|
-
declare type Context = Window & typeof globalThis;
|
|
7
|
-
declare type ContextCallback = (context: Context) => void;
|
|
8
|
-
declare type Offset = {
|
|
9
|
-
top: number;
|
|
10
|
-
left: number;
|
|
11
|
-
};
|
|
12
6
|
export default class TopObserver extends Observer {
|
|
13
7
|
private readonly options;
|
|
14
8
|
constructor(app: App, options: Partial<Options>);
|
|
15
|
-
private readonly contextCallbacks;
|
|
16
|
-
private readonly contextsSet;
|
|
17
|
-
attachContextCallback(cb: ContextCallback): void;
|
|
18
|
-
getDocumentOffset(doc: Document): Offset;
|
|
19
9
|
private iframeObservers;
|
|
20
10
|
private handleIframe;
|
|
21
11
|
private shadowRootObservers;
|
|
@@ -23,4 +13,3 @@ export default class TopObserver extends Observer {
|
|
|
23
13
|
observe(): void;
|
|
24
14
|
disconnect(): void;
|
|
25
15
|
}
|
|
26
|
-
export {};
|
|
@@ -2,19 +2,12 @@ import Observer from './observer.js';
|
|
|
2
2
|
import { isElementNode, hasTag } from '../guards.js';
|
|
3
3
|
import IFrameObserver from './iframe_observer.js';
|
|
4
4
|
import ShadowRootObserver from './shadow_root_observer.js';
|
|
5
|
-
import { CreateDocument } from '
|
|
5
|
+
import { CreateDocument } from '../../common/messages.js';
|
|
6
6
|
import { IN_BROWSER, hasOpenreplayAttribute } from '../../utils.js';
|
|
7
|
-
function isPatchedDocument(doc) {
|
|
8
|
-
// @ts-ignore
|
|
9
|
-
return typeof doc.__openreplay__getOffset === 'function';
|
|
10
|
-
}
|
|
11
7
|
const attachShadowNativeFn = IN_BROWSER ? Element.prototype.attachShadow : () => new ShadowRoot();
|
|
12
8
|
export default class TopObserver extends Observer {
|
|
13
9
|
constructor(app, options) {
|
|
14
10
|
super(app, true);
|
|
15
|
-
this.contextCallbacks = [];
|
|
16
|
-
// Attached once per Tracker instance
|
|
17
|
-
this.contextsSet = new Set();
|
|
18
11
|
this.iframeObservers = [];
|
|
19
12
|
this.shadowRootObservers = [];
|
|
20
13
|
this.options = Object.assign({
|
|
@@ -35,50 +28,23 @@ export default class TopObserver extends Observer {
|
|
|
35
28
|
}
|
|
36
29
|
});
|
|
37
30
|
}
|
|
38
|
-
attachContextCallback(cb) {
|
|
39
|
-
this.contextCallbacks.push(cb);
|
|
40
|
-
}
|
|
41
|
-
// Le truc
|
|
42
|
-
getDocumentOffset(doc) {
|
|
43
|
-
if (isPatchedDocument(doc)) {
|
|
44
|
-
return doc.__openreplay__getOffset();
|
|
45
|
-
}
|
|
46
|
-
return { top: 0, left: 0 };
|
|
47
|
-
}
|
|
48
31
|
handleIframe(iframe) {
|
|
49
32
|
let doc = null;
|
|
50
|
-
let win = null;
|
|
51
33
|
const handle = this.app.safe(() => {
|
|
52
34
|
const id = this.app.nodes.getID(iframe);
|
|
53
35
|
if (id === undefined) {
|
|
54
|
-
|
|
36
|
+
return;
|
|
37
|
+
} //log
|
|
38
|
+
if (iframe.contentDocument === doc) {
|
|
39
|
+
return;
|
|
40
|
+
} // How frequently can it happen?
|
|
41
|
+
doc = iframe.contentDocument;
|
|
42
|
+
if (!doc || !iframe.contentWindow) {
|
|
55
43
|
return;
|
|
56
44
|
}
|
|
57
|
-
const
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
const observer = new IFrameObserver(this.app);
|
|
61
|
-
this.iframeObservers.push(observer);
|
|
62
|
-
observer.observe(iframe);
|
|
63
|
-
doc = currentDoc;
|
|
64
|
-
doc.__openreplay__getOffset = () => {
|
|
65
|
-
const { top, left } = this.getDocumentOffset(iframe.ownerDocument);
|
|
66
|
-
return {
|
|
67
|
-
top: iframe.offsetTop + top,
|
|
68
|
-
left: iframe.offsetLeft + left,
|
|
69
|
-
};
|
|
70
|
-
};
|
|
71
|
-
}
|
|
72
|
-
if (currentWin &&
|
|
73
|
-
// Sometimes currentWin.window is null (not in specification). Such window object is not functional
|
|
74
|
-
currentWin === currentWin.window &&
|
|
75
|
-
!this.contextsSet.has(currentWin) // for each context callbacks called once per Tracker (TopObserver) instance
|
|
76
|
-
) {
|
|
77
|
-
this.contextsSet.add(currentWin);
|
|
78
|
-
//@ts-ignore https://github.com/microsoft/TypeScript/issues/41684
|
|
79
|
-
this.contextCallbacks.forEach((cb) => cb(currentWin));
|
|
80
|
-
win = currentWin;
|
|
81
|
-
}
|
|
45
|
+
const observer = new IFrameObserver(this.app);
|
|
46
|
+
this.iframeObservers.push(observer);
|
|
47
|
+
observer.observe(iframe);
|
|
82
48
|
});
|
|
83
49
|
iframe.addEventListener('load', handle); // why app.attachEventListener not working?
|
|
84
50
|
handle();
|
|
@@ -104,7 +70,7 @@ export default class TopObserver extends Observer {
|
|
|
104
70
|
// the 0-node ("fRoot") will become #document rather than documentElement as it is now.
|
|
105
71
|
// Alternatively - observe(#document) then bindNode(documentElement)
|
|
106
72
|
this.observeRoot(window.document, () => {
|
|
107
|
-
this.app.send(CreateDocument());
|
|
73
|
+
this.app.send(new CreateDocument());
|
|
108
74
|
}, window.document.documentElement);
|
|
109
75
|
}
|
|
110
76
|
disconnect() {
|
package/lib/app/session.d.ts
CHANGED
|
@@ -26,12 +26,6 @@ export default class Session {
|
|
|
26
26
|
update(newInfo: Partial<SessionInfo>): void;
|
|
27
27
|
setMetadata(key: string, value: string): void;
|
|
28
28
|
setUserID(userID: string): void;
|
|
29
|
-
private getPageNumber;
|
|
30
|
-
incPageNo(): number;
|
|
31
|
-
getSessionToken(): string | undefined;
|
|
32
|
-
setSessionToken(token: string): void;
|
|
33
|
-
applySessionHash(hash: string): void;
|
|
34
|
-
getSessionHash(): string | undefined;
|
|
35
29
|
getInfo(): SessionInfo;
|
|
36
30
|
reset(): void;
|
|
37
31
|
}
|
package/lib/app/session.js
CHANGED
|
@@ -46,52 +46,6 @@ export default class Session {
|
|
|
46
46
|
this.userID = userID;
|
|
47
47
|
this.handleUpdate({ userID });
|
|
48
48
|
}
|
|
49
|
-
getPageNumber() {
|
|
50
|
-
const pageNoStr = this.app.sessionStorage.getItem(this.options.session_pageno_key);
|
|
51
|
-
if (pageNoStr == null) {
|
|
52
|
-
return undefined;
|
|
53
|
-
}
|
|
54
|
-
return parseInt(pageNoStr);
|
|
55
|
-
}
|
|
56
|
-
incPageNo() {
|
|
57
|
-
let pageNo = this.getPageNumber();
|
|
58
|
-
if (pageNo === undefined) {
|
|
59
|
-
pageNo = 0;
|
|
60
|
-
}
|
|
61
|
-
else {
|
|
62
|
-
pageNo++;
|
|
63
|
-
}
|
|
64
|
-
this.app.sessionStorage.setItem(this.options.session_pageno_key, pageNo.toString());
|
|
65
|
-
return pageNo;
|
|
66
|
-
}
|
|
67
|
-
getSessionToken() {
|
|
68
|
-
return this.app.sessionStorage.getItem(this.options.session_token_key) || undefined;
|
|
69
|
-
}
|
|
70
|
-
setSessionToken(token) {
|
|
71
|
-
this.app.sessionStorage.setItem(this.options.session_token_key, token);
|
|
72
|
-
}
|
|
73
|
-
applySessionHash(hash) {
|
|
74
|
-
const hashParts = decodeURI(hash).split('&');
|
|
75
|
-
let token = hash;
|
|
76
|
-
let pageNoStr = '100500'; // back-compat for sessionToken
|
|
77
|
-
if (hashParts.length == 2) {
|
|
78
|
-
;
|
|
79
|
-
[token, pageNoStr] = hashParts;
|
|
80
|
-
}
|
|
81
|
-
if (!pageNoStr || !token) {
|
|
82
|
-
return;
|
|
83
|
-
}
|
|
84
|
-
this.app.sessionStorage.setItem(this.options.session_token_key, token);
|
|
85
|
-
this.app.sessionStorage.setItem(this.options.session_pageno_key, pageNoStr);
|
|
86
|
-
}
|
|
87
|
-
getSessionHash() {
|
|
88
|
-
const pageNo = this.getPageNumber();
|
|
89
|
-
const token = this.getSessionToken();
|
|
90
|
-
if (pageNo === undefined || token === undefined) {
|
|
91
|
-
return;
|
|
92
|
-
}
|
|
93
|
-
return encodeURI(String(pageNo) + '&' + token);
|
|
94
|
-
}
|
|
95
49
|
getInfo() {
|
|
96
50
|
return {
|
|
97
51
|
sessionID: this.sessionID,
|