@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
|
@@ -3,17 +3,17 @@ export interface Options {
|
|
|
3
3
|
connAttemptGap?: number;
|
|
4
4
|
}
|
|
5
5
|
declare type Start = {
|
|
6
|
-
type:
|
|
6
|
+
type: 'start';
|
|
7
7
|
ingestPoint: string;
|
|
8
8
|
pageNo: number;
|
|
9
9
|
timestamp: number;
|
|
10
10
|
} & Options;
|
|
11
11
|
declare type Auth = {
|
|
12
|
-
type:
|
|
12
|
+
type: 'auth';
|
|
13
13
|
token: string;
|
|
14
14
|
beaconSizeLimit?: number;
|
|
15
15
|
};
|
|
16
|
-
export declare type WorkerMessageData = null |
|
|
16
|
+
export declare type WorkerMessageData = null | 'stop' | Start | Auth | Array<{
|
|
17
17
|
_id: number;
|
|
18
18
|
}>;
|
|
19
19
|
export {};
|
package/lib/index.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import App from
|
|
1
|
+
import App from './app/index.js';
|
|
2
2
|
export { default as App } from './app/index.js';
|
|
3
|
-
import * as _Messages from
|
|
3
|
+
import * as _Messages from './common/messages.js';
|
|
4
4
|
export declare const Messages: typeof _Messages;
|
|
5
|
-
import type { Options as AppOptions } from
|
|
6
|
-
import type { Options as ConsoleOptions } from
|
|
7
|
-
import type { Options as ExceptionOptions } from
|
|
8
|
-
import type { Options as InputOptions } from
|
|
9
|
-
import type { Options as PerformanceOptions } from
|
|
10
|
-
import type { Options as TimingOptions } from
|
|
5
|
+
import type { Options as AppOptions } from './app/index.js';
|
|
6
|
+
import type { Options as ConsoleOptions } from './modules/console.js';
|
|
7
|
+
import type { Options as ExceptionOptions } from './modules/exception.js';
|
|
8
|
+
import type { Options as InputOptions } from './modules/input.js';
|
|
9
|
+
import type { Options as PerformanceOptions } from './modules/performance.js';
|
|
10
|
+
import type { Options as TimingOptions } from './modules/timing.js';
|
|
11
11
|
import type { StartOptions } from './app/index.js';
|
|
12
12
|
import type { StartPromiseReturn } from './app/index.js';
|
|
13
13
|
export declare type Options = Partial<AppOptions & ConsoleOptions & ExceptionOptions & InputOptions & PerformanceOptions & TimingOptions> & {
|
|
@@ -29,6 +29,7 @@ export default class API {
|
|
|
29
29
|
getSessionToken(): string | null | undefined;
|
|
30
30
|
getSessionID(): string | null | undefined;
|
|
31
31
|
sessionID(): string | null | undefined;
|
|
32
|
+
getSessionURL(): string | undefined;
|
|
32
33
|
setUserID(id: string): void;
|
|
33
34
|
userID(id: string): void;
|
|
34
35
|
setUserAnonymousID(id: string): void;
|
package/lib/index.js
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import App, { DEFAULT_INGEST_POINT } from
|
|
1
|
+
import App, { DEFAULT_INGEST_POINT } from './app/index.js';
|
|
2
2
|
export { default as App } from './app/index.js';
|
|
3
|
-
import { UserAnonymousID, RawCustomEvent, CustomIssue } from
|
|
4
|
-
import * as _Messages from
|
|
3
|
+
import { UserAnonymousID, RawCustomEvent, CustomIssue, } from './common/messages.js';
|
|
4
|
+
import * as _Messages from './common/messages.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 CSSRules from
|
|
17
|
-
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 CSSRules from './modules/cssrules.js';
|
|
17
|
+
import { IN_BROWSER, deprecationWarn, DOCS_HOST } from './utils.js';
|
|
18
18
|
const DOCS_SETUP = '/installation/setup-or';
|
|
19
19
|
function processOptions(obj) {
|
|
20
20
|
if (obj == null) {
|
|
@@ -23,17 +23,18 @@ function processOptions(obj) {
|
|
|
23
23
|
}
|
|
24
24
|
if (typeof obj.projectKey !== 'string') {
|
|
25
25
|
if (typeof obj.projectKey !== 'number') {
|
|
26
|
-
if (typeof obj.projectID !== 'number') {
|
|
26
|
+
if (typeof obj.projectID !== 'number') {
|
|
27
|
+
// Back compatability
|
|
27
28
|
console.error(`OpenReplay: projectKey is missing or wrong type (string is expected). Please, check ${DOCS_HOST}${DOCS_SETUP} for more information.`);
|
|
28
29
|
return false;
|
|
29
30
|
}
|
|
30
31
|
else {
|
|
31
32
|
obj.projectKey = obj.projectID.toString();
|
|
32
|
-
deprecationWarn(
|
|
33
|
+
deprecationWarn('`projectID` option', '`projectKey` option', DOCS_SETUP);
|
|
33
34
|
}
|
|
34
35
|
}
|
|
35
36
|
else {
|
|
36
|
-
console.warn(
|
|
37
|
+
console.warn('OpenReplay: projectKey is expected to have a string type.');
|
|
37
38
|
obj.projectKey = obj.projectKey.toString();
|
|
38
39
|
}
|
|
39
40
|
}
|
|
@@ -65,28 +66,29 @@ export default class API {
|
|
|
65
66
|
return;
|
|
66
67
|
}
|
|
67
68
|
if (window.__OPENREPLAY__) {
|
|
68
|
-
console.error(
|
|
69
|
+
console.error('OpenReplay: one tracker instance has been initialised already');
|
|
69
70
|
return;
|
|
70
71
|
}
|
|
71
72
|
if (!options.__DISABLE_SECURE_MODE && location.protocol !== 'https:') {
|
|
72
|
-
console.error(
|
|
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.');
|
|
73
74
|
return;
|
|
74
75
|
}
|
|
75
76
|
const doNotTrack = options.respectDoNotTrack &&
|
|
76
|
-
(navigator.doNotTrack == '1'
|
|
77
|
+
(navigator.doNotTrack == '1' ||
|
|
77
78
|
// @ts-ignore
|
|
78
|
-
|
|
79
|
-
const app = this.app =
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
79
|
+
window.doNotTrack == '1');
|
|
80
|
+
const app = (this.app =
|
|
81
|
+
doNotTrack ||
|
|
82
|
+
!('Map' in window) ||
|
|
83
|
+
!('Set' in window) ||
|
|
84
|
+
!('MutationObserver' in window) ||
|
|
85
|
+
!('performance' in window) ||
|
|
86
|
+
!('timing' in performance) ||
|
|
87
|
+
!('startsWith' in String.prototype) ||
|
|
88
|
+
!('Blob' in window) ||
|
|
89
|
+
!('Worker' in window)
|
|
90
|
+
? null
|
|
91
|
+
: new App(options.projectKey, options.sessionToken, options));
|
|
90
92
|
if (app !== null) {
|
|
91
93
|
Viewport(app);
|
|
92
94
|
CSSRules(app);
|
|
@@ -119,11 +121,11 @@ export default class API {
|
|
|
119
121
|
console.log("OpenReplay: browser doesn't support API required for tracking or doNotTrack is set to 1.");
|
|
120
122
|
const req = new XMLHttpRequest();
|
|
121
123
|
const orig = options.ingestPoint || DEFAULT_INGEST_POINT;
|
|
122
|
-
req.open(
|
|
124
|
+
req.open('POST', orig + '/v1/web/not-started');
|
|
123
125
|
// no-cors issue only with text/plain or not-set Content-Type
|
|
124
126
|
// req.setRequestHeader("Content-Type", "application/json;charset=UTF-8");
|
|
125
127
|
req.send(JSON.stringify({
|
|
126
|
-
trackerVersion: '3.6.
|
|
128
|
+
trackerVersion: '3.6.6',
|
|
127
129
|
projectKey: options.projectKey,
|
|
128
130
|
doNotTrack,
|
|
129
131
|
// TODO: add precise reason (an exact API missing)
|
|
@@ -142,7 +144,7 @@ export default class API {
|
|
|
142
144
|
start(startOpts) {
|
|
143
145
|
if (!IN_BROWSER) {
|
|
144
146
|
console.error(`OpenReplay: you are trying to start Tracker on a node.js environment. If you want to use OpenReplay with SSR, please, use componentDidMount or useEffect API for placing the \`tracker.start()\` line. Check documentation on ${DOCS_HOST}${DOCS_SETUP}`);
|
|
145
|
-
return Promise.reject(
|
|
147
|
+
return Promise.reject('Trying to start not in browser.');
|
|
146
148
|
}
|
|
147
149
|
if (this.app === null) {
|
|
148
150
|
return Promise.reject("Browser doesn't support required api, or doNotTrack is active.");
|
|
@@ -169,16 +171,22 @@ export default class API {
|
|
|
169
171
|
return this.app.getSessionID();
|
|
170
172
|
}
|
|
171
173
|
sessionID() {
|
|
172
|
-
deprecationWarn("'sessionID' method", "'getSessionID' method",
|
|
174
|
+
deprecationWarn("'sessionID' method", "'getSessionID' method", '/');
|
|
173
175
|
return this.getSessionID();
|
|
174
176
|
}
|
|
177
|
+
getSessionURL() {
|
|
178
|
+
if (this.app === null) {
|
|
179
|
+
return undefined;
|
|
180
|
+
}
|
|
181
|
+
return this.app.getSessionURL();
|
|
182
|
+
}
|
|
175
183
|
setUserID(id) {
|
|
176
184
|
if (typeof id === 'string' && this.app !== null) {
|
|
177
185
|
this.app.session.setUserID(id);
|
|
178
186
|
}
|
|
179
187
|
}
|
|
180
188
|
userID(id) {
|
|
181
|
-
deprecationWarn("'userID' method", "'setUserID' method",
|
|
189
|
+
deprecationWarn("'userID' method", "'setUserID' method", '/');
|
|
182
190
|
this.setUserID(id);
|
|
183
191
|
}
|
|
184
192
|
setUserAnonymousID(id) {
|
|
@@ -187,18 +195,16 @@ export default class API {
|
|
|
187
195
|
}
|
|
188
196
|
}
|
|
189
197
|
userAnonymousID(id) {
|
|
190
|
-
deprecationWarn("'userAnonymousID' method", "'setUserAnonymousID' method",
|
|
198
|
+
deprecationWarn("'userAnonymousID' method", "'setUserAnonymousID' method", '/');
|
|
191
199
|
this.setUserAnonymousID(id);
|
|
192
200
|
}
|
|
193
201
|
setMetadata(key, value) {
|
|
194
|
-
if (typeof key === 'string' &&
|
|
195
|
-
typeof value === 'string' &&
|
|
196
|
-
this.app !== null) {
|
|
202
|
+
if (typeof key === 'string' && typeof value === 'string' && this.app !== null) {
|
|
197
203
|
this.app.session.setMetadata(key, value);
|
|
198
204
|
}
|
|
199
205
|
}
|
|
200
206
|
metadata(key, value) {
|
|
201
|
-
deprecationWarn("'metadata' method", "'setMetadata' method",
|
|
207
|
+
deprecationWarn("'metadata' method", "'setMetadata' method", '/');
|
|
202
208
|
this.setMetadata(key, value);
|
|
203
209
|
}
|
|
204
210
|
event(key, payload, issue = false) {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import App from
|
|
1
|
+
import App from '../app/index.js';
|
|
2
2
|
export default function (app: App): void;
|
package/lib/modules/console.d.ts
CHANGED
package/lib/modules/console.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { hasTag } from
|
|
2
|
-
import { IN_BROWSER } from
|
|
3
|
-
import { ConsoleLog } from
|
|
1
|
+
import { hasTag } from '../app/guards.js';
|
|
2
|
+
import { IN_BROWSER } from '../utils.js';
|
|
3
|
+
import { ConsoleLog } from '../common/messages.js';
|
|
4
4
|
const printError = IN_BROWSER && 'InstallTrigger' in window // detect Firefox
|
|
5
5
|
? (e) => e.message + '\n' + e.stack
|
|
6
6
|
: (e) => e.stack || e.message;
|
|
@@ -87,8 +87,7 @@ export default function (app, opts) {
|
|
|
87
87
|
consoleMethods,
|
|
88
88
|
consoleThrottling: 30,
|
|
89
89
|
}, opts);
|
|
90
|
-
if (!Array.isArray(options.consoleMethods) ||
|
|
91
|
-
options.consoleMethods.length === 0) {
|
|
90
|
+
if (!Array.isArray(options.consoleMethods) || options.consoleMethods.length === 0) {
|
|
92
91
|
return;
|
|
93
92
|
}
|
|
94
93
|
const sendConsoleLog = app.safe((level, args) => app.send(new ConsoleLog(level, printf(args))));
|
|
@@ -113,13 +112,14 @@ export default function (app, opts) {
|
|
|
113
112
|
};
|
|
114
113
|
});
|
|
115
114
|
patchConsole(window.console);
|
|
116
|
-
app.nodes.attachNodeCallback(app.safe(node => {
|
|
117
|
-
if (hasTag(node,
|
|
115
|
+
app.nodes.attachNodeCallback(app.safe((node) => {
|
|
116
|
+
if (hasTag(node, 'IFRAME')) {
|
|
117
|
+
// TODO: newContextCallback
|
|
118
118
|
let context = node.contentWindow;
|
|
119
119
|
if (context) {
|
|
120
120
|
patchConsole(context.console);
|
|
121
121
|
}
|
|
122
|
-
app.attachEventListener(node,
|
|
122
|
+
app.attachEventListener(node, 'load', () => {
|
|
123
123
|
if (node.contentWindow !== context) {
|
|
124
124
|
context = node.contentWindow;
|
|
125
125
|
patchConsole(context.console);
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type App from
|
|
1
|
+
import type App from '../app/index.js';
|
|
2
2
|
export default function (app: App | null): void;
|
package/lib/modules/cssrules.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { CSSInsertRuleURLBased, CSSDeleteRule, TechnicalInfo } from
|
|
2
|
-
import { hasTag } from
|
|
1
|
+
import { CSSInsertRuleURLBased, CSSDeleteRule, TechnicalInfo } from '../common/messages.js';
|
|
2
|
+
import { hasTag } from '../app/guards.js';
|
|
3
3
|
export default function (app) {
|
|
4
4
|
if (app === null) {
|
|
5
5
|
return;
|
|
6
6
|
}
|
|
7
7
|
if (!window.CSSStyleSheet) {
|
|
8
|
-
app.send(new TechnicalInfo(
|
|
8
|
+
app.send(new TechnicalInfo('no_stylesheet_prototype_in_window', ''));
|
|
9
9
|
return;
|
|
10
10
|
}
|
|
11
11
|
const processOperation = app.safe((stylesheet, index, rule) => {
|
|
@@ -14,7 +14,7 @@ export default function (app) {
|
|
|
14
14
|
: (nodeID) => app.send(new CSSDeleteRule(nodeID, index));
|
|
15
15
|
// TODO: Extend messages to maintain nested rules (CSSGroupingRule prototype, as well as CSSKeyframesRule)
|
|
16
16
|
if (stylesheet.ownerNode == null) {
|
|
17
|
-
throw new Error(
|
|
17
|
+
throw new Error('Owner Node not found');
|
|
18
18
|
}
|
|
19
19
|
const nodeID = app.nodes.getID(stylesheet.ownerNode);
|
|
20
20
|
if (nodeID !== undefined) {
|
|
@@ -31,7 +31,7 @@ export default function (app) {
|
|
|
31
31
|
return deleteRule.call(this, index);
|
|
32
32
|
};
|
|
33
33
|
app.nodes.attachNodeCallback((node) => {
|
|
34
|
-
if (!hasTag(node,
|
|
34
|
+
if (!hasTag(node, 'STYLE') || !node.sheet) {
|
|
35
35
|
return;
|
|
36
36
|
}
|
|
37
37
|
if (node.textContent !== null && node.textContent.trim().length > 0) {
|
package/lib/modules/exception.js
CHANGED
|
@@ -1,21 +1,22 @@
|
|
|
1
|
-
import { JSException } from
|
|
1
|
+
import { JSException } from '../common/messages.js';
|
|
2
2
|
import ErrorStackParser from 'error-stack-parser';
|
|
3
3
|
function getDefaultStack(e) {
|
|
4
|
-
return [
|
|
4
|
+
return [
|
|
5
|
+
{
|
|
5
6
|
columnNumber: e.colno,
|
|
6
7
|
lineNumber: e.lineno,
|
|
7
8
|
fileName: e.filename,
|
|
8
|
-
functionName:
|
|
9
|
-
source:
|
|
10
|
-
}
|
|
9
|
+
functionName: '',
|
|
10
|
+
source: '',
|
|
11
|
+
},
|
|
12
|
+
];
|
|
11
13
|
}
|
|
12
14
|
export function getExceptionMessage(error, fallbackStack) {
|
|
13
15
|
let stack = fallbackStack;
|
|
14
16
|
try {
|
|
15
17
|
stack = ErrorStackParser.parse(error);
|
|
16
18
|
}
|
|
17
|
-
catch (e) {
|
|
18
|
-
}
|
|
19
|
+
catch (e) { }
|
|
19
20
|
return new JSException(error.name, error.message, JSON.stringify(stack));
|
|
20
21
|
}
|
|
21
22
|
export function getExceptionMessageFromEvent(e) {
|
package/lib/modules/img.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type App from
|
|
1
|
+
import type App from '../app/index.js';
|
|
2
2
|
export default function (app: App): void;
|
package/lib/modules/img.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { timestamp, isURL } from
|
|
2
|
-
import { ResourceTiming, SetNodeAttributeURLBased, SetNodeAttribute } from
|
|
3
|
-
import { hasTag } from
|
|
1
|
+
import { timestamp, isURL } from '../utils.js';
|
|
2
|
+
import { ResourceTiming, SetNodeAttributeURLBased, SetNodeAttribute, } from '../common/messages.js';
|
|
3
|
+
import { hasTag } from '../app/guards.js';
|
|
4
4
|
function resolveURL(url, location = document.location) {
|
|
5
5
|
url = url.trim();
|
|
6
6
|
if (url.startsWith('/')) {
|
|
@@ -16,16 +16,16 @@ function resolveURL(url, location = document.location) {
|
|
|
16
16
|
return location.origin + location.pathname + url;
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
|
-
const PLACEHOLDER_SRC =
|
|
19
|
+
const PLACEHOLDER_SRC = 'https://static.openreplay.com/tracker/placeholder.jpeg';
|
|
20
20
|
export default function (app) {
|
|
21
21
|
function sendPlaceholder(id, node) {
|
|
22
|
-
app.send(new SetNodeAttribute(id,
|
|
22
|
+
app.send(new SetNodeAttribute(id, 'src', PLACEHOLDER_SRC));
|
|
23
23
|
const { width, height } = node.getBoundingClientRect();
|
|
24
|
-
if (!node.hasAttribute(
|
|
25
|
-
app.send(new SetNodeAttribute(id,
|
|
24
|
+
if (!node.hasAttribute('width')) {
|
|
25
|
+
app.send(new SetNodeAttribute(id, 'width', String(width)));
|
|
26
26
|
}
|
|
27
|
-
if (!node.hasAttribute(
|
|
28
|
-
app.send(new SetNodeAttribute(id,
|
|
27
|
+
if (!node.hasAttribute('height')) {
|
|
28
|
+
app.send(new SetNodeAttribute(id, 'height', String(height)));
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
31
|
const sendImgSrc = app.safe(function () {
|
|
@@ -49,24 +49,27 @@ export default function (app) {
|
|
|
49
49
|
else {
|
|
50
50
|
app.send(new SetNodeAttribute(id, 'src', resolvedSrc));
|
|
51
51
|
if (srcset) {
|
|
52
|
-
const resolvedSrcset = srcset
|
|
52
|
+
const resolvedSrcset = srcset
|
|
53
|
+
.split(',')
|
|
54
|
+
.map((str) => resolveURL(str))
|
|
55
|
+
.join(',');
|
|
53
56
|
app.send(new SetNodeAttribute(id, 'srcset', resolvedSrcset));
|
|
54
57
|
}
|
|
55
58
|
}
|
|
56
59
|
});
|
|
57
60
|
const observer = new MutationObserver((mutations) => {
|
|
58
61
|
for (const mutation of mutations) {
|
|
59
|
-
if (mutation.type ===
|
|
62
|
+
if (mutation.type === 'attributes') {
|
|
60
63
|
const target = mutation.target;
|
|
61
64
|
const id = app.nodes.getID(target);
|
|
62
65
|
if (id === undefined) {
|
|
63
66
|
return;
|
|
64
67
|
}
|
|
65
|
-
if (mutation.attributeName ===
|
|
68
|
+
if (mutation.attributeName === 'src') {
|
|
66
69
|
const src = target.src;
|
|
67
70
|
app.send(new SetNodeAttributeURLBased(id, 'src', src, app.getBaseHref()));
|
|
68
71
|
}
|
|
69
|
-
if (mutation.attributeName ===
|
|
72
|
+
if (mutation.attributeName === 'srcset') {
|
|
70
73
|
const srcset = target.srcset;
|
|
71
74
|
app.send(new SetNodeAttribute(id, 'srcset', srcset));
|
|
72
75
|
}
|
|
@@ -74,12 +77,12 @@ export default function (app) {
|
|
|
74
77
|
}
|
|
75
78
|
});
|
|
76
79
|
app.nodes.attachNodeCallback((node) => {
|
|
77
|
-
if (!hasTag(node,
|
|
80
|
+
if (!hasTag(node, 'IMG')) {
|
|
78
81
|
return;
|
|
79
82
|
}
|
|
80
83
|
app.nodes.attachElementListener('error', node, sendImgSrc);
|
|
81
84
|
app.nodes.attachElementListener('load', node, sendImgSrc);
|
|
82
85
|
sendImgSrc.call(node);
|
|
83
|
-
observer.observe(node, { attributes: true, attributeFilter: [
|
|
86
|
+
observer.observe(node, { attributes: true, attributeFilter: ['src', 'srcset'] });
|
|
84
87
|
});
|
|
85
88
|
}
|
package/lib/modules/input.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type App from
|
|
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 {
|
package/lib/modules/input.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { normSpaces, IN_BROWSER, getLabelAttribute, hasOpenreplayAttribute
|
|
2
|
-
import { hasTag } from
|
|
3
|
-
import { SetInputTarget, SetInputValue, SetInputChecked } from
|
|
1
|
+
import { normSpaces, IN_BROWSER, getLabelAttribute, hasOpenreplayAttribute } from '../utils.js';
|
|
2
|
+
import { hasTag } from '../app/guards.js';
|
|
3
|
+
import { SetInputTarget, SetInputValue, SetInputChecked } from '../common/messages.js';
|
|
4
4
|
const INPUT_TYPES = ['text', 'password', 'email', 'search', 'number', 'range', 'date'];
|
|
5
5
|
function isTextEditable(node) {
|
|
6
|
-
if (hasTag(node,
|
|
6
|
+
if (hasTag(node, 'TEXTAREA')) {
|
|
7
7
|
return true;
|
|
8
8
|
}
|
|
9
|
-
if (!hasTag(node,
|
|
9
|
+
if (!hasTag(node, 'INPUT')) {
|
|
10
10
|
return false;
|
|
11
11
|
}
|
|
12
12
|
return INPUT_TYPES.includes(node.type);
|
|
13
13
|
}
|
|
14
14
|
function isCheckable(node) {
|
|
15
|
-
if (!hasTag(node,
|
|
15
|
+
if (!hasTag(node, 'INPUT')) {
|
|
16
16
|
return false;
|
|
17
17
|
}
|
|
18
18
|
const type = node.type;
|
|
@@ -22,7 +22,7 @@ const labelElementFor = IN_BROWSER && 'labels' in HTMLInputElement.prototype
|
|
|
22
22
|
? (node) => {
|
|
23
23
|
let p = node;
|
|
24
24
|
while ((p = p.parentNode) !== null) {
|
|
25
|
-
if (hasTag(p,
|
|
25
|
+
if (hasTag(p, 'LABEL')) {
|
|
26
26
|
return p;
|
|
27
27
|
}
|
|
28
28
|
}
|
|
@@ -34,7 +34,7 @@ const labelElementFor = IN_BROWSER && 'labels' in HTMLInputElement.prototype
|
|
|
34
34
|
: (node) => {
|
|
35
35
|
let p = node;
|
|
36
36
|
while ((p = p.parentNode) !== null) {
|
|
37
|
-
if (hasTag(p,
|
|
37
|
+
if (hasTag(p, 'LABEL')) {
|
|
38
38
|
return p;
|
|
39
39
|
}
|
|
40
40
|
}
|
|
@@ -50,12 +50,13 @@ export function getInputLabel(node) {
|
|
|
50
50
|
let label = getLabelAttribute(node);
|
|
51
51
|
if (label === null) {
|
|
52
52
|
const labelElement = labelElementFor(node);
|
|
53
|
-
label =
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
53
|
+
label =
|
|
54
|
+
(labelElement && labelElement.innerText) ||
|
|
55
|
+
node.placeholder ||
|
|
56
|
+
node.name ||
|
|
57
|
+
node.id ||
|
|
58
|
+
node.className ||
|
|
59
|
+
node.type;
|
|
59
60
|
}
|
|
60
61
|
return normSpaces(label).slice(0, 100);
|
|
61
62
|
}
|
|
@@ -82,8 +83,7 @@ export default function (app, opts) {
|
|
|
82
83
|
(inputMode === 0 /* Plain */ &&
|
|
83
84
|
((options.obscureInputNumbers && node.type !== 'date' && /\d\d\d\d/.test(value)) ||
|
|
84
85
|
(options.obscureInputDates && node.type === 'date') ||
|
|
85
|
-
(options.obscureInputEmails &&
|
|
86
|
-
(node.type === 'email' || !!~value.indexOf('@')))))) {
|
|
86
|
+
(options.obscureInputEmails && (node.type === 'email' || !!~value.indexOf('@')))))) {
|
|
87
87
|
inputMode = 1 /* Obscured */;
|
|
88
88
|
}
|
|
89
89
|
let mask = 0;
|
|
@@ -146,9 +146,9 @@ export default function (app, opts) {
|
|
|
146
146
|
return;
|
|
147
147
|
}
|
|
148
148
|
// TODO: support multiple select (?): use selectedOptions; Need send target?
|
|
149
|
-
if (hasTag(node,
|
|
149
|
+
if (hasTag(node, 'SELECT')) {
|
|
150
150
|
sendInputValue(id, node);
|
|
151
|
-
app.attachEventListener(node,
|
|
151
|
+
app.attachEventListener(node, 'change', () => {
|
|
152
152
|
sendInputValue(id, node);
|
|
153
153
|
});
|
|
154
154
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type App from
|
|
1
|
+
import type App from '../app/index.js';
|
|
2
2
|
export default function (app: App): void;
|
package/lib/modules/longtasks.js
CHANGED
|
@@ -1,14 +1,22 @@
|
|
|
1
|
-
import { LongTask } from
|
|
2
|
-
;
|
|
3
|
-
;
|
|
1
|
+
import { LongTask } from '../common/messages.js';
|
|
4
2
|
export default function (app) {
|
|
5
3
|
if (!('PerformanceObserver' in window) || !('PerformanceLongTaskTiming' in window)) {
|
|
6
4
|
return;
|
|
7
5
|
}
|
|
8
|
-
const contexts = [
|
|
9
|
-
|
|
6
|
+
const contexts = [
|
|
7
|
+
'unknown',
|
|
8
|
+
'self',
|
|
9
|
+
'same-origin-ancestor',
|
|
10
|
+
'same-origin-descendant',
|
|
11
|
+
'same-origin',
|
|
12
|
+
'cross-origin-ancestor',
|
|
13
|
+
'cross-origin-descendant',
|
|
14
|
+
'cross-origin-unreachable',
|
|
15
|
+
'multiple-contexts',
|
|
16
|
+
];
|
|
17
|
+
const containerTypes = ['window', 'iframe', 'embed', 'object'];
|
|
10
18
|
function longTask(entry) {
|
|
11
|
-
let type =
|
|
19
|
+
let type = '', src = '', id = '', name = '';
|
|
12
20
|
const container = entry.attribution[0];
|
|
13
21
|
if (container != null) {
|
|
14
22
|
type = container.containerType;
|
package/lib/modules/mouse.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type App from
|
|
1
|
+
import type App from '../app/index.js';
|
|
2
2
|
export default function (app: App): void;
|