From 37e9b9fbed2407fce4813453153114bf744e89cf Mon Sep 17 00:00:00 2001 From: Maksym Pavlenko Date: Mon, 9 Jan 2017 12:11:32 -0800 Subject: [PATCH] Eliminate Application Insights --- src/Podsync/Controllers/DownloadController.cs | 15 +-------------- src/Podsync/Controllers/FeedController.cs | 10 +--------- .../Application Insights/ConnectedService.json | 7 ------- src/Podsync/Startup.cs | 17 +---------------- src/Podsync/Views/Shared/_Layout.cshtml | 2 -- src/Podsync/Views/_ViewImports.cshtml | 4 +--- src/Podsync/appsettings.json | 3 --- src/Podsync/project.json | 1 - 8 files changed, 4 insertions(+), 55 deletions(-) delete mode 100644 src/Podsync/Service References/Application Insights/ConnectedService.json diff --git a/src/Podsync/Controllers/DownloadController.cs b/src/Podsync/Controllers/DownloadController.cs index ce9bd93..a92c43f 100644 --- a/src/Podsync/Controllers/DownloadController.cs +++ b/src/Podsync/Controllers/DownloadController.cs @@ -1,7 +1,5 @@ using System; -using System.Collections.Generic; using System.Threading.Tasks; -using Microsoft.ApplicationInsights; using Microsoft.AspNetCore.Mvc; using Podsync.Helpers; using Podsync.Services.Links; @@ -17,14 +15,12 @@ namespace Podsync.Controllers private readonly IResolverService _resolverService; private readonly ILinkService _linkService; private readonly IStorageService _storageService; - private readonly TelemetryClient _telemetry; - public DownloadController(IResolverService resolverService, ILinkService linkService, IStorageService storageService, TelemetryClient telemetry) + public DownloadController(IResolverService resolverService, ILinkService linkService, IStorageService storageService) { _resolverService = resolverService; _linkService = linkService; _storageService = storageService; - _telemetry = telemetry; } // Main video download endpoint, don't forget to reflect any changes in LinkService.Download @@ -49,12 +45,6 @@ namespace Podsync.Controllers } catch (Exception ex) { - _telemetry.TrackException(ex, new Dictionary - { - ["FeedId"] = feedId, - ["VideoId"] = videoId - }); - var response = "Could nou resolve URL"; if (ex is InvalidOperationException) { @@ -64,9 +54,6 @@ namespace Podsync.Controllers return BadRequest(response); } - // Report metrics - _telemetry.TrackEvent("Download"); - return Redirect(redirectUrl.ToString()); } } diff --git a/src/Podsync/Controllers/FeedController.cs b/src/Podsync/Controllers/FeedController.cs index bd634f9..17afad1 100644 --- a/src/Podsync/Controllers/FeedController.cs +++ b/src/Podsync/Controllers/FeedController.cs @@ -5,7 +5,6 @@ using System.Linq; using System.Security.Claims; using System.Threading.Tasks; using System.Xml.Serialization; -using Microsoft.ApplicationInsights; using Microsoft.AspNetCore.Mvc; using Podsync.Helpers; using Podsync.Services; @@ -34,14 +33,12 @@ namespace Podsync.Controllers private readonly IRssBuilder _rssBuilder; private readonly ILinkService _linkService; private readonly IStorageService _storageService; - private readonly TelemetryClient _telemetry; - public FeedController(IRssBuilder rssBuilder, ILinkService linkService, IStorageService storageService, TelemetryClient telemetry) + public FeedController(IRssBuilder rssBuilder, ILinkService linkService, IStorageService storageService) { _rssBuilder = rssBuilder; _linkService = linkService; _storageService = storageService; - _telemetry = telemetry; } [HttpPost] @@ -92,8 +89,6 @@ namespace Podsync.Controllers properties.Add("Email", User.GetClaim(ClaimTypes.Email)); } - _telemetry.TrackEvent("CreateFeed", properties); - return url; } @@ -135,9 +130,6 @@ namespace Podsync.Controllers body = writer.ToString(); } - // Report metrics - _telemetry.TrackEvent("GetFeed"); - return Content(body, "application/rss+xml; charset=UTF-8"); } } diff --git a/src/Podsync/Service References/Application Insights/ConnectedService.json b/src/Podsync/Service References/Application Insights/ConnectedService.json deleted file mode 100644 index 92d8ae9..0000000 --- a/src/Podsync/Service References/Application Insights/ConnectedService.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "ProviderId": "Microsoft.ApplicationInsights.ConnectedService.ConnectedServiceProvider", - "Version": "7.15.1215.1", - "GettingStartedDocument": { - "Uri": "https://go.microsoft.com/fwlink/?LinkID=798432" - } -} \ No newline at end of file diff --git a/src/Podsync/Startup.cs b/src/Podsync/Startup.cs index 4349439..047e072 100644 --- a/src/Podsync/Startup.cs +++ b/src/Podsync/Startup.cs @@ -1,7 +1,5 @@ -using System.Collections.Generic; -using System.Linq; +using System.Linq; using System.Security.Claims; -using Microsoft.ApplicationInsights; using Microsoft.AspNetCore.Authentication.Cookies; using Microsoft.AspNetCore.Authentication.OAuth; using Microsoft.AspNetCore.Builder; @@ -36,7 +34,6 @@ namespace Podsync if (env.IsDevelopment()) { builder.AddUserSecrets(); - builder.AddApplicationInsightsSettings(true); } Configuration = builder.Build(); @@ -62,7 +59,6 @@ namespace Podsync services.AddAuthentication(config => config.SignInScheme = CookieAuthenticationDefaults.AuthenticationScheme); // Add framework services - services.AddApplicationInsightsTelemetry(Configuration); services.AddMvc(); } @@ -72,9 +68,6 @@ namespace Podsync loggerFactory.AddConsole(Configuration.GetSection("Logging")); loggerFactory.AddDebug(); - app.UseApplicationInsightsRequestTelemetry(); - app.UseApplicationInsightsExceptionTelemetry(); - if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); @@ -130,14 +123,6 @@ namespace Podsync var amountCents = user.Pledges.Sum(x => x.AmountCents); context.Identity.AddClaim(new Claim(Constants.Patreon.AmountDonated, amountCents.ToString())); - - var telemetry = app.ApplicationServices.GetService(); - telemetry.TrackEvent("Login", new Dictionary - { - ["Email"] = user.Email, - ["Url"] = user.Url, - ["Donated"] = amountCents.ToString() - }); } } }); diff --git a/src/Podsync/Views/Shared/_Layout.cshtml b/src/Podsync/Views/Shared/_Layout.cshtml index 6606080..242bdaf 100644 --- a/src/Podsync/Views/Shared/_Layout.cshtml +++ b/src/Podsync/Views/Shared/_Layout.cshtml @@ -30,8 +30,6 @@ asp-fallback-test-value="inline-block" asp-append-version="true" /> - - @Html.ApplicationInsightsJavaScript(TelemetryConfiguration)
diff --git a/src/Podsync/Views/_ViewImports.cshtml b/src/Podsync/Views/_ViewImports.cshtml index 61e8b96..7139b18 100644 --- a/src/Podsync/Views/_ViewImports.cshtml +++ b/src/Podsync/Views/_ViewImports.cshtml @@ -1,4 +1,2 @@ @using Podsync -@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers - -@inject Microsoft.ApplicationInsights.Extensibility.TelemetryConfiguration TelemetryConfiguration \ No newline at end of file +@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers \ No newline at end of file diff --git a/src/Podsync/appsettings.json b/src/Podsync/appsettings.json index 6952186..1b52cd1 100644 --- a/src/Podsync/appsettings.json +++ b/src/Podsync/appsettings.json @@ -14,8 +14,5 @@ "BaseUrl": "", "PatreonClientId": "", "PatreonSecret": "" - }, - "ApplicationInsights": { - "InstrumentationKey": "7250dc81-d025-4fa5-af49-6d8ea8024863" } } \ No newline at end of file diff --git a/src/Podsync/project.json b/src/Podsync/project.json index 570ac58..b598a7d 100644 --- a/src/Podsync/project.json +++ b/src/Podsync/project.json @@ -3,7 +3,6 @@ "Google.Apis.YouTube.v3": "1.16.0.582", "Hashids.net": "1.2.2", "MedallionShell": "1.2.1", - "Microsoft.ApplicationInsights.AspNetCore": "1.0.0", "Microsoft.AspNetCore.Authentication.Cookies": "1.0.0", "Microsoft.AspNetCore.Authentication.OAuth": "1.0.0", "Microsoft.AspNetCore.Diagnostics": "1.0.0",