@openreplay/tracker 16.4.1 → 16.4.2-beta.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
@@ -5259,7 +5259,7 @@ class App {
5259
5259
  this.stopCallbacks = [];
5260
5260
  this.commitCallbacks = [];
5261
5261
  this.activityState = ActivityState.NotActive;
5262
- this.version = '16.4.1'; // TODO: version compatability check inside each plugin.
5262
+ this.version = '16.4.2-beta.2'; // TODO: version compatability check inside each plugin.
5263
5263
  this.socketMode = false;
5264
5264
  this.compressionThreshold = 24 * 1000;
5265
5265
  this.bc = null;
@@ -5694,12 +5694,13 @@ class App {
5694
5694
  line: proto.ask,
5695
5695
  source: thisTab,
5696
5696
  context: this.contextId,
5697
+ projectKey: this.projectKey,
5697
5698
  });
5698
5699
  this.startTimeout = setTimeout(() => {
5699
5700
  this.allowAppStart();
5700
5701
  }, 250);
5701
5702
  this.bc.onmessage = (ev) => {
5702
- if (ev.data.context === this.contextId) {
5703
+ if (ev.data.context === this.contextId || this.projectKey !== ev.data.projectKey) {
5703
5704
  return;
5704
5705
  }
5705
5706
  this.debug.log(ev);
@@ -5722,6 +5723,7 @@ class App {
5722
5723
  token,
5723
5724
  source: thisTab,
5724
5725
  context: this.contextId,
5726
+ projectKey: this.projectKey,
5725
5727
  });
5726
5728
  }
5727
5729
  }
@@ -8557,42 +8559,47 @@ const genStringBody = (body) => {
8557
8559
  return null;
8558
8560
  }
8559
8561
  let result;
8560
- if (typeof body === 'string') {
8561
- if (body[0] === '{' || body[0] === '[') {
8562
- result = body;
8562
+ try {
8563
+ if (typeof body === 'string') {
8564
+ if (body[0] === '{' || body[0] === '[') {
8565
+ result = body;
8566
+ }
8567
+ // 'a=1&b=2' => try to parse as query
8568
+ const arr = body.split('&');
8569
+ if (arr.length === 1) {
8570
+ // not a query, parse as original string
8571
+ result = body;
8572
+ }
8573
+ else {
8574
+ // 'a=1&b=2&c' => parse as query
8575
+ result = arr.join(',');
8576
+ }
8577
+ }
8578
+ else if (isIterable(body)) {
8579
+ // FormData or URLSearchParams or Array
8580
+ const arr = [];
8581
+ for (const [key, value] of body) {
8582
+ arr.push(`${key}=${typeof value === 'string' ? value : '[object Object]'}`);
8583
+ }
8584
+ result = arr.join(',');
8563
8585
  }
8564
- // 'a=1&b=2' => try to parse as query
8565
- const arr = body.split('&');
8566
- if (arr.length === 1) {
8567
- // not a query, parse as original string
8586
+ else if (body instanceof Blob ||
8587
+ body instanceof ReadableStream ||
8588
+ body instanceof ArrayBuffer) {
8589
+ result = 'byte data';
8590
+ }
8591
+ else if (isPureObject(body)) {
8592
+ // overriding ArrayBufferView which is not convertable to string
8568
8593
  result = body;
8569
8594
  }
8570
8595
  else {
8571
- // 'a=1&b=2&c' => parse as query
8572
- result = arr.join(',');
8573
- }
8574
- }
8575
- else if (isIterable(body)) {
8576
- // FormData or URLSearchParams or Array
8577
- const arr = [];
8578
- for (const [key, value] of body) {
8579
- arr.push(`${key}=${typeof value === 'string' ? value : '[object Object]'}`);
8596
+ result = `can't parse body ${typeof body}`;
8580
8597
  }
8581
- result = arr.join(',');
8598
+ return result;
8582
8599
  }
8583
- else if (body instanceof Blob ||
8584
- body instanceof ReadableStream ||
8585
- body instanceof ArrayBuffer) {
8586
- result = 'byte data';
8600
+ catch (_) {
8601
+ return "can't parse body";
8587
8602
  }
8588
- else if (isPureObject(body)) {
8589
- // overriding ArrayBufferView which is not convertable to string
8590
- result = body;
8591
- }
8592
- else {
8593
- result = `can't parse body ${typeof body}`;
8594
- }
8595
- return result;
8596
8603
  };
8597
8604
  const genGetDataByUrl = (url, getData = {}) => {
8598
8605
  if (!isPureObject(getData)) {
@@ -9632,7 +9639,7 @@ class API {
9632
9639
  this.signalStartIssue = (reason, missingApi) => {
9633
9640
  const doNotTrack = this.checkDoNotTrack();
9634
9641
  console.log("Tracker couldn't start due to:", JSON.stringify({
9635
- trackerVersion: '16.4.1',
9642
+ trackerVersion: '16.4.2-beta.2',
9636
9643
  projectKey: this.options.projectKey,
9637
9644
  doNotTrack,
9638
9645
  reason: missingApi.length ? `missing api: ${missingApi.join(',')}` : reason,