diff --git a/PlexRequests.UI/Modules/AdminModule.cs b/PlexRequests.UI/Modules/AdminModule.cs index 8370d0907..7ad308735 100644 --- a/PlexRequests.UI/Modules/AdminModule.cs +++ b/PlexRequests.UI/Modules/AdminModule.cs @@ -719,7 +719,7 @@ namespace PlexRequests.UI.Modules private Response UpdateLogLevels(int level) { var settings = LogService.GetSettings(); - + Analytics.TrackEventAsync(Category.Admin, Action.Update, "Updated Log Levels", Username, CookieHelper.GetAnalyticClientId(Cookies), level); // apply the level var newLevel = LogLevel.FromOrdinal(level); LoggingHelper.ReconfigureLogLevel(newLevel); @@ -760,6 +760,7 @@ namespace PlexRequests.UI.Modules private Response CreateApiKey() { this.RequiresClaims(UserClaims.Admin); + Analytics.TrackEventAsync(Category.Admin, Action.Create, "Created API Key", Username, CookieHelper.GetAnalyticClientId(Cookies)); var apiKey = Guid.NewGuid().ToString("N"); var settings = PrService.GetSettings(); @@ -847,6 +848,7 @@ namespace PlexRequests.UI.Modules { var settings = this.Bind(); + Analytics.TrackEventAsync(Category.Admin, Action.Update, "Update Landing Page", Username, CookieHelper.GetAnalyticClientId(Cookies)); var plexSettings = await PlexService.GetSettingsAsync(); if (string.IsNullOrEmpty(plexSettings.Ip)) { @@ -885,6 +887,8 @@ namespace PlexRequests.UI.Modules private async Task SaveScheduledJobs() { + + Analytics.TrackEventAsync(Category.Admin, Action.Update, "Update ScheduledJobs", Username, CookieHelper.GetAnalyticClientId(Cookies)); var settings = this.Bind(); var result = await ScheduledJobSettings.SaveSettingsAsync(settings); @@ -898,6 +902,7 @@ namespace PlexRequests.UI.Modules { try { + Analytics.TrackEventAsync(Category.Admin, Action.Delete, "Clear Logs", Username, CookieHelper.GetAnalyticClientId(Cookies)); var allLogs = await LogsRepo.GetAllAsync(); foreach (var logEntity in allLogs) { diff --git a/PlexRequests.UI/Modules/RequestsModule.cs b/PlexRequests.UI/Modules/RequestsModule.cs index 13f557186..c538fa409 100644 --- a/PlexRequests.UI/Modules/RequestsModule.cs +++ b/PlexRequests.UI/Modules/RequestsModule.cs @@ -47,6 +47,9 @@ using System.Threading.Tasks; using NLog; using PlexRequests.Core.Models; +using PlexRequests.Helpers.Analytics; + +using Action = PlexRequests.Helpers.Analytics.Action; namespace PlexRequests.UI.Modules { @@ -63,7 +66,8 @@ namespace PlexRequests.UI.Modules ICouchPotatoApi cpApi, ISonarrApi sonarrApi, ISickRageApi sickRageApi, - ICacheProvider cache) : base("requests", prSettings) + ICacheProvider cache, + IAnalytics an) : base("requests", prSettings) { Service = service; PrSettings = prSettings; @@ -76,6 +80,7 @@ namespace PlexRequests.UI.Modules SickRageApi = sickRageApi; CpApi = cpApi; Cache = cache; + Analytics = an; Get["/", true] = async (x, ct) => await LoadRequests(); Get["/movies", true] = async (x, ct) => await GetMovies(); @@ -92,6 +97,7 @@ namespace PlexRequests.UI.Modules private static Logger Log = LogManager.GetCurrentClassLogger(); private IRequestService Service { get; } + private IAnalytics Analytics { get; } private INotificationService NotificationService { get; } private ISettingsService PrSettings { get; } private ISettingsService PlexSettings { get; } @@ -295,6 +301,7 @@ namespace PlexRequests.UI.Modules private async Task DeleteRequest(int requestid) { this.RequiresClaims(UserClaims.Admin); + Analytics.TrackEventAsync(Category.Requests, Action.Delete, "Delete Request", Username, CookieHelper.GetAnalyticClientId(Cookies)); var currentEntity = await Service.GetAsync(requestid); await Service.DeleteRequestAsync(currentEntity); @@ -360,6 +367,7 @@ namespace PlexRequests.UI.Modules private async Task ChangeRequestAvailability(int requestId, bool available) { this.RequiresClaims(UserClaims.Admin); + Analytics.TrackEventAsync(Category.Requests, Action.Update, available ? "Make request available" : "Make request unavailable", Username, CookieHelper.GetAnalyticClientId(Cookies)); var originalRequest = await Service.GetAsync(requestId); if (originalRequest == null) {