@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/lib/entry.js CHANGED
@@ -4740,7 +4740,7 @@ class App {
4740
4740
  this.stopCallbacks = [];
4741
4741
  this.commitCallbacks = [];
4742
4742
  this.activityState = ActivityState.NotActive;
4743
- this.version = '16.1.2'; // TODO: version compatability check inside each plugin.
4743
+ this.version = '16.1.4'; // TODO: version compatability check inside each plugin.
4744
4744
  this.socketMode = false;
4745
4745
  this.compressionThreshold = 24 * 1000;
4746
4746
  this.bc = null;
@@ -8063,7 +8063,10 @@ function obscure(value) {
8063
8063
  const digits = numDigits(value);
8064
8064
  return "9".repeat(digits);
8065
8065
  }
8066
- return value.replace(/[^\f\n\r\t\v\u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff\s]/g, '*');
8066
+ if (typeof value === "string") {
8067
+ return value.replace(/[^\f\n\r\t\v\u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff\s]/g, '*');
8068
+ }
8069
+ return value;
8067
8070
  }
8068
8071
  function filterHeaders(headers) {
8069
8072
  const filteredHeaders = {};
@@ -8107,14 +8110,27 @@ function filterBody(body) {
8107
8110
  return JSON.stringify(parsedBody);
8108
8111
  }
8109
8112
  else {
8110
- const params = new URLSearchParams(body);
8111
- for (const key of params.keys()) {
8112
- if (sensitiveParams.has(key.toLowerCase())) {
8113
- const value = obscure(params.get(key));
8114
- params.set(key, value);
8113
+ const isUrlSearch = typeof body === "string" && body.includes("?") && body.includes("=");
8114
+ if (isUrlSearch) {
8115
+ try {
8116
+ const params = new URLSearchParams(body);
8117
+ for (const key of params.keys()) {
8118
+ if (sensitiveParams.has(key.toLowerCase())) {
8119
+ const value = obscure(params.get(key));
8120
+ params.set(key, value);
8121
+ }
8122
+ }
8123
+ return params.toString();
8124
+ }
8125
+ catch (e) {
8126
+ // not url query ?
8127
+ return body;
8115
8128
  }
8116
8129
  }
8117
- return params.toString();
8130
+ else {
8131
+ // not json or url query
8132
+ return body;
8133
+ }
8118
8134
  }
8119
8135
  }
8120
8136
  function sanitizeObject(obj) {
@@ -8515,9 +8531,10 @@ class ResponseProxyHandler {
8515
8531
  if (typeof this.resp.body.getReader !== 'function') {
8516
8532
  return;
8517
8533
  }
8518
- const _getReader = this.resp.body.getReader;
8534
+ const clonedResp = this.resp.clone();
8535
+ const _getReader = clonedResp.body.getReader;
8519
8536
  // @ts-ignore
8520
- this.resp.body.getReader = () => {
8537
+ clonedResp.body.getReader = () => {
8521
8538
  const reader = _getReader.apply(this.resp.body);
8522
8539
  // when readyState is already 4,
8523
8540
  // it's not a chunked stream, or it had already been read.
@@ -9359,7 +9376,7 @@ class API {
9359
9376
  this.signalStartIssue = (reason, missingApi) => {
9360
9377
  const doNotTrack = this.checkDoNotTrack();
9361
9378
  console.log("Tracker couldn't start due to:", JSON.stringify({
9362
- trackerVersion: '16.1.2',
9379
+ trackerVersion: '16.1.4',
9363
9380
  projectKey: this.options.projectKey,
9364
9381
  doNotTrack,
9365
9382
  reason: missingApi.length ? `missing api: ${missingApi.join(',')}` : reason,