6

I have a React native application with configured using react native firebase lib and added the module of Crashlytics. Everything works okay but when i try to log an error using recordError() method or when i just use crash() its just logs errors in the dashboard in native form. I tried to find a way of getting js error to the dashboard but so far nothing has worked.


Is this possible or i should try a different way? maybe another platform like bugsnag or sentry?

Prakash Natarajan
  • 138
  • 1
  • 1
  • 11
  • Tried [reading through this](https://stackoverflow.com/questions/50480099/unable-to-find-meaningful-logs-for-reactnative-using-crashlytics)? – Jake Lee Dec 12 '18 at 12:13
  • @JakeSteam Hey thank you for replying, yeah but it mentioned about react-native-fabric-crashlytics not firebase crashlytics. – Shehan Fonseka Dec 12 '18 at 12:45
  • I know that in version 6 of rn-firebase package added functionality of javascript stack traces, but this version is in alpha. Also I have an article about this topic, but didn't checked if this method still works with version 5.x.x of rn-firebase crashlytics: https://medium.com/delivery-com-engineering/add-crashlytics-to-your-react-native-ios-app-69a983a9062a – Artem Shevtsov Jun 13 '19 at 08:47

2 Answers2

1

This is working for me and showing javascript stacktrace:

....
catch (error) {
    crashlytics().recordError(new Error(error));
}
Gurmukh Singh
  • 1,875
  • 3
  • 24
  • 62
1

you can use react-native-exception-handler to get a js stack trace for the crash and also send js stack trace to firebase crashlytics

like this

import {getJSExceptionHandler} from 'react-native-exception-handler';


setJSExceptionHandler((error, isFatal) => {
  if(isFatal)
  {
  crashlytics().recordError(new Error(error));
  }
});

Muhammad Numan
  • 23,222
  • 6
  • 63
  • 80