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

Can't record an error with Crashlytics.recordError() #152

Open
igorarkhipenko opened this issue Nov 8, 2017 · 8 comments
Open

Can't record an error with Crashlytics.recordError() #152

igorarkhipenko opened this issue Nov 8, 2017 · 8 comments

Comments

@igorarkhipenko
Copy link

igorarkhipenko commented Nov 8, 2017

So that pretty much it is. Crashlytics.crash() does well and everything gets recorded as expected, but not in case with recordError(error) method.
My code snipped is below and it's needless to say that componentDidCatch() method is called as well.

componentDidCatch(error, info) {
    Crashlytics.recordError(error);
  }

What could be the reason of such behavior? Any help is appreciated.

@willderness
Copy link

recordError only works on iOS and the reverse is true of logException on Android. Are you on Android? I've added code in my exception handles to check Platform.OS before calling a method but its less than ideal.

@igorarkhipenko
Copy link
Author

@willderness no, I use iOS device and emulator for testing and still can't make it work. How is that even possible? The very first and basic function doesn't work for some reason.
Thanks for your reply.

@shyaniv7
Copy link

shyaniv7 commented Jan 8, 2018

@igorarkhipenko after having the same issue myself i realized recordError only works on an actual device and does not work via the emulator. Hope this helps

@shyaniv7
Copy link

shyaniv7 commented Jan 8, 2018

I created a helper for logging errors feel free to use it

import { Crashlytics } from "react-native-fabric";
import { Platform } from "react-native";

export default logError = ( err ) => {
  if ( Platform.OS === "ios" ) {
    Crashlytics.recordError( err );
  } else {
    Crashlytics.logException( err );
  }
  console.log( err );
};

console.log should help you in the emulator

@alvinmatias69
Copy link

@shyaniv7 could you please elaborate on what environments you manage to makes it work?

@shyaniv7
Copy link

shyaniv7 commented Jul 1, 2018

As stated in the code this will log an error to crashlytics on both android and iOS using a single logError function.

@alvinmatias69
Copy link

@shyaniv7 I mean configuration like are you on debug mode, simulator, or device. Something like that

@shyaniv7
Copy link

shyaniv7 commented Jul 1, 2018

We actually have environment variables where we are able to know what environment we are running, what device, api version, app version and more information and whenever we use the logError we concatenate those information onto the error message before logging it.

We wrote a fetch wrapper that makes our api requests and handles any caught errors using logError

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants