@kush_hemant/react-api-monitor 1.0.30 → 1.0.31

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 +4 -9
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -32,10 +32,7 @@ function getMetadata() {
32
32
  }
33
33
 
34
34
  // src/network/fetchMonitor.js
35
- var alreadyPatched = false;
36
35
  function monitorFetch() {
37
- if (alreadyPatched) return;
38
- alreadyPatched = true;
39
36
  const originalFetch = globalThis.fetch || window.fetch;
40
37
  const patchedFetch = async (input, init = {}) => {
41
38
  const request = input instanceof Request ? input : new Request(input, init);
@@ -55,9 +52,7 @@ function monitorFetch() {
55
52
  requestHeaders[k] = v;
56
53
  });
57
54
  try {
58
- const response = await originalFetch(
59
- request
60
- );
55
+ const response = await originalFetch(request);
61
56
  let responseBody = null;
62
57
  try {
63
58
  responseBody = await response.clone().text();
@@ -87,6 +82,8 @@ function monitorFetch() {
87
82
  transport: "fetch",
88
83
  url,
89
84
  method,
85
+ requestHeaders,
86
+ requestBody,
90
87
  error: err.message,
91
88
  duration: Date.now() - start,
92
89
  ...getMetadata()
@@ -95,9 +92,7 @@ function monitorFetch() {
95
92
  }
96
93
  };
97
94
  globalThis.fetch = patchedFetch;
98
- if (typeof window !== "undefined") {
99
- window.fetch = patchedFetch;
100
- }
95
+ if (typeof window !== "undefined") window.fetch = patchedFetch;
101
96
  }
102
97
 
103
98
  // src/network/xhrMonitor.js
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kush_hemant/react-api-monitor",
3
- "version": "1.0.30",
3
+ "version": "1.0.31",
4
4
  "description": "Automatic API monitoring SDK for React apps",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",