@openreplay/tracker 16.4.2-beta.1 → 16.4.2-beta.3
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 +56 -43
- package/dist/cjs/entry.js.map +1 -1
- package/dist/cjs/index.js +56 -43
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/main/app/session.d.ts +2 -2
- package/dist/lib/entry.js +56 -43
- package/dist/lib/entry.js.map +1 -1
- package/dist/lib/index.js +56 -43
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/main/app/session.d.ts +2 -2
- package/dist/types/main/app/session.d.ts +2 -2
- package/package.json +2 -2
package/dist/cjs/entry.js
CHANGED
|
@@ -5089,13 +5089,21 @@ class Session {
|
|
|
5089
5089
|
setUserInfo(userInfo) {
|
|
5090
5090
|
this.userInfo = userInfo;
|
|
5091
5091
|
}
|
|
5092
|
-
getSessionToken() {
|
|
5092
|
+
getSessionToken(projectKey) {
|
|
5093
5093
|
const token = this.token || this.app.sessionStorage.getItem(this.options.session_token_key);
|
|
5094
|
+
if (projectKey && token) {
|
|
5095
|
+
const savedProject = token.split('_&_')[1];
|
|
5096
|
+
if (!savedProject || savedProject !== projectKey) {
|
|
5097
|
+
this.app.sessionStorage.removeItem(this.options.session_token_key);
|
|
5098
|
+
this.token = undefined;
|
|
5099
|
+
return undefined;
|
|
5100
|
+
}
|
|
5101
|
+
}
|
|
5094
5102
|
return token || undefined;
|
|
5095
5103
|
}
|
|
5096
|
-
setSessionToken(token) {
|
|
5104
|
+
setSessionToken(token, projectKey) {
|
|
5097
5105
|
this.token = token;
|
|
5098
|
-
this.app.sessionStorage.setItem(this.options.session_token_key, token);
|
|
5106
|
+
this.app.sessionStorage.setItem(this.options.session_token_key, `${token}_&_${projectKey}`);
|
|
5099
5107
|
}
|
|
5100
5108
|
applySessionHash(hash) {
|
|
5101
5109
|
const hashParts = decodeURI(hash).split('&');
|
|
@@ -5259,7 +5267,7 @@ class App {
|
|
|
5259
5267
|
this.stopCallbacks = [];
|
|
5260
5268
|
this.commitCallbacks = [];
|
|
5261
5269
|
this.activityState = ActivityState.NotActive;
|
|
5262
|
-
this.version = '16.4.2-beta.
|
|
5270
|
+
this.version = '16.4.2-beta.3'; // TODO: version compatability check inside each plugin.
|
|
5263
5271
|
this.socketMode = false;
|
|
5264
5272
|
this.compressionThreshold = 24 * 1000;
|
|
5265
5273
|
this.bc = null;
|
|
@@ -5300,7 +5308,7 @@ class App {
|
|
|
5300
5308
|
if (data.line === proto.iframeId) {
|
|
5301
5309
|
this.parentActive = true;
|
|
5302
5310
|
this.rootId = data.id;
|
|
5303
|
-
this.session.setSessionToken(data.token);
|
|
5311
|
+
this.session.setSessionToken(data.token, this.projectKey);
|
|
5304
5312
|
this.frameOderNumber = data.frameOrderNumber;
|
|
5305
5313
|
this.debug.log('starting iframe tracking', data);
|
|
5306
5314
|
this.allowAppStart();
|
|
@@ -5342,7 +5350,7 @@ class App {
|
|
|
5342
5350
|
this.trackedFrames.push(data.context);
|
|
5343
5351
|
}
|
|
5344
5352
|
await this.waitStarted();
|
|
5345
|
-
const token = this.session.getSessionToken();
|
|
5353
|
+
const token = this.session.getSessionToken(this.projectKey);
|
|
5346
5354
|
const order = this.trackedFrames.findIndex((f) => f === data.context) + 1;
|
|
5347
5355
|
if (order === 0) {
|
|
5348
5356
|
this.debug.error('Couldnt get order number for iframe', data.context, this.trackedFrames);
|
|
@@ -5706,17 +5714,17 @@ class App {
|
|
|
5706
5714
|
this.debug.log(ev);
|
|
5707
5715
|
if (ev.data.line === proto.resp) {
|
|
5708
5716
|
const sessionToken = ev.data.token;
|
|
5709
|
-
this.session.setSessionToken(sessionToken);
|
|
5717
|
+
this.session.setSessionToken(sessionToken, this.projectKey);
|
|
5710
5718
|
this.allowAppStart();
|
|
5711
5719
|
}
|
|
5712
5720
|
if (ev.data.line === proto.reg) {
|
|
5713
5721
|
const sessionToken = ev.data.token;
|
|
5714
5722
|
this.session.regenerateTabId();
|
|
5715
|
-
this.session.setSessionToken(sessionToken);
|
|
5723
|
+
this.session.setSessionToken(sessionToken, this.projectKey);
|
|
5716
5724
|
this.allowAppStart();
|
|
5717
5725
|
}
|
|
5718
5726
|
if (ev.data.line === proto.ask) {
|
|
5719
|
-
const token = this.session.getSessionToken();
|
|
5727
|
+
const token = this.session.getSessionToken(this.projectKey);
|
|
5720
5728
|
if (token && this.bc) {
|
|
5721
5729
|
this.bc.postMessage({
|
|
5722
5730
|
line: ev.data.source === thisTab ? proto.reg : proto.resp,
|
|
@@ -5991,7 +5999,7 @@ class App {
|
|
|
5991
5999
|
};
|
|
5992
6000
|
}
|
|
5993
6001
|
getSessionToken() {
|
|
5994
|
-
return this.session.getSessionToken();
|
|
6002
|
+
return this.session.getSessionToken(this.projectKey);
|
|
5995
6003
|
}
|
|
5996
6004
|
getSessionID() {
|
|
5997
6005
|
return this.session.getInfo().sessionID || undefined;
|
|
@@ -6053,7 +6061,7 @@ class App {
|
|
|
6053
6061
|
checkSessionToken(forceNew) {
|
|
6054
6062
|
const lsReset = this.sessionStorage.getItem(this.options.session_reset_key) !== null;
|
|
6055
6063
|
const needNewSessionID = forceNew || lsReset;
|
|
6056
|
-
const sessionToken = this.session.getSessionToken();
|
|
6064
|
+
const sessionToken = this.session.getSessionToken(this.projectKey);
|
|
6057
6065
|
return needNewSessionID || !sessionToken;
|
|
6058
6066
|
}
|
|
6059
6067
|
/**
|
|
@@ -6320,7 +6328,7 @@ class App {
|
|
|
6320
6328
|
connAttemptGap: this.options.connAttemptGap,
|
|
6321
6329
|
tabId: this.session.getTabId(),
|
|
6322
6330
|
});
|
|
6323
|
-
const sessionToken = this.session.getSessionToken();
|
|
6331
|
+
const sessionToken = this.session.getSessionToken(this.projectKey);
|
|
6324
6332
|
const isNewSession = this.checkSessionToken(startOpts.forceNew);
|
|
6325
6333
|
this.sessionStorage.removeItem(this.options.session_reset_key);
|
|
6326
6334
|
this.debug.log('OpenReplay: starting session; need new session id?', isNewSession, 'session token: ', sessionToken);
|
|
@@ -6373,7 +6381,7 @@ class App {
|
|
|
6373
6381
|
return UnsuccessfulStart(reason);
|
|
6374
6382
|
}
|
|
6375
6383
|
this.delay = delay;
|
|
6376
|
-
this.session.setSessionToken(token);
|
|
6384
|
+
this.session.setSessionToken(token, this.projectKey);
|
|
6377
6385
|
this.session.setUserInfo({
|
|
6378
6386
|
userBrowser,
|
|
6379
6387
|
userCity,
|
|
@@ -8559,42 +8567,47 @@ const genStringBody = (body) => {
|
|
|
8559
8567
|
return null;
|
|
8560
8568
|
}
|
|
8561
8569
|
let result;
|
|
8562
|
-
|
|
8563
|
-
if (
|
|
8564
|
-
|
|
8570
|
+
try {
|
|
8571
|
+
if (typeof body === 'string') {
|
|
8572
|
+
if (body[0] === '{' || body[0] === '[') {
|
|
8573
|
+
result = body;
|
|
8574
|
+
}
|
|
8575
|
+
// 'a=1&b=2' => try to parse as query
|
|
8576
|
+
const arr = body.split('&');
|
|
8577
|
+
if (arr.length === 1) {
|
|
8578
|
+
// not a query, parse as original string
|
|
8579
|
+
result = body;
|
|
8580
|
+
}
|
|
8581
|
+
else {
|
|
8582
|
+
// 'a=1&b=2&c' => parse as query
|
|
8583
|
+
result = arr.join(',');
|
|
8584
|
+
}
|
|
8565
8585
|
}
|
|
8566
|
-
|
|
8567
|
-
|
|
8568
|
-
|
|
8569
|
-
|
|
8586
|
+
else if (isIterable(body)) {
|
|
8587
|
+
// FormData or URLSearchParams or Array
|
|
8588
|
+
const arr = [];
|
|
8589
|
+
for (const [key, value] of body) {
|
|
8590
|
+
arr.push(`${key}=${typeof value === 'string' ? value : '[object Object]'}`);
|
|
8591
|
+
}
|
|
8592
|
+
result = arr.join(',');
|
|
8593
|
+
}
|
|
8594
|
+
else if (body instanceof Blob ||
|
|
8595
|
+
body instanceof ReadableStream ||
|
|
8596
|
+
body instanceof ArrayBuffer) {
|
|
8597
|
+
result = 'byte data';
|
|
8598
|
+
}
|
|
8599
|
+
else if (isPureObject(body)) {
|
|
8600
|
+
// overriding ArrayBufferView which is not convertable to string
|
|
8570
8601
|
result = body;
|
|
8571
8602
|
}
|
|
8572
8603
|
else {
|
|
8573
|
-
|
|
8574
|
-
result = arr.join(',');
|
|
8604
|
+
result = `can't parse body ${typeof body}`;
|
|
8575
8605
|
}
|
|
8606
|
+
return result;
|
|
8576
8607
|
}
|
|
8577
|
-
|
|
8578
|
-
|
|
8579
|
-
const arr = [];
|
|
8580
|
-
for (const [key, value] of body) {
|
|
8581
|
-
arr.push(`${key}=${typeof value === 'string' ? value : '[object Object]'}`);
|
|
8582
|
-
}
|
|
8583
|
-
result = arr.join(',');
|
|
8608
|
+
catch (_) {
|
|
8609
|
+
return "can't parse body";
|
|
8584
8610
|
}
|
|
8585
|
-
else if (body instanceof Blob ||
|
|
8586
|
-
body instanceof ReadableStream ||
|
|
8587
|
-
body instanceof ArrayBuffer) {
|
|
8588
|
-
result = 'byte data';
|
|
8589
|
-
}
|
|
8590
|
-
else if (isPureObject(body)) {
|
|
8591
|
-
// overriding ArrayBufferView which is not convertable to string
|
|
8592
|
-
result = body;
|
|
8593
|
-
}
|
|
8594
|
-
else {
|
|
8595
|
-
result = `can't parse body ${typeof body}`;
|
|
8596
|
-
}
|
|
8597
|
-
return result;
|
|
8598
8611
|
};
|
|
8599
8612
|
const genGetDataByUrl = (url, getData = {}) => {
|
|
8600
8613
|
if (!isPureObject(getData)) {
|
|
@@ -9634,7 +9647,7 @@ class API {
|
|
|
9634
9647
|
this.signalStartIssue = (reason, missingApi) => {
|
|
9635
9648
|
const doNotTrack = this.checkDoNotTrack();
|
|
9636
9649
|
console.log("Tracker couldn't start due to:", JSON.stringify({
|
|
9637
|
-
trackerVersion: '16.4.2-beta.
|
|
9650
|
+
trackerVersion: '16.4.2-beta.3',
|
|
9638
9651
|
projectKey: this.options.projectKey,
|
|
9639
9652
|
doNotTrack,
|
|
9640
9653
|
reason: missingApi.length ? `missing api: ${missingApi.join(',')}` : reason,
|