@openreplay/tracker 16.4.3-beta.0 → 16.4.4
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/dist/cjs/entry.js +34 -37
- package/dist/cjs/entry.js.map +1 -1
- package/dist/cjs/index.js +34 -37
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/main/index.d.ts +2 -0
- package/dist/cjs/main/modules/viewport.d.ts +5 -1
- package/dist/lib/entry.js +34 -37
- package/dist/lib/entry.js.map +1 -1
- package/dist/lib/index.js +34 -37
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/main/index.d.ts +2 -0
- package/dist/lib/main/modules/viewport.d.ts +5 -1
- package/dist/types/main/index.d.ts +2 -0
- package/dist/types/main/modules/viewport.d.ts +5 -1
- package/package.json +2 -2
package/dist/cjs/main/index.d.ts
CHANGED
|
@@ -14,6 +14,7 @@ import type { Options as NetworkOptions } from './modules/network.js';
|
|
|
14
14
|
import type { MouseHandlerOptions } from './modules/mouse.js';
|
|
15
15
|
import type { SessionInfo } from './app/session.js';
|
|
16
16
|
import type { CssRulesOptions } from './modules/cssrules.js';
|
|
17
|
+
import type { Options as ViewportOptions } from './modules/viewport.js';
|
|
17
18
|
import type { StartOptions } from './app/index.js';
|
|
18
19
|
import type { StartPromiseReturn } from './app/index.js';
|
|
19
20
|
export type Options = Partial<AppOptions & ConsoleOptions & ExceptionOptions & InputOptions & PerformanceOptions & TimingOptions> & {
|
|
@@ -30,6 +31,7 @@ export type Options = Partial<AppOptions & ConsoleOptions & ExceptionOptions & I
|
|
|
30
31
|
};
|
|
31
32
|
__DISABLE_SECURE_MODE?: boolean;
|
|
32
33
|
css: CssRulesOptions;
|
|
34
|
+
urls?: Partial<ViewportOptions>;
|
|
33
35
|
};
|
|
34
36
|
export default class API {
|
|
35
37
|
readonly options: Partial<Options>;
|
package/dist/lib/entry.js
CHANGED
|
@@ -5094,15 +5094,16 @@ class Session {
|
|
|
5094
5094
|
this.userInfo = userInfo;
|
|
5095
5095
|
}
|
|
5096
5096
|
getSessionToken(projectKey) {
|
|
5097
|
-
const
|
|
5098
|
-
if (projectKey &&
|
|
5099
|
-
const savedProject =
|
|
5097
|
+
const tokenWithProject = this.token || this.app.sessionStorage.getItem(this.options.session_token_key);
|
|
5098
|
+
if (projectKey && tokenWithProject) {
|
|
5099
|
+
const savedProject = tokenWithProject.split('_&_')[1];
|
|
5100
5100
|
if (!savedProject || savedProject !== projectKey) {
|
|
5101
5101
|
this.app.sessionStorage.removeItem(this.options.session_token_key);
|
|
5102
5102
|
this.token = undefined;
|
|
5103
5103
|
return undefined;
|
|
5104
5104
|
}
|
|
5105
5105
|
}
|
|
5106
|
+
const token = tokenWithProject ? tokenWithProject.split('_&_')[0] : null;
|
|
5106
5107
|
return token || undefined;
|
|
5107
5108
|
}
|
|
5108
5109
|
setSessionToken(token, projectKey) {
|
|
@@ -5167,7 +5168,7 @@ class Session {
|
|
|
5167
5168
|
}
|
|
5168
5169
|
}
|
|
5169
5170
|
|
|
5170
|
-
function wrap(callback, n) {
|
|
5171
|
+
function wrap$1(callback, n) {
|
|
5171
5172
|
let t = 0;
|
|
5172
5173
|
return () => {
|
|
5173
5174
|
if (t++ >= n) {
|
|
@@ -5195,7 +5196,7 @@ class Ticker {
|
|
|
5195
5196
|
if (useSafe) {
|
|
5196
5197
|
callback = this.app.safe(callback);
|
|
5197
5198
|
}
|
|
5198
|
-
this.callbacks.unshift(n ? wrap(callback, n) : callback) - 1;
|
|
5199
|
+
this.callbacks.unshift(n ? wrap$1(callback, n) : callback) - 1;
|
|
5199
5200
|
}
|
|
5200
5201
|
start() {
|
|
5201
5202
|
if (this.timer === null) {
|
|
@@ -5271,7 +5272,7 @@ class App {
|
|
|
5271
5272
|
this.stopCallbacks = [];
|
|
5272
5273
|
this.commitCallbacks = [];
|
|
5273
5274
|
this.activityState = ActivityState.NotActive;
|
|
5274
|
-
this.version = '16.4.
|
|
5275
|
+
this.version = '16.4.4'; // TODO: version compatability check inside each plugin.
|
|
5275
5276
|
this.socketMode = false;
|
|
5276
5277
|
this.compressionThreshold = 24 * 1000;
|
|
5277
5278
|
this.bc = null;
|
|
@@ -7672,11 +7673,6 @@ function Timing (app, opts) {
|
|
|
7672
7673
|
if (shouldSkip) {
|
|
7673
7674
|
return;
|
|
7674
7675
|
}
|
|
7675
|
-
const failed = entry.responseEnd === 0
|
|
7676
|
-
|| (entry.transferSize === 0 && entry.decodedBodySize === 0);
|
|
7677
|
-
if (failed) {
|
|
7678
|
-
app.send(ResourceTiming(entry.startTime + getTimeOrigin(), 0, 0, 0, 0, 0, entry.name, entry.initiatorType, 0, true));
|
|
7679
|
-
}
|
|
7680
7676
|
app.send(ResourceTiming(entry.startTime + getTimeOrigin(), entry.duration, entry.responseStart && entry.startTime ? entry.responseStart - entry.startTime : 0, entry.transferSize > entry.encodedBodySize ? entry.transferSize - entry.encodedBodySize : 0, entry.encodedBodySize || 0, entry.decodedBodySize || 0, app.sanitizer.privateMode ? entry.name.replaceAll(/./g, '*') : entry.name, entry.initiatorType, entry.transferSize,
|
|
7681
7677
|
// @ts-ignore
|
|
7682
7678
|
(entry.responseStatus && entry.responseStatus === 304) || entry.transferSize === 0));
|
|
@@ -7687,14 +7683,8 @@ function Timing (app, opts) {
|
|
|
7687
7683
|
return app.send(WebVitals(msg.name, String(msg.value)));
|
|
7688
7684
|
}
|
|
7689
7685
|
}
|
|
7690
|
-
let prevSessionID;
|
|
7691
7686
|
app.attachStartCallback(function ({ sessionID }) {
|
|
7692
|
-
|
|
7693
|
-
// Send past page resources on a newly started session
|
|
7694
|
-
performance.getEntriesByType('resource').forEach(resourceTiming);
|
|
7695
|
-
prevSessionID = sessionID;
|
|
7696
|
-
}
|
|
7697
|
-
observer.observe({ entryTypes: ['resource'] });
|
|
7687
|
+
observer.observe({ type: 'resource', buffered: true });
|
|
7698
7688
|
// browser support:
|
|
7699
7689
|
// onCLS(): Chromium
|
|
7700
7690
|
// onFCP(): Chromium, Firefox, Safari
|
|
@@ -7858,15 +7848,17 @@ function Scroll (app, insideIframe) {
|
|
|
7858
7848
|
}, 5, false);
|
|
7859
7849
|
}
|
|
7860
7850
|
|
|
7861
|
-
function Viewport (app) {
|
|
7851
|
+
function Viewport (app, options) {
|
|
7862
7852
|
let url, width, height;
|
|
7863
7853
|
let navigationStart;
|
|
7864
7854
|
let referrer = document.referrer;
|
|
7855
|
+
const urlSanitizer = options?.urlSanitizer || ((u) => u);
|
|
7856
|
+
const titleSanitizer = options?.titleSanitizer || ((t) => t);
|
|
7865
7857
|
const sendSetPageLocation = app.safe(() => {
|
|
7866
7858
|
const { URL } = document;
|
|
7867
7859
|
if (URL !== url) {
|
|
7868
|
-
url = URL;
|
|
7869
|
-
const safeTitle = app.sanitizer.privateMode ? stringWiper(document.title) : document.title;
|
|
7860
|
+
url = urlSanitizer(URL);
|
|
7861
|
+
const safeTitle = app.sanitizer.privateMode ? stringWiper(document.title) : titleSanitizer(document.title);
|
|
7870
7862
|
const safeUrl = app.sanitizer.privateMode ? stringWiper(url) : url;
|
|
7871
7863
|
const safeReferrer = app.sanitizer.privateMode ? stringWiper(referrer) : referrer;
|
|
7872
7864
|
app.send(SetPageLocation(safeUrl, safeReferrer, navigationStart, safeTitle));
|
|
@@ -9254,10 +9246,17 @@ class XHRProxy {
|
|
|
9254
9246
|
}
|
|
9255
9247
|
}
|
|
9256
9248
|
|
|
9257
|
-
const
|
|
9249
|
+
const warn = (api) => {
|
|
9258
9250
|
const str = `Openreplay: Can't find ${api} in global context.`;
|
|
9259
9251
|
console.warn(str);
|
|
9260
9252
|
};
|
|
9253
|
+
const OR_FLAG = Symbol('OpenReplayProxyOriginal');
|
|
9254
|
+
const isProxied = (fn) => !!fn && fn[OR_FLAG] !== undefined;
|
|
9255
|
+
const unwrap = (fn) => isProxied(fn) ? fn[OR_FLAG] : fn;
|
|
9256
|
+
const wrap = (proxy, orig) => {
|
|
9257
|
+
proxy[OR_FLAG] = orig;
|
|
9258
|
+
return proxy;
|
|
9259
|
+
};
|
|
9261
9260
|
/**
|
|
9262
9261
|
* Creates network proxies for XMLHttpRequest, fetch, and sendBeacon to intercept and monitor network requests and
|
|
9263
9262
|
* responses.
|
|
@@ -9291,26 +9290,24 @@ function createNetworkProxy(context, ignoredHeaders, setSessionTokenHeader, sani
|
|
|
9291
9290
|
if (!context)
|
|
9292
9291
|
return;
|
|
9293
9292
|
if (modules.xhr) {
|
|
9294
|
-
|
|
9295
|
-
|
|
9296
|
-
|
|
9293
|
+
const original = unwrap(context.XMLHttpRequest);
|
|
9294
|
+
if (!original)
|
|
9295
|
+
warn('XMLHttpRequest');
|
|
9297
9296
|
else {
|
|
9298
|
-
|
|
9297
|
+
context.XMLHttpRequest = wrap(XHRProxy.create(ignoredHeaders, setSessionTokenHeader, sanitize, sendMessage, isServiceUrl, tokenUrlMatcher), original);
|
|
9299
9298
|
}
|
|
9300
9299
|
}
|
|
9301
9300
|
if (modules.fetch) {
|
|
9302
|
-
|
|
9303
|
-
|
|
9304
|
-
|
|
9301
|
+
const original = unwrap(context.fetch);
|
|
9302
|
+
if (!original)
|
|
9303
|
+
warn('fetch');
|
|
9305
9304
|
else {
|
|
9306
|
-
|
|
9305
|
+
context.fetch = wrap(FetchProxy.create(ignoredHeaders, setSessionTokenHeader, sanitize, sendMessage, isServiceUrl, tokenUrlMatcher), original);
|
|
9307
9306
|
}
|
|
9308
9307
|
}
|
|
9309
|
-
if (modules.beacon) {
|
|
9310
|
-
|
|
9311
|
-
|
|
9312
|
-
context.navigator.sendBeacon = BeaconProxy.create(origBeacon, ignoredHeaders, setSessionTokenHeader, sanitize, sendMessage, isServiceUrl);
|
|
9313
|
-
}
|
|
9308
|
+
if (modules.beacon && ((_a = context.navigator) === null || _a === void 0 ? void 0 : _a.sendBeacon)) {
|
|
9309
|
+
const original = unwrap(context.navigator.sendBeacon);
|
|
9310
|
+
context.navigator.sendBeacon = wrap(BeaconProxy.create(original, ignoredHeaders, setSessionTokenHeader, sanitize, sendMessage, isServiceUrl), original);
|
|
9314
9311
|
}
|
|
9315
9312
|
}
|
|
9316
9313
|
|
|
@@ -9651,7 +9648,7 @@ class API {
|
|
|
9651
9648
|
this.signalStartIssue = (reason, missingApi) => {
|
|
9652
9649
|
const doNotTrack = this.checkDoNotTrack();
|
|
9653
9650
|
console.log("Tracker couldn't start due to:", JSON.stringify({
|
|
9654
|
-
trackerVersion: '16.4.
|
|
9651
|
+
trackerVersion: '16.4.4',
|
|
9655
9652
|
projectKey: this.options.projectKey,
|
|
9656
9653
|
doNotTrack,
|
|
9657
9654
|
reason: missingApi.length ? `missing api: ${missingApi.join(',')}` : reason,
|
|
@@ -9739,7 +9736,7 @@ class API {
|
|
|
9739
9736
|
this.app = app;
|
|
9740
9737
|
if (!this.crossdomainMode) {
|
|
9741
9738
|
// no need to send iframe viewport data since its a node for us
|
|
9742
|
-
Viewport(app);
|
|
9739
|
+
Viewport(app, options.urls);
|
|
9743
9740
|
// calculated in main window
|
|
9744
9741
|
Connection(app);
|
|
9745
9742
|
// while we can calculate it here, trying to compute it for all parts is hard
|