expo / sentry-expo

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

beforeSend won't be trigger if the error is handled, but still the error will be reported to Sentry

matiasfacio opened this issue · comments

Summary

Basically, I want to run beforeSend to stop reporting handled errors to Sentry.

This is my sentry config file:

`export const sentryConfig: Sentry.SentryExpoNativeOptions = {
dsn: 'https://4,
tracesSampleRate: 1.0,
environment,
ignoreErrors: [
'No current user',
'No current user available',
'NotAuthorizedException',
'User does not exist.',
'NO_SPOTS_EDIT',
],
enableInExpoDevelopment: true, // set to true when working tracking error on development
release: Constants?.expoConfig?.version,
enabled: true,
debug: true,
beforeSend(event, hint) {
console.log({ event, hint });
if (event.exception?.values[0].mechanism.handled === 'true') {
console.log('Handled:true, will not send');
return null;
}
if (
event.message?.match(/No current user/i) ||
event.message?.match(/No current user available/i)
) {
return null;
}
if (
event.exception?.values?.[0].value?.match(/No current user/i) ||
event.exception?.values?.[0].value?.match(/No current user available/i)
) {
return null;
}
const error = hint.originalException || hint.syntheticException;
if (
error &&
error instanceof Error &&
error.message &&
(error.message.match(/No current user/i) ||
error.message.match(/No current user available/i))
) {
return null;
}
const scrubbedEvent = (event.breadcrumbs ?? []).map((c) => {
if (c.category !== 'console') {
return c;
}
return {};
});

event.breadcrumbs = scrubbedEvent;
return event;

},
};`

Here you can see that I tried to ignore errors and what not.
I tried to console.log inside beforeSend to see if it calls the function, but nothing happens. It only logs if I throw an error and don't caught it in a try/catch.

Expected behaviour:

handled errors won't be reported

Current behaviour:

handled errors get reported to Sentry servers.

Managed or bare workflow? If you have ios/ or android/ directories in your project, the answer is bare!

managed

What platform(s) does this occur on?

Web

SDK Version (managed workflow only)

No response

Environment

expo-env-info 1.0.5 environment info:
System:
OS: macOS 13.4
Shell: 5.9 - /bin/zsh
Binaries:
Node: 19.2.0 - ~/.nvm/versions/node/v19.2.0/bin/node
Yarn: 1.22.19 - ~/.nvm/versions/node/v19.2.0/bin/yarn
npm: 8.19.3 - ~/.nvm/versions/node/v19.2.0/bin/npm
SDKs:
iOS SDK:
Platforms: DriverKit 22.4, iOS 16.4, macOS 13.3, tvOS 16.4, watchOS 9.4
IDEs:
Xcode: 14.3.1/14E300c - /usr/bin/xcodebuild
npmPackages:
@expo/webpack-config: ^18.0.1 => 18.0.4
expo: ^48.0.0 => 48.0.17
react: 18.2.0 => 18.2.0
react-dom: 18.2.0 => 18.2.0
react-native: 0.71.8 => 0.71.8
react-native-web: ~0.18.7 => 0.18.12
npmGlobalPackages:
eas-cli: 3.13.3
Expo Workflow: managed

Reproducible demo or steps to reproduce from a blank project

Steps to reproduce:

On your expo app

  • configure you sentry with a beforeSend method,
  • inside beforeSend console.log event and hint
  • throw an error in your app and handle it inside a try/catch
  • check the console

Expected:

event and hint objects are being logged.

Outcome:

nothing gets logged.

This issue is stale because it has been open for 60 days with no activity. If there is no activity in the next 7 days, the issue will be closed.

This issue was closed because it has been inactive for 7 days since being marked as stale. Please open a new issue if you believe you are encountering a related problem.