@openreplay/tracker 14.0.13 → 14.0.14

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/index.js CHANGED
@@ -82,7 +82,7 @@ class API {
82
82
  const orig = this.options.ingestPoint || index_js_1.DEFAULT_INGEST_POINT;
83
83
  req.open('POST', orig + '/v1/web/not-started');
84
84
  req.send(JSON.stringify({
85
- trackerVersion: '14.0.13',
85
+ trackerVersion: '14.0.14',
86
86
  projectKey: this.options.projectKey,
87
87
  doNotTrack,
88
88
  reason: missingApi.length ? `missing api: ${missingApi.join(',')}` : reason,
package/dist/lib/index.js CHANGED
@@ -50,7 +50,7 @@ var freb = function (eb, start) {
50
50
  }
51
51
  return { b: b, r: r };
52
52
  };
53
- var _a$1 = freb(fleb, 2), fl = _a$1.b, revfl = _a$1.r;
53
+ var _a = freb(fleb, 2), fl = _a.b, revfl = _a.r;
54
54
  // we can ignore the fact that the other numbers are wrong; they never happen anyway
55
55
  fl[28] = 258, revfl[258] = 28;
56
56
  var _b = freb(fdeb, 0), revfd = _b.r;
@@ -4612,7 +4612,7 @@ class App {
4612
4612
  this.stopCallbacks = [];
4613
4613
  this.commitCallbacks = [];
4614
4614
  this.activityState = ActivityState.NotActive;
4615
- this.version = '14.0.13'; // TODO: version compatability check inside each plugin.
4615
+ this.version = '14.0.14'; // TODO: version compatability check inside each plugin.
4616
4616
  this.socketMode = false;
4617
4617
  this.compressionThreshold = 24 * 1000;
4618
4618
  this.bc = null;
@@ -4682,32 +4682,36 @@ class App {
4682
4682
  return console.error('Couldnt connect to event.source for child iframe tracking');
4683
4683
  }
4684
4684
  const id = await this.checkNodeId(event.source);
4685
- if (id && !this.trackedFrames.includes(data.context)) {
4686
- try {
4685
+ if (!id) {
4686
+ this.debug.log('Couldnt get node id for iframe', event.source);
4687
+ return;
4688
+ }
4689
+ try {
4690
+ if (this.trackedFrames.includes(data.context)) {
4691
+ this.debug.log('Trying to observe already added iframe; ignore if its a restart');
4692
+ }
4693
+ else {
4687
4694
  this.trackedFrames.push(data.context);
4688
- await this.waitStarted();
4689
- const token = this.session.getSessionToken();
4690
- const order = this.trackedFrames.findIndex((f) => f === data.context) + 1;
4691
- if (order === 0) {
4692
- this.debug.error('Couldnt get order number for iframe', data.context, this.trackedFrames);
4693
- }
4694
- const iframeData = {
4695
- line: proto.iframeId,
4696
- id,
4697
- token,
4698
- // since indexes go from 0 we +1
4699
- frameOrderNumber: order,
4700
- };
4701
- this.debug.log('Got child frame signal; nodeId', id, event.source, iframeData);
4702
- // @ts-ignore
4703
- event.source?.postMessage(iframeData, '*');
4704
4695
  }
4705
- catch (e) {
4706
- console.error(e);
4696
+ await this.waitStarted();
4697
+ const token = this.session.getSessionToken();
4698
+ const order = this.trackedFrames.findIndex((f) => f === data.context) + 1;
4699
+ if (order === 0) {
4700
+ this.debug.error('Couldnt get order number for iframe', data.context, this.trackedFrames);
4707
4701
  }
4702
+ const iframeData = {
4703
+ line: proto.iframeId,
4704
+ id,
4705
+ token,
4706
+ // since indexes go from 0 we +1
4707
+ frameOrderNumber: order,
4708
+ };
4709
+ this.debug.log('Got child frame signal; nodeId', id, event.source, iframeData);
4710
+ // @ts-ignore
4711
+ event.source?.postMessage(iframeData, '*');
4708
4712
  }
4709
- else {
4710
- this.debug.log('Couldnt get node id for iframe', event.source);
4713
+ catch (e) {
4714
+ console.error(e);
4711
4715
  }
4712
4716
  };
4713
4717
  void signalId();
@@ -8038,7 +8042,6 @@ const getURL = (urlString) => {
8038
8042
  }
8039
8043
  };
8040
8044
 
8041
- var _a;
8042
8045
  // https://fetch.spec.whatwg.org/#concept-bodyinit-extract
8043
8046
  const getContentType = (data) => {
8044
8047
  if (data instanceof Blob) {
@@ -8105,17 +8108,13 @@ class BeaconProxyHandler {
8105
8108
  }
8106
8109
  }
8107
8110
  class BeaconProxy {
8108
- static hasSendBeacon() {
8109
- return !!BeaconProxy.origSendBeacon;
8110
- }
8111
- static create(ignoredHeaders, setSessionTokenHeader, sanitize, sendMessage, isServiceUrl) {
8112
- if (!BeaconProxy.hasSendBeacon()) {
8111
+ static create(originalSendBeacon, ignoredHeaders, setSessionTokenHeader, sanitize, sendMessage, isServiceUrl) {
8112
+ if (!originalSendBeacon) {
8113
8113
  return undefined;
8114
8114
  }
8115
- return new Proxy(BeaconProxy.origSendBeacon, new BeaconProxyHandler(ignoredHeaders, setSessionTokenHeader, sanitize, sendMessage, isServiceUrl));
8115
+ return new Proxy(originalSendBeacon, new BeaconProxyHandler(ignoredHeaders, setSessionTokenHeader, sanitize, sendMessage, isServiceUrl));
8116
8116
  }
8117
8117
  }
8118
- BeaconProxy.origSendBeacon = (_a = window === null || window === void 0 ? void 0 : window.navigator) === null || _a === void 0 ? void 0 : _a.sendBeacon;
8119
8118
 
8120
8119
  var RequestState;
8121
8120
  (function (RequestState) {
@@ -8656,6 +8655,8 @@ function createNetworkProxy(context, ignoredHeaders, setSessionTokenHeader, sani
8656
8655
  beacon: true,
8657
8656
  }, tokenUrlMatcher) {
8658
8657
  var _a;
8658
+ if (!context)
8659
+ return;
8659
8660
  if (modules.xhr) {
8660
8661
  if (context.XMLHttpRequest) {
8661
8662
  context.XMLHttpRequest = XHRProxy.create(ignoredHeaders, setSessionTokenHeader, sanitize, sendMessage, isServiceUrl, tokenUrlMatcher);
@@ -8673,8 +8674,9 @@ function createNetworkProxy(context, ignoredHeaders, setSessionTokenHeader, sani
8673
8674
  }
8674
8675
  }
8675
8676
  if (modules.beacon) {
8676
- if ((_a = context === null || context === void 0 ? void 0 : context.navigator) === null || _a === void 0 ? void 0 : _a.sendBeacon) {
8677
- context.navigator.sendBeacon = BeaconProxy.create(ignoredHeaders, setSessionTokenHeader, sanitize, sendMessage, isServiceUrl);
8677
+ if ((_a = context.navigator) === null || _a === void 0 ? void 0 : _a.sendBeacon) {
8678
+ const origBeacon = context.navigator.sendBeacon;
8679
+ context.navigator.sendBeacon = BeaconProxy.create(origBeacon, ignoredHeaders, setSessionTokenHeader, sanitize, sendMessage, isServiceUrl);
8678
8680
  }
8679
8681
  }
8680
8682
  }
@@ -9012,7 +9014,7 @@ class API {
9012
9014
  const orig = this.options.ingestPoint || DEFAULT_INGEST_POINT;
9013
9015
  req.open('POST', orig + '/v1/web/not-started');
9014
9016
  req.send(JSON.stringify({
9015
- trackerVersion: '14.0.13',
9017
+ trackerVersion: '14.0.14',
9016
9018
  projectKey: this.options.projectKey,
9017
9019
  doNotTrack,
9018
9020
  reason: missingApi.length ? `missing api: ${missingApi.join(',')}` : reason,