@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.
- package/dist/index.js +5 -4
- 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(
|
|
5
|
-
LOG_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.
|
|
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(
|
|
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", () => {
|