Appcenter GetLastSessionCrashReportAsync equivalent for Xamarin
Does Rollbar have an equivalent to Appcenter's GetLastSessionCrashReportAsync for a Xamarin Forms app? I am trying to not have to mix-and-match Rollbar and Appcenter for crash reporting.
if (Crashes.HasCrashedInLastSessionAsync().Result)
{
ErrorReport crashReport = Crashes.GetLastSessionCrashReportAsync().Result;
if (crashReport.Exception == null)
Analytics.TrackEvent("AppCrashedInLastLaunch: Crash Report Exception is Null");
else
{
Crashes.TrackError(crashReport.Exception);
var dict = new Dictionary<string, string>();
dict.Add("CrashId", crashReport.Id);
dict.Add("StackTrace", crashReport.Exception.StackTrace);
Analytics.TrackEvent(string.Format("AppCrashedInLastLaunch: " + crashReport.Exception.Message), dict);
}
}
Hi @rezamohamed , no we do not have explicit/automated support for reporting mobile app crashes at the moment. It was in a discussion at some point but since we did not have any user requests for it (until now) it was shelved until then. I'll bring the conversation up again.
Meanwhile, since we do support sending custom data with our payloads, you can add any data field of the crashReport object as a custom data to a payload while seeding the payload itself from the crashReport.Exception property (I assume the property is of System.Exception type). You can use our exception packager to pack the exception and then decorate it with the custom data package decorator. Then, you send the resulting package over to Rollbar (like you normally send any other error/payload) either instead of or side-by-side with the TrackEvent call on Analytics.
Let me know if my assumptions here are wrong, I am sure we most likely can find for now workable alternative via the custom data.
hi @rezamohamed, i just wanted to check on the status of this item. are you unblocked for now?
What do you mean unblocked? from your last reply, it sounded like the CatchLastException feature is not currently available but could possibly be in your future roadmap
Right, but as a short-term solution, i suggested:
Meanwhile, since we do support sending custom data with our payloads, you can add any data field of the crashReport object as a custom data to a payload while seeding the payload itself from the crashReport.Exception property (I assume the property is of System.Exception type). You can use our exception packager to pack the exception and then decorate it with the custom data package decorator. Then, you send the resulting package over to Rollbar (like you normally send any other error/payload) either instead of or side-by-side with the TrackEvent call on Analytics.
Would work for you meantime?
It's still unclear how I can check if the application crashed last, and then get that crash exception. Delivery doesn't seem to be the problem, I am just not sure what the Rollbar equivalent, if it exists for
if (Crashes.HasCrashedInLastSessionAsync().Result) { ErrorReport crashReport = Crashes.GetLastSessionCrashReportAsync().Result;
my thinking was that you can "load" the last crash via ErrorReport crashReport = Crashes.GetLastSessionCrashReportAsync().Result; and then send its exception plus some extra custom data that you need from the ErrorReport to Rollbar as an exception payload...
I gotcha, yea I was trying to move away from AppCenter Crashes all together, cause that's one more library that I would need in my mobile app.
Definitely consider it for your future rollout if possible. Handling crashes, especially unexplained crashes are super important in mobile apps.
yes, we most likely will eventually address the crash reporting. but most likely not earlier than the second half of 2020. unless we see it is becoming a very popular feature request :)
I'll see if I can get a few people to like my OP :)