Add analytics datapoints for installs and channels

This commit is contained in:
pizzaboxer 2024-10-02 22:27:58 +01:00
parent 0cd87366a7
commit d09bffeb22
No known key found for this signature in database
GPG Key ID: 59D4A1DBAD0F2BA8
3 changed files with 28 additions and 7 deletions

View File

@ -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";

View File

@ -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<string>? files = null)

View File

@ -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}");