@openreplay/tracker 18.1.1 → 18.1.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/dist/cjs/entry.js CHANGED
@@ -4364,7 +4364,7 @@ class App {
4364
4364
  this.stopCallbacks = [];
4365
4365
  this.commitCallbacks = [];
4366
4366
  this.activityState = ActivityState.NotActive;
4367
- this.version = '18.1.1'; // TODO: version compatability check inside each plugin.
4367
+ this.version = '18.1.2'; // TODO: version compatability check inside each plugin.
4368
4368
  this.socketMode = false;
4369
4369
  this.compressionThreshold = 24 * 1000;
4370
4370
  this.bc = null;
@@ -5119,12 +5119,14 @@ class App {
5119
5119
  if (ev.data.line === proto.resp) {
5120
5120
  const sessionToken = ev.data.token;
5121
5121
  this.session.setSessionToken(sessionToken, this.projectKey);
5122
+ this.adoptSessionVersion(ev.data.version);
5122
5123
  this.allowAppStart();
5123
5124
  }
5124
5125
  if (ev.data.line === proto.reg) {
5125
5126
  const sessionToken = ev.data.token;
5126
5127
  this.session.regenerateTabId();
5127
5128
  this.session.setSessionToken(sessionToken, this.projectKey);
5129
+ this.adoptSessionVersion(ev.data.version);
5128
5130
  this.allowAppStart();
5129
5131
  }
5130
5132
  if (ev.data.line === proto.ask) {
@@ -5133,6 +5135,7 @@ class App {
5133
5135
  this.bc.postMessage({
5134
5136
  line: ev.data.source === thisTab ? proto.reg : proto.resp,
5135
5137
  token,
5138
+ version: this.getSessionVersionHash(),
5136
5139
  source: thisTab,
5137
5140
  context: this.contextId,
5138
5141
  projectKey: this.projectKey,
@@ -5620,15 +5623,29 @@ class App {
5620
5623
  const PROTO_VERSION = '2';
5621
5624
  return `${PROTO_VERSION}x${this.version}`;
5622
5625
  }
5626
+ get sessionVersionKey() {
5627
+ return `${this.options.session_token_key}_version`;
5628
+ }
5629
+ storeSessionVersion(version) {
5630
+ this.sessionStorage.setItem(this.sessionVersionKey, version);
5631
+ }
5632
+ /** a tab adopting a session over BroadcastChannel inherits its version too */
5633
+ adoptSessionVersion(version) {
5634
+ if (version) {
5635
+ this.storeSessionVersion(version);
5636
+ }
5637
+ }
5623
5638
  checkSessionToken(forceNew) {
5624
5639
  const versionHash = this.getSessionVersionHash();
5625
5640
  const needReset = this.sessionStorage.getItem(this.options.session_reset_key) !== null;
5626
- let needNewSessionID = forceNew || needReset;
5641
+ let needNewSessionID = Boolean(forceNew || needReset);
5627
5642
  const sessionToken = this.session.getSessionToken(this.projectKey);
5628
5643
  if (sessionToken) {
5629
- const storedVersion = this.sessionStorage.getItem(`${this.options.session_token_key}_version`);
5630
- needNewSessionID = !storedVersion || storedVersion !== versionHash;
5631
- this.sessionStorage.setItem(`${this.options.session_token_key}_version`, versionHash);
5644
+ const storedVersion = this.sessionStorage.getItem(this.sessionVersionKey);
5645
+ if (!storedVersion || storedVersion !== versionHash) {
5646
+ needNewSessionID = true;
5647
+ }
5648
+ this.storeSessionVersion(versionHash);
5632
5649
  }
5633
5650
  return needNewSessionID || !sessionToken;
5634
5651
  }
@@ -5952,7 +5969,7 @@ class App {
5952
5969
  }
5953
5970
  this.delay = delay;
5954
5971
  this.session.setSessionToken(token, this.projectKey);
5955
- this.sessionStorage.setItem(`${this.options.session_token_key}_version`, this.getSessionVersionHash());
5972
+ this.storeSessionVersion(this.getSessionVersionHash());
5956
5973
  if (sessionToken && sessionToken !== token) {
5957
5974
  this.bc?.postMessage({
5958
5975
  type: proto.reset,
@@ -9777,7 +9794,7 @@ class ConstantProperties {
9777
9794
  user_id: this.user_id,
9778
9795
  distinct_id: this.deviceId,
9779
9796
  sdk_edition: 'web',
9780
- sdk_version: '18.1.1',
9797
+ sdk_version: '18.1.2',
9781
9798
  timezone: getUTCOffsetString(),
9782
9799
  search_engine: this.searchEngine,
9783
9800
  };
@@ -10518,7 +10535,7 @@ class API {
10518
10535
  this.signalStartIssue = (reason, missingApi) => {
10519
10536
  const doNotTrack = this.checkDoNotTrack();
10520
10537
  console.log("Tracker couldn't start due to:", JSON.stringify({
10521
- trackerVersion: '18.1.1',
10538
+ trackerVersion: '18.1.2',
10522
10539
  projectKey: this.options.projectKey,
10523
10540
  doNotTrack,
10524
10541
  reason: missingApi.length ? `missing api: ${missingApi.join(',')}` : reason,