@kush_hemant/react-api-monitor 1.0.23 → 1.0.25
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 +0 -52
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -117,62 +117,10 @@ function monitorXHR() {
|
|
|
117
117
|
};
|
|
118
118
|
}
|
|
119
119
|
|
|
120
|
-
// src/network/resourceMonitor.js
|
|
121
|
-
function monitorResources() {
|
|
122
|
-
if (!window.PerformanceObserver) return;
|
|
123
|
-
const observer = new PerformanceObserver((list) => {
|
|
124
|
-
list.getEntries().forEach((entry) => {
|
|
125
|
-
if (entry.initiatorType === "fetch" || entry.initiatorType === "xmlhttprequest" || entry.initiatorType === "beacon") {
|
|
126
|
-
return;
|
|
127
|
-
}
|
|
128
|
-
if (LOG_ENDPOINT2 && entry.name.includes(LOG_ENDPOINT2)) {
|
|
129
|
-
return;
|
|
130
|
-
}
|
|
131
|
-
sendLog2({
|
|
132
|
-
type: "resource",
|
|
133
|
-
transport: "resource",
|
|
134
|
-
url: entry.name,
|
|
135
|
-
method: "GET",
|
|
136
|
-
duration: Math.round(entry.duration),
|
|
137
|
-
statusCode: 0,
|
|
138
|
-
...getMetadata2()
|
|
139
|
-
});
|
|
140
|
-
});
|
|
141
|
-
});
|
|
142
|
-
observer.observe({ entryTypes: ["resource"] });
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
// src/network/monitorAxios.js
|
|
146
|
-
function monitorAxios() {
|
|
147
|
-
if (!window.axios) return;
|
|
148
|
-
window.axios.interceptors.request.use((config) => {
|
|
149
|
-
config.__startTime = Date.now();
|
|
150
|
-
return config;
|
|
151
|
-
});
|
|
152
|
-
window.axios.interceptors.response.use(
|
|
153
|
-
(response) => {
|
|
154
|
-
var _a;
|
|
155
|
-
sendLog2({
|
|
156
|
-
type: "api_call",
|
|
157
|
-
transport: "axios",
|
|
158
|
-
url: response.config.url,
|
|
159
|
-
method: (_a = response.config.method) == null ? void 0 : _a.toUpperCase(),
|
|
160
|
-
statusCode: response.status,
|
|
161
|
-
duration: Date.now() - response.config.__startTime,
|
|
162
|
-
...getMetadata2()
|
|
163
|
-
});
|
|
164
|
-
return response;
|
|
165
|
-
},
|
|
166
|
-
(error) => Promise.reject(error)
|
|
167
|
-
);
|
|
168
|
-
}
|
|
169
|
-
|
|
170
120
|
// src/network/auto.js
|
|
171
121
|
function startNetworkMonitoring() {
|
|
172
122
|
monitorFetch();
|
|
173
123
|
monitorXHR();
|
|
174
|
-
monitorAxios();
|
|
175
|
-
monitorResources();
|
|
176
124
|
}
|
|
177
125
|
|
|
178
126
|
// src/index.js
|