@openreplay/tracker 16.4.7 → 16.4.8

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.
@@ -44,8 +44,8 @@ export default class Session {
44
44
  setUserInfo(userInfo: UserInfo): void;
45
45
  getPageNumber: () => number | undefined;
46
46
  incPageNo: () => number;
47
- getSessionToken(projectKey?: string): string | undefined;
48
- setSessionToken(token: string, projectKey: string): void;
47
+ getSessionToken: (projectKey?: string) => string | undefined;
48
+ setSessionToken: (token: string, projectKey: string) => void;
49
49
  applySessionHash(hash: string): void;
50
50
  getSessionHash(): string | undefined;
51
51
  getTabId(): string;
package/dist/lib/entry.js CHANGED
@@ -5047,6 +5047,23 @@ class Session {
5047
5047
  this.app.sessionStorage.setItem(this.options.session_pageno_key, pageNo.toString());
5048
5048
  return pageNo;
5049
5049
  };
5050
+ this.getSessionToken = (projectKey) => {
5051
+ const tokenWithProject = this.token || this.app.sessionStorage.getItem(this.options.session_token_key);
5052
+ if (projectKey && tokenWithProject) {
5053
+ const savedProject = tokenWithProject.split('_&_')[1];
5054
+ if (!savedProject || savedProject !== projectKey) {
5055
+ this.app.sessionStorage.removeItem(this.options.session_token_key);
5056
+ this.token = undefined;
5057
+ return undefined;
5058
+ }
5059
+ }
5060
+ const token = tokenWithProject ? tokenWithProject.split('_&_')[0] : null;
5061
+ return token || undefined;
5062
+ };
5063
+ this.setSessionToken = (token, projectKey) => {
5064
+ this.token = `${token}_&_${projectKey}`;
5065
+ this.app.sessionStorage.setItem(this.options.session_token_key, `${token}_&_${projectKey}`);
5066
+ };
5050
5067
  this.app = params.app;
5051
5068
  this.options = params.options;
5052
5069
  this.createTabId();
@@ -5093,23 +5110,6 @@ class Session {
5093
5110
  setUserInfo(userInfo) {
5094
5111
  this.userInfo = userInfo;
5095
5112
  }
5096
- getSessionToken(projectKey) {
5097
- const tokenWithProject = this.token || this.app.sessionStorage.getItem(this.options.session_token_key);
5098
- if (projectKey && tokenWithProject) {
5099
- const savedProject = tokenWithProject.split('_&_')[1];
5100
- if (!savedProject || savedProject !== projectKey) {
5101
- this.app.sessionStorage.removeItem(this.options.session_token_key);
5102
- this.token = undefined;
5103
- return undefined;
5104
- }
5105
- }
5106
- const token = tokenWithProject ? tokenWithProject.split('_&_')[0] : null;
5107
- return token || undefined;
5108
- }
5109
- setSessionToken(token, projectKey) {
5110
- this.token = token;
5111
- this.app.sessionStorage.setItem(this.options.session_token_key, `${token}_&_${projectKey}`);
5112
- }
5113
5113
  applySessionHash(hash) {
5114
5114
  const hashParts = decodeURI(hash).split('&');
5115
5115
  let token = hash;
@@ -5272,7 +5272,7 @@ class App {
5272
5272
  this.stopCallbacks = [];
5273
5273
  this.commitCallbacks = [];
5274
5274
  this.activityState = ActivityState.NotActive;
5275
- this.version = '16.4.7'; // TODO: version compatability check inside each plugin.
5275
+ this.version = '16.4.8'; // TODO: version compatability check inside each plugin.
5276
5276
  this.socketMode = false;
5277
5277
  this.compressionThreshold = 24 * 1000;
5278
5278
  this.bc = null;
@@ -5376,6 +5376,13 @@ class App {
5376
5376
  }
5377
5377
  };
5378
5378
  void signalId();
5379
+ if (this.active()) {
5380
+ // @ts-ignore
5381
+ event.source?.postMessage({ line: proto.startIframe }, '*');
5382
+ }
5383
+ else {
5384
+ this.addCommand(proto.startIframe);
5385
+ }
5379
5386
  }
5380
5387
  /**
5381
5388
  * proxying messages from iframe to main body, so they can be in one batch (same indexes, etc)
@@ -5875,6 +5882,7 @@ class App {
5875
5882
  }, 250);
5876
5883
  this.bc.onmessage = (ev) => {
5877
5884
  if (ev.data.context === this.contextId || this.projectKey !== ev.data.projectKey) {
5885
+ this.debug.log('same ctx event', ev);
5878
5886
  return;
5879
5887
  }
5880
5888
  this.debug.log(ev);
@@ -7676,9 +7684,15 @@ function Timing (app, opts) {
7676
7684
  const entryName = options.resourceNameSanitizer
7677
7685
  ? options.resourceNameSanitizer(entry.name)
7678
7686
  : entry.name;
7679
- 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, '*') : entryName, entry.initiatorType, entry.transferSize,
7687
+ const cached =
7680
7688
  // @ts-ignore
7681
- (entry.responseStatus && entry.responseStatus === 304) || entry.transferSize === 0));
7689
+ (entry.responseStatus && entry.responseStatus === 304) ||
7690
+ // @ts-ignore
7691
+ (entry.deliveryType && entry.deliveryType === 'cache') ||
7692
+ (entry.transferSize === 0 && entry.decodedBodySize > 0);
7693
+ const requestFailed = entry.responseStatus && entry.responseStatus >= 400;
7694
+ const decodedBodySize = requestFailed ? -111 : entry.decodedBodySize || 0;
7695
+ 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, decodedBodySize, app.sanitizer.privateMode ? entry.name.replaceAll(/./g, '*') : entryName, entry.initiatorType, entry.transferSize, cached));
7682
7696
  }
7683
7697
  const observer = new PerformanceObserver((list) => list.getEntries().forEach(resourceTiming));
7684
7698
  function onVitalsSignal(msg) {
@@ -9652,7 +9666,7 @@ class API {
9652
9666
  this.signalStartIssue = (reason, missingApi) => {
9653
9667
  const doNotTrack = this.checkDoNotTrack();
9654
9668
  console.log("Tracker couldn't start due to:", JSON.stringify({
9655
- trackerVersion: '16.4.7',
9669
+ trackerVersion: '16.4.8',
9656
9670
  projectKey: this.options.projectKey,
9657
9671
  doNotTrack,
9658
9672
  reason: missingApi.length ? `missing api: ${missingApi.join(',')}` : reason,