@openreplay/tracker 3.5.11 → 3.5.13
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 +18 -0
- package/cjs/app/guards.js +24 -0
- package/cjs/app/index.d.ts +18 -4
- package/cjs/app/index.js +69 -43
- package/cjs/app/nodes.d.ts +3 -3
- package/cjs/app/nodes.js +2 -2
- package/cjs/app/observer/observer.d.ts +1 -2
- package/cjs/app/observer/observer.js +73 -60
- package/cjs/app/observer/top_observer.js +3 -3
- package/cjs/app/sanitizer.d.ts +3 -1
- package/cjs/app/sanitizer.js +13 -2
- package/cjs/app/session.d.ts +2 -7
- package/cjs/app/session.js +24 -37
- package/cjs/index.d.ts +2 -2
- package/cjs/index.js +2 -2
- package/cjs/modules/console.d.ts +1 -1
- package/cjs/modules/console.js +2 -1
- package/cjs/modules/cssrules.d.ts +1 -1
- package/cjs/modules/cssrules.js +2 -4
- package/cjs/modules/exception.d.ts +1 -1
- package/cjs/modules/img.d.ts +1 -1
- package/cjs/modules/img.js +14 -6
- package/cjs/modules/input.d.ts +2 -1
- package/cjs/modules/input.js +18 -20
- package/cjs/modules/longtasks.d.ts +1 -1
- package/cjs/modules/mouse.d.ts +1 -1
- package/cjs/modules/mouse.js +3 -2
- package/cjs/modules/performance.d.ts +1 -1
- package/cjs/modules/scroll.d.ts +1 -1
- package/cjs/modules/scroll.js +3 -2
- package/cjs/modules/timing.d.ts +1 -1
- package/cjs/modules/timing.js +2 -1
- package/cjs/modules/viewport.d.ts +1 -1
- package/lib/app/guards.d.ts +18 -0
- package/lib/app/guards.js +16 -0
- package/lib/app/index.d.ts +18 -4
- package/lib/app/index.js +68 -42
- package/lib/app/nodes.d.ts +3 -3
- package/lib/app/nodes.js +2 -2
- package/lib/app/observer/observer.d.ts +1 -2
- package/lib/app/observer/observer.js +70 -57
- package/lib/app/observer/top_observer.js +3 -3
- package/lib/app/sanitizer.d.ts +3 -1
- package/lib/app/sanitizer.js +13 -2
- package/lib/app/session.d.ts +2 -7
- package/lib/app/session.js +24 -37
- package/lib/common/tsconfig.tsbuildinfo +1 -1
- package/lib/index.d.ts +2 -2
- package/lib/index.js +2 -2
- package/lib/modules/console.d.ts +1 -1
- package/lib/modules/console.js +2 -1
- package/lib/modules/cssrules.d.ts +1 -1
- package/lib/modules/cssrules.js +2 -4
- package/lib/modules/exception.d.ts +1 -1
- package/lib/modules/img.d.ts +1 -1
- package/lib/modules/img.js +14 -6
- package/lib/modules/input.d.ts +2 -1
- package/lib/modules/input.js +18 -20
- package/lib/modules/longtasks.d.ts +1 -1
- package/lib/modules/mouse.d.ts +1 -1
- package/lib/modules/mouse.js +3 -2
- package/lib/modules/performance.d.ts +1 -1
- package/lib/modules/scroll.d.ts +1 -1
- package/lib/modules/scroll.js +3 -2
- package/lib/modules/timing.d.ts +1 -1
- package/lib/modules/timing.js +2 -1
- package/lib/modules/viewport.d.ts +1 -1
- package/package.json +2 -2
- package/cjs/app/context.d.ts +0 -18
- package/cjs/app/context.js +0 -73
- package/lib/app/context.d.ts +0 -18
- package/lib/app/context.js +0 -68
package/cjs/modules/img.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const utils_js_1 = require("../utils.js");
|
|
4
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) {
|
|
@@ -19,7 +20,7 @@ function default_1(app) {
|
|
|
19
20
|
if (id === undefined) {
|
|
20
21
|
return;
|
|
21
22
|
}
|
|
22
|
-
const { src, complete, naturalWidth, naturalHeight } = this;
|
|
23
|
+
const { src, complete, naturalWidth, naturalHeight, srcset } = this;
|
|
23
24
|
if (!complete) {
|
|
24
25
|
return;
|
|
25
26
|
}
|
|
@@ -33,29 +34,36 @@ function default_1(app) {
|
|
|
33
34
|
}
|
|
34
35
|
else {
|
|
35
36
|
app.send(new messages_js_1.SetNodeAttributeURLBased(id, 'src', src, app.getBaseHref()));
|
|
37
|
+
srcset && app.send(new messages_js_1.SetNodeAttribute(id, 'srcset', srcset));
|
|
36
38
|
}
|
|
37
39
|
});
|
|
38
40
|
const observer = new MutationObserver((mutations) => {
|
|
39
41
|
for (const mutation of mutations) {
|
|
40
|
-
if (mutation.type === "attributes"
|
|
42
|
+
if (mutation.type === "attributes") {
|
|
41
43
|
const target = mutation.target;
|
|
42
44
|
const id = app.nodes.getID(target);
|
|
43
45
|
if (id === undefined) {
|
|
44
46
|
return;
|
|
45
47
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
+
if (mutation.attributeName === "src") {
|
|
49
|
+
const src = target.src;
|
|
50
|
+
app.send(new messages_js_1.SetNodeAttributeURLBased(id, 'src', src, app.getBaseHref()));
|
|
51
|
+
}
|
|
52
|
+
if (mutation.attributeName === "srcset") {
|
|
53
|
+
const srcset = target.srcset;
|
|
54
|
+
app.send(new messages_js_1.SetNodeAttribute(id, 'srcset', srcset));
|
|
55
|
+
}
|
|
48
56
|
}
|
|
49
57
|
}
|
|
50
58
|
});
|
|
51
59
|
app.nodes.attachNodeCallback((node) => {
|
|
52
|
-
if (!(node
|
|
60
|
+
if (!(0, guards_js_1.hasTag)(node, "IMG")) {
|
|
53
61
|
return;
|
|
54
62
|
}
|
|
55
63
|
app.nodes.attachElementListener('error', node, sendImgSrc);
|
|
56
64
|
app.nodes.attachElementListener('load', node, sendImgSrc);
|
|
57
65
|
sendImgSrc.call(node);
|
|
58
|
-
observer.observe(node, { attributes: true });
|
|
66
|
+
observer.observe(node, { attributes: true, attributeFilter: ["src", "srcset"] });
|
|
59
67
|
});
|
|
60
68
|
}
|
|
61
69
|
exports.default = default_1;
|
package/cjs/modules/input.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import App from "../app/index.js";
|
|
1
|
+
import type App from "../app/index.js";
|
|
2
2
|
declare type TextEditableElement = HTMLInputElement | HTMLTextAreaElement;
|
|
3
3
|
export declare function getInputLabel(node: TextEditableElement): string;
|
|
4
4
|
export declare const enum InputMode {
|
|
@@ -10,6 +10,7 @@ export interface Options {
|
|
|
10
10
|
obscureInputNumbers: boolean;
|
|
11
11
|
obscureInputEmails: boolean;
|
|
12
12
|
defaultInputMode: InputMode;
|
|
13
|
+
obscureInputDates: boolean;
|
|
13
14
|
}
|
|
14
15
|
export default function (app: App, opts: Partial<Options>): void;
|
|
15
16
|
export {};
|
package/cjs/modules/input.js
CHANGED
|
@@ -2,24 +2,20 @@
|
|
|
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 guards_js_1 = require("../app/guards.js");
|
|
5
6
|
const messages_js_1 = require("../common/messages.js");
|
|
7
|
+
const INPUT_TYPES = ['text', 'password', 'email', 'search', 'number', 'range', 'date'];
|
|
6
8
|
function isTextEditable(node) {
|
|
7
|
-
if (node
|
|
9
|
+
if ((0, guards_js_1.hasTag)(node, "TEXTAREA")) {
|
|
8
10
|
return true;
|
|
9
11
|
}
|
|
10
|
-
if (!(node
|
|
12
|
+
if (!(0, guards_js_1.hasTag)(node, "INPUT")) {
|
|
11
13
|
return false;
|
|
12
14
|
}
|
|
13
|
-
|
|
14
|
-
return (type === 'text' ||
|
|
15
|
-
type === 'password' ||
|
|
16
|
-
type === 'email' ||
|
|
17
|
-
type === 'search' ||
|
|
18
|
-
type === 'number' ||
|
|
19
|
-
type === 'range');
|
|
15
|
+
return INPUT_TYPES.includes(node.type);
|
|
20
16
|
}
|
|
21
17
|
function isCheckable(node) {
|
|
22
|
-
if (!(node
|
|
18
|
+
if (!(0, guards_js_1.hasTag)(node, "INPUT")) {
|
|
23
19
|
return false;
|
|
24
20
|
}
|
|
25
21
|
const type = node.type;
|
|
@@ -29,7 +25,7 @@ const labelElementFor = utils_js_1.IN_BROWSER && 'labels' in HTMLInputElement.pr
|
|
|
29
25
|
? (node) => {
|
|
30
26
|
let p = node;
|
|
31
27
|
while ((p = p.parentNode) !== null) {
|
|
32
|
-
if (p
|
|
28
|
+
if ((0, guards_js_1.hasTag)(p, "LABEL")) {
|
|
33
29
|
return p;
|
|
34
30
|
}
|
|
35
31
|
}
|
|
@@ -41,7 +37,7 @@ const labelElementFor = utils_js_1.IN_BROWSER && 'labels' in HTMLInputElement.pr
|
|
|
41
37
|
: (node) => {
|
|
42
38
|
let p = node;
|
|
43
39
|
while ((p = p.parentNode) !== null) {
|
|
44
|
-
if (p
|
|
40
|
+
if ((0, guards_js_1.hasTag)(p, "LABEL")) {
|
|
45
41
|
return p;
|
|
46
42
|
}
|
|
47
43
|
}
|
|
@@ -71,7 +67,8 @@ function default_1(app, opts) {
|
|
|
71
67
|
const options = Object.assign({
|
|
72
68
|
obscureInputNumbers: true,
|
|
73
69
|
obscureInputEmails: true,
|
|
74
|
-
defaultInputMode: 0 /* Plain */,
|
|
70
|
+
defaultInputMode: 0 /* InputMode.Plain */,
|
|
71
|
+
obscureInputDates: false,
|
|
75
72
|
}, opts);
|
|
76
73
|
function sendInputTarget(id, node) {
|
|
77
74
|
const label = getInputLabel(node);
|
|
@@ -83,22 +80,23 @@ function default_1(app, opts) {
|
|
|
83
80
|
let value = node.value;
|
|
84
81
|
let inputMode = options.defaultInputMode;
|
|
85
82
|
if (node.type === 'password' || (0, utils_js_1.hasOpenreplayAttribute)(node, 'hidden')) {
|
|
86
|
-
inputMode = 2 /* Hidden */;
|
|
83
|
+
inputMode = 2 /* InputMode.Hidden */;
|
|
87
84
|
}
|
|
88
85
|
else if ((0, utils_js_1.hasOpenreplayAttribute)(node, 'obscured') ||
|
|
89
|
-
(inputMode === 0 /* Plain */ &&
|
|
90
|
-
((options.obscureInputNumbers && /\d\d\d\d/.test(value)) ||
|
|
86
|
+
(inputMode === 0 /* InputMode.Plain */ &&
|
|
87
|
+
((options.obscureInputNumbers && node.type !== 'date' && /\d\d\d\d/.test(value)) ||
|
|
88
|
+
(options.obscureInputDates && node.type === 'date') ||
|
|
91
89
|
(options.obscureInputEmails &&
|
|
92
90
|
(node.type === 'email' || !!~value.indexOf('@')))))) {
|
|
93
|
-
inputMode = 1 /* Obscured */;
|
|
91
|
+
inputMode = 1 /* InputMode.Obscured */;
|
|
94
92
|
}
|
|
95
93
|
let mask = 0;
|
|
96
94
|
switch (inputMode) {
|
|
97
|
-
case 2 /* Hidden */:
|
|
95
|
+
case 2 /* InputMode.Hidden */:
|
|
98
96
|
mask = -1;
|
|
99
97
|
value = '';
|
|
100
98
|
break;
|
|
101
|
-
case 1 /* Obscured */:
|
|
99
|
+
case 1 /* InputMode.Obscured */:
|
|
102
100
|
mask = value.length;
|
|
103
101
|
value = '';
|
|
104
102
|
break;
|
|
@@ -148,7 +146,7 @@ function default_1(app, opts) {
|
|
|
148
146
|
return;
|
|
149
147
|
}
|
|
150
148
|
// TODO: support multiple select (?): use selectedOptions; Need send target?
|
|
151
|
-
if (node
|
|
149
|
+
if ((0, guards_js_1.hasTag)(node, "SELECT")) {
|
|
152
150
|
sendInputValue(id, node);
|
|
153
151
|
app.attachEventListener(node, "change", () => {
|
|
154
152
|
sendInputValue(id, node);
|
|
@@ -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.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,5 +1,6 @@
|
|
|
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
5
|
const messages_js_1 = require("../common/messages.js");
|
|
5
6
|
const input_js_1 = require("./input.js");
|
|
@@ -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)) {
|
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,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
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
|
let documentScroll = false;
|
|
6
7
|
const nodeScroll = new Map();
|
|
@@ -22,8 +23,8 @@ function default_1(app) {
|
|
|
22
23
|
documentScroll = false;
|
|
23
24
|
nodeScroll.clear();
|
|
24
25
|
});
|
|
25
|
-
app.nodes.attachNodeCallback(node => {
|
|
26
|
-
if (
|
|
26
|
+
app.nodes.attachNodeCallback((node, isStart) => {
|
|
27
|
+
if (isStart && (0, guards_js_1.isElementNode)(node) && node.scrollLeft + node.scrollTop > 0) {
|
|
27
28
|
nodeScroll.set(node, [node.scrollLeft, node.scrollTop]);
|
|
28
29
|
}
|
|
29
30
|
});
|
package/cjs/modules/timing.d.ts
CHANGED
package/cjs/modules/timing.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
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
5
|
const messages_js_1 = require("../common/messages.js");
|
|
5
6
|
function getPaintBlocks(resources) {
|
|
@@ -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) {
|
|
@@ -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;
|
|
@@ -0,0 +1,18 @@
|
|
|
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;
|
|
14
|
+
style: SVGStyleElement;
|
|
15
|
+
LINK: HTMLLinkElement;
|
|
16
|
+
};
|
|
17
|
+
export declare function hasTag<T extends keyof TagTypeMap>(el: Node, tagName: T): el is TagTypeMap[typeof tagName];
|
|
18
|
+
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 === tagName;
|
|
16
|
+
}
|
package/lib/app/index.d.ts
CHANGED
|
@@ -13,11 +13,22 @@ export interface StartOptions {
|
|
|
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<
|
|
92
|
-
stop(): void;
|
|
105
|
+
start(options?: StartOptions): Promise<StartPromiseReturn>;
|
|
106
|
+
stop(calledFromAPI?: boolean): void;
|
|
93
107
|
}
|
|
94
108
|
export {};
|