@kush_hemant/react-api-monitor 1.0.33 → 1.0.35
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 +15 -10
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,19 +1,21 @@
|
|
|
1
1
|
// src/core/sender.js
|
|
2
2
|
var LOG_ENDPOINT = "";
|
|
3
|
-
|
|
3
|
+
var API_KEY = "";
|
|
4
|
+
function configureSender(url, apiKey) {
|
|
4
5
|
LOG_ENDPOINT = url;
|
|
6
|
+
API_KEY = apiKey;
|
|
5
7
|
}
|
|
6
8
|
function sendLog(data) {
|
|
7
|
-
var _a;
|
|
8
9
|
if (!LOG_ENDPOINT) return;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
LOG_ENDPOINT,
|
|
12
|
-
JSON.stringify(data)
|
|
13
|
-
)) || fetch(LOG_ENDPOINT, {
|
|
10
|
+
const payload = JSON.stringify(data);
|
|
11
|
+
fetch(LOG_ENDPOINT, {
|
|
14
12
|
method: "POST",
|
|
15
|
-
headers: {
|
|
16
|
-
|
|
13
|
+
headers: {
|
|
14
|
+
"Content-Type": "application/json",
|
|
15
|
+
/* 🔥 REQUIRED FOR SAAS */
|
|
16
|
+
"x-api-key": API_KEY
|
|
17
|
+
},
|
|
18
|
+
body: payload,
|
|
17
19
|
keepalive: true
|
|
18
20
|
}).catch(() => {
|
|
19
21
|
});
|
|
@@ -168,7 +170,10 @@ function startNetworkMonitoring() {
|
|
|
168
170
|
|
|
169
171
|
// src/index.js
|
|
170
172
|
function initMonitoring(options) {
|
|
171
|
-
configureSender(
|
|
173
|
+
configureSender({
|
|
174
|
+
endpoint: options.endpoint,
|
|
175
|
+
apiKey: options.apiKey
|
|
176
|
+
});
|
|
172
177
|
startNetworkMonitoring();
|
|
173
178
|
}
|
|
174
179
|
export {
|