Please Note: Exrin is no longer actively developed.
Following on from Part 2, Exrin Insights is part of the Exrin package and provides a single point for collecting all logged information without tying you to a single insight provider.
Why provide this wrapper, when I can just call straight to the insight service? I’m glad you hypothetically asked. I never thought that being tied to an Insight provider such as Xamarin Insights or Microsoft Application Insights would pose much of a problem. But what happened recently? Xamarin Insights and Microsoft Application Insights for Mobile both are merging into HockeyApp. For 2 projects I actively manage, one is switching to WebTrends and the other to Raygun because other parts of their business run on these platforms and they are trying to consolidate.
I never thought I would be so busy ripping out insight services and replacing them. Many people including myself fall into the trap of lets just code Insights.Report(ex);. Now look what we just did, we managed to tightly couple this service all over your code. But i’ll never change it you say, well you just wait ….
The other issue is I have found there are 3 types of information you generally want to collect.
- Debug Logging information
- User Insights (what the user is doing) / Metrics
- Exception Tracking (sometimes with debugging information attached)
Insight and Exception Tracking providers normally have different services for this, or maybe you even want different services for handling the different data? Either way we only want one place to put all the information in our app and let the service determine where they should go.
Tracking with Exrin Insights
Just pass the IApplicationInsights service around as required and then call the appropriate method as shown below. The Insights Processor will take care of the rest in relaying it to your InsightsProvider. Now you have a completely separate Insights/Exception handling service in your code that can be changed or more added as needed.
While you don’t need to do anything if you like the defaults, the processor is started automatically in the bootstrapper. The processor gets all stored insights data and passes it to the providers. You can override as you see fit. Below is what the default currently does.
Now we just need to wire up and create our Insight Providers. These are were we send the insight reports to the providers as needed. We can filter and modify as needed to send through and we can create multiple of them per provider we want to wire up.
Then in the bootstrapper override the StartInsights() method to register your Insight Providers.