I am currently trying to find a way to send non-fatals in such a way that
- EITHER they are grouped inside the Crashlytics UI like I want them to
- OR that the keys are set correctly so that I can search for them
To give some more detail: We have a token refresh request that is occasionally failing due to various reasons. To get a better idea about the actual frequency of these errors, we are logging them to Crashlytics as non-fatals.
FirebaseCrashlytics.getInstance().recordException(networkError)
At the moment, the errors in the Crashlytics UI are sorted by their root cause, e.g. no internet, server unreachable, timeout, etc. However, I don't really care about the specific network problem that occurred - I would prefer to have all network errors combined in one item in the UI.
To that end, I first tried wrapping the error in a dedicated subclass of Exception:
FirebaseCrashlytics.getInstance().recordException(
NetworkErrorDuringTokenRefreshException(networkError)
)
This, however, made no difference at all - the non-fatals are still sorted by their root cause, i. e. by the specific networkError.
Next, I tried setting a custom key directly before logging the non-fatal and then un-setting it directly after, hoping that I could then search for that key:
FirebaseCrashlytics.getInstance().setCustomKey("network_error_during_token_refresh", true)
FirebaseCrashlytics.getInstance().recordException(
NetworkErrorDuringTokenRefreshException(networkError)
)
FirebaseCrashlytics.getInstance().setCustomKey("network_error_during_token_refresh", false)
And indeed, all exceptions logged by this code do now have the custom key, but it is always set to false!
I think I have now run out of ideas (short of exporting everything to BigQuery and learn how to write the queries there...)
- Can you recommend a way to achieve my goal of easily finding all network errors in the UI?
- Why is the custom key in my example always false? As you can see in the code it should be true at the point where the non-fatal is logged...?