Why you need Firebase Crashlytics in your Flutter Apps
Tags: firebase, flutter, mobile, beginners
Published: 2022-12-21 09:07:39

You have just finished building your first mobile app using the Flutter framework and now you’re excited to release it to both stores _(play store and app store)_. But a few questions keep popping up in your mind before or after the release date;
1. How do you track unexpected crashes that happen while the users make use of the app?
2. How do you troubleshoot to get detailed information about a crash and its impact on the users of the app?

A user expectation is to have a seamless experience while engaging a mobile app. Bad user experience leads to app uninstalls and negative app reviews that eventually affect the brand image. This fundamentally creates a need for a stable app that is bug-free (crash-free). Although this is feasible, it is not always the case. Some crashes may occur in runtime but not in debug mode,  making it difficult to detect and quickly resolve. Therefore a real-time crash reporter is needed to monitor such crashes.

In this article, we will take a deep dive into Firebase Crashlytics and what it entails. Specifically, we’ll cover:

- Brief Introduction to Flutter and Firebase
- What is Firebase Crashlytics
- Benefits of Integrating Firebase Crashlytics in your Flutter app
- Conclusion

So…let’s get into it

---

### Brief Introduction to Flutter and Firebase


#### What is Flutter

> 
Flutter is an open-source UI software development kit created by Google that uses Dart as the programming language. It is used to develop cross-platform applications for Android, iOS, Linux, macOS, Windows, and the web from a single codebase.
> 

Flutter provides many advanced packages to work with databases such as Cloud Firestore provided by Firebase. Check out the [Official Flutter Documentation](https://flutter.dev/) for more information on Flutter.

#### What is Firebase

> 
Firebase is a Google-backed application development software that enables developers to develop iOS, Android, and Web apps. It provides tools for tracking analytics, reporting and fixing app crashes, creating marketing and product experiments.
> 

Firebase also provides various plugins for pertinent functions such as cloud firestore, firebase analytics, and firebase crashlytics. Check out the [Official Firebase Documentation](https://firebase.google.com/) for more information on Firebase.

---

### What is Firebase Crashlytics

Firebase Crashlytics is a lightweight, real-time crash reporter that collects, organize and group crash report highlighting the circumstances that led to them. It provides you with a platform to track, monitor, and prioritize these unexpected crash issues that arise in your mobile apps. This ensures app stability, simplifies debugging, and makes troubleshooting easier by giving you a snapshot of the problem.

![Firebase Crashlytics Dashboard](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xse43v8l6tbq5tmge6la.png)

A crash report may contain the following information:

- The name and version of the local operating system.
- The runtime type of the error, for example, StateError or NoSuchMethodError.
- The stack trace generated by the crash includes the lines of code causing the crashes.

Firebase Crashlytics also allows you to customize your crash reports by adding logs, keys, etc. It provides real-time alerts when a crash report suddenly increases in severity.

The 3 core aspects of Firebase Crashlytics are:

- **Logs**: Firebase Crashlytics logs each event of an app crash alongside the details.
- **Crash reports**: Firebase Crashlytics gives details on Crash reports whenever a crash occurs in the app.
- **Stack traces**: In the case of the app recovering from an error, Firebase Crashlytics helps to nonetheless report the error with the help of Dart Stack trace.

---

### Benefits of Integrating Firebase Crashlytics in your Flutter app

**1. Access to Crash-Free Users (CFU) Metrics to Debug Faster**
The Crash-Free Users metric provided by Firebase Crashlytics helps developers monitor and determine the health of their app based on the percentage of users who have not experienced a crash during the entire selected time range. This is made possible and accurate through the Crashlytics Flutter SDK which provides an API for capturing fatal event crashes that a user experiences in your mobile app.

![Crash Free Users Metric](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hrc8kabdtel2g3huu41d.png)


**2. Receive Crash Report Notifications in real-time with Crashlytics Alerts**
Critical user issues or crash reports may occur at any time and the need to be notified as soon as they occur is very important. With the help of [Velocity alerts](https://firebase.google.com/docs/crashlytics/velocity-alerts) in Firebase Crashlytics, you can configure real-time alerts by different levels of your app’s stability such as high-priority alerts, regression alerts, and new issue alerts.  They are particularly useful in the case of feature flags, when an issue in your app crosses a threshold that has been defined, it is a great signal to turn off the feature and investigate further. 
    
**3. Gain user insights with Custom logs and data**
Firebase Crashlytics helps you track the state and sequence of your app usage prior to a crash through [custom logs](https://firebase.google.com/docs/crashlytics/customize-crash-reports?platform=android#add-logs). It shows up within the stack trace in your Crashlytics dashboard displaying all the crash report logs in one place.
    Custom data gives you an insight into the user’s device information such as the brand name, model, android/ios version, etc, this helps when it comes to grouping various crash reports

![Custom Data](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5whsgkd1xzaxlrou4ly7.png)


**4. Reproduce crashes faster with a predefined Google Analytics event**
When there is a need to capture every event your user triggers in your app manually, it can be very frustrating. However, through the help of Firebase Crashlytics with Google Analytics, you can automatically capture these events
    They also further enhance the data captured with custom logs. It is found within your stack trace in the Crashlytics dashboard and it displays actions a user has taken prior to a crash as well as pertinent parameters within the event.

![Stack Trace Report](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/t99ep5v8qxphdwvyn9jv.png)

&nbsp;
### Conclusion

In Conclusion, the mobile app ecosystem is very competitive therefore ensuring that your app doesn’t crash frequently is integral to the app's success. Firebase Crashlytics provides essential tools that help you debug crashes and get the most out of the crash reports. 

This article has explained the core aspects and benefits of integrating Firebase Crashlytics before or after the release of your app. Check out [Firebase Crashlytics](https://firebase.google.com/docs/crashlytics) for further detailed information. In the next article post, we will look at how to integrate Firebase Crashlytics into your Flutter app. Thanks for reading.
 
If you have any questions or inquiries, feel free to reach out to me on Twitter: [@CalebJ](https://twitter.com/CalebJesusegun) or LinkedIn: [@CalebJ](https://www.linkedin.com/in/caleb-jesusegun/).