In order to use the App Center SDK in our TripLog app, we will want to abstract it into a service, like we did for geolocation. As we saw multiple times in previous chapters, there are numerous benefits to this approach, namely, it loosely couples our ViewModels from the actual code that uses the App Center SDK, making unit testing our ViewModels much simpler and cleaner.
In order to create an analytics service, perform the following steps:
- First, create a new interface named IAnalyticsService in the Services folder of the core library:
public interface IAnalyticsService { }
- Next, update the IAnalyticsService interface with methods to track usage events and errors:
public interface IAnalyticsService { ...