xamarinxamarin.ioscrash-reportshockeyapp

How to add addtional information to hockeyapp (appcenter) crash report in Xamarin?


I'm following the article https://support.hockeyapp.net/kb/client-integration-cross-platform/how-to-integrate-hockeyapp-with-xamarin trying to add some more information into hockeyapp's crash data.

Collect crash reports: If your app crashes, a crash log is written to the device's storage. If the user starts the app again, they will be asked asked to submit the crash report to HockeyApp. This works for both beta and live apps, i.e. those submitted to the App Store. Crash logs contain viable information for you to help resolve the issue. Furthermore, you as a developer can add additional information to the report as well.

I found some example code at https://support.hockeyapp.net/kb/client-integration-ios-mac-os-x-tvos/how-to-add-application-specific-log-data-on-ios-or-os-x from Add custom information to HockeyApp crash report but it's in objective-c and swift, How can I do it in Xamarin / c#?


Solution

  • I assume that you want to use AppCenter instead of HockeyApp. With AppCenter you need to tell what the AppCenter-client should watch for. If you want to use crashes and analytics your start would look like this:

    AppCenter.Start("YOUR KEY", typeof(Analytics), typeof(Crashes));
    

    If you want to report an exception you could easily do it with:

    Crashes.TrackError(exception);
    

    Additional information can be added with a dictionary:

    var additionalInformation = new Dictionary<string, string>();
    additionalInformation.Add("TITLE", "VALUE");
    
    Crashes.TrackError(exception, additionalInformation);