From 8fa7b30be5b9d2ab002ed8f30ff7d44a019afca2 Mon Sep 17 00:00:00 2001 From: Maksym Pavlenko Date: Wed, 4 Jan 2017 11:36:37 -0800 Subject: [PATCH] Track telemetry while login --- src/Podsync/Startup.cs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/Podsync/Startup.cs b/src/Podsync/Startup.cs index 8202d0c..dfa0964 100644 --- a/src/Podsync/Startup.cs +++ b/src/Podsync/Startup.cs @@ -1,5 +1,7 @@ -using System.Linq; +using System.Collections.Generic; +using System.Linq; using System.Security.Claims; +using Microsoft.ApplicationInsights; using Microsoft.AspNetCore.Authentication.Cookies; using Microsoft.AspNetCore.Authentication.OAuth; using Microsoft.AspNetCore.Builder; @@ -9,7 +11,6 @@ using Microsoft.AspNetCore.Http.Authentication; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; -using Podsync.Helpers; using Podsync.Services; using Podsync.Services.Builder; using Podsync.Services.Links; @@ -20,6 +21,7 @@ using Podsync.Services.Videos.YouTube; namespace Podsync { + // ReSharper disable once ClassNeverInstantiated.Global public class Startup { public Startup(IHostingEnvironment env) @@ -126,6 +128,14 @@ namespace Podsync var amountCents = user.Pledges.Sum(x => x.AmountCents); context.Identity.AddClaim(new Claim(PatreonConstants.AmountDonated, amountCents.ToString())); + + var telemetry = app.ApplicationServices.GetService(); + telemetry.TrackEvent("Login", new Dictionary + { + ["Email"] = user.Email, + ["Url"] = user.Url, + ["Donated"] = amountCents.ToString() + }); } } });