Skip to content

Commit

Permalink
[PTRun]Fix crash when plugins have the same name (#15456)
Browse files Browse the repository at this point in the history
  • Loading branch information
jaimecbernardo committed Jan 11, 2022
1 parent 5bcdbbc commit aac430c
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ namespace PowerLauncher.Telemetry.Events
[EventData]
public class PluginModel
{
public string ID { get; set; }

public string Name { get; set; }

public bool Disabled { get; set; }

public bool IsGlobal { get; set; }
Expand Down
29 changes: 20 additions & 9 deletions src/modules/launcher/PowerLauncher/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,27 @@ public MainWindow(PowerToysRunSettings settings, MainViewModel mainVM)

private void SendSettingsTelemetry()
{
Log.Info("Send Run settings telemetry", this.GetType());
var plugins = PluginManager.AllPlugins.ToDictionary(x => x.Metadata.Name, x => new PluginModel()
try
{
Disabled = x.Metadata.Disabled,
ActionKeyword = x.Metadata.ActionKeyword,
IsGlobal = x.Metadata.IsGlobal,
});

var telemetryEvent = new RunPluginsSettingsEvent(plugins);
PowerToysTelemetry.Log.WriteEvent(telemetryEvent);
Log.Info("Send Run settings telemetry", this.GetType());
var plugins = PluginManager.AllPlugins.ToDictionary(x => x.Metadata.Name + " " + x.Metadata.ID, x => new PluginModel()
{
ID = x.Metadata.ID,
Name = x.Metadata.Name,
Disabled = x.Metadata.Disabled,
ActionKeyword = x.Metadata.ActionKeyword,
IsGlobal = x.Metadata.IsGlobal,
});

var telemetryEvent = new RunPluginsSettingsEvent(plugins);
PowerToysTelemetry.Log.WriteEvent(telemetryEvent);
}
#pragma warning disable CA1031 // Do not catch general exception types
catch (Exception ex)
#pragma warning restore CA1031 // Do not catch general exception types
{
Log.Exception("Unhandled exception when trying to send PowerToys Run settings telemetry.", ex, GetType());
}
}

protected override void OnSourceInitialized(EventArgs e)
Expand Down

0 comments on commit aac430c

Please sign in to comment.