sentry-react-native icon indicating copy to clipboard operation
sentry-react-native copied to clipboard

Catch react native warnings

Open tilonet opened this issue 6 years ago • 5 comments

OS:

  • [ ] Windows
  • [x ] MacOS
  • [ ] Linux

Platform:

  • [ x] iOS
  • [ x] Android

SDK:

  • [ x] @sentry/react-native
  • [ ] react-native-sentry

react-native version: 0.59.9

Init Code:

Sentry.init({
  dsn: 'SELF_HOSTED_URL.'
});

I have following issue: Catching errors works well, but no warnings sent to sentry

Description: Is ist possible to catch also the react native warnings ? I mean the warnings appearing in the yellow boxes.

tilonet avatar Feb 11 '20 14:02 tilonet

If you update to 1.3.0 you should also get console statements.

HazAT avatar Feb 12 '20 12:02 HazAT

Update to 1.3.0 change nothing, only errors sent to sentry. Is any configuration necessary?

tilonet avatar Feb 12 '20 13:02 tilonet

@tilonet have you found the solution? I'm also facing the same issue

usamaasfar avatar Oct 29 '20 06:10 usamaasfar

As clarification, warnings are not sent as separate events/issues but as breadcrumbs in subsequent events.

jennmueng avatar Oct 30 '20 08:10 jennmueng

You can use this code block.

Sentry.init({
    dsn: 'YOUR_DSN',
    enableInExpoDevelopment: true,
    debug: true, // If `true`, Sentry will try to print out useful debugging information if something goes wrong with sending the event. Set it to `false` in production
    beforeBreadcrumb(event, hint) {
        if (event.level !== 'log' && event.category !== 'xhr' && event.level !== 'info' && !event.message?.startsWith('Error')) {
            SentryRN.captureMessage(event.message ? event.message.replace(/\%s/g, '\n') : 'Warning without message', SentryRN.Severity.Warning);
        }
        return event;
    },
});

ofkarakus avatar Jan 08 '22 15:01 ofkarakus