Skip to content
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

How to capture console warnings and errors in react native #3865

Closed
ishaangandhi opened this issue Jun 5, 2024 · 4 comments
Closed

How to capture console warnings and errors in react native #3865

ishaangandhi opened this issue Jun 5, 2024 · 4 comments

Comments

@ishaangandhi
Copy link

Environment

SaaS (https://sentry.io/)

What are you trying to accomplish?

I want console warnings and errors to be captured in my Expo application and be reported to Sentry so I can get alerts. The reason is that sometimes there are async functions which have errors logged with console.error, but don't throw. I want to get reports of these issues.

How are you getting stuck?

I see capture console exists in the JS SDK, but I don't see an equivalent in the React-Native SDK.

Where in the product are you?

Alerts

Link

No response

DSN

No response

Version

No response

@getsantry
Copy link

getsantry bot commented Jun 5, 2024

Assigning to @getsentry/support for routing ⏲️

@ishaangandhi
Copy link
Author

Ah, this works, but is not mentioned in the React-Native SDK documentation, as far as I could tell.

import { captureConsoleIntegration } from "@sentry/integrations";

Sentry.init({
  dsn: "https://...",
  integrations: [
    captureConsoleIntegration({ levels: ["warn", "error"] }),
  ],
});

Is this ok to use? Or will it cause problems?

@InterstellarStella InterstellarStella transferred this issue from getsentry/sentry Jun 6, 2024
@krystofwoldrich
Copy link
Member

Hi @ishaangandhi,
thank you for the message,

you are correct the captureConsoleIntegration will work for RN projects.

We will add it to the RN Docs.

@krystofwoldrich
Copy link
Member

The docs page will be added as part of #3876.

@krystofwoldrich krystofwoldrich closed this as not planned Won't fix, can't repro, duplicate, stale Jun 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Archived in project
Development

No branches or pull requests

2 participants