Skip to content

Commit b86dfcb

Browse files
fix: drop non-error objects when reporting errors (#1279)
* Fix: omitted non-error objects when logging errors * ci: publish snapshots to npm (#1274) * Fix: omitted non-error objects when logging errors * fix: use warn instead of logs Co-authored-by: Ahmed Elrefaey <[email protected]> * Update CHANGELOG.md Co-authored-by: Ahmed Elrefaey <[email protected]> * fix: merge issues --------- Co-authored-by: Ahmed Elrefaey <[email protected]>
1 parent c318909 commit b86dfcb

File tree

2 files changed

+19
-11
lines changed

2 files changed

+19
-11
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
### Fixed
1010

11+
- Drop non-error objects reported as crashes since they don't have a stack trace ([#1279](https://github.com/Instabug/Instabug-React-Native/pull/1279)).
1112
- Fix APM network logging on iOS when the response body is missing or empty. ([#1273](https://github.com/Instabug/Instabug-React-Native/pull/1273)).
1213

1314
## [13.3.0](https://github.com/Instabug/Instabug-React-Native/compare/v13.2.0...v13.3.0) (August 4, 2024)

src/modules/CrashReporting.ts

+18-11
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,25 @@ export const setEnabled = (isEnabled: boolean) => {
2121
* @param nonFatalOptions extra config for the non-fatal error sent with Error Object
2222
*/
2323
export const reportError = (error: ExtendedError, nonFatalOptions: NonFatalOptions = {}) => {
24-
let level = NonFatalErrorLevel.error;
25-
if (nonFatalOptions.level != null) {
26-
level = nonFatalOptions.level;
24+
if (error instanceof Error) {
25+
let level = NonFatalErrorLevel.error;
26+
if (nonFatalOptions.level != null) {
27+
level = nonFatalOptions.level;
28+
}
29+
return InstabugUtils.sendCrashReport(error, (data) =>
30+
NativeCrashReporting.sendHandledJSCrash(
31+
data,
32+
nonFatalOptions.userAttributes,
33+
nonFatalOptions.fingerprint,
34+
level,
35+
),
36+
);
37+
} else {
38+
console.warn(
39+
`IBG-RN: The error ${error} has been omitted because only error type is supported.`,
40+
);
41+
return;
2742
}
28-
return InstabugUtils.sendCrashReport(error, (data) =>
29-
NativeCrashReporting.sendHandledJSCrash(
30-
data,
31-
nonFatalOptions.userAttributes,
32-
nonFatalOptions.fingerprint,
33-
level,
34-
),
35-
);
3643
};
3744

3845
/**

0 commit comments

Comments
 (0)