diff --git a/Bloxstrap/App.xaml.cs b/Bloxstrap/App.xaml.cs index 2c06cf5..228d2cc 100644 --- a/Bloxstrap/App.xaml.cs +++ b/Bloxstrap/App.xaml.cs @@ -131,6 +131,21 @@ namespace Bloxstrap return null; } + public static async void SendStat(string key, string value) + { + if (!Settings.Prop.EnableAnalytics) + return; + + try + { + await HttpClient.GetAsync($"https://bloxstrapabs.com/metrics/post?key={key}&value={value}"); + } + catch (Exception ex) + { + Logger.WriteException("App::SendStat", ex); + } + } + protected override void OnStartup(StartupEventArgs e) { const string LOG_IDENT = "App::OnStartup"; diff --git a/Bloxstrap/Bootstrapper.cs b/Bloxstrap/Bootstrapper.cs index 12955a3..7d833d0 100644 --- a/Bloxstrap/Bootstrapper.cs +++ b/Bloxstrap/Bootstrapper.cs @@ -245,6 +245,9 @@ namespace Bloxstrap channel = value; } + if (channel != "production") + App.SendStat("robloxChannel", channel); + ClientVersion clientVersion; try @@ -1055,8 +1058,7 @@ namespace Bloxstrap if (ex.GetType() == typeof(ChecksumFailedException)) { - if (App.Settings.Prop.EnableAnalytics) - _ = App.HttpClient.GetAsync($"https://bloxstraplabs.com/metrics/post?key=packageDownloadState&value=httpFail"); + App.SendStat("packageDownloadState", "httpFail"); Frontend.ShowConnectivityDialog( Strings.Dialog_Connectivity_UnableToDownload, @@ -1088,11 +1090,8 @@ namespace Bloxstrap } } - if (statIsRetrying && App.Settings.Prop.EnableAnalytics) - { - string stat = statIsHttp ? "httpSuccess" : "retrySuccess"; - _ = App.HttpClient.GetAsync($"https://bloxstraplabs.com/metrics/post?key=packageDownloadState&value={stat}"); - } + if (statIsRetrying) + App.SendStat("packageDownloadState", statIsHttp ? "httpSuccess" : "retrySuccess"); } private void ExtractPackage(Package package, List? files = null) diff --git a/Bloxstrap/Installer.cs b/Bloxstrap/Installer.cs index bda9f34..96784a7 100644 --- a/Bloxstrap/Installer.cs +++ b/Bloxstrap/Installer.cs @@ -92,6 +92,9 @@ namespace Bloxstrap WindowsRegistry.RegisterStudio(); App.Logger.WriteLine(LOG_IDENT, "Installation finished"); + + if (!IsImplicitInstall) + App.SendStat("installAction", "install"); } private bool ValidateLocation() @@ -340,6 +343,8 @@ namespace Bloxstrap WindowStyle = ProcessWindowStyle.Hidden }); } + + App.SendStat("installAction", "uninstall"); } public static void HandleUpgrade() @@ -561,6 +566,8 @@ namespace Bloxstrap if (currentVer is null) return; + App.SendStat("installAction", "upgrade"); + if (isAutoUpgrade) { Utilities.ShellExecute($"https://github.com/{App.ProjectRepository}/wiki/Release-notes-for-Bloxstrap-v{currentVer}");