@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.
@@ -319,6 +319,10 @@ export default class App {
319
319
  coldStartTs: number;
320
320
  singleBuffer: boolean;
321
321
  private getSessionVersionHash;
322
+ private get sessionVersionKey();
323
+ private storeSessionVersion;
324
+ /** a tab adopting a session over BroadcastChannel inherits its version too */
325
+ private adoptSessionVersion;
322
326
  private checkSessionToken;
323
327
  /**
324
328
  * start buffering messages without starting the actual session, which gives
package/dist/lib/entry.js CHANGED
@@ -4360,7 +4360,7 @@ class App {
4360
4360
  this.stopCallbacks = [];
4361
4361
  this.commitCallbacks = [];
4362
4362
  this.activityState = ActivityState.NotActive;
4363
- this.version = '18.1.1'; // TODO: version compatability check inside each plugin.
4363
+ this.version = '18.1.2'; // TODO: version compatability check inside each plugin.
4364
4364
  this.socketMode = false;
4365
4365
  this.compressionThreshold = 24 * 1000;
4366
4366
  this.bc = null;
@@ -5115,12 +5115,14 @@ class App {
5115
5115
  if (ev.data.line === proto.resp) {
5116
5116
  const sessionToken = ev.data.token;
5117
5117
  this.session.setSessionToken(sessionToken, this.projectKey);
5118
+ this.adoptSessionVersion(ev.data.version);
5118
5119
  this.allowAppStart();
5119
5120
  }
5120
5121
  if (ev.data.line === proto.reg) {
5121
5122
  const sessionToken = ev.data.token;
5122
5123
  this.session.regenerateTabId();
5123
5124
  this.session.setSessionToken(sessionToken, this.projectKey);
5125
+ this.adoptSessionVersion(ev.data.version);
5124
5126
  this.allowAppStart();
5125
5127
  }
5126
5128
  if (ev.data.line === proto.ask) {
@@ -5129,6 +5131,7 @@ class App {
5129
5131
  this.bc.postMessage({
5130
5132
  line: ev.data.source === thisTab ? proto.reg : proto.resp,
5131
5133
  token,
5134
+ version: this.getSessionVersionHash(),
5132
5135
  source: thisTab,
5133
5136
  context: this.contextId,
5134
5137
  projectKey: this.projectKey,
@@ -5616,15 +5619,29 @@ class App {
5616
5619
  const PROTO_VERSION = '2';
5617
5620
  return `${PROTO_VERSION}x${this.version}`;
5618
5621
  }
5622
+ get sessionVersionKey() {
5623
+ return `${this.options.session_token_key}_version`;
5624
+ }
5625
+ storeSessionVersion(version) {
5626
+ this.sessionStorage.setItem(this.sessionVersionKey, version);
5627
+ }
5628
+ /** a tab adopting a session over BroadcastChannel inherits its version too */
5629
+ adoptSessionVersion(version) {
5630
+ if (version) {
5631
+ this.storeSessionVersion(version);
5632
+ }
5633
+ }
5619
5634
  checkSessionToken(forceNew) {
5620
5635
  const versionHash = this.getSessionVersionHash();
5621
5636
  const needReset = this.sessionStorage.getItem(this.options.session_reset_key) !== null;
5622
- let needNewSessionID = forceNew || needReset;
5637
+ let needNewSessionID = Boolean(forceNew || needReset);
5623
5638
  const sessionToken = this.session.getSessionToken(this.projectKey);
5624
5639
  if (sessionToken) {
5625
- const storedVersion = this.sessionStorage.getItem(`${this.options.session_token_key}_version`);
5626
- needNewSessionID = !storedVersion || storedVersion !== versionHash;
5627
- this.sessionStorage.setItem(`${this.options.session_token_key}_version`, versionHash);
5640
+ const storedVersion = this.sessionStorage.getItem(this.sessionVersionKey);
5641
+ if (!storedVersion || storedVersion !== versionHash) {
5642
+ needNewSessionID = true;
5643
+ }
5644
+ this.storeSessionVersion(versionHash);
5628
5645
  }
5629
5646
  return needNewSessionID || !sessionToken;
5630
5647
  }
@@ -5948,7 +5965,7 @@ class App {
5948
5965
  }
5949
5966
  this.delay = delay;
5950
5967
  this.session.setSessionToken(token, this.projectKey);
5951
- this.sessionStorage.setItem(`${this.options.session_token_key}_version`, this.getSessionVersionHash());
5968
+ this.storeSessionVersion(this.getSessionVersionHash());
5952
5969
  if (sessionToken && sessionToken !== token) {
5953
5970
  this.bc?.postMessage({
5954
5971
  type: proto.reset,
@@ -9773,7 +9790,7 @@ class ConstantProperties {
9773
9790
  user_id: this.user_id,
9774
9791
  distinct_id: this.deviceId,
9775
9792
  sdk_edition: 'web',
9776
- sdk_version: '18.1.1',
9793
+ sdk_version: '18.1.2',
9777
9794
  timezone: getUTCOffsetString(),
9778
9795
  search_engine: this.searchEngine,
9779
9796
  };
@@ -10514,7 +10531,7 @@ class API {
10514
10531
  this.signalStartIssue = (reason, missingApi) => {
10515
10532
  const doNotTrack = this.checkDoNotTrack();
10516
10533
  console.log("Tracker couldn't start due to:", JSON.stringify({
10517
- trackerVersion: '18.1.1',
10534
+ trackerVersion: '18.1.2',
10518
10535
  projectKey: this.options.projectKey,
10519
10536
  doNotTrack,
10520
10537
  reason: missingApi.length ? `missing api: ${missingApi.join(',')}` : reason,