What is the recommended way to avoid sending debug errors while developing to Sentry in JS and the native side?
JS error in Dev mode
Native crash error in Dev mode
What was tried for Sentry @sentry/react-native version 6.1.0, but it did not work:
Option 1:
Sentry.init({
enabled: !__DEV__
dsn: "SOME_VALID_URL"
})
Result: This just works for js errors, but keep sending native errors to Sentry
Option 2:
if(!__DEV__) {
Sentry.init({
dsn: "SOME_VALID_URL"
})
}
Result: This will generate a warning when using Sentry.wrap
in the root component
App Start Span could not be finished.
Sentry.wrap
was called beforeSentry.init
.
if(!__DEV__) {
Sentry.init({
dsn: "SOME_VALID_URL"
})
}
function RootLayout() {
...
}
export default Sentry.wrap(RootLayout);
2
Answers
According to the Sentry options docs, it suggests setting dns to
undefined
.Be careful with
enabled: !__DEV__
. It currently keeps sending native errors generated in dev modeSource:
How to disable sentry in development ?
How to disable sentry while debugging?
Enabled option in Sentry init does not avoid sending native events to Sentry in Dev mode
If you just wanna minimise it you can below solution: