Giter VIP home page Giter VIP logo

tinyinsights's Introduction

TinyInsights

Build status

build status

About

The idea behind TinyInsights is to build a cross platform library to use with your favorite Analytics provider. Right now there are a providers for AppCenter, Application Insights and Google Analytics. And you are of course welcome to contribute with your favorite provider.

Release notes

1.1 - Introducing an Application Insigts provider and a new method for tracking dependencies. Read more in this blog post, https://danielhindrikes.se/index.php/2020/03/10/application-insights-for-xamarin-and-uwp-apps-with-tinyinsights/

Get started

Install the Nuget package for the provider you want to use in the platform project, in other projects use the TinyInsights package.

For Microsoft AppCenter install the package TinyInsights.AppCenter.

Ìnstall-Package TinyInsights.AppCenter

For Azure ApplicationInsights install the package TinyInsights.ApplicationInsights.

Ìnstall-Package TinyInsights.ApplicationInsights

If you have more projects in yout solution and want to use TinyInsights in them, you can install just the TinyInsights package. The "provider package" is just needed in the procject handling the configuration.

Ìnstall-Package TinyInsights

Configure TinyInsights

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

TinyInsights.Configure(appCenterProvider);

When multiple providers will be available you can use them simultaneously, just use configure for all of the providers.

var appInsightsProvider = new ApplicationInsightsProvider("{InstrumentationKey}");

TinyInsights.Configure(appCenterProvider, appInsightsProvider);

If you have multiple providers you can configure what to track with each provider. By default everything is tracked.

appCenterProvider.IsTrackPageViewsEnabled = false;
appCenterProvider.IsTrackEventsEnabled = false;
appCenterProvider.IsTrackDependencyEnabled = false;

appInsightsProvider.IsTrackErrorsEnabled = false;

Track errors

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

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

catch(Ecception ex)
{
     await TinyInsights.TrackErrorAsync(ex, properties);
}

Track page views

await TinyInsights.TrackPageViewAsync("SuperCoolView");

//with properties
var properties = new  Dictionarty<string, string>();
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<string, string>();
properties.Add("MyFirstProperty", "MyFirstValue");
properties.Add("MySecondProperty", "MySeconndValue");

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

Track dependencies

There are a two of ways to track dependencies with TinyInsights. The first and the basic method is TrackDependencyAsync, and is also used in the background by the other way to do it.

var startTime = DateTimeOffset.Now;

var success = await GetData();

var duration = DateTimeOffset.Now - startTime

await TinyInsights.TrackDependencyAsync("api.mydomain.se", "https://api/mydomain.se/v1/data/get", startTime, duration, success);

The second way is to create a TinyDependency object that handles most of the tracking for you. You will do that by just by wrapping your code for the dependency in a using statement.

using (var tracker = TinyInsights.CreateDependencyTracker("api.mydomain.se", "https://api/mydomain.se/v1/data/get"))
{
     await GetData();
}

If the dependency succeded that is fine, but if it not you need to handle that on your own, using the Finish method of the TinyDependency object.

using (var tracker = TinyInsights.CreateDependencyTracker("api.mydomain.se", "https://api/mydomain.se/v1/data/get"))
{
     try
     {
          var repsonse = await GetData();
     
          if(!response.IsSuccessStatusCode)
          {
               await tracker.Finish(false, (int)response.StatusCode);
          }
     }
     catch(Exception ex)
     {
          tracker.Finish(false, ex);
     }
}

tinyinsights's People

Contributors

dhindrik avatar jacobduijzer avatar jtone123 avatar georgeleithead avatar

Stargazers

 avatar Anderson Fernandes do Nascimento avatar Nate Harris avatar Saleem Basit avatar Dave Black avatar Aaron Pierson avatar Ieuan Walker avatar David Glassborow avatar buzouxun avatar Tomasz Cielecki avatar Daniel Frear avatar Atif Rehman avatar Matt Kiggen avatar Dr Milan Milanović avatar Grant Molloy avatar Ivar Løvlie avatar  avatar Chris Godwin avatar  avatar Manuel avatar Daniel Christmas avatar Charlie Smith avatar Giorgos Sgouridis avatar Alex D. avatar Mahmoud Ali avatar Roman Rudyak avatar Roberto Sanz avatar Sam Macpherson avatar Ryan Wersal avatar Evgeny Zborovsky avatar Chris avatar Pierre Haufe avatar FroggieFrog avatar

Watchers

David Glassborow avatar James Cloos avatar Johan Karlsson avatar Chris Godwin avatar  avatar Iman Mesgaran avatar

tinyinsights's Issues

AppCenter runs fine but how about Google Analytics?

How can i configure Google Analytics? One simply cant add TinyInsights.GoogleAnalytics package to PCL project to configure, because its not a .net standard project.
Should i call TinyInsights.Configure() in Android & IOS Projects instead of PCL, if i want to use GoogleAnalytics?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.