About Health. Or Health Metrics of iOS and Android applications to be honest.
While your product grows, you become more and more aware of how it works. We have a lot of great practice in the backend world, loggers, monitoring and etc.
While in mobile, we mostly watch crash-free?? But! In modern iOS and Android applications, we have some type-safe unwrapping that we can use to prevent crashes and show some blank screen or screen without data. At the same time, we will see 100% crash-free for our application and feel safe. A bad situation, don't you think? ??
This is where health metrics come into play. Health metrics provide a fuller view of your application's performance, going beyond just crash reports. They can help identify issues that don't necessarily cause a crash but can still significantly impact the user experience.
It can be based on product metrics or can be based on logs inside application. Let’s go into second variant ??
Firebase, a tool you definitely already use for crash reporting, can also be use for collection health metrics. It's an easy and cost-effective solution, no need for additional integration ?? ♂?
First of all, we need to think about problem areas. To my understanding, they can be:
In our case, we also have websockets, some SDKs, our custom analytics, and a lot more. I think you got an idea.
So what you can do is write a simple function that will store an error inside Firebase. Here is example for iOS
领英推荐
func log(
message: LosslessStringConvertible,
errorDomain: ErrorDomain,
params: [String : String]) {
params["device_id"] = _deviceTokenStore.deviceToken ?? ""
params["error_description"] = message.description
return Crashlytics.crashlytics().record(error: NSError(
domain: errorDomain.rawValue,
code: 400,
userInfo: params))
}
And put this in your code. For example for us great practice is:
guard var messages = contents.messages else {
mcAssertionFailure() // Here we call assertionFailure for Debug code or log to Firebase
return contents
}
Now you can visit the Firebase Crashlytics page, select non-fatals, and check how many events are there. Understand the impact of these non-fatal errors and investigate them using parameters you added.
You can track for example place of error by this parameters or add additional data from error
file: String = #file,
function: String = #function,
line: Int = #line
Next step can be using more professional instruments like Sentry, Embrace and etc but it’s another story.
Do you track you apps health beyond crashfree metric?