Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Update telemetry for skipped failures and target frameworks #336

Merged
merged 2 commits into from
Feb 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions UnoCheck/CheckCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class CheckCommand : AsyncCommand<CheckSettings>
public override async Task<int> ExecuteAsync(CommandContext context, CheckSettings settings)
{
var sw = Stopwatch.StartNew();
TelemetryClient.TrackStartCheck();
TelemetryClient.TrackStartCheck(settings.Frameworks);

Util.Verbose = settings.Verbose;
Util.LogFile = settings.LogFile;
Expand Down Expand Up @@ -70,9 +70,10 @@ public override async Task<int> ExecuteAsync(CommandContext context, CheckSettin
var results = new Dictionary<string, DiagnosticResult>();
var consoleStatus = AnsiConsole.Status();

var skippedChecks = new List<string>();
var skippedChecks = new List<string>();
var skippedFix = new List<string>();

AnsiConsole.Markup($"[bold blue]{Icon.Thinking} Synchronizing configuration...[/]");
AnsiConsole.Markup($"[bold blue]{Icon.Thinking} Synchronizing configuration...[/]");

var channel = ManifestChannel.Default;
if (settings.Preview)
Expand Down Expand Up @@ -239,6 +240,11 @@ public override async Task<int> ExecuteAsync(CommandContext context, CheckSettin
|| (!settings.NonInteractive && AnsiConsole.Confirm($"[bold]{Icon.Bell} Attempt to fix?[/]"))
);

if(!doFix && !isRetry)
{
skippedFix.Add(checkup.Id);
}

if (doFix && !isRetry)
{
var isAdmin = Util.IsAdmin();
Expand Down Expand Up @@ -302,7 +308,9 @@ public override async Task<int> ExecuteAsync(CommandContext context, CheckSettin

if (hasErrors)
{
TelemetryClient.TrackCheckFail(sw.Elapsed, string.Join(",", erroredChecks.Select(c => c.Checkup.Id)));
TelemetryClient.TrackCheckFail(
sw.Elapsed,
string.Join(",", erroredChecks.Select(c => (skippedFix.Contains(c.Checkup.Id) ? "~" : "") + c.Checkup.Id)));

AnsiConsole.Console.WriteLine();

Expand Down
16 changes: 14 additions & 2 deletions UnoCheck/Telemetry/TelemetryClient.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Uno.DevTools.Telemetry;

Expand All @@ -26,13 +27,24 @@ public static void Init()
}
}

public static void TrackStartCheck()
public static void TrackStartCheck(string[] requestedFrameworks)
{
try
{
// Remove strings that are not of the format net8.0 or net8.0-XXXXX, using a regex
var frameworks = string.Join(
",",
requestedFrameworks
.OrderBy(s => s)
.Where(f => System.Text.RegularExpressions.Regex.IsMatch(f, @"^net\d+(\.0)(?:-[a-zA-Z0-9.]+)*$"))
.Select(s => s[..32])
.Take(10));

_telemetry.TrackEvent(
"check-start",
[],
[
("RequestedFrameworks", frameworks),
],
[]
);
}
Expand Down
Loading