@openreplay/tracker 16.1.2 → 16.1.4

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
@@ -4744,7 +4744,7 @@ class App {
4744
4744
  this.stopCallbacks = [];
4745
4745
  this.commitCallbacks = [];
4746
4746
  this.activityState = ActivityState.NotActive;
4747
- this.version = '16.1.2'; // TODO: version compatability check inside each plugin.
4747
+ this.version = '16.1.4'; // TODO: version compatability check inside each plugin.
4748
4748
  this.socketMode = false;
4749
4749
  this.compressionThreshold = 24 * 1000;
4750
4750
  this.bc = null;
@@ -8067,7 +8067,10 @@ function obscure(value) {
8067
8067
  const digits = numDigits(value);
8068
8068
  return "9".repeat(digits);
8069
8069
  }
8070
- return value.replace(/[^\f\n\r\t\v\u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff\s]/g, '*');
8070
+ if (typeof value === "string") {
8071
+ return value.replace(/[^\f\n\r\t\v\u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff\s]/g, '*');
8072
+ }
8073
+ return value;
8071
8074
  }
8072
8075
  function filterHeaders(headers) {
8073
8076
  const filteredHeaders = {};
@@ -8111,14 +8114,27 @@ function filterBody(body) {
8111
8114
  return JSON.stringify(parsedBody);
8112
8115
  }
8113
8116
  else {
8114
- const params = new URLSearchParams(body);
8115
- for (const key of params.keys()) {
8116
- if (sensitiveParams.has(key.toLowerCase())) {
8117
- const value = obscure(params.get(key));
8118
- params.set(key, value);
8117
+ const isUrlSearch = typeof body === "string" && body.includes("?") && body.includes("=");
8118
+ if (isUrlSearch) {
8119
+ try {
8120
+ const params = new URLSearchParams(body);
8121
+ for (const key of params.keys()) {
8122
+ if (sensitiveParams.has(key.toLowerCase())) {
8123
+ const value = obscure(params.get(key));
8124
+ params.set(key, value);
8125
+ }
8126
+ }
8127
+ return params.toString();
8128
+ }
8129
+ catch (e) {
8130
+ // not url query ?
8131
+ return body;
8119
8132
  }
8120
8133
  }
8121
- return params.toString();
8134
+ else {
8135
+ // not json or url query
8136
+ return body;
8137
+ }
8122
8138
  }
8123
8139
  }
8124
8140
  function sanitizeObject(obj) {
@@ -8519,9 +8535,10 @@ class ResponseProxyHandler {
8519
8535
  if (typeof this.resp.body.getReader !== 'function') {
8520
8536
  return;
8521
8537
  }
8522
- const _getReader = this.resp.body.getReader;
8538
+ const clonedResp = this.resp.clone();
8539
+ const _getReader = clonedResp.body.getReader;
8523
8540
  // @ts-ignore
8524
- this.resp.body.getReader = () => {
8541
+ clonedResp.body.getReader = () => {
8525
8542
  const reader = _getReader.apply(this.resp.body);
8526
8543
  // when readyState is already 4,
8527
8544
  // it's not a chunked stream, or it had already been read.
@@ -9363,7 +9380,7 @@ class API {
9363
9380
  this.signalStartIssue = (reason, missingApi) => {
9364
9381
  const doNotTrack = this.checkDoNotTrack();
9365
9382
  console.log("Tracker couldn't start due to:", JSON.stringify({
9366
- trackerVersion: '16.1.2',
9383
+ trackerVersion: '16.1.4',
9367
9384
  projectKey: this.options.projectKey,
9368
9385
  doNotTrack,
9369
9386
  reason: missingApi.length ? `missing api: ${missingApi.join(',')}` : reason,