Skip to content

fix: drop non-error objects when reporting errors #1279

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

### Fixed

- 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)).
- Fix APM network logging on iOS when the response body is missing or empty. ([#1273](https://github.com/Instabug/Instabug-React-Native/pull/1273)).

## [13.3.0](https://github.com/Instabug/Instabug-React-Native/compare/v13.2.0...v13.3.0) (August 4, 2024)
Expand Down
29 changes: 18 additions & 11 deletions src/modules/CrashReporting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,25 @@ export const setEnabled = (isEnabled: boolean) => {
* @param nonFatalOptions extra config for the non-fatal error sent with Error Object
*/
export const reportError = (error: ExtendedError, nonFatalOptions: NonFatalOptions = {}) => {
let level = NonFatalErrorLevel.error;
if (nonFatalOptions.level != null) {
level = nonFatalOptions.level;
if (error instanceof Error) {
let level = NonFatalErrorLevel.error;
if (nonFatalOptions.level != null) {
level = nonFatalOptions.level;
}
return InstabugUtils.sendCrashReport(error, (data) =>
NativeCrashReporting.sendHandledJSCrash(
data,
nonFatalOptions.userAttributes,
nonFatalOptions.fingerprint,
level,
),
);
} else {
console.warn(
`IBG-RN: The error ${error} has been omitted because only error type is supported.`,
);
return;
}
return InstabugUtils.sendCrashReport(error, (data) =>
NativeCrashReporting.sendHandledJSCrash(
data,
nonFatalOptions.userAttributes,
nonFatalOptions.fingerprint,
level,
),
);
};

/**
Expand Down