Rollbar.NET icon indicating copy to clipboard operation
Rollbar.NET copied to clipboard

Appcenter GetLastSessionCrashReportAsync equivalent for Xamarin

Open rezamohamed opened this issue 6 years ago • 9 comments

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);
    }
}

rezamohamed avatar Apr 10 '20 06:04 rezamohamed

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.

akornich avatar Apr 14 '20 18:04 akornich

hi @rezamohamed, i just wanted to check on the status of this item. are you unblocked for now?

akornich avatar Apr 27 '20 22:04 akornich

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

rezamohamed avatar Apr 27 '20 22:04 rezamohamed

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?

akornich avatar Apr 27 '20 22:04 akornich

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;

rezamohamed avatar Apr 27 '20 22:04 rezamohamed

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...

akornich avatar Apr 27 '20 22:04 akornich

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.

rezamohamed avatar Apr 27 '20 22:04 rezamohamed

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 :)

akornich avatar Apr 27 '20 22:04 akornich

I'll see if I can get a few people to like my OP :)

rezamohamed avatar Apr 27 '20 23:04 rezamohamed