0

I was using Xamarin Insights until recently. I removed it from my project because it increases start up time and app size significantly. So I was left with 2 options Hockeyapp and Mobile Center from Microsoft. Problem with these 2 is that they dont have any reporting functionality for reporting caught exceptions typically what you would do inside your try catch in your xamarin forms project.

Very disappointing indeed.

xamarin insight had this and it worked fine. I would like to ask how can we report exceptions in forms project? is application insight an option. I used in other .net projects but UI is not so usable indeed.

There is even a thread on github here

https://github.com/Microsoft/ApplicationInsights-Xamarin/issues/26

Microsoft is saying that we are working on it for a year or more and never delivers anything and keeps deprecating things.

Brandon Minnick
  • 11,396
  • 12
  • 55
  • 108
Emil
  • 5,290
  • 6
  • 47
  • 87
  • In HockeyApp, you could track the number of times you caught an exception by adding an event in the catch block. However, you can't really send back additional information. – cvanbeek Jun 17 '17 at 16:20
  • How about sending exception as event? Does it work as string? – Emil Jun 17 '17 at 16:27
  • The [HockeyApp documents](https://support.hockeyapp.net/kb/client-integration-cross-platform/how-to-integrate-hockeyapp-with-xamarin) say that there is support for adding Dictionary to contain measurements and such, but I haven't found a way to actually read the measurements on their website (I may be just doing something wrong though). Otherwise, all the events are good for is keeping track of how many times that line of code was executed. – cvanbeek Jun 17 '17 at 16:38
  • I did more digging and found you can look-up Event measurements using [Application Insights](https://azure.microsoft.com/en-us/blog/access-hockeyapp-data-in-ai-with-hockeyapp-bridge-app/?v=17.23h). So using HockeyApp you could write a method to pack the info from the exception into a dictionary and then send that in an event. – cvanbeek Jun 17 '17 at 16:43
  • @cvanbeek it doesnt seem to be possible without using DI. I simply tried using as Microsoft.HockeyApp.HockeyClient.Current.TrackEvent(). it doesnt crash but I dont see any event under events tab in hockeyapp – Emil Jun 17 '17 at 19:45
  • I'm sorry, I'm not familiar with what 'DI' is, could you explain? – cvanbeek Jun 17 '17 at 19:47
  • @cvanbeek Dependency Injection I wanted to say. you can find implementation on this post https://forums.xamarin.com/discussion/92974/hockeyapp-custom-events-on-xamarin-forms – Emil Jun 17 '17 at 19:52
  • Since Insights was deprecated, we moved over to using [RayGun](https://raygun.com/). It works much the same as Insights does, and also has a `Report()` method. It is worth a consideration at least. – Demitrian Jun 17 '17 at 20:34

1 Answers1

3

We use Mobile Center for reporting issues. Basically in each catch statement we use a static class to report issues, like so:

public static class EventTrace
{
    public static void Trace(string menuName, string actionName, Dictionary<string, string> parameters = null)
    {
        try
        {
            Dictionary<string, string> tmp;
            if (parameters != null)
                tmp = new Dictionary<string, string>(parameters);
            else
                tmp = new Dictionary<string, string>();

            tmp.Add("GUID", MobileCenter.InstallId.ToString());
            Analytics.TrackEvent(menuName + " - " + actionName, tmp);
        }
        catch (Exception ex)
        {
            Analytics.TrackEvent("Event Trace - Error creating event", new Dictionary<string, string> { { "Exception", ex.ToString() } });
            Analytics.TrackEvent(menuName + " - " + actionName, parameters);
        }
    }

    public static void Error(string menuName, string exception)
    {
        var parameters = new Dictionary<string, string> { { "Exception", exception } };
        var tmp = new Dictionary<string, string>(parameters);
        try
        {
            tmp.Add("GUID", MobileCenter.InstallId.ToString());
            Analytics.TrackEvent(menuName + " - Error", tmp);
        }
        catch (Exception ex)
        {
            Analytics.TrackEvent("Event Trace - Error creating event", new Dictionary<string, string> { { "Exception", ex.ToString() } });
            Analytics.TrackEvent(menuName + " - Error", parameters);
        }
    }
}

We have events for tracing, and events for catch error. In mobile center, we can basically search for the "Error" statement in the event tab.

It works for us, hope it works for you!

  • Hockeyapp has similar but they dont have trackevent in forms level and only in native level. it requires to do dependency injection like described here https://forums.xamarin.com/discussion/92974/hockeyapp-custom-events-on-xamarin-forms . did you do something similar ? so your Analytics object is your object defined by you injected using an interface? beside that are you able to see device information and app version information as well? – Emil Jun 18 '17 at 16:36
  • Seeing as i used PCL, all the error reporting and event tracking are located in the portable part of the application. The only tricky thing i had to do was create different Mobile Center projects for each Operating System (Android and iOS in my case), and in each startup initialize the Mobile Center with the different Mobile Center ID's provided. Here( https://screenpresso.com/=NGCLe ) is an example: I'm using MVVMCross, so my startup is in Setup in both. – Tiago Alexandre De Noronha Jun 19 '17 at 22:40