@kush_hemant/react-api-monitor 1.0.34 → 1.0.37

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.
Files changed (2) hide show
  1. package/dist/index.js +5 -4
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1,8 +1,8 @@
1
1
  // src/core/sender.js
2
2
  var LOG_ENDPOINT = "";
3
3
  var API_KEY = "";
4
- function configureSender({ endpoint, apiKey }) {
5
- LOG_ENDPOINT = endpoint;
4
+ function configureSender(url, apiKey) {
5
+ LOG_ENDPOINT = url;
6
6
  API_KEY = apiKey;
7
7
  }
8
8
  function sendLog(data) {
@@ -12,6 +12,7 @@ function sendLog(data) {
12
12
  method: "POST",
13
13
  headers: {
14
14
  "Content-Type": "application/json",
15
+ /* 🔥 REQUIRED FOR SAAS */
15
16
  "x-api-key": API_KEY
16
17
  },
17
18
  body: payload,
@@ -40,7 +41,7 @@ function monitorFetch() {
40
41
  const request = args[0] instanceof Request ? args[0] : new Request(args[0], args[1]);
41
42
  const url = request.url;
42
43
  const method = request.method || "GET";
43
- if (LOG_ENDPOINT && url.startsWith(LOG_ENDPOINT)) {
44
+ if (LOG_ENDPOINT && url.includes("/v1/logs")) {
44
45
  return originalFetch.apply(this, args);
45
46
  }
46
47
  let requestBody = null;
@@ -93,7 +94,7 @@ function monitorXHR() {
93
94
  };
94
95
  XMLHttpRequest.prototype.send = function(body) {
95
96
  const start = Date.now();
96
- if (this._url && LOG_ENDPOINT && this._url.includes(LOG_ENDPOINT)) {
97
+ if (this._url && LOG_ENDPOINT && this._url.includes("/v1/logs")) {
97
98
  return originalSend.call(this, body);
98
99
  }
99
100
  this.addEventListener("loadend", () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kush_hemant/react-api-monitor",
3
- "version": "1.0.34",
3
+ "version": "1.0.37",
4
4
  "description": "Automatic API monitoring SDK for React apps",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",