Skip to content

Commit

Permalink
Merge pull request #564 from christianhelle/limit-exceptionless-telem…
Browse files Browse the repository at this point in the history
…etry

Limit Exceptionless telemetry
  • Loading branch information
christianhelle authored Dec 17, 2024
2 parents 35c7c16 + b95b011 commit 91a5544
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 15 deletions.
16 changes: 2 additions & 14 deletions src/Refitter/Analytics.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ public static void Configure()
telemetryClient.TelemetryConfiguration.TelemetryInitializers.Add(new SupportKeyInitializer());
}

public static Task LogFeatureUsage(
public static void LogFeatureUsage(
Settings settings,
RefitGeneratorSettings refitGeneratorSettings)
{
if (settings.NoLogging)
return Task.CompletedTask;
return;

foreach (var property in typeof(Settings).GetProperties())
{
Expand All @@ -64,11 +64,6 @@ public static Task LogFeatureUsage(

if (settings.SettingsFilePath is not null)
{
ExceptionlessClient
.Default.CreateFeatureUsage("settings-file")
.AddObject(refitGeneratorSettings, ignoreSerializationErrors: true)
.Submit();

telemetryClient.TrackEvent(
"settings-file",
new Dictionary<string, string>
Expand All @@ -77,19 +72,12 @@ public static Task LogFeatureUsage(
});
telemetryClient.Flush();
}

return ExceptionlessClient.Default.ProcessQueueAsync();
}

private static void LogFeatureUsage(CommandOptionAttribute attribute, PropertyInfo property)
{
var featureName = attribute.LongNames.FirstOrDefault() ?? property.Name;

ExceptionlessClient
.Default
.CreateFeatureUsage(featureName)
.Submit();

telemetryClient.TrackEvent(featureName);
telemetryClient.Flush();
}
Expand Down
2 changes: 1 addition & 1 deletion src/Refitter/GenerateCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public override async Task<int> ExecuteAsync(CommandContext context, Settings se
? WriteMultipleFiles(generator, settings, refitGeneratorSettings)
: WriteSingleFile(generator, settings, refitGeneratorSettings));

await Analytics.LogFeatureUsage(settings, refitGeneratorSettings);
Analytics.LogFeatureUsage(settings, refitGeneratorSettings);
AnsiConsole.MarkupLine($"[green]Duration: {stopwatch.Elapsed}{Crlf}[/]");

if (!settings.NoBanner)
Expand Down

0 comments on commit 91a5544

Please sign in to comment.