OS:
_Platform:_
SDK:
@sentry/react-nativereact-native-sentryreact-native version: 0.60.5
Init Code:
Sentry.init({
dsn: 'https://[email protected]/...'
});
In the old api with react-native-sentry we would use the following to ignore errors:
const ignoreErrors = [
/^ValidationError:/,
/Network Error/,
/status code 401/
]
Sentry.setShouldSendCallback((event) => {
let allow = true
const errors = get(event, "exception.values")
if (Array.isArray(errors)) {
errors.forEach((err) => {
ignoreErrors.forEach((regex) => {
if (err.value.match(regex)) {
allow = false
}
})
})
}
const sentryIgnoreError = get(event, "extra.error.config.sentryIgnoreError")
if (Array.isArray(sentryIgnoreError)) {
const code = get(event, "extra.error.response.code")
if (sentryIgnoreError.indexOf(code) > -1) {
allow = false
}
}
return allow
})
How we do this with @sentry/react-native?
I found a section in the JavaScript advanced usage section about filtering events with beforeSend. Should I be using this instead setShouldSendCallback?
It would help if there was a detailed migration guide from react-native-sentry to @sentry/react-native
Yes, beforeSend should be used.
And yes sorry you are right, we could have done a better job writing a more in-depth migration guide.
I am still closing this issue because I think you fixed the issue yourself.
Most helpful comment
Yes,
beforeSendshould be used.And yes sorry you are right, we could have done a better job writing a more in-depth migration guide.
I am still closing this issue because I think you fixed the issue yourself.