@openreplay/tracker 16.4.2-beta.2 → 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 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.2'; // TODO: version compatability check inside each plugin.
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,
@@ -9639,7 +9647,7 @@ class API {
9639
9647
  this.signalStartIssue = (reason, missingApi) => {
9640
9648
  const doNotTrack = this.checkDoNotTrack();
9641
9649
  console.log("Tracker couldn't start due to:", JSON.stringify({
9642
- trackerVersion: '16.4.2-beta.2',
9650
+ trackerVersion: '16.4.2-beta.3',
9643
9651
  projectKey: this.options.projectKey,
9644
9652
  doNotTrack,
9645
9653
  reason: missingApi.length ? `missing api: ${missingApi.join(',')}` : reason,