HTTP API to create an issue within a project via a React Native application


#1

Hi,

I’m using a native module react-native-exception-handler to handle all JS as well as native exceptions in my react-native application. The primary reason behind this is that my app is an offline first app and I’m logging errors locally on the device. I am interested in logging my app’s errors and crashes on to sentry without wanting sentry to take over the entire exception handling, is that possible and if yes, how can I achieve it? Doesn’t Sentry have an HTTP API where I can POST to and create the issues?


#2

Here are the API docs, everything should be there https://docs.sentry.io/api/

But I don’t really understand why you don’t use our react-native SDK https://github.com/getsentry/react-native-sentry

It supports JS/Native errors and stores them locally if there is no internet connection.


#3

@HazAT I need some custom error message dialog box pop up to display to the user that an error as occurred, Sentry SDK does not provide me with such a functionality and hence I’m handling my app’s errors manually. I have seen the API docs before but in the endpoints section for events there’s no documentation about how to create an event. Please elaborate on how to do that. It’d be a huge assistance.


#4

There are callbacks in the SDK where you could hook into to show a dialog.
But if you want to take on the task of building an event by yourself, this is an example event that should get you started:


#5

@HazAT after seeing that example, I really don’t like the idea of creating an event manually. What about the callbacks in the SDK, an example would help, and why aren’t they mentioned within the react-native-sentry docs?


#6

Well, creating a event is basically creating a JSON object like this and send it to the endpoint.

About the callbacks you can find them here:
https://docs.sentry.io/clients/react-native/config/

Sentry.setShouldSendCallback((event) => {
  return true; // if return false, event will not be sent
});

You have the event and show an alert before sending it (or not).