@openreplay/tracker 3.4.17-beta.0 → 3.5.1
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 +8 -1
- package/cjs/app/index.d.ts +30 -4
- package/cjs/app/index.js +148 -117
- package/cjs/app/logger.d.ts +27 -0
- package/cjs/app/logger.js +42 -0
- package/cjs/app/observer/top_observer.js +2 -1
- package/cjs/index.d.ts +10 -10
- package/cjs/index.js +32 -27
- package/cjs/modules/console.js +1 -1
- package/cjs/modules/mouse.js +2 -0
- package/cjs/utils.d.ts +0 -8
- package/cjs/utils.js +3 -4
- package/lib/app/index.d.ts +30 -4
- package/lib/app/index.js +149 -118
- package/lib/app/logger.d.ts +27 -0
- package/lib/app/logger.js +39 -1
- package/lib/app/observer/top_observer.js +2 -1
- package/lib/index.d.ts +10 -10
- package/lib/index.js +32 -27
- package/lib/modules/console.js +1 -1
- package/lib/modules/mouse.js +2 -0
- package/lib/utils.d.ts +0 -8
- package/lib/utils.js +2 -3
- package/package.json +2 -2
package/cjs/index.d.ts
CHANGED
|
@@ -2,18 +2,20 @@ import App from "./app/index.js";
|
|
|
2
2
|
export { default as App } from './app/index.js';
|
|
3
3
|
import * as _Messages from "./messages/index.js";
|
|
4
4
|
export declare const Messages: typeof _Messages;
|
|
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
|
-
|
|
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
|
+
import type { StartOptions } from './app/index.js';
|
|
12
|
+
import type { OnStartInfo } from './app/index.js';
|
|
12
13
|
export declare type Options = Partial<AppOptions & ConsoleOptions & ExceptionOptions & InputOptions & PerformanceOptions & TimingOptions> & {
|
|
13
14
|
projectID?: number;
|
|
14
15
|
projectKey: string;
|
|
15
16
|
sessionToken?: string;
|
|
16
17
|
respectDoNotTrack?: boolean;
|
|
18
|
+
autoResetOnWindowOpen?: boolean;
|
|
17
19
|
__DISABLE_SECURE_MODE?: boolean;
|
|
18
20
|
};
|
|
19
21
|
export default class API {
|
|
@@ -22,8 +24,7 @@ export default class API {
|
|
|
22
24
|
constructor(options: Options);
|
|
23
25
|
use<T>(fn: (app: App | null, options?: Options) => T): T;
|
|
24
26
|
isActive(): boolean;
|
|
25
|
-
|
|
26
|
-
start(): Promise<import("./app/index.js").OnStartInfo>;
|
|
27
|
+
start(startOpts?: StartOptions): Promise<OnStartInfo>;
|
|
27
28
|
stop(): void;
|
|
28
29
|
getSessionToken(): string | null | undefined;
|
|
29
30
|
getSessionID(): string | null | undefined;
|
|
@@ -37,5 +38,4 @@ export default class API {
|
|
|
37
38
|
event(key: string, payload: any, issue?: boolean): void;
|
|
38
39
|
issue(key: string, payload: any): void;
|
|
39
40
|
handleError: (e: Error | ErrorEvent | PromiseRejectionEvent) => void;
|
|
40
|
-
resetNextPageSession(flag: boolean): void;
|
|
41
41
|
}
|
package/cjs/index.js
CHANGED
|
@@ -81,7 +81,7 @@ class API {
|
|
|
81
81
|
(navigator.doNotTrack == '1'
|
|
82
82
|
// @ts-ignore
|
|
83
83
|
|| window.doNotTrack == '1');
|
|
84
|
-
this.app = doNotTrack ||
|
|
84
|
+
const app = this.app = doNotTrack ||
|
|
85
85
|
!('Map' in window) ||
|
|
86
86
|
!('Set' in window) ||
|
|
87
87
|
!('MutationObserver' in window) ||
|
|
@@ -92,20 +92,34 @@ class API {
|
|
|
92
92
|
!('Worker' in window)
|
|
93
93
|
? null
|
|
94
94
|
: new index_js_1.default(options.projectKey, options.sessionToken, options);
|
|
95
|
-
if (
|
|
96
|
-
(0, viewport_js_1.default)(
|
|
97
|
-
(0, cssrules_js_1.default)(
|
|
98
|
-
(0, connection_js_1.default)(
|
|
99
|
-
(0, console_js_1.default)(
|
|
100
|
-
(0, exception_js_1.default)(
|
|
101
|
-
(0, img_js_1.default)(
|
|
102
|
-
(0, input_js_1.default)(
|
|
103
|
-
(0, mouse_js_1.default)(
|
|
104
|
-
(0, timing_js_1.default)(
|
|
105
|
-
(0, performance_js_1.default)(
|
|
106
|
-
(0, scroll_js_1.default)(
|
|
107
|
-
(0, longtasks_js_1.default)(
|
|
95
|
+
if (app !== null) {
|
|
96
|
+
(0, viewport_js_1.default)(app);
|
|
97
|
+
(0, cssrules_js_1.default)(app);
|
|
98
|
+
(0, connection_js_1.default)(app);
|
|
99
|
+
(0, console_js_1.default)(app, options);
|
|
100
|
+
(0, exception_js_1.default)(app, options);
|
|
101
|
+
(0, img_js_1.default)(app);
|
|
102
|
+
(0, input_js_1.default)(app, options);
|
|
103
|
+
(0, mouse_js_1.default)(app);
|
|
104
|
+
(0, timing_js_1.default)(app, options);
|
|
105
|
+
(0, performance_js_1.default)(app, options);
|
|
106
|
+
(0, scroll_js_1.default)(app);
|
|
107
|
+
(0, longtasks_js_1.default)(app);
|
|
108
108
|
window.__OPENREPLAY__ = this;
|
|
109
|
+
if (options.autoResetOnWindowOpen) {
|
|
110
|
+
const wOpen = window.open;
|
|
111
|
+
app.attachStartCallback(() => {
|
|
112
|
+
// @ts-ignore ?
|
|
113
|
+
window.open = function (...args) {
|
|
114
|
+
app.resetNextPageSession(true);
|
|
115
|
+
wOpen.call(window, ...args);
|
|
116
|
+
app.resetNextPageSession(false);
|
|
117
|
+
};
|
|
118
|
+
});
|
|
119
|
+
app.attachStopCallback(() => {
|
|
120
|
+
window.open = wOpen;
|
|
121
|
+
});
|
|
122
|
+
}
|
|
109
123
|
}
|
|
110
124
|
else {
|
|
111
125
|
console.log("OpenReplay: browser doesn't support API required for tracking or doNotTrack is set to 1.");
|
|
@@ -115,7 +129,7 @@ class API {
|
|
|
115
129
|
// no-cors issue only with text/plain or not-set Content-Type
|
|
116
130
|
// req.setRequestHeader("Content-Type", "application/json;charset=UTF-8");
|
|
117
131
|
req.send(JSON.stringify({
|
|
118
|
-
trackerVersion: '3.
|
|
132
|
+
trackerVersion: '3.5.1',
|
|
119
133
|
projectKey: options.projectKey,
|
|
120
134
|
doNotTrack,
|
|
121
135
|
// TODO: add precise reason (an exact API missing)
|
|
@@ -131,11 +145,7 @@ class API {
|
|
|
131
145
|
}
|
|
132
146
|
return this.app.active();
|
|
133
147
|
}
|
|
134
|
-
|
|
135
|
-
(0, utils_js_1.deprecationWarn)("'active' method", "'isActive' method", "/");
|
|
136
|
-
return this.isActive();
|
|
137
|
-
}
|
|
138
|
-
start() {
|
|
148
|
+
start(startOpts) {
|
|
139
149
|
if (!utils_js_1.IN_BROWSER) {
|
|
140
150
|
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 ${utils_js_1.DOCS_HOST}${DOCS_SETUP}`);
|
|
141
151
|
return Promise.reject("Trying to start not in browser.");
|
|
@@ -143,7 +153,8 @@ class API {
|
|
|
143
153
|
if (this.app === null) {
|
|
144
154
|
return Promise.reject("Browser doesn't support required api, or doNotTrack is active.");
|
|
145
155
|
}
|
|
146
|
-
|
|
156
|
+
// TODO: check argument typing
|
|
157
|
+
return this.app.start(startOpts);
|
|
147
158
|
}
|
|
148
159
|
stop() {
|
|
149
160
|
if (this.app === null) {
|
|
@@ -223,11 +234,5 @@ class API {
|
|
|
223
234
|
this.app.send(new index_js_3.CustomIssue(key, payload));
|
|
224
235
|
}
|
|
225
236
|
}
|
|
226
|
-
resetNextPageSession(flag) {
|
|
227
|
-
if (typeof flag !== 'boolean' || !this.app) {
|
|
228
|
-
return;
|
|
229
|
-
}
|
|
230
|
-
this.app.resetNextPageSession(flag);
|
|
231
|
-
}
|
|
232
237
|
}
|
|
233
238
|
exports.default = API;
|
package/cjs/modules/console.js
CHANGED
package/cjs/modules/mouse.js
CHANGED
|
@@ -57,6 +57,7 @@ function _getTarget(target) {
|
|
|
57
57
|
if (tag === 'BUTTON' ||
|
|
58
58
|
tag === 'A' ||
|
|
59
59
|
tag === 'LI' ||
|
|
60
|
+
tag === 'SELECT' ||
|
|
60
61
|
element.onclick != null ||
|
|
61
62
|
element.getAttribute('role') === 'button' ||
|
|
62
63
|
(0, utils_js_1.getLabelAttribute)(element) !== null) {
|
|
@@ -83,6 +84,7 @@ function default_1(app) {
|
|
|
83
84
|
if (tag === 'BUTTON' ||
|
|
84
85
|
tag === 'A' ||
|
|
85
86
|
tag === 'LI' ||
|
|
87
|
+
tag === 'SELECT' ||
|
|
86
88
|
target.onclick != null ||
|
|
87
89
|
target.getAttribute('role') === 'button') {
|
|
88
90
|
const label = app.sanitizer.getInnerTextSecure(target);
|
package/cjs/utils.d.ts
CHANGED
|
@@ -3,14 +3,6 @@ export declare const stars: (str: string) => string;
|
|
|
3
3
|
export declare function normSpaces(str: string): string;
|
|
4
4
|
export declare function isURL(s: string): boolean;
|
|
5
5
|
export declare const IN_BROWSER: boolean;
|
|
6
|
-
export declare const log: {
|
|
7
|
-
(...data: any[]): void;
|
|
8
|
-
(message?: any, ...optionalParams: any[]): void;
|
|
9
|
-
};
|
|
10
|
-
export declare const warn: {
|
|
11
|
-
(...data: any[]): void;
|
|
12
|
-
(message?: any, ...optionalParams: any[]): void;
|
|
13
|
-
};
|
|
14
6
|
export declare const DOCS_HOST = "https://docs.openreplay.com";
|
|
15
7
|
export declare function deprecationWarn(nameOfFeature: string, useInstead: string, docsPath?: string): void;
|
|
16
8
|
export declare function getLabelAttribute(e: Element): string | null;
|
package/cjs/utils.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.hasOpenreplayAttribute = exports.getLabelAttribute = exports.deprecationWarn = exports.DOCS_HOST = exports.
|
|
3
|
+
exports.hasOpenreplayAttribute = exports.getLabelAttribute = exports.deprecationWarn = exports.DOCS_HOST = exports.IN_BROWSER = exports.isURL = exports.normSpaces = exports.stars = exports.timestamp = void 0;
|
|
4
4
|
function timestamp() {
|
|
5
5
|
return Math.round(performance.now()) + performance.timing.navigationStart;
|
|
6
6
|
}
|
|
@@ -18,15 +18,14 @@ function isURL(s) {
|
|
|
18
18
|
}
|
|
19
19
|
exports.isURL = isURL;
|
|
20
20
|
exports.IN_BROWSER = !(typeof window === "undefined");
|
|
21
|
-
|
|
22
|
-
exports.warn = console.warn;
|
|
21
|
+
// TODO: JOIN IT WITH LOGGER somehow (use logging decorators?); Don't forget about index.js loggin when there is no logger instance.
|
|
23
22
|
exports.DOCS_HOST = 'https://docs.openreplay.com';
|
|
24
23
|
const warnedFeatures = {};
|
|
25
24
|
function deprecationWarn(nameOfFeature, useInstead, docsPath = "/") {
|
|
26
25
|
if (warnedFeatures[nameOfFeature]) {
|
|
27
26
|
return;
|
|
28
27
|
}
|
|
29
|
-
|
|
28
|
+
console.warn(`OpenReplay: ${nameOfFeature} is deprecated. ${useInstead ? `Please, use ${useInstead} instead.` : ""} Visit ${exports.DOCS_HOST}${docsPath} for more information.`);
|
|
30
29
|
warnedFeatures[nameOfFeature] = true;
|
|
31
30
|
}
|
|
32
31
|
exports.deprecationWarn = deprecationWarn;
|
package/lib/app/index.d.ts
CHANGED
|
@@ -2,14 +2,21 @@ import Message from "../messages/message.js";
|
|
|
2
2
|
import Nodes from "./nodes.js";
|
|
3
3
|
import Sanitizer from "./sanitizer.js";
|
|
4
4
|
import Ticker from "./ticker.js";
|
|
5
|
+
import Logger from "./logger.js";
|
|
5
6
|
import type { Options as ObserverOptions } from "./observer/top_observer.js";
|
|
6
7
|
import type { Options as SanitizerOptions } from "./sanitizer.js";
|
|
8
|
+
import type { Options as LoggerOptions } from "./logger.js";
|
|
7
9
|
import type { Options as WebworkerOptions } from "../messages/webworker.js";
|
|
8
10
|
export interface OnStartInfo {
|
|
9
11
|
sessionID: string;
|
|
10
12
|
sessionToken: string;
|
|
11
13
|
userUUID: string;
|
|
12
14
|
}
|
|
15
|
+
export interface StartOptions {
|
|
16
|
+
userID?: string;
|
|
17
|
+
metadata?: Record<string, string>;
|
|
18
|
+
forceNew: boolean;
|
|
19
|
+
}
|
|
13
20
|
declare type AppOptions = {
|
|
14
21
|
revID: string;
|
|
15
22
|
node_id: string;
|
|
@@ -19,20 +26,24 @@ declare type AppOptions = {
|
|
|
19
26
|
local_uuid_key: string;
|
|
20
27
|
ingestPoint: string;
|
|
21
28
|
resourceBaseHref: string | null;
|
|
29
|
+
verbose: boolean;
|
|
22
30
|
__is_snippet: boolean;
|
|
23
31
|
__debug_report_edp: string | null;
|
|
24
|
-
|
|
32
|
+
__debug__?: LoggerOptions;
|
|
25
33
|
onStart?: (info: OnStartInfo) => void;
|
|
26
34
|
} & WebworkerOptions;
|
|
27
35
|
export declare type Options = AppOptions & ObserverOptions & SanitizerOptions;
|
|
28
36
|
declare type Callback = () => void;
|
|
29
37
|
declare type CommitCallback = (messages: Array<Message>) => void;
|
|
38
|
+
export declare const CANCELED = "canceled";
|
|
30
39
|
export declare const DEFAULT_INGEST_POINT = "https://api.openreplay.com/ingest";
|
|
31
40
|
export default class App {
|
|
32
41
|
readonly nodes: Nodes;
|
|
33
42
|
readonly ticker: Ticker;
|
|
34
43
|
readonly projectKey: string;
|
|
35
44
|
readonly sanitizer: Sanitizer;
|
|
45
|
+
readonly debug: Logger;
|
|
46
|
+
readonly notify: Logger;
|
|
36
47
|
private readonly messages;
|
|
37
48
|
private readonly observer;
|
|
38
49
|
private readonly startCallbacks;
|
|
@@ -41,19 +52,34 @@ export default class App {
|
|
|
41
52
|
private readonly options;
|
|
42
53
|
private readonly revID;
|
|
43
54
|
private _sessionID;
|
|
44
|
-
private
|
|
55
|
+
private _userID;
|
|
56
|
+
private _metadata;
|
|
57
|
+
private activityState;
|
|
45
58
|
private version;
|
|
46
59
|
private readonly worker?;
|
|
47
60
|
constructor(projectKey: string, sessionToken: string | null | undefined, options: Partial<Options>);
|
|
48
61
|
private _debug;
|
|
62
|
+
private readonly preStartMessages;
|
|
49
63
|
send(message: Message, urgent?: boolean): void;
|
|
50
64
|
private commit;
|
|
51
65
|
attachCommitCallback(cb: CommitCallback): void;
|
|
52
|
-
addCommitCallback(cb: CommitCallback): void;
|
|
53
66
|
safe<T extends (...args: any[]) => void>(fn: T): T;
|
|
54
67
|
attachStartCallback(cb: Callback): void;
|
|
55
68
|
attachStopCallback(cb: Callback): void;
|
|
56
69
|
attachEventListener(target: EventTarget, type: string, listener: EventListener, useSafe?: boolean, useCapture?: boolean): void;
|
|
70
|
+
checkRequiredVersion(version: string): boolean;
|
|
71
|
+
private getStartInfo;
|
|
72
|
+
getSessionInfo(): {
|
|
73
|
+
userUUID: string | null;
|
|
74
|
+
projectKey: string;
|
|
75
|
+
revID: string;
|
|
76
|
+
timestamp: number;
|
|
77
|
+
trackerVersion: string;
|
|
78
|
+
userID: string | null;
|
|
79
|
+
isSnippet: boolean;
|
|
80
|
+
sessionID: string | null;
|
|
81
|
+
metadata: Record<string, string>;
|
|
82
|
+
};
|
|
57
83
|
getSessionToken(): string | undefined;
|
|
58
84
|
getSessionID(): string | undefined;
|
|
59
85
|
getHost(): string;
|
|
@@ -64,7 +90,7 @@ export default class App {
|
|
|
64
90
|
active(): boolean;
|
|
65
91
|
resetNextPageSession(flag: boolean): void;
|
|
66
92
|
private _start;
|
|
67
|
-
start(
|
|
93
|
+
start(options?: StartOptions): Promise<OnStartInfo>;
|
|
68
94
|
stop(): void;
|
|
69
95
|
}
|
|
70
96
|
export {};
|