Crashlytics Customize Crash Reports - tuarua/Firebase-ANE GitHub Wiki

The contents of this page are based on the original Firebase Documentation

Firebase Crashlytics can work with very little setup on your part—as soon as you add the SDK, Crashlytics gets to work sending crash reports to the Firebase console.

For more fine-grained control of your crash reports, customize your Crashlytics SDK configuration. For example add logs to track down pesky bugs, and more.

Add custom logs (Android only)

To give yourself more context for the events leading up to a crash, you can add custom Crashlytics logs to your app. Crashlytics associates the logs with your crash data and makes them visible in the Firebase console.

On Android, use Crashlytics.log to help pinpoint issues.

Crashlytics.log can write logs to a crash report:

crashlytics.log("I am a test message");

To avoid slowing down your app, Crashlytics limits logs to 64kB. Crashlytics deletes older log entries if a session's logs go over that limit.

Add custom keys

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 four methods to set keys. Each handles a different data type:

crashlytics.setString(key, "foo" /* string value */);

crashlytics.setBool(key, true /* boolean value */);

crashlytics.setDouble(key, 1.0 /* double value */);

crashlytics.setInt(key, 1 /* int value */);

Re-setting a key updates its value, for example:

crashlytics.setInt("current_level", 3);
crashlytics.setString("last_UI_action", "logged_in");

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.

Set user IDs

To diagnose an issue, it’s often helpful to know which of your users experienced a given crash. Crashlytics includes a way to anonymously identify users in your crash reports.

To add user IDs to your reports, assign each user a unique identifier in the form of an ID number, token, or hashed value:

crashlytics.userIdentifier = "123456789";

If you ever need to clear a user identifier after you set it, reset the value to a blank string. Clearing a user identifier does not remove existing Crashlytics records. If you need to delete records associated with a user ID, contact Firebase support.

Log non-fatal exceptions

In addition to automatically reporting your app’s crashes, Crashlytics lets you log non-fatal exceptions.

That means you can log caught Actionscript exceptions in your app’s catch blocks:

try {
    methodThatThrows();
} catch (e: Error) {
    crashlytics.logException(e);
    // handle your exception here
}

All logged exceptions appear as non-fatal issues in the Firebase console. The issue summary contains all the state information you normally get from crashes, along with breakdowns by Android version and hardware device.

Crashlytics processes exceptions on a dedicated background thread, so the performance impact to your app is minimal. To reduce your users’ network traffic, Crashlytics batches logged exceptions together and sends them the next time the app launches.

Crashlytics only stores the most recent 8 exceptions in a given app session. If your app throws more than 8 exceptions in a session, older exceptions are lost.

Manage Crash Insights data

Crash Insights helps you resolve issues by comparing your anonymized stack traces to traces from other Firebase apps and letting you know if your issue is part of a larger trend. For many issues, Crash Insights even provides resources to help you debug the crash.

Crash Insights uses aggregated crash data to identify common stability trends. If you’d prefer not to share your app's data, you can opt-out of Crash Insights from the Crash Insights menu at the top of your Crashlytics issue list in the Firebase console.