From 42706a30680be4fc2b2f5f8b0ec4fc77f700d9ac Mon Sep 17 00:00:00 2001 From: tidusjar Date: Tue, 9 Aug 2016 16:53:09 +0100 Subject: [PATCH] Added some useful analytical infomation around the wizard. --- PlexRequests.Helpers/Analytics/Action.cs | 3 ++- PlexRequests.Helpers/Analytics/Category.cs | 1 + PlexRequests.UI/Modules/UserWizardModule.cs | 12 +++++++++++- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/PlexRequests.Helpers/Analytics/Action.cs b/PlexRequests.Helpers/Analytics/Action.cs index d91356747..37019751c 100644 --- a/PlexRequests.Helpers/Analytics/Action.cs +++ b/PlexRequests.Helpers/Analytics/Action.cs @@ -40,6 +40,7 @@ namespace PlexRequests.Helpers.Analytics TvShow, Album, Request, - Language + Language, + Finish } } \ No newline at end of file diff --git a/PlexRequests.Helpers/Analytics/Category.cs b/PlexRequests.Helpers/Analytics/Category.cs index 252c6fdc8..33d0cecf1 100644 --- a/PlexRequests.Helpers/Analytics/Category.cs +++ b/PlexRequests.Helpers/Analytics/Category.cs @@ -28,6 +28,7 @@ namespace PlexRequests.Helpers.Analytics { public enum Category { + Wizard, Startup, Search, Requests, diff --git a/PlexRequests.UI/Modules/UserWizardModule.cs b/PlexRequests.UI/Modules/UserWizardModule.cs index 9736337f2..253288929 100644 --- a/PlexRequests.UI/Modules/UserWizardModule.cs +++ b/PlexRequests.UI/Modules/UserWizardModule.cs @@ -38,24 +38,31 @@ using Nancy.Validation; using PlexRequests.Api.Interfaces; using PlexRequests.Core; using PlexRequests.Core.SettingModels; +using PlexRequests.Helpers; +using PlexRequests.Helpers.Analytics; using PlexRequests.UI.Helpers; using PlexRequests.UI.Models; +using Action = PlexRequests.Helpers.Analytics.Action; + namespace PlexRequests.UI.Modules { public class UserWizardModule : BaseModule { public UserWizardModule(ISettingsService pr, ISettingsService plex, IPlexApi plexApi, - ISettingsService auth, ICustomUserMapper m) : base("wizard", pr) + ISettingsService auth, ICustomUserMapper m, IAnalytics a) : base("wizard", pr) { PlexSettings = plex; PlexApi = plexApi; PlexRequestSettings = pr; Auth = auth; Mapper = m; + Analytics = a; Get["/", true] = async (x, ct) => { + a.TrackEventAsync(Category.Wizard, Action.Start, "Started the wizard", Username, CookieHelper.GetAnalyticClientId(Cookies)); + var settings = await PlexRequestSettings.GetSettingsAsync(); if (settings.Wizard) { @@ -75,6 +82,7 @@ namespace PlexRequests.UI.Modules private ISettingsService PlexRequestSettings { get; } private ISettingsService Auth { get; } private ICustomUserMapper Mapper { get; } + private IAnalytics Analytics { get; } private Response PlexAuth() @@ -153,6 +161,7 @@ namespace PlexRequests.UI.Modules { var username = (string)Request.Form.Username; var userId = Mapper.CreateAdmin(username, Request.Form.Password); + Analytics.TrackEventAsync(Category.Wizard, Action.Finish, "Finished the wizard", username, CookieHelper.GetAnalyticClientId(Cookies)); Session[SessionKeys.UsernameKey] = username; // Destroy the Plex Auth Token @@ -163,6 +172,7 @@ namespace PlexRequests.UI.Modules settings.Wizard = true; await PlexRequestSettings.SaveSettingsAsync(settings); + return this.LoginAndRedirect((Guid)userId, fallbackRedirectUrl: "/search"); } }