@openreplay/tracker 3.6.3 → 3.6.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintignore +8 -0
- package/cjs/app/guards.js +1 -2
- package/cjs/app/index.d.ts +15 -13
- package/cjs/app/index.js +58 -42
- package/cjs/app/logger.js +6 -3
- package/cjs/app/observer/iframe_observer.d.ts +1 -1
- package/cjs/app/observer/iframe_observer.js +1 -1
- package/cjs/app/observer/observer.d.ts +2 -3
- package/cjs/app/observer/observer.js +38 -40
- package/cjs/app/observer/shadow_root_observer.d.ts +1 -1
- package/cjs/app/observer/shadow_root_observer.js +1 -1
- package/cjs/app/observer/top_observer.d.ts +2 -2
- package/cjs/app/observer/top_observer.js +12 -11
- package/cjs/app/sanitizer.d.ts +1 -1
- package/cjs/app/sanitizer.js +5 -5
- package/cjs/app/session.d.ts +14 -2
- package/cjs/app/session.js +19 -6
- package/cjs/app/ticker.d.ts +1 -1
- package/cjs/common/messages.d.ts +1 -1
- package/cjs/common/messages.js +69 -120
- package/cjs/common/webworker.d.ts +3 -3
- package/cjs/index.d.ts +9 -8
- package/cjs/index.js +34 -28
- package/cjs/modules/connection.d.ts +1 -1
- package/cjs/modules/console.d.ts +1 -1
- package/cjs/modules/console.js +5 -5
- package/cjs/modules/cssrules.d.ts +1 -1
- package/cjs/modules/cssrules.js +3 -3
- package/cjs/modules/exception.d.ts +2 -2
- package/cjs/modules/exception.js +7 -6
- package/cjs/modules/img.d.ts +1 -1
- package/cjs/modules/img.js +15 -12
- package/cjs/modules/input.d.ts +1 -1
- package/cjs/modules/input.js +15 -15
- package/cjs/modules/longtasks.d.ts +1 -1
- package/cjs/modules/longtasks.js +13 -5
- package/cjs/modules/mouse.d.ts +1 -1
- package/cjs/modules/mouse.js +10 -12
- package/cjs/modules/performance.d.ts +1 -1
- package/cjs/modules/scroll.d.ts +1 -1
- package/cjs/modules/timing.d.ts +1 -1
- package/cjs/modules/timing.js +12 -24
- package/cjs/modules/viewport.d.ts +1 -1
- package/cjs/utils.js +7 -7
- package/cjs/vendors/finder/finder.js +53 -48
- package/lib/app/guards.js +1 -2
- package/lib/app/index.d.ts +15 -13
- package/lib/app/index.js +67 -51
- package/lib/app/logger.js +6 -3
- 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 +40 -42
- 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 +2 -2
- package/lib/app/observer/top_observer.js +17 -16
- package/lib/app/sanitizer.d.ts +1 -1
- package/lib/app/sanitizer.js +7 -7
- package/lib/app/session.d.ts +14 -2
- package/lib/app/session.js +19 -6
- package/lib/app/ticker.d.ts +1 -1
- package/lib/common/messages.d.ts +1 -1
- package/lib/common/messages.js +69 -120
- package/lib/common/tsconfig.tsbuildinfo +1 -1
- package/lib/common/webworker.d.ts +3 -3
- package/lib/index.d.ts +9 -8
- package/lib/index.js +49 -43
- package/lib/modules/connection.d.ts +1 -1
- package/lib/modules/connection.js +1 -1
- package/lib/modules/console.d.ts +1 -1
- package/lib/modules/console.js +8 -8
- package/lib/modules/cssrules.d.ts +1 -1
- package/lib/modules/cssrules.js +5 -5
- package/lib/modules/exception.d.ts +2 -2
- package/lib/modules/exception.js +8 -7
- package/lib/modules/img.d.ts +1 -1
- package/lib/modules/img.js +18 -15
- package/lib/modules/input.d.ts +1 -1
- package/lib/modules/input.js +18 -18
- package/lib/modules/longtasks.d.ts +1 -1
- package/lib/modules/longtasks.js +14 -6
- package/lib/modules/mouse.d.ts +1 -1
- package/lib/modules/mouse.js +14 -16
- package/lib/modules/performance.d.ts +1 -1
- package/lib/modules/performance.js +2 -2
- package/lib/modules/scroll.d.ts +1 -1
- package/lib/modules/scroll.js +2 -2
- package/lib/modules/timing.d.ts +1 -1
- package/lib/modules/timing.js +15 -27
- package/lib/modules/viewport.d.ts +1 -1
- package/lib/modules/viewport.js +1 -1
- package/lib/utils.js +7 -7
- package/lib/vendors/finder/finder.js +53 -48
- package/package.json +28 -10
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import Observer from
|
|
2
|
-
import { isElementNode, hasTag
|
|
3
|
-
import IFrameObserver from
|
|
4
|
-
import ShadowRootObserver from
|
|
5
|
-
import { CreateDocument } from
|
|
1
|
+
import Observer from './observer.js';
|
|
2
|
+
import { isElementNode, hasTag } from '../guards.js';
|
|
3
|
+
import IFrameObserver from './iframe_observer.js';
|
|
4
|
+
import ShadowRootObserver from './shadow_root_observer.js';
|
|
5
|
+
import { CreateDocument } from '../../common/messages.js';
|
|
6
6
|
import { IN_BROWSER, hasOpenreplayAttribute } from '../../utils.js';
|
|
7
7
|
const attachShadowNativeFn = IN_BROWSER ? Element.prototype.attachShadow : () => new ShadowRoot();
|
|
8
8
|
export default class TopObserver extends Observer {
|
|
@@ -11,18 +11,18 @@ export default class TopObserver extends Observer {
|
|
|
11
11
|
this.iframeObservers = [];
|
|
12
12
|
this.shadowRootObservers = [];
|
|
13
13
|
this.options = Object.assign({
|
|
14
|
-
captureIFrames: true
|
|
14
|
+
captureIFrames: true,
|
|
15
15
|
}, options);
|
|
16
16
|
// IFrames
|
|
17
|
-
this.app.nodes.attachNodeCallback(node => {
|
|
18
|
-
if (hasTag(node,
|
|
19
|
-
((this.options.captureIFrames && !hasOpenreplayAttribute(node,
|
|
20
|
-
|
|
17
|
+
this.app.nodes.attachNodeCallback((node) => {
|
|
18
|
+
if (hasTag(node, 'IFRAME') &&
|
|
19
|
+
((this.options.captureIFrames && !hasOpenreplayAttribute(node, 'obscured')) ||
|
|
20
|
+
hasOpenreplayAttribute(node, 'capture'))) {
|
|
21
21
|
this.handleIframe(node);
|
|
22
22
|
}
|
|
23
23
|
});
|
|
24
24
|
// ShadowDOM
|
|
25
|
-
this.app.nodes.attachNodeCallback(node => {
|
|
25
|
+
this.app.nodes.attachNodeCallback((node) => {
|
|
26
26
|
if (isElementNode(node) && node.shadowRoot !== null) {
|
|
27
27
|
this.handleShadowRoot(node.shadowRoot);
|
|
28
28
|
}
|
|
@@ -46,7 +46,7 @@ export default class TopObserver extends Observer {
|
|
|
46
46
|
this.iframeObservers.push(observer);
|
|
47
47
|
observer.observe(iframe);
|
|
48
48
|
});
|
|
49
|
-
iframe.addEventListener(
|
|
49
|
+
iframe.addEventListener('load', handle); // why app.attachEventListener not working?
|
|
50
50
|
handle();
|
|
51
51
|
}
|
|
52
52
|
handleShadowRoot(shRoot) {
|
|
@@ -58,14 +58,15 @@ export default class TopObserver extends Observer {
|
|
|
58
58
|
// Protection from several subsequent calls?
|
|
59
59
|
const observer = this;
|
|
60
60
|
Element.prototype.attachShadow = function () {
|
|
61
|
+
// eslint-disable-next-line
|
|
61
62
|
const shadow = attachShadowNativeFn.apply(this, arguments);
|
|
62
63
|
observer.handleShadowRoot(shadow);
|
|
63
64
|
return shadow;
|
|
64
65
|
};
|
|
65
66
|
// Can observe documentElement (<html>) here, because it is not supposed to be changing.
|
|
66
67
|
// However, it is possible in some exotic cases and may cause an ignorance of the newly created <html>
|
|
67
|
-
// In this case context.document have to be observed, but this will cause
|
|
68
|
-
// the change in the re-player behaviour caused by CreateDocument message:
|
|
68
|
+
// In this case context.document have to be observed, but this will cause
|
|
69
|
+
// the change in the re-player behaviour caused by CreateDocument message:
|
|
69
70
|
// the 0-node ("fRoot") will become #document rather than documentElement as it is now.
|
|
70
71
|
// Alternatively - observe(#document) then bindNode(documentElement)
|
|
71
72
|
this.observeRoot(window.document, () => {
|
|
@@ -74,9 +75,9 @@ export default class TopObserver extends Observer {
|
|
|
74
75
|
}
|
|
75
76
|
disconnect() {
|
|
76
77
|
Element.prototype.attachShadow = attachShadowNativeFn;
|
|
77
|
-
this.iframeObservers.forEach(o => o.disconnect());
|
|
78
|
+
this.iframeObservers.forEach((o) => o.disconnect());
|
|
78
79
|
this.iframeObservers = [];
|
|
79
|
-
this.shadowRootObservers.forEach(o => o.disconnect());
|
|
80
|
+
this.shadowRootObservers.forEach((o) => o.disconnect());
|
|
80
81
|
this.shadowRootObservers = [];
|
|
81
82
|
super.disconnect();
|
|
82
83
|
}
|
package/lib/app/sanitizer.d.ts
CHANGED
package/lib/app/sanitizer.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { stars, hasOpenreplayAttribute } from
|
|
2
|
-
import { isElementNode } from
|
|
1
|
+
import { stars, hasOpenreplayAttribute } from '../utils.js';
|
|
2
|
+
import { isElementNode } from './guards.js';
|
|
3
3
|
export default class Sanitizer {
|
|
4
4
|
constructor(app, options) {
|
|
5
5
|
this.app = app;
|
|
@@ -12,20 +12,20 @@ export default class Sanitizer {
|
|
|
12
12
|
}
|
|
13
13
|
handleNode(id, parentID, node) {
|
|
14
14
|
if (this.masked.has(parentID) ||
|
|
15
|
-
(isElementNode(node) &&
|
|
16
|
-
hasOpenreplayAttribute(node, 'masked'))) {
|
|
15
|
+
(isElementNode(node) && hasOpenreplayAttribute(node, 'masked'))) {
|
|
17
16
|
this.masked.add(id);
|
|
18
17
|
}
|
|
19
18
|
if (this.maskedContainers.has(parentID) ||
|
|
20
|
-
(isElementNode(node) &&
|
|
21
|
-
hasOpenreplayAttribute(node, 'htmlmasked'))) {
|
|
19
|
+
(isElementNode(node) && hasOpenreplayAttribute(node, 'htmlmasked'))) {
|
|
22
20
|
this.maskedContainers.add(id);
|
|
23
21
|
}
|
|
24
22
|
}
|
|
25
23
|
sanitize(id, data) {
|
|
26
24
|
if (this.masked.has(id)) {
|
|
27
25
|
// TODO: is it the best place to put trim() ? Might trimmed spaces be considered in layout in certain cases?
|
|
28
|
-
return data
|
|
26
|
+
return data
|
|
27
|
+
.trim()
|
|
28
|
+
.replace(/[^\f\n\r\t\v\u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff]/g, '█');
|
|
29
29
|
}
|
|
30
30
|
if (this.options.obscureTextNumbers) {
|
|
31
31
|
data = data.replace(/\d/g, '0');
|
package/lib/app/session.d.ts
CHANGED
|
@@ -1,14 +1,26 @@
|
|
|
1
|
+
import type App from './index.js';
|
|
1
2
|
interface SessionInfo {
|
|
2
|
-
sessionID: string |
|
|
3
|
+
sessionID: string | undefined;
|
|
3
4
|
metadata: Record<string, string>;
|
|
4
5
|
userID: string | null;
|
|
6
|
+
timestamp: number;
|
|
7
|
+
projectID?: string;
|
|
5
8
|
}
|
|
6
9
|
declare type OnUpdateCallback = (i: Partial<SessionInfo>) => void;
|
|
10
|
+
export declare type Options = {
|
|
11
|
+
session_token_key: string;
|
|
12
|
+
session_pageno_key: string;
|
|
13
|
+
};
|
|
7
14
|
export default class Session {
|
|
15
|
+
private readonly app;
|
|
16
|
+
private readonly options;
|
|
8
17
|
private metadata;
|
|
9
18
|
private userID;
|
|
10
19
|
private sessionID;
|
|
11
|
-
private callbacks;
|
|
20
|
+
private readonly callbacks;
|
|
21
|
+
private timestamp;
|
|
22
|
+
private projectID;
|
|
23
|
+
constructor(app: App, options: Options);
|
|
12
24
|
attachUpdateCallback(cb: OnUpdateCallback): void;
|
|
13
25
|
private handleUpdate;
|
|
14
26
|
update(newInfo: Partial<SessionInfo>): void;
|
package/lib/app/session.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
export default class Session {
|
|
2
|
-
constructor() {
|
|
2
|
+
constructor(app, options) {
|
|
3
|
+
this.app = app;
|
|
4
|
+
this.options = options;
|
|
3
5
|
this.metadata = {};
|
|
4
6
|
this.userID = null;
|
|
5
|
-
this.sessionID = null;
|
|
6
7
|
this.callbacks = [];
|
|
8
|
+
this.timestamp = 0;
|
|
7
9
|
}
|
|
8
10
|
attachUpdateCallback(cb) {
|
|
9
11
|
this.callbacks.push(cb);
|
|
@@ -15,18 +17,25 @@ export default class Session {
|
|
|
15
17
|
if (newInfo.sessionID == null) {
|
|
16
18
|
delete newInfo.sessionID;
|
|
17
19
|
}
|
|
18
|
-
this.callbacks.forEach(cb => cb(newInfo));
|
|
20
|
+
this.callbacks.forEach((cb) => cb(newInfo));
|
|
19
21
|
}
|
|
20
22
|
update(newInfo) {
|
|
21
|
-
if (newInfo.userID !== undefined) {
|
|
23
|
+
if (newInfo.userID !== undefined) {
|
|
24
|
+
// TODO clear nullable/undefinable types
|
|
22
25
|
this.userID = newInfo.userID;
|
|
23
26
|
}
|
|
24
27
|
if (newInfo.metadata !== undefined) {
|
|
25
|
-
Object.entries(newInfo.metadata).forEach(([k, v]) => this.metadata[k] = v);
|
|
28
|
+
Object.entries(newInfo.metadata).forEach(([k, v]) => (this.metadata[k] = v));
|
|
26
29
|
}
|
|
27
30
|
if (newInfo.sessionID !== undefined) {
|
|
28
31
|
this.sessionID = newInfo.sessionID;
|
|
29
32
|
}
|
|
33
|
+
if (newInfo.timestamp !== undefined) {
|
|
34
|
+
this.timestamp = newInfo.timestamp;
|
|
35
|
+
}
|
|
36
|
+
if (newInfo.projectID !== undefined) {
|
|
37
|
+
this.projectID = newInfo.projectID;
|
|
38
|
+
}
|
|
30
39
|
this.handleUpdate(newInfo);
|
|
31
40
|
}
|
|
32
41
|
setMetadata(key, value) {
|
|
@@ -42,11 +51,15 @@ export default class Session {
|
|
|
42
51
|
sessionID: this.sessionID,
|
|
43
52
|
metadata: this.metadata,
|
|
44
53
|
userID: this.userID,
|
|
54
|
+
timestamp: this.timestamp,
|
|
55
|
+
projectID: this.projectID,
|
|
45
56
|
};
|
|
46
57
|
}
|
|
47
58
|
reset() {
|
|
59
|
+
this.app.sessionStorage.removeItem(this.options.session_token_key);
|
|
48
60
|
this.metadata = {};
|
|
49
61
|
this.userID = null;
|
|
50
|
-
this.sessionID =
|
|
62
|
+
this.sessionID = undefined;
|
|
63
|
+
this.timestamp = 0;
|
|
51
64
|
}
|
|
52
65
|
}
|
package/lib/app/ticker.d.ts
CHANGED
package/lib/common/messages.d.ts
CHANGED