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