Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React Native error logging with firebase Crashlytics - How to get javascript stack trace

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?

like image 236
Shehan Fonseka Avatar asked Nov 07 '22 23:11

Shehan Fonseka


2 Answers

This is working for me and showing javascript stacktrace:

....
catch (error) {
    crashlytics().recordError(new Error(error));
}
like image 69
Gurmukh Singh Avatar answered Nov 15 '22 07:11

Gurmukh Singh


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));
  }
});

like image 36
Muhammad Numan Avatar answered Nov 15 '22 07:11

Muhammad Numan