What services will you need to deploy your own version of Beer Drinkin?

Beer Drinkin has been developed to avoid being tightly coupled with any particular services.

If you're looking to deploy your own version of Beer Drinkin without modification, you'll want to signup and use the following services.

Replacing Services

Replacing Services is very straight forward with Beer Drinkin. Let's take a look at how we'd replace Raygun with Xamarin.Insights.

Implement ILogService

The log service within Beer Drinkin implements a very simple interface for reporting exceptions which makes it perfect for swapping out.

public interface ILogService
{
    void Identify(string userId);
        
    void Report(Exception exception);
    void Report(Exception exception, IList<string> tags);
}

We'd want to implement this interface within our platform specifics projects and register the implementation with the Service Locator.

public class Logger : ILogService
{
    public Logger()
    {
        Xamarin.Insights.Initialize(Utils.Keys.CrashReportingKey);
    }

    public void Identify(string userId)
    {
        Insights.Identify(userId, "UniqueId", userId);
    }

    public void Report(Exception exception)
    {
        Insights.Report(ex);
    } 
    
    public void Report(Exception exception, IList<string> tags)
    {
         Insights.Report(ex, tags);
    }

Register with ServiceLocator

The logger should be added to the ServiceLocator as early as possible within the launching process. I recommend placing it in the App Delegate Finished Launching event for iOS.

ServiceLocator.Instance.Add<ILogService, InsightsLogger>();

🚧

Configuring & Customising the ServiceLocator

Most implementations for the ServiceLocator are registered in the ViewModelBase class. Please read the Configure docs to understand how to swap interface implementations.