Customize your Firebase Crashlytics crash reports

This guide describes how to customize your crash reports using the Firebase Crashlytics SDK. By default, Crashlytics automatically collects crash reports for all your app's users (you can turn off automatic crash reporting and enable opt-in reporting for your users instead). Crashlytics provides four logging mechanisms out of the box: custom keys, custom logs, user identifiers, and caught exceptions.

Report exceptions

Report caught exceptions

If you have exceptions that are expected, you can have the Crashlytics SDK report them as non-fatal events. These events are logged on device and then sent along with the next fatal event report or when the end-user restarts the game.

You can log exceptions in C# using the following method:

Crashlytics.LogException(Exception ex);

You can log expected exceptions in your game's try/catch blocks:

try {
} catch (Exception e) {
   // handle your exception here!

Report uncaught exceptions

For uncaught exceptions that don't crash your game (for example, uncaught C# exceptions in game logic), you can have the Crashlytics SDK report them as fatal events by setting the Crashlytics.ReportUncaughtExceptionsAsFatal property to true where you initialize Crashlytics in your Unity project . These events are reported to Crashlytics in real-time without the need for the end-user to restart the game.

Reporting these uncaught exceptions as fatal events means that they'll count in your crash-free user statistics and towards velocity alerts.

Note that native crashes are always reported as fatal events. These events are logged on device and then sent along when the end-user restarts the game.

void Start() {
    // Since there is no try-block surrounding this call, if an exception is thrown,
    // it is considered unexpected.
    // Setting `Crashlytics.ReportUncaughtExceptionsAsFatal = true`
    // will ensure that such cases are reported as fatals.

Include GWP-ASan reports to debug memory corruption issues

For Android apps that use IL2CPP, Crashlytics can help you debug crashes caused by native memory errors by collecting GWP-ASan reports. These memory-related errors can be associated with memory corruption within your app, which is the leading cause of app security vulnerabilities.

  • You can view this data in a new "Memory stack traces" tab when you click into an issue's details in the Crashlytics dashboard.

  • You can also use the new "GWP-ASan report" signal and filter to quickly view all issues with this data.

You can get GWP-ASan memory reports if your app uses the latest Crashlytics SDK for Unity (v10.7.0+) and has GWP-ASan explicitly enabled (requires you to modify your Android App Manifest). If you have any C++ code in your app, you can test your GWP-ASan setup using the example native code in the Android documentation.

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, then use the custom keys to search and filter crash reports in the Firebase console.

  • In the Crashlytics dashboard, you can search for issues that match a custom key.
  • When you're reviewing a specific issue in the console, you can view the associated custom keys for each event (Keys subtab) and even filter the events by custom keys (Filter menu at the top of the page).

When called multiple times, new values for existing keys will update the value, and only the most current value is captured when a crash is recorded.

Crashlytics.SetCustomKey(string key, string value);

Add custom log messages

Logged messages are associated with your crash data and are visible in the Firebase Crashlytics dashboard when viewing a specific crash.

Crashlytics.Log(string message);

Set user identifiers

You can use an ID number, token, or hashed value to uniquely identify the end-user of your application without disclosing or transmitting any of their personal information. You can also clear the value by setting it to a blank string. This value is displayed in the Firebase Crashlytics dashboard when viewing a specific crash.

Crashlytics.SetUserId(string identifier);

Enable opt-in reporting

By default, Crashlytics automatically collects crash reports for all your app's users. You can give users more control over the data they send by letting them opt-in to reporting crashes.

To disable automatic collection and initialize Crashlytics only for selected users, call the Crashlytics data collection override at runtime. The override value persists across launches of your app so Crashlytics can automatically collect reports. To opt out of automatic crash reporting, pass false as the override value. When set to false, the new value does not apply until the next run of the app.

Crashlytics.IsCrashlyticsCollectionEnabled = true

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.