@kush_hemant/react-api-monitor 1.0.42 → 1.0.44

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 +20 -0
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -169,6 +169,7 @@ function monitorErrors() {
169
169
  message: event.message,
170
170
  stack: (_a = event.error) == null ? void 0 : _a.stack,
171
171
  pageUrl: location.href,
172
+ source: "window.onerror",
172
173
  ...getMetadata()
173
174
  });
174
175
  });
@@ -181,10 +182,29 @@ function monitorErrors() {
181
182
  message: ((_a = event.reason) == null ? void 0 : _a.message) || "Unhandled Promise Rejection",
182
183
  stack: (_b = event.reason) == null ? void 0 : _b.stack,
183
184
  pageUrl: location.href,
185
+ source: "unhandledrejection",
184
186
  ...getMetadata()
185
187
  });
186
188
  }
187
189
  );
190
+ const originalError = console.error;
191
+ console.error = function(...args) {
192
+ try {
193
+ const message = args.map(
194
+ (a) => typeof a === "string" ? a : JSON.stringify(a)
195
+ ).join(" ");
196
+ sendLog({
197
+ type: "error",
198
+ message,
199
+ stack: new Error().stack,
200
+ pageUrl: location.href,
201
+ source: "console.error",
202
+ ...getMetadata()
203
+ });
204
+ } catch {
205
+ }
206
+ originalError.apply(console, args);
207
+ };
188
208
  }
189
209
 
190
210
  // src/network/auto.js
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kush_hemant/react-api-monitor",
3
- "version": "1.0.42",
3
+ "version": "1.0.44",
4
4
  "description": "Automatic API monitoring SDK for React apps",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",