TinyInsights – A library for helping developers with analytics and crash reporting

There are a lot of great analytics services out there. But I always use to create wrappers around their native SDK:s so I easily can replace them. But what I did with TinyInsights is that I added support for multiple service providers. That makes it possible to track data to multiple destinations with one common call. Right now TinyInsights has providers for AppCenter and Google Analytics. I will create more providers when I need them in projects I working on. But you are very welcome to contribute with more providers.

Install and configure TinyInsights

TinyInsights core package: https://www.nuget.org/packages/TinyInsights/
TinyInsights.AppCenter: https://www.nuget.org/packages/TinyInsights.AppCenter/
TinyInsights.GoogleAnalytics: https://www.nuget.org/packages/TinyInsights.GoogleAnalytics/

During the startup of the app, you need to do some configuration to get started. If you do not want the Google Analytics provider to catch unhandled exceptions you need to pass false to the constructor. For the AppCenter provider, it is always on.

var appCenterProvider = new AppCenterProvider(iOSKey, AndroidKey, UWPKey)

And with multiple providers:

var appCenterProvider = new AppCenterProvider(iOSKey, AndroidKey, UWPKey)

var catchUnhandledExceptions = false;
var googleAnalyticsProvider = var googleAnalyticsProvider = new GoogleAnalyticsProvider(googleAnalyticsKey, catchUnhandledExceptions);

TinyInsights.Configure(appCenterProvider, googleAnalyticsProvider);

ITinyInsightsProvider interface that should be implemented for each provider has three properties that you can use to configure what the provider should track. The default value is true;

provider.IsTrackErrorEnabled = false;
provider.IsTrackPageViewsEnabled = false;
provider.IsTrackEventsEnabled = false;

Google Analytics provider

The google analytics provider is platform specific so you need to do the configuration in your platform projects (or in a shared project).

Track errors

catch(Ecception ex)
await TinyInsights.TrackErrorAsync(ex);

Track page views

If you are using the AppCenter provider, page views will appear as a custom event.

await TinyInsights.TrackPageViewAsync("SuperCoolView");

//with properties
var properties = new  Dictionarty();
properties.Add("MyFirstProperty", "MyFirstValue");
properties.Add("MySecondProperty", "MySeconndValue");

await TinyInsights.TrackPageViewAsync("SuperCoolView", properties);

Track custom events

await TinyInsights.TrackEventAsync("SuperCoolEvent");

//with properties
var properties = new  Dictionarty();
properties.Add("MyFirstProperty", "MyFirstValue");
properties.Add("MySecondProperty", "MySeconndValue");

await TinyInsights.TrackEventAsync("SuperCoolEvent", properties);

Google Analytics provider notes

If you are using the Google Analytics provider, you need to pass a property with key "action".

Custom tracking

If you want to change the way a provider is tracking data, all methods are virtual so you can create your own overrides in a subclass.

Create a provider

If you want to create an own provider, the only thing you need to do to get it work with TinyInsights is to implement the ITinyInsightsProvider interface. If you are creating an own provider I will be very happy if you create a pull request to the original repository on GitHub, https://github.com/TinyStuff/TinyInsights.

  7/2/2018 - 10:40 AM