Search code examples
androidfirebasecrashlyticscrashlytics-android

Global settings for custom firebase crashlytics


I want to send custom crash log (like userid, name, etc) on every crash so we can trace back which user experience crash.

My question is that how can I set custom crash report at a single place and automatically send on every crash?


Solution

  • Add custom keys in firebase crashlytics

    Custom keys help you get the specific state of your app leading up to a crash. You can associate arbitrary key/value pairs with your crash reports, and see them in the Firebase console.

    There are five methods to set keys. Each handles a different data type:

    Crashlytics.setString(key, value);
    
    Crashlytics.setBool(String key, boolean value);
    
    Crashlytics.setDouble(String key, double value);
    
    Crashlytics.setFloat(String key, float value);
    
    Crashlytics.setInt(String key, int value);
    

    In your case you can add for Eg. Like below

    // for userid
    Crashlytics.setString("userid", userIdValue);
    
    // for name
    Crashlytics.setString("name", nameValue);
    

    For more refrence see this Add Custom Logs

    Imp Note:- Crashlytics supports a maximum of 64 key/value pairs. Once you reach this threshold, additional values are not saved. Each key/value pair can be up to 1 kB in size.