Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there any way to see country data for a Crash in Crashlytics?

Tags:

crashlytics

Previously we used to rely on Firebase Console for crash reports. It was working pretty good but then Google also announced the official support for Crash reporting through Crashlytics and we went ahead with Crashlytics integration. The only problem being, we can't see the country code for a Crash anymore.

So, is there any way, we can have the country information for a Crash in Crashlytics?

like image 492
Manish Kumar Sharma Avatar asked Mar 08 '23 04:03

Manish Kumar Sharma


2 Answers

Mike from Fabric here. By default, we don't capture country information for crashes. However, you can set this via a custom key.

On Android, use:

 Crashlytics.setString("Country_Code", "Canada");

On iOS, use:

# Objective-C
[CrashlyticsKit setObjectValue:@"Canada" forKey:(@"Country_Code")];

# Swift
Crashlytics.sharedInstance().setObjectValue("Canada", forKey: "Country_Code")
like image 116
Mike Bonnell Avatar answered May 08 '23 15:05

Mike Bonnell


To add on to what Mike have posted, you can get the Locale of the machine as a "guess" of the country.

It is not exactly accurate, but should suffice as an approximation of the app's distribution. (if you do not want to use the Location permission)

some thing like the following:

public class MainActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Fabric.with(this, new Crashlytics());

        logCountry();

        setContentView(R.layout.activity_main);
    }
    private void logCountry() { 
        Crashlytics.setString("Locale", Locale.getDefault().toString()); 
    }
}

you will get to see the locale/country under the "KEYS" tab in the firebase console.

enter image description here

Would have been a lot cleaner if that information is in the "DATA" tab, but guess we have to make do with what's provided.

enter image description here

like image 20
Angel Koh Avatar answered May 08 '23 15:05

Angel Koh