Xamarin Insights: after only 5 minutes, it's already saving my arse

One of the most exciting bits of news at Xamarin Evolve 2014 last week in Atalanta was the announcement of Xamarin Insights, a new platform/service/libraries for gathering data from mobile apps on sessions, crashes, and events. And while there's already a bunch of tools available for this type of thing (TestFlight, Crashlytics, Applause, etc.), Insights is now the Xamarin-native way of getting realtime and post-crash stats from your app running in the wild.

The pain point of other similar services has been that there has typically not been provided C# libraries that you can just drop into your Xamarin app and start using. If you wanted to use one of the other services, you had to either bind to their native library, or hope that someone else had already done it, and done it right. In the case of TestFlight in particular, you'd only get the reporting from iOS anyway, not Android. Not very useful when you're targeting multiple platforms. Additionally, these other services typically only provide libraries that work with the native SDK language environments (Obj-C and Java), not with the Mono runtime. So crash reports would contain lots of native trace feedback, but not many meaningful Mono/C# stacktraces.

So, when Xamarin Insights was announced and demo'd last week at Evolve 2014, the buzz in the room of 1200+ developers was palpable. Once again, Xamarin has given us great tools to create the best cross-platform mobile apps.

Let's see it in action

  1. Create an "app" in Xamarin Insights: http://insights.xamarin.com. It should be noted that the term "app" here simply refers to the collection of stats for a single given real-world mobile app. An "app domain", if you will. So, you could have "App A", "App B", and "App C" in Insights. Each will have it's own uniquely identifying API key, and each will correspond to your actual mobile apps App A, App B, and App C.

  2. Insert a line of initialization code in the startup portion of your app. See the examples here: http://insights.xamarin.com/docs. It's a wee bit different for each different mobile platform type, but super easy and only one line of code.

Ummm...yeah. That's pretty much it for setup. It really doesn't get any easier than that! The only caveat I should mention is that for iOS, the docs don't curently specify exactly where to put that line of code. Experience would suggest that it goes in the AppDelegate class, but that actually doesn't work at the time of this writing. You actually need to put it in your Main.cs immediately before the usual UIApplication.Main(args, null, "AppDelegate"); line. So, your Main.cs should look something like this:

Insights.Initialize("your Xamarin Insights api key goes here");
UIApplication.Main(args, null, "AppDelegate");

How Insights immediately helped me

I of course fired up my newly Insight-ified iOS app immediately after wiring up my api key. Within 5 minutes of testing, I caused a crash that I've been seeing for a while but was previously unable to track down. It was a null reference exception around the title property of a view in my app. This view gets its title from some remote data. It turns out that the title property was attempting to have its value set before the data for it was available. It was a crash I'd seen quite a few times, but was happening intermittently and I hadn't beeen able to track it down. Xamarin Insights revealed it to me within 5 minutes. BOOM! Amazing! All because now there is this dead-simple way to do cloud-based exception and crash reporting in Xamarin apps.

And if that's not cool enough, you can also:

  • see user sessions in realtime
  • see which users are being affected by which errors
  • see stacktraces for each exception
  • see device stats for each exception (operating system, app version, network status, device orientation, jalbreak status, and bluetooth status)
  • see advanced reporting and filtering of aggregate exception statistics
  • setup webhooks for triggering actions on certain Insights events
  • integrate with third-party services (Campire, Github, HipChat, Jira, PIvotalTracker, and Visual Studio Online)

The Xamarin Insights information pages and the interface itself are very self-explanatory, so I won't waste time posting any pictures here. All I can say is: you'd be a fool not to use Xamarin Insights in your apps. It's fantastic.

comments powered by Disqus