@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/entry.js
CHANGED
|
@@ -5098,15 +5098,16 @@ class Session {
|
|
|
5098
5098
|
this.userInfo = userInfo;
|
|
5099
5099
|
}
|
|
5100
5100
|
getSessionToken(projectKey) {
|
|
5101
|
-
const
|
|
5102
|
-
if (projectKey &&
|
|
5103
|
-
const savedProject =
|
|
5101
|
+
const tokenWithProject = this.token || this.app.sessionStorage.getItem(this.options.session_token_key);
|
|
5102
|
+
if (projectKey && tokenWithProject) {
|
|
5103
|
+
const savedProject = tokenWithProject.split('_&_')[1];
|
|
5104
5104
|
if (!savedProject || savedProject !== projectKey) {
|
|
5105
5105
|
this.app.sessionStorage.removeItem(this.options.session_token_key);
|
|
5106
5106
|
this.token = undefined;
|
|
5107
5107
|
return undefined;
|
|
5108
5108
|
}
|
|
5109
5109
|
}
|
|
5110
|
+
const token = tokenWithProject ? tokenWithProject.split('_&_')[0] : null;
|
|
5110
5111
|
return token || undefined;
|
|
5111
5112
|
}
|
|
5112
5113
|
setSessionToken(token, projectKey) {
|
|
@@ -5171,7 +5172,7 @@ class Session {
|
|
|
5171
5172
|
}
|
|
5172
5173
|
}
|
|
5173
5174
|
|
|
5174
|
-
function wrap(callback, n) {
|
|
5175
|
+
function wrap$1(callback, n) {
|
|
5175
5176
|
let t = 0;
|
|
5176
5177
|
return () => {
|
|
5177
5178
|
if (t++ >= n) {
|
|
@@ -5199,7 +5200,7 @@ class Ticker {
|
|
|
5199
5200
|
if (useSafe) {
|
|
5200
5201
|
callback = this.app.safe(callback);
|
|
5201
5202
|
}
|
|
5202
|
-
this.callbacks.unshift(n ? wrap(callback, n) : callback) - 1;
|
|
5203
|
+
this.callbacks.unshift(n ? wrap$1(callback, n) : callback) - 1;
|
|
5203
5204
|
}
|
|
5204
5205
|
start() {
|
|
5205
5206
|
if (this.timer === null) {
|
|
@@ -5275,7 +5276,7 @@ class App {
|
|
|
5275
5276
|
this.stopCallbacks = [];
|
|
5276
5277
|
this.commitCallbacks = [];
|
|
5277
5278
|
this.activityState = ActivityState.NotActive;
|
|
5278
|
-
this.version = '16.4.
|
|
5279
|
+
this.version = '16.4.4'; // TODO: version compatability check inside each plugin.
|
|
5279
5280
|
this.socketMode = false;
|
|
5280
5281
|
this.compressionThreshold = 24 * 1000;
|
|
5281
5282
|
this.bc = null;
|
|
@@ -7676,11 +7677,6 @@ function Timing (app, opts) {
|
|
|
7676
7677
|
if (shouldSkip) {
|
|
7677
7678
|
return;
|
|
7678
7679
|
}
|
|
7679
|
-
const failed = entry.responseEnd === 0
|
|
7680
|
-
|| (entry.transferSize === 0 && entry.decodedBodySize === 0);
|
|
7681
|
-
if (failed) {
|
|
7682
|
-
app.send(ResourceTiming(entry.startTime + getTimeOrigin(), 0, 0, 0, 0, 0, entry.name, entry.initiatorType, 0, true));
|
|
7683
|
-
}
|
|
7684
7680
|
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,
|
|
7685
7681
|
// @ts-ignore
|
|
7686
7682
|
(entry.responseStatus && entry.responseStatus === 304) || entry.transferSize === 0));
|
|
@@ -7691,14 +7687,8 @@ function Timing (app, opts) {
|
|
|
7691
7687
|
return app.send(WebVitals(msg.name, String(msg.value)));
|
|
7692
7688
|
}
|
|
7693
7689
|
}
|
|
7694
|
-
let prevSessionID;
|
|
7695
7690
|
app.attachStartCallback(function ({ sessionID }) {
|
|
7696
|
-
|
|
7697
|
-
// Send past page resources on a newly started session
|
|
7698
|
-
performance.getEntriesByType('resource').forEach(resourceTiming);
|
|
7699
|
-
prevSessionID = sessionID;
|
|
7700
|
-
}
|
|
7701
|
-
observer.observe({ entryTypes: ['resource'] });
|
|
7691
|
+
observer.observe({ type: 'resource', buffered: true });
|
|
7702
7692
|
// browser support:
|
|
7703
7693
|
// onCLS(): Chromium
|
|
7704
7694
|
// onFCP(): Chromium, Firefox, Safari
|
|
@@ -7862,15 +7852,17 @@ function Scroll (app, insideIframe) {
|
|
|
7862
7852
|
}, 5, false);
|
|
7863
7853
|
}
|
|
7864
7854
|
|
|
7865
|
-
function Viewport (app) {
|
|
7855
|
+
function Viewport (app, options) {
|
|
7866
7856
|
let url, width, height;
|
|
7867
7857
|
let navigationStart;
|
|
7868
7858
|
let referrer = document.referrer;
|
|
7859
|
+
const urlSanitizer = options?.urlSanitizer || ((u) => u);
|
|
7860
|
+
const titleSanitizer = options?.titleSanitizer || ((t) => t);
|
|
7869
7861
|
const sendSetPageLocation = app.safe(() => {
|
|
7870
7862
|
const { URL } = document;
|
|
7871
7863
|
if (URL !== url) {
|
|
7872
|
-
url = URL;
|
|
7873
|
-
const safeTitle = app.sanitizer.privateMode ? stringWiper(document.title) : document.title;
|
|
7864
|
+
url = urlSanitizer(URL);
|
|
7865
|
+
const safeTitle = app.sanitizer.privateMode ? stringWiper(document.title) : titleSanitizer(document.title);
|
|
7874
7866
|
const safeUrl = app.sanitizer.privateMode ? stringWiper(url) : url;
|
|
7875
7867
|
const safeReferrer = app.sanitizer.privateMode ? stringWiper(referrer) : referrer;
|
|
7876
7868
|
app.send(SetPageLocation(safeUrl, safeReferrer, navigationStart, safeTitle));
|
|
@@ -9258,10 +9250,17 @@ class XHRProxy {
|
|
|
9258
9250
|
}
|
|
9259
9251
|
}
|
|
9260
9252
|
|
|
9261
|
-
const
|
|
9253
|
+
const warn = (api) => {
|
|
9262
9254
|
const str = `Openreplay: Can't find ${api} in global context.`;
|
|
9263
9255
|
console.warn(str);
|
|
9264
9256
|
};
|
|
9257
|
+
const OR_FLAG = Symbol('OpenReplayProxyOriginal');
|
|
9258
|
+
const isProxied = (fn) => !!fn && fn[OR_FLAG] !== undefined;
|
|
9259
|
+
const unwrap = (fn) => isProxied(fn) ? fn[OR_FLAG] : fn;
|
|
9260
|
+
const wrap = (proxy, orig) => {
|
|
9261
|
+
proxy[OR_FLAG] = orig;
|
|
9262
|
+
return proxy;
|
|
9263
|
+
};
|
|
9265
9264
|
/**
|
|
9266
9265
|
* Creates network proxies for XMLHttpRequest, fetch, and sendBeacon to intercept and monitor network requests and
|
|
9267
9266
|
* responses.
|
|
@@ -9295,26 +9294,24 @@ function createNetworkProxy(context, ignoredHeaders, setSessionTokenHeader, sani
|
|
|
9295
9294
|
if (!context)
|
|
9296
9295
|
return;
|
|
9297
9296
|
if (modules.xhr) {
|
|
9298
|
-
|
|
9299
|
-
|
|
9300
|
-
|
|
9297
|
+
const original = unwrap(context.XMLHttpRequest);
|
|
9298
|
+
if (!original)
|
|
9299
|
+
warn('XMLHttpRequest');
|
|
9301
9300
|
else {
|
|
9302
|
-
|
|
9301
|
+
context.XMLHttpRequest = wrap(XHRProxy.create(ignoredHeaders, setSessionTokenHeader, sanitize, sendMessage, isServiceUrl, tokenUrlMatcher), original);
|
|
9303
9302
|
}
|
|
9304
9303
|
}
|
|
9305
9304
|
if (modules.fetch) {
|
|
9306
|
-
|
|
9307
|
-
|
|
9308
|
-
|
|
9305
|
+
const original = unwrap(context.fetch);
|
|
9306
|
+
if (!original)
|
|
9307
|
+
warn('fetch');
|
|
9309
9308
|
else {
|
|
9310
|
-
|
|
9309
|
+
context.fetch = wrap(FetchProxy.create(ignoredHeaders, setSessionTokenHeader, sanitize, sendMessage, isServiceUrl, tokenUrlMatcher), original);
|
|
9311
9310
|
}
|
|
9312
9311
|
}
|
|
9313
|
-
if (modules.beacon) {
|
|
9314
|
-
|
|
9315
|
-
|
|
9316
|
-
context.navigator.sendBeacon = BeaconProxy.create(origBeacon, ignoredHeaders, setSessionTokenHeader, sanitize, sendMessage, isServiceUrl);
|
|
9317
|
-
}
|
|
9312
|
+
if (modules.beacon && ((_a = context.navigator) === null || _a === void 0 ? void 0 : _a.sendBeacon)) {
|
|
9313
|
+
const original = unwrap(context.navigator.sendBeacon);
|
|
9314
|
+
context.navigator.sendBeacon = wrap(BeaconProxy.create(original, ignoredHeaders, setSessionTokenHeader, sanitize, sendMessage, isServiceUrl), original);
|
|
9318
9315
|
}
|
|
9319
9316
|
}
|
|
9320
9317
|
|
|
@@ -9655,7 +9652,7 @@ class API {
|
|
|
9655
9652
|
this.signalStartIssue = (reason, missingApi) => {
|
|
9656
9653
|
const doNotTrack = this.checkDoNotTrack();
|
|
9657
9654
|
console.log("Tracker couldn't start due to:", JSON.stringify({
|
|
9658
|
-
trackerVersion: '16.4.
|
|
9655
|
+
trackerVersion: '16.4.4',
|
|
9659
9656
|
projectKey: this.options.projectKey,
|
|
9660
9657
|
doNotTrack,
|
|
9661
9658
|
reason: missingApi.length ? `missing api: ${missingApi.join(',')}` : reason,
|
|
@@ -9743,7 +9740,7 @@ class API {
|
|
|
9743
9740
|
this.app = app;
|
|
9744
9741
|
if (!this.crossdomainMode) {
|
|
9745
9742
|
// no need to send iframe viewport data since its a node for us
|
|
9746
|
-
Viewport(app);
|
|
9743
|
+
Viewport(app, options.urls);
|
|
9747
9744
|
// calculated in main window
|
|
9748
9745
|
Connection(app);
|
|
9749
9746
|
// while we can calculate it here, trying to compute it for all parts is hard
|