@openreplay/tracker 3.4.4 → 3.4.8
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/cjs/app/index.d.ts +8 -6
- package/cjs/app/index.js +26 -21
- package/cjs/app/observer.d.ts +3 -1
- package/cjs/app/observer.js +54 -34
- package/cjs/app/ticker.d.ts +1 -1
- package/cjs/index.d.ts +10 -11
- package/cjs/index.js +56 -53
- package/cjs/messages/index.d.ts +2 -2
- package/cjs/messages/message.d.ts +1 -1
- package/cjs/messages/webworker.d.ts +0 -1
- package/cjs/modules/connection.d.ts +1 -1
- package/cjs/modules/connection.js +2 -2
- package/cjs/modules/console.d.ts +1 -1
- package/cjs/modules/console.js +20 -5
- package/cjs/modules/cssrules.d.ts +1 -1
- package/cjs/modules/cssrules.js +4 -4
- 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 +6 -6
- package/cjs/modules/input.d.ts +1 -1
- package/cjs/modules/input.js +11 -11
- package/cjs/modules/longtasks.d.ts +1 -1
- package/cjs/modules/longtasks.js +3 -3
- package/cjs/modules/mouse.d.ts +2 -10
- package/cjs/modules/mouse.js +52 -40
- package/cjs/modules/performance.d.ts +1 -1
- package/cjs/modules/performance.js +5 -5
- package/cjs/modules/scroll.d.ts +1 -1
- package/cjs/modules/scroll.js +3 -3
- package/cjs/modules/timing.d.ts +1 -1
- package/cjs/modules/timing.js +6 -6
- package/cjs/modules/viewport.d.ts +1 -1
- package/cjs/modules/viewport.js +4 -4
- package/cjs/utils.js +1 -1
- package/lib/app/index.d.ts +8 -6
- package/lib/app/index.js +15 -10
- package/lib/app/observer.d.ts +3 -1
- package/lib/app/observer.js +38 -18
- package/lib/app/ticker.d.ts +1 -1
- package/lib/index.d.ts +10 -11
- package/lib/index.js +23 -20
- package/lib/messages/index.d.ts +2 -2
- package/lib/messages/message.d.ts +1 -1
- package/lib/messages/tsconfig.tsbuildinfo +1 -1
- package/lib/messages/webworker.d.ts +0 -1
- 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 +18 -3
- package/lib/modules/cssrules.d.ts +1 -1
- package/lib/modules/cssrules.js +1 -1
- 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 +2 -2
- package/lib/modules/input.d.ts +1 -1
- package/lib/modules/input.js +2 -2
- package/lib/modules/longtasks.d.ts +1 -1
- package/lib/modules/longtasks.js +2 -2
- package/lib/modules/mouse.d.ts +2 -10
- package/lib/modules/mouse.js +48 -36
- 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 +1 -1
- package/lib/modules/timing.d.ts +1 -1
- package/lib/modules/timing.js +3 -3
- package/lib/modules/viewport.d.ts +1 -1
- package/lib/modules/viewport.js +1 -1
- package/package.json +2 -3
- package/tsconfig-base.json +1 -1
package/cjs/modules/mouse.js
CHANGED
|
@@ -1,9 +1,29 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
|
|
3
|
+
const utils_js_1 = require("../utils.js");
|
|
4
|
+
const index_js_1 = require("../messages/index.js");
|
|
5
|
+
const input_js_1 = require("./input.js");
|
|
6
|
+
function _getSelector(target) {
|
|
7
|
+
let el = target;
|
|
8
|
+
let selector = null;
|
|
9
|
+
do {
|
|
10
|
+
if (el.id) {
|
|
11
|
+
return `#${el.id}` + (selector ? ` > ${selector}` : '');
|
|
12
|
+
}
|
|
13
|
+
selector =
|
|
14
|
+
el.className.split(' ')
|
|
15
|
+
.map(cn => cn.trim())
|
|
16
|
+
.filter(cn => cn !== '')
|
|
17
|
+
.reduce((sel, cn) => `${sel}.${cn}`, el.tagName.toLowerCase()) +
|
|
18
|
+
(selector ? ` > ${selector}` : '');
|
|
19
|
+
if (el === document.body) {
|
|
20
|
+
return selector;
|
|
21
|
+
}
|
|
22
|
+
el = el.parentElement;
|
|
23
|
+
} while (el !== document.body && el !== null);
|
|
24
|
+
return selector;
|
|
25
|
+
}
|
|
26
|
+
//TODO: fix (typescript doesn't allow work when the guard is inside the function)
|
|
7
27
|
function getTarget(target) {
|
|
8
28
|
if (target instanceof Element) {
|
|
9
29
|
return _getTarget(target);
|
|
@@ -13,7 +33,7 @@ function getTarget(target) {
|
|
|
13
33
|
function _getTarget(target) {
|
|
14
34
|
let element = target;
|
|
15
35
|
while (element !== null && element !== document.documentElement) {
|
|
16
|
-
if (
|
|
36
|
+
if ((0, utils_js_1.hasOpenreplayAttribute)(element, 'masked')) {
|
|
17
37
|
return null;
|
|
18
38
|
}
|
|
19
39
|
element = element.parentElement;
|
|
@@ -39,41 +59,37 @@ function _getTarget(target) {
|
|
|
39
59
|
tag === 'LI' ||
|
|
40
60
|
element.onclick != null ||
|
|
41
61
|
element.getAttribute('role') === 'button' ||
|
|
42
|
-
|
|
62
|
+
(0, utils_js_1.getLabelAttribute)(element) !== null) {
|
|
43
63
|
return element;
|
|
44
64
|
}
|
|
45
65
|
element = element.parentElement;
|
|
46
66
|
}
|
|
47
67
|
return target === document.documentElement ? null : target;
|
|
48
68
|
}
|
|
49
|
-
function
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
tag
|
|
60
|
-
tag === '
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
69
|
+
function default_1(app) {
|
|
70
|
+
// const options: Options = Object.assign(
|
|
71
|
+
// {},
|
|
72
|
+
// opts,
|
|
73
|
+
// );
|
|
74
|
+
function getTargetLabel(target) {
|
|
75
|
+
const dl = (0, utils_js_1.getLabelAttribute)(target);
|
|
76
|
+
if (dl !== null) {
|
|
77
|
+
return dl;
|
|
78
|
+
}
|
|
79
|
+
const tag = target.tagName.toUpperCase();
|
|
80
|
+
if (tag === 'INPUT') {
|
|
81
|
+
return (0, input_js_1.getInputLabel)(target);
|
|
82
|
+
}
|
|
83
|
+
if (tag === 'BUTTON' ||
|
|
84
|
+
tag === 'A' ||
|
|
85
|
+
tag === 'LI' ||
|
|
86
|
+
target.onclick != null ||
|
|
87
|
+
target.getAttribute('role') === 'button') {
|
|
88
|
+
const label = app.observer.getInnerTextSecure(target);
|
|
89
|
+
return (0, utils_js_1.normSpaces)(label).slice(0, 100);
|
|
90
|
+
}
|
|
91
|
+
return '';
|
|
65
92
|
}
|
|
66
|
-
return '';
|
|
67
|
-
}
|
|
68
|
-
function default_1(app, opts) {
|
|
69
|
-
const options = Object.assign({
|
|
70
|
-
heatmaps: false // {
|
|
71
|
-
// finder: {
|
|
72
|
-
// threshold: 5,
|
|
73
|
-
// maxNumberOfTries: 600,
|
|
74
|
-
// },
|
|
75
|
-
// },
|
|
76
|
-
}, opts);
|
|
77
93
|
let mousePositionX = -1;
|
|
78
94
|
let mousePositionY = -1;
|
|
79
95
|
let mousePositionChanged = false;
|
|
@@ -87,17 +103,13 @@ function default_1(app, opts) {
|
|
|
87
103
|
});
|
|
88
104
|
const sendMouseMove = () => {
|
|
89
105
|
if (mousePositionChanged) {
|
|
90
|
-
app.send(new
|
|
106
|
+
app.send(new index_js_1.MouseMove(mousePositionX, mousePositionY));
|
|
91
107
|
mousePositionChanged = false;
|
|
92
108
|
}
|
|
93
109
|
};
|
|
94
110
|
const selectorMap = {};
|
|
95
111
|
function getSelector(id, target) {
|
|
96
|
-
|
|
97
|
-
return '';
|
|
98
|
-
}
|
|
99
|
-
return selectorMap[id] = selectorMap[id] ||
|
|
100
|
-
finder_1.finder(target, options.heatmaps === true ? undefined : options.heatmaps.finder);
|
|
112
|
+
return selectorMap[id] = selectorMap[id] || _getSelector(target);
|
|
101
113
|
}
|
|
102
114
|
app.attachEventListener(document.documentElement, 'mouseover', (e) => {
|
|
103
115
|
const target = getTarget(e.target);
|
|
@@ -119,7 +131,7 @@ function default_1(app, opts) {
|
|
|
119
131
|
const id = app.nodes.getID(target);
|
|
120
132
|
if (id !== undefined) {
|
|
121
133
|
sendMouseMove();
|
|
122
|
-
app.send(new
|
|
134
|
+
app.send(new index_js_1.MouseClick(id, mouseTarget === target
|
|
123
135
|
? Math.round(performance.now() - mouseTargetTime)
|
|
124
136
|
: 0, getTargetLabel(target), getSelector(id, target)), true);
|
|
125
137
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.jsHeapSizeLimit = exports.deviceMemory = void 0;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const perf =
|
|
4
|
+
const utils_js_1 = require("../utils.js");
|
|
5
|
+
const index_js_1 = require("../messages/index.js");
|
|
6
|
+
const perf = utils_js_1.IN_BROWSER && 'performance' in window && 'memory' in performance // works in Chrome only
|
|
7
7
|
? performance
|
|
8
8
|
: { memory: {} };
|
|
9
|
-
exports.deviceMemory =
|
|
9
|
+
exports.deviceMemory = utils_js_1.IN_BROWSER ? (navigator.deviceMemory || 0) * 1024 : 0;
|
|
10
10
|
exports.jsHeapSizeLimit = perf.memory.jsHeapSizeLimit || 0;
|
|
11
11
|
function default_1(app, opts) {
|
|
12
12
|
const options = Object.assign({
|
|
@@ -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 index_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
|
|
1
|
+
import 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 index_js_1 = require("../messages/index.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 index_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 index_js_1.SetNodeScroll(id, s[0], s[1]));
|
|
18
18
|
}
|
|
19
19
|
});
|
|
20
20
|
app.attachStartCallback(sendSetViewportScroll);
|
package/cjs/modules/timing.d.ts
CHANGED
package/cjs/modules/timing.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const
|
|
4
|
-
const
|
|
3
|
+
const utils_js_1 = require("../utils.js");
|
|
4
|
+
const index_js_1 = require("../messages/index.js");
|
|
5
5
|
function getPaintBlocks(resources) {
|
|
6
6
|
const paintBlocks = [];
|
|
7
7
|
const elements = document.getElementsByTagName('*');
|
|
@@ -84,12 +84,12 @@ function default_1(app, opts) {
|
|
|
84
84
|
});
|
|
85
85
|
let resources = {};
|
|
86
86
|
function resourceTiming(entry) {
|
|
87
|
-
if (entry.duration
|
|
87
|
+
if (entry.duration < 0 || !(0, utils_js_1.isURL)(entry.name) || app.isServiceURL(entry.name))
|
|
88
88
|
return;
|
|
89
89
|
if (resources !== null) {
|
|
90
90
|
resources[entry.name] = entry.startTime + entry.duration;
|
|
91
91
|
}
|
|
92
|
-
sendOnStart(new
|
|
92
|
+
sendOnStart(new index_js_1.ResourceTiming(entry.startTime + performance.timing.navigationStart, entry.duration, entry.responseStart && entry.startTime
|
|
93
93
|
? entry.responseStart - entry.startTime
|
|
94
94
|
: 0, entry.transferSize > entry.encodedBodySize
|
|
95
95
|
? entry.transferSize - entry.encodedBodySize
|
|
@@ -123,7 +123,7 @@ function default_1(app, opts) {
|
|
|
123
123
|
if (performance.timing.loadEventEnd || performance.now() > 30000) {
|
|
124
124
|
pageLoadTimingSent = true;
|
|
125
125
|
const { navigationStart, requestStart, responseStart, responseEnd, domContentLoadedEventStart, domContentLoadedEventEnd, loadEventStart, loadEventEnd, } = performance.timing;
|
|
126
|
-
app.send(new
|
|
126
|
+
app.send(new index_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));
|
|
127
127
|
}
|
|
128
128
|
}, 30);
|
|
129
129
|
}
|
|
@@ -160,7 +160,7 @@ function default_1(app, opts) {
|
|
|
160
160
|
? Math.max(interactiveWindowStartTime, firstContentfulPaint, performance.timing.domContentLoadedEventEnd -
|
|
161
161
|
performance.timing.navigationStart || 0)
|
|
162
162
|
: 0;
|
|
163
|
-
app.send(new
|
|
163
|
+
app.send(new index_js_1.PageRenderTiming(speedIndex, firstContentfulPaint > visuallyComplete
|
|
164
164
|
? firstContentfulPaint
|
|
165
165
|
: visuallyComplete, timeToInteractive));
|
|
166
166
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import App from
|
|
1
|
+
import 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 index_js_1 = require("../messages/index.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 index_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 index_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 index_js_1.SetPageVisibility(document.hidden)));
|
|
26
26
|
app.attachStartCallback(() => {
|
|
27
27
|
url = '';
|
|
28
28
|
width = height = -1;
|
package/cjs/utils.js
CHANGED
|
@@ -26,7 +26,7 @@ function deprecationWarn(nameOfFeature, useInstead, docsPath = "/") {
|
|
|
26
26
|
if (warnedFeatures[nameOfFeature]) {
|
|
27
27
|
return;
|
|
28
28
|
}
|
|
29
|
-
exports.warn(`OpenReplay: ${nameOfFeature} is deprecated. ${useInstead ? `Please, use ${useInstead} instead.` : ""} Visit ${exports.DOCS_HOST}${docsPath} for more information.`);
|
|
29
|
+
(0, exports.warn)(`OpenReplay: ${nameOfFeature} is deprecated. ${useInstead ? `Please, use ${useInstead} instead.` : ""} Visit ${exports.DOCS_HOST}${docsPath} for more information.`);
|
|
30
30
|
warnedFeatures[nameOfFeature] = true;
|
|
31
31
|
}
|
|
32
32
|
exports.deprecationWarn = deprecationWarn;
|
package/lib/app/index.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import Message from
|
|
2
|
-
import Nodes from
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import type { Options as
|
|
1
|
+
import Message from "../messages/message.js";
|
|
2
|
+
import Nodes from "./nodes.js";
|
|
3
|
+
import Observer from "./observer.js";
|
|
4
|
+
import Ticker from "./ticker.js";
|
|
5
|
+
import type { Options as ObserverOptions } from "./observer.js";
|
|
6
|
+
import type { Options as WebworkerOptions } from "../messages/webworker.js";
|
|
6
7
|
interface OnStartInfo {
|
|
7
8
|
sessionID: string;
|
|
8
9
|
sessionToken: string;
|
|
@@ -29,7 +30,7 @@ export default class App {
|
|
|
29
30
|
readonly ticker: Ticker;
|
|
30
31
|
readonly projectKey: string;
|
|
31
32
|
private readonly messages;
|
|
32
|
-
|
|
33
|
+
readonly observer: Observer;
|
|
33
34
|
private readonly startCallbacks;
|
|
34
35
|
private readonly stopCallbacks;
|
|
35
36
|
private readonly commitCallbacks;
|
|
@@ -43,6 +44,7 @@ export default class App {
|
|
|
43
44
|
private _debug;
|
|
44
45
|
send(message: Message, urgent?: boolean): void;
|
|
45
46
|
private commit;
|
|
47
|
+
attachCommitCallback(cb: CommitCallback): void;
|
|
46
48
|
addCommitCallback(cb: CommitCallback): void;
|
|
47
49
|
safe<T extends (...args: any[]) => void>(fn: T): T;
|
|
48
50
|
attachStartCallback(cb: Callback): void;
|
package/lib/app/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { timestamp, log, warn } from
|
|
2
|
-
import { Timestamp } from
|
|
3
|
-
import Nodes from
|
|
4
|
-
import Observer from
|
|
5
|
-
import Ticker from
|
|
6
|
-
import { deviceMemory, jsHeapSizeLimit } from
|
|
1
|
+
import { timestamp, log, warn } from "../utils.js";
|
|
2
|
+
import { Timestamp } from "../messages/index.js";
|
|
3
|
+
import Nodes from "./nodes.js";
|
|
4
|
+
import Observer from "./observer.js";
|
|
5
|
+
import Ticker from "./ticker.js";
|
|
6
|
+
import { deviceMemory, jsHeapSizeLimit } from "../modules/performance.js";
|
|
7
7
|
// TODO: use backendHost only
|
|
8
8
|
export const DEFAULT_INGEST_POINT = 'https://api.openreplay.com/ingest';
|
|
9
9
|
export default class App {
|
|
@@ -14,7 +14,7 @@ export default class App {
|
|
|
14
14
|
this.commitCallbacks = [];
|
|
15
15
|
this._sessionID = null;
|
|
16
16
|
this.isActive = false;
|
|
17
|
-
this.version = '3.4.
|
|
17
|
+
this.version = '3.4.8';
|
|
18
18
|
this.projectKey = projectKey;
|
|
19
19
|
this.options = Object.assign({
|
|
20
20
|
revID: '',
|
|
@@ -82,7 +82,7 @@ export default class App {
|
|
|
82
82
|
});
|
|
83
83
|
}
|
|
84
84
|
if (this.options.__debug_log) {
|
|
85
|
-
warn("OpenReplay
|
|
85
|
+
warn("OpenReplay error: ", context, e);
|
|
86
86
|
}
|
|
87
87
|
}
|
|
88
88
|
send(message, urgent = false) {
|
|
@@ -102,9 +102,13 @@ export default class App {
|
|
|
102
102
|
this.messages.length = 0;
|
|
103
103
|
}
|
|
104
104
|
}
|
|
105
|
-
|
|
105
|
+
attachCommitCallback(cb) {
|
|
106
106
|
this.commitCallbacks.push(cb);
|
|
107
107
|
}
|
|
108
|
+
// @Depricated (TODO: remove in 3.5.*)
|
|
109
|
+
addCommitCallback(cb) {
|
|
110
|
+
this.attachCommitCallback(cb);
|
|
111
|
+
}
|
|
108
112
|
safe(fn) {
|
|
109
113
|
const app = this;
|
|
110
114
|
return function (...args) {
|
|
@@ -251,13 +255,14 @@ export default class App {
|
|
|
251
255
|
return onStartInfo;
|
|
252
256
|
})
|
|
253
257
|
.catch(e => {
|
|
258
|
+
sessionStorage.removeItem(this.options.session_token_key);
|
|
254
259
|
this.stop();
|
|
255
260
|
warn("OpenReplay was unable to start. ", e);
|
|
256
261
|
this._debug("session_start", e);
|
|
257
262
|
throw e;
|
|
258
263
|
});
|
|
259
264
|
}
|
|
260
|
-
return Promise.reject("Player is active");
|
|
265
|
+
return Promise.reject("Player is already active");
|
|
261
266
|
}
|
|
262
267
|
start(reset = false) {
|
|
263
268
|
if (!document.hidden) {
|
package/lib/app/observer.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import App from
|
|
1
|
+
import App from "./index.js";
|
|
2
2
|
interface Window extends WindowProxy {
|
|
3
3
|
HTMLInputElement: typeof HTMLInputElement;
|
|
4
4
|
HTMLLinkElement: typeof HTMLLinkElement;
|
|
@@ -29,6 +29,8 @@ export default class Observer {
|
|
|
29
29
|
private isInstance;
|
|
30
30
|
private isIgnored;
|
|
31
31
|
private sendNodeAttribute;
|
|
32
|
+
getInnerTextSecure(el: HTMLElement): string;
|
|
33
|
+
private checkObscure;
|
|
32
34
|
private sendNodeData;
|
|
33
35
|
private bindNode;
|
|
34
36
|
private bindTree;
|
package/lib/app/observer.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { stars, hasOpenreplayAttribute } from
|
|
2
|
-
import { CreateDocument, CreateElementNode, CreateTextNode, SetNodeData, SetCSSDataURLBased, SetNodeAttribute, SetNodeAttributeURLBased, RemoveNodeAttribute, MoveNode, RemoveNode, CreateIFrameDocument, } from
|
|
1
|
+
import { stars, hasOpenreplayAttribute } from "../utils.js";
|
|
2
|
+
import { CreateDocument, CreateElementNode, CreateTextNode, SetNodeData, SetCSSDataURLBased, SetNodeAttribute, SetNodeAttributeURLBased, RemoveNodeAttribute, MoveNode, RemoveNode, CreateIFrameDocument, } from "../messages/index.js";
|
|
3
3
|
function isSVGElement(node) {
|
|
4
4
|
return node.namespaceURI === 'http://www.w3.org/2000/svg';
|
|
5
5
|
}
|
|
@@ -167,24 +167,35 @@ export default class Observer {
|
|
|
167
167
|
}
|
|
168
168
|
this.app.send(new SetNodeAttribute(id, name, value));
|
|
169
169
|
}
|
|
170
|
+
/* TODO: abstract sanitation */
|
|
171
|
+
getInnerTextSecure(el) {
|
|
172
|
+
const id = this.app.nodes.getID(el);
|
|
173
|
+
if (!id) {
|
|
174
|
+
return '';
|
|
175
|
+
}
|
|
176
|
+
return this.checkObscure(id, el.innerText);
|
|
177
|
+
}
|
|
178
|
+
checkObscure(id, data) {
|
|
179
|
+
if (this.textMasked.has(id)) {
|
|
180
|
+
return data.replace(/[^\f\n\r\t\v\u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff]/g, '█');
|
|
181
|
+
}
|
|
182
|
+
if (this.options.obscureTextNumbers) {
|
|
183
|
+
data = data.replace(/\d/g, '0');
|
|
184
|
+
}
|
|
185
|
+
if (this.options.obscureTextEmails) {
|
|
186
|
+
data = data.replace(/([^\s]+)@([^\s]+)\.([^\s]+)/g, (...f) => stars(f[1]) + '@' + stars(f[2]) + '.' + stars(f[3]));
|
|
187
|
+
}
|
|
188
|
+
return data;
|
|
189
|
+
}
|
|
170
190
|
sendNodeData(id, parentElement, data) {
|
|
171
191
|
if (this.isInstance(parentElement, HTMLStyleElement) || this.isInstance(parentElement, SVGStyleElement)) {
|
|
172
192
|
this.app.send(new SetCSSDataURLBased(id, data, this.app.getBaseHref()));
|
|
173
193
|
return;
|
|
174
194
|
}
|
|
175
|
-
|
|
176
|
-
data = data.replace(/[^\f\n\r\t\v\u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff]/g, '█');
|
|
177
|
-
}
|
|
178
|
-
else {
|
|
179
|
-
if (this.options.obscureTextNumbers) {
|
|
180
|
-
data = data.replace(/\d/g, '0');
|
|
181
|
-
}
|
|
182
|
-
if (this.options.obscureTextEmails) {
|
|
183
|
-
data = data.replace(/([^\s]+)@([^\s]+)\.([^\s]+)/g, (...f) => stars(f[1]) + '@' + stars(f[2]) + '.' + stars(f[3]));
|
|
184
|
-
}
|
|
185
|
-
}
|
|
195
|
+
data = this.checkObscure(id, data);
|
|
186
196
|
this.app.send(new SetNodeData(id, data));
|
|
187
197
|
}
|
|
198
|
+
/* end TODO: abstract sanitation */
|
|
188
199
|
bindNode(node) {
|
|
189
200
|
const r = this.app.nodes.registerNode(node);
|
|
190
201
|
const id = r[0];
|
|
@@ -199,7 +210,9 @@ export default class Observer {
|
|
|
199
210
|
acceptNode: (node) => this.isIgnored(node) || this.app.nodes.getID(node) !== undefined
|
|
200
211
|
? NodeFilter.FILTER_REJECT
|
|
201
212
|
: NodeFilter.FILTER_ACCEPT,
|
|
202
|
-
},
|
|
213
|
+
},
|
|
214
|
+
// @ts-ignore
|
|
215
|
+
false);
|
|
203
216
|
while (walker.nextNode()) {
|
|
204
217
|
this.bindNode(walker.currentNode);
|
|
205
218
|
}
|
|
@@ -317,16 +330,23 @@ export default class Observer {
|
|
|
317
330
|
this.clear();
|
|
318
331
|
}
|
|
319
332
|
handleIframe(iframe) {
|
|
320
|
-
|
|
321
|
-
|
|
333
|
+
let context = null;
|
|
334
|
+
const handle = this.app.safe(() => {
|
|
322
335
|
const id = this.app.nodes.getID(iframe);
|
|
323
|
-
if (
|
|
336
|
+
if (id === undefined) {
|
|
337
|
+
return;
|
|
338
|
+
}
|
|
339
|
+
if (iframe.contentWindow === context) {
|
|
340
|
+
return;
|
|
341
|
+
}
|
|
342
|
+
context = iframe.contentWindow;
|
|
343
|
+
if (!context) {
|
|
324
344
|
return;
|
|
325
345
|
}
|
|
326
346
|
const observer = new Observer(this.app, this.options, context);
|
|
327
347
|
this.iframeObservers.push(observer);
|
|
328
348
|
observer.observeIframe(id, context);
|
|
329
|
-
};
|
|
349
|
+
});
|
|
330
350
|
this.app.attachEventListener(iframe, "load", handle);
|
|
331
351
|
handle();
|
|
332
352
|
}
|
package/lib/app/ticker.d.ts
CHANGED
package/lib/index.d.ts
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
import App from
|
|
2
|
-
export { default as App } from './app';
|
|
3
|
-
import * as _Messages from
|
|
1
|
+
import App from "./app/index.js";
|
|
2
|
+
export { default as App } from './app/index.js';
|
|
3
|
+
import * as _Messages from "./messages/index.js";
|
|
4
4
|
export declare const Messages: typeof _Messages;
|
|
5
|
-
import { Options as AppOptions } from
|
|
6
|
-
import { Options as ConsoleOptions } from
|
|
7
|
-
import { Options as ExceptionOptions } from
|
|
8
|
-
import { Options as InputOptions } from
|
|
9
|
-
import { Options as
|
|
10
|
-
import { Options as
|
|
11
|
-
|
|
12
|
-
export declare type Options = Partial<AppOptions & ConsoleOptions & ExceptionOptions & InputOptions & MouseOptions & PerformanceOptions & TimingOptions> & {
|
|
5
|
+
import { Options as AppOptions } from "./app/index.js";
|
|
6
|
+
import { Options as ConsoleOptions } from "./modules/console.js";
|
|
7
|
+
import { Options as ExceptionOptions } from "./modules/exception.js";
|
|
8
|
+
import { Options as InputOptions } from "./modules/input.js";
|
|
9
|
+
import { Options as PerformanceOptions } from "./modules/performance.js";
|
|
10
|
+
import { Options as TimingOptions } from "./modules/timing.js";
|
|
11
|
+
export declare type Options = Partial<AppOptions & ConsoleOptions & ExceptionOptions & InputOptions & PerformanceOptions & TimingOptions> & {
|
|
13
12
|
projectID?: number;
|
|
14
13
|
projectKey: string;
|
|
15
14
|
sessionToken?: string;
|
package/lib/index.js
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import App, { DEFAULT_INGEST_POINT } from
|
|
2
|
-
export { default as App } from './app';
|
|
3
|
-
import { UserID, UserAnonymousID, Metadata, RawCustomEvent, CustomIssue } from
|
|
4
|
-
import * as _Messages from
|
|
1
|
+
import App, { DEFAULT_INGEST_POINT } from "./app/index.js";
|
|
2
|
+
export { default as App } from './app/index.js';
|
|
3
|
+
import { UserID, UserAnonymousID, Metadata, RawCustomEvent, CustomIssue } from "./messages/index.js";
|
|
4
|
+
import * as _Messages from "./messages/index.js";
|
|
5
5
|
export const Messages = _Messages;
|
|
6
|
-
import Connection from
|
|
7
|
-
import Console from
|
|
8
|
-
import Exception, { getExceptionMessageFromEvent, getExceptionMessage } from
|
|
9
|
-
import Img from
|
|
10
|
-
import Input from
|
|
11
|
-
import Mouse from
|
|
12
|
-
import Timing from
|
|
13
|
-
import Performance from
|
|
14
|
-
import Scroll from
|
|
15
|
-
import Viewport from
|
|
16
|
-
import Longtasks from
|
|
17
|
-
import CSSRules from
|
|
18
|
-
import { IN_BROWSER, deprecationWarn, DOCS_HOST } from
|
|
6
|
+
import Connection from "./modules/connection.js";
|
|
7
|
+
import Console from "./modules/console.js";
|
|
8
|
+
import Exception, { getExceptionMessageFromEvent, getExceptionMessage } from "./modules/exception.js";
|
|
9
|
+
import Img from "./modules/img.js";
|
|
10
|
+
import Input from "./modules/input.js";
|
|
11
|
+
import Mouse from "./modules/mouse.js";
|
|
12
|
+
import Timing from "./modules/timing.js";
|
|
13
|
+
import Performance from "./modules/performance.js";
|
|
14
|
+
import Scroll from "./modules/scroll.js";
|
|
15
|
+
import Viewport from "./modules/viewport.js";
|
|
16
|
+
import Longtasks from "./modules/longtasks.js";
|
|
17
|
+
import CSSRules from "./modules/cssrules.js";
|
|
18
|
+
import { IN_BROWSER, deprecationWarn, DOCS_HOST } from "./utils.js";
|
|
19
19
|
const DOCS_SETUP = '/installation/setup-or';
|
|
20
20
|
function processOptions(obj) {
|
|
21
21
|
if (obj == null) {
|
|
@@ -73,7 +73,10 @@ export default class API {
|
|
|
73
73
|
console.error("OpenReplay: Your website must be publicly accessible and running on SSL in order for OpenReplay to properly capture and replay the user session. You can disable this check by setting `__DISABLE_SECURE_MODE` option to `true` if you are testing in localhost. Keep in mind, that asset files on a local machine are not available to the outside world. This might affect tracking if you use css files.");
|
|
74
74
|
return;
|
|
75
75
|
}
|
|
76
|
-
const doNotTrack = options.respectDoNotTrack &&
|
|
76
|
+
const doNotTrack = options.respectDoNotTrack &&
|
|
77
|
+
(navigator.doNotTrack == '1'
|
|
78
|
+
// @ts-ignore
|
|
79
|
+
|| window.doNotTrack == '1');
|
|
77
80
|
this.app = doNotTrack ||
|
|
78
81
|
!('Map' in window) ||
|
|
79
82
|
!('Set' in window) ||
|
|
@@ -93,7 +96,7 @@ export default class API {
|
|
|
93
96
|
Exception(this.app, options);
|
|
94
97
|
Img(this.app);
|
|
95
98
|
Input(this.app, options);
|
|
96
|
-
Mouse(this.app
|
|
99
|
+
Mouse(this.app);
|
|
97
100
|
Timing(this.app, options);
|
|
98
101
|
Performance(this.app, options);
|
|
99
102
|
Scroll(this.app);
|
|
@@ -108,7 +111,7 @@ export default class API {
|
|
|
108
111
|
// no-cors issue only with text/plain or not-set Content-Type
|
|
109
112
|
// req.setRequestHeader("Content-Type", "application/json;charset=UTF-8");
|
|
110
113
|
req.send(JSON.stringify({
|
|
111
|
-
trackerVersion: '3.4.
|
|
114
|
+
trackerVersion: '3.4.8',
|
|
112
115
|
projectKey: options.projectKey,
|
|
113
116
|
doNotTrack,
|
|
114
117
|
// TODO: add precise reason (an exact API missing)
|
package/lib/messages/index.d.ts
CHANGED