@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.
package/dist/cjs/entry.js CHANGED
@@ -5051,6 +5051,23 @@ class Session {
5051
5051
  this.app.sessionStorage.setItem(this.options.session_pageno_key, pageNo.toString());
5052
5052
  return pageNo;
5053
5053
  };
5054
+ this.getSessionToken = (projectKey) => {
5055
+ const tokenWithProject = this.token || this.app.sessionStorage.getItem(this.options.session_token_key);
5056
+ if (projectKey && tokenWithProject) {
5057
+ const savedProject = tokenWithProject.split('_&_')[1];
5058
+ if (!savedProject || savedProject !== projectKey) {
5059
+ this.app.sessionStorage.removeItem(this.options.session_token_key);
5060
+ this.token = undefined;
5061
+ return undefined;
5062
+ }
5063
+ }
5064
+ const token = tokenWithProject ? tokenWithProject.split('_&_')[0] : null;
5065
+ return token || undefined;
5066
+ };
5067
+ this.setSessionToken = (token, projectKey) => {
5068
+ this.token = `${token}_&_${projectKey}`;
5069
+ this.app.sessionStorage.setItem(this.options.session_token_key, `${token}_&_${projectKey}`);
5070
+ };
5054
5071
  this.app = params.app;
5055
5072
  this.options = params.options;
5056
5073
  this.createTabId();
@@ -5097,23 +5114,6 @@ class Session {
5097
5114
  setUserInfo(userInfo) {
5098
5115
  this.userInfo = userInfo;
5099
5116
  }
5100
- getSessionToken(projectKey) {
5101
- const tokenWithProject = this.token || this.app.sessionStorage.getItem(this.options.session_token_key);
5102
- if (projectKey && tokenWithProject) {
5103
- const savedProject = tokenWithProject.split('_&_')[1];
5104
- if (!savedProject || savedProject !== projectKey) {
5105
- this.app.sessionStorage.removeItem(this.options.session_token_key);
5106
- this.token = undefined;
5107
- return undefined;
5108
- }
5109
- }
5110
- const token = tokenWithProject ? tokenWithProject.split('_&_')[0] : null;
5111
- return token || undefined;
5112
- }
5113
- setSessionToken(token, projectKey) {
5114
- this.token = token;
5115
- this.app.sessionStorage.setItem(this.options.session_token_key, `${token}_&_${projectKey}`);
5116
- }
5117
5117
  applySessionHash(hash) {
5118
5118
  const hashParts = decodeURI(hash).split('&');
5119
5119
  let token = hash;
@@ -5276,7 +5276,7 @@ class App {
5276
5276
  this.stopCallbacks = [];
5277
5277
  this.commitCallbacks = [];
5278
5278
  this.activityState = ActivityState.NotActive;
5279
- this.version = '16.4.7'; // TODO: version compatability check inside each plugin.
5279
+ this.version = '16.4.8'; // TODO: version compatability check inside each plugin.
5280
5280
  this.socketMode = false;
5281
5281
  this.compressionThreshold = 24 * 1000;
5282
5282
  this.bc = null;
@@ -5380,6 +5380,13 @@ class App {
5380
5380
  }
5381
5381
  };
5382
5382
  void signalId();
5383
+ if (this.active()) {
5384
+ // @ts-ignore
5385
+ event.source?.postMessage({ line: proto.startIframe }, '*');
5386
+ }
5387
+ else {
5388
+ this.addCommand(proto.startIframe);
5389
+ }
5383
5390
  }
5384
5391
  /**
5385
5392
  * proxying messages from iframe to main body, so they can be in one batch (same indexes, etc)
@@ -5879,6 +5886,7 @@ class App {
5879
5886
  }, 250);
5880
5887
  this.bc.onmessage = (ev) => {
5881
5888
  if (ev.data.context === this.contextId || this.projectKey !== ev.data.projectKey) {
5889
+ this.debug.log('same ctx event', ev);
5882
5890
  return;
5883
5891
  }
5884
5892
  this.debug.log(ev);
@@ -7680,9 +7688,15 @@ function Timing (app, opts) {
7680
7688
  const entryName = options.resourceNameSanitizer
7681
7689
  ? options.resourceNameSanitizer(entry.name)
7682
7690
  : entry.name;
7683
- 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,
7691
+ const cached =
7684
7692
  // @ts-ignore
7685
- (entry.responseStatus && entry.responseStatus === 304) || entry.transferSize === 0));
7693
+ (entry.responseStatus && entry.responseStatus === 304) ||
7694
+ // @ts-ignore
7695
+ (entry.deliveryType && entry.deliveryType === 'cache') ||
7696
+ (entry.transferSize === 0 && entry.decodedBodySize > 0);
7697
+ const requestFailed = entry.responseStatus && entry.responseStatus >= 400;
7698
+ const decodedBodySize = requestFailed ? -111 : entry.decodedBodySize || 0;
7699
+ 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));
7686
7700
  }
7687
7701
  const observer = new PerformanceObserver((list) => list.getEntries().forEach(resourceTiming));
7688
7702
  function onVitalsSignal(msg) {
@@ -9656,7 +9670,7 @@ class API {
9656
9670
  this.signalStartIssue = (reason, missingApi) => {
9657
9671
  const doNotTrack = this.checkDoNotTrack();
9658
9672
  console.log("Tracker couldn't start due to:", JSON.stringify({
9659
- trackerVersion: '16.4.7',
9673
+ trackerVersion: '16.4.8',
9660
9674
  projectKey: this.options.projectKey,
9661
9675
  doNotTrack,
9662
9676
  reason: missingApi.length ? `missing api: ${missingApi.join(',')}` : reason,