@openreplay/tracker 3.6.0-beta.0 → 3.6.2
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/guards.d.ts +1 -2
- package/cjs/app/guards.js +3 -6
- package/cjs/app/index.d.ts +22 -24
- package/cjs/app/index.js +84 -85
- package/cjs/app/logger.js +3 -6
- package/cjs/app/nodes.js +0 -2
- package/cjs/app/observer/iframe_observer.d.ts +1 -1
- package/cjs/app/observer/iframe_observer.js +3 -3
- package/cjs/app/observer/observer.d.ts +3 -2
- package/cjs/app/observer/observer.js +52 -50
- package/cjs/app/observer/shadow_root_observer.d.ts +1 -1
- package/cjs/app/observer/shadow_root_observer.js +3 -3
- package/cjs/app/observer/top_observer.d.ts +2 -11
- package/cjs/app/observer/top_observer.js +23 -52
- package/cjs/app/sanitizer.d.ts +1 -1
- package/cjs/app/sanitizer.js +5 -5
- package/cjs/app/session.d.ts +2 -18
- package/cjs/app/session.js +6 -55
- package/cjs/app/ticker.d.ts +1 -1
- package/cjs/common/messages.d.ts +444 -0
- package/cjs/common/messages.js +794 -0
- package/cjs/common/types.d.ts +9 -0
- package/cjs/common/{interaction.js → types.js} +0 -0
- package/cjs/common/{interaction.d.ts → webworker.d.ts} +5 -5
- package/cjs/common/webworker.js +2 -0
- package/cjs/index.d.ts +10 -10
- package/cjs/index.js +37 -42
- 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 +21 -7
- package/cjs/modules/cssrules.d.ts +1 -1
- package/cjs/modules/cssrules.js +14 -18
- package/cjs/modules/exception.d.ts +3 -3
- package/cjs/modules/exception.js +20 -25
- package/cjs/modules/img.d.ts +1 -1
- package/cjs/modules/img.js +26 -39
- package/cjs/modules/input.d.ts +1 -1
- package/cjs/modules/input.js +21 -21
- package/cjs/modules/longtasks.d.ts +2 -0
- package/cjs/modules/longtasks.js +26 -0
- package/cjs/modules/mouse.d.ts +1 -1
- package/cjs/modules/mouse.js +43 -50
- package/cjs/modules/performance.d.ts +1 -1
- package/cjs/modules/performance.js +2 -2
- package/cjs/modules/scroll.d.ts +1 -1
- package/cjs/modules/scroll.js +7 -16
- package/cjs/modules/timing.d.ts +1 -1
- package/cjs/modules/timing.js +26 -14
- package/cjs/modules/viewport.d.ts +1 -1
- package/cjs/modules/viewport.js +4 -4
- package/cjs/utils.js +7 -7
- package/cjs/vendors/finder/finder.js +48 -53
- package/lib/app/guards.d.ts +1 -2
- package/lib/app/guards.js +2 -4
- package/lib/app/index.d.ts +22 -24
- package/lib/app/index.js +92 -93
- package/lib/app/logger.js +3 -6
- package/lib/app/nodes.js +0 -2
- 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 +3 -2
- package/lib/app/observer/observer.js +53 -51
- 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 -11
- package/lib/app/observer/top_observer.js +27 -56
- package/lib/app/sanitizer.d.ts +1 -1
- package/lib/app/sanitizer.js +7 -7
- package/lib/app/session.d.ts +2 -18
- package/lib/app/session.js +6 -55
- package/lib/app/ticker.d.ts +1 -1
- package/lib/common/messages.d.ts +444 -0
- package/lib/common/messages.js +790 -0
- package/lib/common/tsconfig.tsbuildinfo +1 -1
- package/lib/common/types.d.ts +9 -0
- package/lib/common/{interaction.js → types.js} +0 -0
- package/lib/common/{interaction.d.ts → webworker.d.ts} +5 -5
- package/lib/common/webworker.js +1 -0
- package/lib/index.d.ts +10 -10
- package/lib/index.js +50 -55
- package/lib/modules/connection.d.ts +1 -1
- package/lib/modules/connection.js +2 -2
- package/lib/modules/console.d.ts +1 -1
- package/lib/modules/console.js +22 -8
- package/lib/modules/cssrules.d.ts +1 -1
- package/lib/modules/cssrules.js +15 -19
- package/lib/modules/exception.d.ts +3 -3
- package/lib/modules/exception.js +20 -25
- package/lib/modules/img.d.ts +1 -1
- package/lib/modules/img.js +28 -41
- package/lib/modules/input.d.ts +1 -1
- package/lib/modules/input.js +23 -23
- package/lib/modules/longtasks.d.ts +2 -0
- package/lib/modules/longtasks.js +23 -0
- package/lib/modules/mouse.d.ts +1 -1
- package/lib/modules/mouse.js +46 -53
- package/lib/modules/performance.d.ts +1 -1
- package/lib/modules/performance.js +3 -3
- package/lib/modules/scroll.d.ts +1 -1
- package/lib/modules/scroll.js +8 -17
- package/lib/modules/timing.d.ts +1 -1
- package/lib/modules/timing.js +28 -16
- package/lib/modules/viewport.d.ts +1 -1
- package/lib/modules/viewport.js +4 -4
- package/lib/utils.js +7 -7
- package/lib/vendors/finder/finder.js +48 -53
- package/package.json +10 -27
- package/.eslintignore +0 -8
- package/.prettierignore +0 -1
- package/cjs/app/messages.d.ts +0 -52
- package/cjs/app/messages.gen.d.ts +0 -57
- package/cjs/app/messages.gen.js +0 -494
- package/cjs/app/messages.js +0 -235
- package/cjs/common/messages.gen.d.ts +0 -382
- package/cjs/common/messages.gen.js +0 -62
- package/cjs/modules/adoptedStyleSheets.d.ts +0 -2
- package/cjs/modules/adoptedStyleSheets.js +0 -127
- package/lib/app/messages.d.ts +0 -52
- package/lib/app/messages.gen.d.ts +0 -57
- package/lib/app/messages.gen.js +0 -435
- package/lib/app/messages.js +0 -182
- package/lib/common/messages.gen.d.ts +0 -382
- package/lib/common/messages.gen.js +0 -59
- package/lib/modules/adoptedStyleSheets.d.ts +0 -2
- package/lib/modules/adoptedStyleSheets.js +0 -124
|
File without changes
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import Message from './messages.gen.js';
|
|
2
1
|
export interface Options {
|
|
3
2
|
connAttemptCount?: number;
|
|
4
3
|
connAttemptGap?: number;
|
|
5
4
|
}
|
|
6
5
|
declare type Start = {
|
|
7
|
-
type:
|
|
6
|
+
type: "start";
|
|
8
7
|
ingestPoint: string;
|
|
9
8
|
pageNo: number;
|
|
10
9
|
timestamp: number;
|
|
11
|
-
url: string;
|
|
12
10
|
} & Options;
|
|
13
11
|
declare type Auth = {
|
|
14
|
-
type:
|
|
12
|
+
type: "auth";
|
|
15
13
|
token: string;
|
|
16
14
|
beaconSizeLimit?: number;
|
|
17
15
|
};
|
|
18
|
-
export declare type WorkerMessageData = null |
|
|
16
|
+
export declare type WorkerMessageData = null | "stop" | Start | Auth | Array<{
|
|
17
|
+
_id: number;
|
|
18
|
+
}>;
|
|
19
19
|
export {};
|
package/cjs/index.d.ts
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
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> & {
|
|
14
14
|
projectID?: number;
|
|
15
15
|
projectKey: string;
|
|
16
|
-
|
|
16
|
+
sessionToken?: string;
|
|
17
17
|
respectDoNotTrack?: boolean;
|
|
18
18
|
autoResetOnWindowOpen?: boolean;
|
|
19
19
|
__DISABLE_SECURE_MODE?: boolean;
|
|
@@ -25,7 +25,7 @@ export default class API {
|
|
|
25
25
|
use<T>(fn: (app: App | null, options?: Options) => T): T;
|
|
26
26
|
isActive(): boolean;
|
|
27
27
|
start(startOpts?: Partial<StartOptions>): Promise<StartPromiseReturn>;
|
|
28
|
-
stop():
|
|
28
|
+
stop(): void;
|
|
29
29
|
getSessionToken(): string | null | undefined;
|
|
30
30
|
getSessionID(): string | null | undefined;
|
|
31
31
|
sessionID(): string | null | undefined;
|
package/cjs/index.js
CHANGED
|
@@ -4,8 +4,8 @@ exports.Messages = exports.App = void 0;
|
|
|
4
4
|
const index_js_1 = require("./app/index.js");
|
|
5
5
|
var index_js_2 = require("./app/index.js");
|
|
6
6
|
Object.defineProperty(exports, "App", { enumerable: true, get: function () { return index_js_2.default; } });
|
|
7
|
-
const
|
|
8
|
-
const _Messages = require("./
|
|
7
|
+
const messages_js_1 = require("./common/messages.js");
|
|
8
|
+
const _Messages = require("./common/messages.js");
|
|
9
9
|
exports.Messages = _Messages;
|
|
10
10
|
const connection_js_1 = require("./modules/connection.js");
|
|
11
11
|
const console_js_1 = require("./modules/console.js");
|
|
@@ -18,7 +18,6 @@ const performance_js_1 = require("./modules/performance.js");
|
|
|
18
18
|
const scroll_js_1 = require("./modules/scroll.js");
|
|
19
19
|
const viewport_js_1 = require("./modules/viewport.js");
|
|
20
20
|
const cssrules_js_1 = require("./modules/cssrules.js");
|
|
21
|
-
const adoptedStyleSheets_js_1 = require("./modules/adoptedStyleSheets.js");
|
|
22
21
|
const utils_js_1 = require("./utils.js");
|
|
23
22
|
const DOCS_SETUP = '/installation/setup-or';
|
|
24
23
|
function processOptions(obj) {
|
|
@@ -28,23 +27,22 @@ function processOptions(obj) {
|
|
|
28
27
|
}
|
|
29
28
|
if (typeof obj.projectKey !== 'string') {
|
|
30
29
|
if (typeof obj.projectKey !== 'number') {
|
|
31
|
-
if (typeof obj.projectID !== 'number') {
|
|
32
|
-
// Back compatability
|
|
30
|
+
if (typeof obj.projectID !== 'number') { // Back compatability
|
|
33
31
|
console.error(`OpenReplay: projectKey is missing or wrong type (string is expected). Please, check ${utils_js_1.DOCS_HOST}${DOCS_SETUP} for more information.`);
|
|
34
32
|
return false;
|
|
35
33
|
}
|
|
36
34
|
else {
|
|
37
35
|
obj.projectKey = obj.projectID.toString();
|
|
38
|
-
(0, utils_js_1.deprecationWarn)(
|
|
36
|
+
(0, utils_js_1.deprecationWarn)("`projectID` option", "`projectKey` option", DOCS_SETUP);
|
|
39
37
|
}
|
|
40
38
|
}
|
|
41
39
|
else {
|
|
42
|
-
console.warn(
|
|
40
|
+
console.warn("OpenReplay: projectKey is expected to have a string type.");
|
|
43
41
|
obj.projectKey = obj.projectKey.toString();
|
|
44
42
|
}
|
|
45
43
|
}
|
|
46
|
-
if (typeof obj.
|
|
47
|
-
console.warn(`OpenReplay: invalid
|
|
44
|
+
if (typeof obj.sessionToken !== 'string' && obj.sessionToken != null) {
|
|
45
|
+
console.warn(`OpenReplay: invalid options argument type. Please, check documentation on ${utils_js_1.DOCS_HOST}${DOCS_SETUP}`);
|
|
48
46
|
}
|
|
49
47
|
return true;
|
|
50
48
|
}
|
|
@@ -71,33 +69,31 @@ class API {
|
|
|
71
69
|
return;
|
|
72
70
|
}
|
|
73
71
|
if (window.__OPENREPLAY__) {
|
|
74
|
-
console.error(
|
|
72
|
+
console.error("OpenReplay: one tracker instance has been initialised already");
|
|
75
73
|
return;
|
|
76
74
|
}
|
|
77
75
|
if (!options.__DISABLE_SECURE_MODE && location.protocol !== 'https:') {
|
|
78
|
-
console.error(
|
|
76
|
+
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.");
|
|
79
77
|
return;
|
|
80
78
|
}
|
|
81
79
|
const doNotTrack = options.respectDoNotTrack &&
|
|
82
|
-
(navigator.doNotTrack == '1'
|
|
80
|
+
(navigator.doNotTrack == '1'
|
|
83
81
|
// @ts-ignore
|
|
84
|
-
window.doNotTrack == '1');
|
|
85
|
-
const app =
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
: new index_js_1.default(options.projectKey, options.sessionHash, options));
|
|
82
|
+
|| window.doNotTrack == '1');
|
|
83
|
+
const app = this.app = doNotTrack ||
|
|
84
|
+
!('Map' in window) ||
|
|
85
|
+
!('Set' in window) ||
|
|
86
|
+
!('MutationObserver' in window) ||
|
|
87
|
+
!('performance' in window) ||
|
|
88
|
+
!('timing' in performance) ||
|
|
89
|
+
!('startsWith' in String.prototype) ||
|
|
90
|
+
!('Blob' in window) ||
|
|
91
|
+
!('Worker' in window)
|
|
92
|
+
? null
|
|
93
|
+
: new index_js_1.default(options.projectKey, options.sessionToken, options);
|
|
97
94
|
if (app !== null) {
|
|
98
95
|
(0, viewport_js_1.default)(app);
|
|
99
96
|
(0, cssrules_js_1.default)(app);
|
|
100
|
-
(0, adoptedStyleSheets_js_1.default)(app);
|
|
101
97
|
(0, connection_js_1.default)(app);
|
|
102
98
|
(0, console_js_1.default)(app, options);
|
|
103
99
|
(0, exception_js_1.default)(app, options);
|
|
@@ -127,11 +123,11 @@ class API {
|
|
|
127
123
|
console.log("OpenReplay: browser doesn't support API required for tracking or doNotTrack is set to 1.");
|
|
128
124
|
const req = new XMLHttpRequest();
|
|
129
125
|
const orig = options.ingestPoint || index_js_1.DEFAULT_INGEST_POINT;
|
|
130
|
-
req.open(
|
|
126
|
+
req.open("POST", orig + "/v1/web/not-started");
|
|
131
127
|
// no-cors issue only with text/plain or not-set Content-Type
|
|
132
128
|
// req.setRequestHeader("Content-Type", "application/json;charset=UTF-8");
|
|
133
129
|
req.send(JSON.stringify({
|
|
134
|
-
trackerVersion: '3.
|
|
130
|
+
trackerVersion: '3.6.2',
|
|
135
131
|
projectKey: options.projectKey,
|
|
136
132
|
doNotTrack,
|
|
137
133
|
// TODO: add precise reason (an exact API missing)
|
|
@@ -150,7 +146,7 @@ class API {
|
|
|
150
146
|
start(startOpts) {
|
|
151
147
|
if (!utils_js_1.IN_BROWSER) {
|
|
152
148
|
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}`);
|
|
153
|
-
return Promise.reject(
|
|
149
|
+
return Promise.reject("Trying to start not in browser.");
|
|
154
150
|
}
|
|
155
151
|
if (this.app === null) {
|
|
156
152
|
return Promise.reject("Browser doesn't support required api, or doNotTrack is active.");
|
|
@@ -160,12 +156,9 @@ class API {
|
|
|
160
156
|
}
|
|
161
157
|
stop() {
|
|
162
158
|
if (this.app === null) {
|
|
163
|
-
return
|
|
159
|
+
return;
|
|
164
160
|
}
|
|
165
|
-
this.app.stop();
|
|
166
|
-
const sessionHash = this.app.session.getSessionHash();
|
|
167
|
-
this.app.session.reset();
|
|
168
|
-
return sessionHash;
|
|
161
|
+
this.app.stop(true);
|
|
169
162
|
}
|
|
170
163
|
getSessionToken() {
|
|
171
164
|
if (this.app === null) {
|
|
@@ -180,7 +173,7 @@ class API {
|
|
|
180
173
|
return this.app.getSessionID();
|
|
181
174
|
}
|
|
182
175
|
sessionID() {
|
|
183
|
-
(0, utils_js_1.deprecationWarn)("'sessionID' method", "'getSessionID' method",
|
|
176
|
+
(0, utils_js_1.deprecationWarn)("'sessionID' method", "'getSessionID' method", "/");
|
|
184
177
|
return this.getSessionID();
|
|
185
178
|
}
|
|
186
179
|
setUserID(id) {
|
|
@@ -189,25 +182,27 @@ class API {
|
|
|
189
182
|
}
|
|
190
183
|
}
|
|
191
184
|
userID(id) {
|
|
192
|
-
(0, utils_js_1.deprecationWarn)("'userID' method", "'setUserID' method",
|
|
185
|
+
(0, utils_js_1.deprecationWarn)("'userID' method", "'setUserID' method", "/");
|
|
193
186
|
this.setUserID(id);
|
|
194
187
|
}
|
|
195
188
|
setUserAnonymousID(id) {
|
|
196
189
|
if (typeof id === 'string' && this.app !== null) {
|
|
197
|
-
this.app.send(
|
|
190
|
+
this.app.send(new messages_js_1.UserAnonymousID(id));
|
|
198
191
|
}
|
|
199
192
|
}
|
|
200
193
|
userAnonymousID(id) {
|
|
201
|
-
(0, utils_js_1.deprecationWarn)("'userAnonymousID' method", "'setUserAnonymousID' method",
|
|
194
|
+
(0, utils_js_1.deprecationWarn)("'userAnonymousID' method", "'setUserAnonymousID' method", "/");
|
|
202
195
|
this.setUserAnonymousID(id);
|
|
203
196
|
}
|
|
204
197
|
setMetadata(key, value) {
|
|
205
|
-
if (typeof key === 'string' &&
|
|
198
|
+
if (typeof key === 'string' &&
|
|
199
|
+
typeof value === 'string' &&
|
|
200
|
+
this.app !== null) {
|
|
206
201
|
this.app.session.setMetadata(key, value);
|
|
207
202
|
}
|
|
208
203
|
}
|
|
209
204
|
metadata(key, value) {
|
|
210
|
-
(0, utils_js_1.deprecationWarn)("'metadata' method", "'setMetadata' method",
|
|
205
|
+
(0, utils_js_1.deprecationWarn)("'metadata' method", "'setMetadata' method", "/");
|
|
211
206
|
this.setMetadata(key, value);
|
|
212
207
|
}
|
|
213
208
|
event(key, payload, issue = false) {
|
|
@@ -222,7 +217,7 @@ class API {
|
|
|
222
217
|
catch (e) {
|
|
223
218
|
return;
|
|
224
219
|
}
|
|
225
|
-
this.app.send(
|
|
220
|
+
this.app.send(new messages_js_1.RawCustomEvent(key, payload));
|
|
226
221
|
}
|
|
227
222
|
}
|
|
228
223
|
}
|
|
@@ -234,7 +229,7 @@ class API {
|
|
|
234
229
|
catch (e) {
|
|
235
230
|
return;
|
|
236
231
|
}
|
|
237
|
-
this.app.send(
|
|
232
|
+
this.app.send(new messages_js_1.CustomIssue(key, payload));
|
|
238
233
|
}
|
|
239
234
|
}
|
|
240
235
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import App from
|
|
1
|
+
import App from "../app/index.js";
|
|
2
2
|
export default function (app: App): void;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const
|
|
3
|
+
const messages_js_1 = require("../common/messages.js");
|
|
4
4
|
function default_1(app) {
|
|
5
5
|
const connection = navigator.connection ||
|
|
6
6
|
navigator.mozConnection ||
|
|
@@ -8,7 +8,7 @@ function default_1(app) {
|
|
|
8
8
|
if (connection === undefined) {
|
|
9
9
|
return;
|
|
10
10
|
}
|
|
11
|
-
const sendConnectionInformation = () => app.send(
|
|
11
|
+
const sendConnectionInformation = () => app.send(new messages_js_1.ConnectionInformation(Math.round(connection.downlink * 1000), connection.type || 'unknown'));
|
|
12
12
|
sendConnectionInformation();
|
|
13
13
|
connection.addEventListener('change', sendConnectionInformation);
|
|
14
14
|
}
|
package/cjs/modules/console.d.ts
CHANGED
package/cjs/modules/console.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
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
|
-
const
|
|
5
|
+
const messages_js_1 = require("../common/messages.js");
|
|
5
6
|
const printError = utils_js_1.IN_BROWSER && 'InstallTrigger' in window // detect Firefox
|
|
6
7
|
? (e) => e.message + '\n' + e.stack
|
|
7
8
|
: (e) => e.stack || e.message;
|
|
@@ -88,10 +89,11 @@ function default_1(app, opts) {
|
|
|
88
89
|
consoleMethods,
|
|
89
90
|
consoleThrottling: 30,
|
|
90
91
|
}, opts);
|
|
91
|
-
if (!Array.isArray(options.consoleMethods) ||
|
|
92
|
+
if (!Array.isArray(options.consoleMethods) ||
|
|
93
|
+
options.consoleMethods.length === 0) {
|
|
92
94
|
return;
|
|
93
95
|
}
|
|
94
|
-
const sendConsoleLog = app.safe((level, args) => app.send(
|
|
96
|
+
const sendConsoleLog = app.safe((level, args) => app.send(new messages_js_1.ConsoleLog(level, printf(args))));
|
|
95
97
|
let n;
|
|
96
98
|
const reset = () => {
|
|
97
99
|
n = 0;
|
|
@@ -100,7 +102,7 @@ function default_1(app, opts) {
|
|
|
100
102
|
app.ticker.attach(reset, 33, false);
|
|
101
103
|
const patchConsole = (console) => options.consoleMethods.forEach((method) => {
|
|
102
104
|
if (consoleMethods.indexOf(method) === -1) {
|
|
103
|
-
|
|
105
|
+
console.error(`OpenReplay: unsupported console method "${method}"`);
|
|
104
106
|
return;
|
|
105
107
|
}
|
|
106
108
|
const fn = console[method];
|
|
@@ -112,8 +114,20 @@ function default_1(app, opts) {
|
|
|
112
114
|
sendConsoleLog(method, args);
|
|
113
115
|
};
|
|
114
116
|
});
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
117
|
+
patchConsole(window.console);
|
|
118
|
+
app.nodes.attachNodeCallback(app.safe(node => {
|
|
119
|
+
if ((0, guards_js_1.hasTag)(node, "IFRAME")) { // TODO: newContextCallback
|
|
120
|
+
let context = node.contentWindow;
|
|
121
|
+
if (context) {
|
|
122
|
+
patchConsole(context.console);
|
|
123
|
+
}
|
|
124
|
+
app.attachEventListener(node, "load", () => {
|
|
125
|
+
if (node.contentWindow !== context) {
|
|
126
|
+
context = node.contentWindow;
|
|
127
|
+
patchConsole(context.console);
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
}));
|
|
118
132
|
}
|
|
119
133
|
exports.default = default_1;
|
|
@@ -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/cjs/modules/cssrules.js
CHANGED
|
@@ -1,43 +1,39 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const
|
|
3
|
+
const messages_js_1 = require("../common/messages.js");
|
|
4
4
|
const guards_js_1 = require("../app/guards.js");
|
|
5
5
|
function default_1(app) {
|
|
6
6
|
if (app === null) {
|
|
7
7
|
return;
|
|
8
8
|
}
|
|
9
9
|
if (!window.CSSStyleSheet) {
|
|
10
|
-
app.send(
|
|
10
|
+
app.send(new messages_js_1.TechnicalInfo("no_stylesheet_prototype_in_window", ""));
|
|
11
11
|
return;
|
|
12
12
|
}
|
|
13
13
|
const processOperation = app.safe((stylesheet, index, rule) => {
|
|
14
14
|
const sendMessage = typeof rule === 'string'
|
|
15
|
-
? (nodeID) => app.send(
|
|
16
|
-
: (nodeID) => app.send(
|
|
15
|
+
? (nodeID) => app.send(new messages_js_1.CSSInsertRuleURLBased(nodeID, rule, index, app.getBaseHref()))
|
|
16
|
+
: (nodeID) => app.send(new messages_js_1.CSSDeleteRule(nodeID, index));
|
|
17
17
|
// TODO: Extend messages to maintain nested rules (CSSGroupingRule prototype, as well as CSSKeyframesRule)
|
|
18
18
|
if (stylesheet.ownerNode == null) {
|
|
19
|
-
throw new Error(
|
|
19
|
+
throw new Error("Owner Node not found");
|
|
20
20
|
}
|
|
21
21
|
const nodeID = app.nodes.getID(stylesheet.ownerNode);
|
|
22
22
|
if (nodeID !== undefined) {
|
|
23
23
|
sendMessage(nodeID);
|
|
24
24
|
} // else error?
|
|
25
25
|
});
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
return deleteRule.call(this, index);
|
|
35
|
-
};
|
|
26
|
+
const { insertRule, deleteRule } = CSSStyleSheet.prototype;
|
|
27
|
+
CSSStyleSheet.prototype.insertRule = function (rule, index = 0) {
|
|
28
|
+
processOperation(this, index, rule);
|
|
29
|
+
return insertRule.call(this, rule, index);
|
|
30
|
+
};
|
|
31
|
+
CSSStyleSheet.prototype.deleteRule = function (index) {
|
|
32
|
+
processOperation(this, index);
|
|
33
|
+
return deleteRule.call(this, index);
|
|
36
34
|
};
|
|
37
|
-
patchContext(window);
|
|
38
|
-
app.observer.attachContextCallback(patchContext);
|
|
39
35
|
app.nodes.attachNodeCallback((node) => {
|
|
40
|
-
if (!(0, guards_js_1.hasTag)(node,
|
|
36
|
+
if (!(0, guards_js_1.hasTag)(node, "STYLE") || !node.sheet) {
|
|
41
37
|
return;
|
|
42
38
|
}
|
|
43
39
|
if (node.textContent !== null && node.textContent.trim().length > 0) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type App from
|
|
2
|
-
import type Message from
|
|
1
|
+
import type App from "../app/index.js";
|
|
2
|
+
import type Message from "../common/messages.js";
|
|
3
3
|
export interface Options {
|
|
4
4
|
captureExceptions: boolean;
|
|
5
5
|
}
|
|
@@ -11,6 +11,6 @@ interface StackFrame {
|
|
|
11
11
|
source?: string;
|
|
12
12
|
}
|
|
13
13
|
export declare function getExceptionMessage(error: Error, fallbackStack: Array<StackFrame>): Message;
|
|
14
|
-
export declare function getExceptionMessageFromEvent(e: ErrorEvent | PromiseRejectionEvent
|
|
14
|
+
export declare function getExceptionMessageFromEvent(e: ErrorEvent | PromiseRejectionEvent): Message | null;
|
|
15
15
|
export default function (app: App, opts: Partial<Options>): void;
|
|
16
16
|
export {};
|
package/cjs/modules/exception.js
CHANGED
|
@@ -1,29 +1,28 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getExceptionMessageFromEvent = exports.getExceptionMessage = void 0;
|
|
4
|
-
const
|
|
4
|
+
const messages_js_1 = require("../common/messages.js");
|
|
5
5
|
const error_stack_parser_1 = require("error-stack-parser");
|
|
6
6
|
function getDefaultStack(e) {
|
|
7
|
-
return [
|
|
8
|
-
{
|
|
7
|
+
return [{
|
|
9
8
|
columnNumber: e.colno,
|
|
10
9
|
lineNumber: e.lineno,
|
|
11
10
|
fileName: e.filename,
|
|
12
|
-
functionName:
|
|
13
|
-
source:
|
|
14
|
-
}
|
|
15
|
-
];
|
|
11
|
+
functionName: "",
|
|
12
|
+
source: "",
|
|
13
|
+
}];
|
|
16
14
|
}
|
|
17
15
|
function getExceptionMessage(error, fallbackStack) {
|
|
18
16
|
let stack = fallbackStack;
|
|
19
17
|
try {
|
|
20
18
|
stack = error_stack_parser_1.default.parse(error);
|
|
21
19
|
}
|
|
22
|
-
catch (e) {
|
|
23
|
-
|
|
20
|
+
catch (e) {
|
|
21
|
+
}
|
|
22
|
+
return new messages_js_1.JSException(error.name, error.message, JSON.stringify(stack));
|
|
24
23
|
}
|
|
25
24
|
exports.getExceptionMessage = getExceptionMessage;
|
|
26
|
-
function getExceptionMessageFromEvent(e
|
|
25
|
+
function getExceptionMessageFromEvent(e) {
|
|
27
26
|
if (e instanceof ErrorEvent) {
|
|
28
27
|
if (e.error instanceof Error) {
|
|
29
28
|
return getExceptionMessage(e.error, getDefaultStack(e));
|
|
@@ -34,10 +33,10 @@ function getExceptionMessageFromEvent(e, context = window) {
|
|
|
34
33
|
name = 'Error';
|
|
35
34
|
message = e.message;
|
|
36
35
|
}
|
|
37
|
-
return
|
|
36
|
+
return new messages_js_1.JSException(name, message, JSON.stringify(getDefaultStack(e)));
|
|
38
37
|
}
|
|
39
38
|
}
|
|
40
|
-
else if ('PromiseRejectionEvent' in
|
|
39
|
+
else if ('PromiseRejectionEvent' in window && e instanceof PromiseRejectionEvent) {
|
|
41
40
|
if (e.reason instanceof Error) {
|
|
42
41
|
return getExceptionMessage(e.reason, []);
|
|
43
42
|
}
|
|
@@ -49,7 +48,7 @@ function getExceptionMessageFromEvent(e, context = window) {
|
|
|
49
48
|
catch (_) {
|
|
50
49
|
message = String(e.reason);
|
|
51
50
|
}
|
|
52
|
-
return
|
|
51
|
+
return new messages_js_1.JSException('Unhandled Promise Rejection', message, '[]');
|
|
53
52
|
}
|
|
54
53
|
}
|
|
55
54
|
return null;
|
|
@@ -60,18 +59,14 @@ function default_1(app, opts) {
|
|
|
60
59
|
captureExceptions: true,
|
|
61
60
|
}, opts);
|
|
62
61
|
if (options.captureExceptions) {
|
|
63
|
-
|
|
64
|
-
const
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
app.attachEventListener(context, 'error', handler);
|
|
72
|
-
}
|
|
73
|
-
app.observer.attachContextCallback(patchContext);
|
|
74
|
-
patchContext(window);
|
|
62
|
+
const handler = (e) => {
|
|
63
|
+
const msg = getExceptionMessageFromEvent(e);
|
|
64
|
+
if (msg != null) {
|
|
65
|
+
app.send(msg);
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
app.attachEventListener(window, 'unhandledrejection', (e) => handler(e));
|
|
69
|
+
app.attachEventListener(window, 'error', (e) => handler(e));
|
|
75
70
|
}
|
|
76
71
|
}
|
|
77
72
|
exports.default = default_1;
|
package/cjs/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;
|