telem too

This commit is contained in:
Mike Griese
2025-07-08 13:51:00 -05:00
parent 1e198d4acf
commit f2c57ee33e
6 changed files with 49 additions and 3 deletions

View File

@@ -0,0 +1,7 @@
// Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
namespace Microsoft.CmdPal.UI.ViewModels.Messages;
public record BeginInvokeMessage;

View File

@@ -0,0 +1,7 @@
// Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
namespace Microsoft.CmdPal.UI.ViewModels.Messages;
public record CmdPalInvokeResultMessage(Microsoft.CommandPalette.Extensions.CommandResultKind Kind);

View File

@@ -280,7 +280,7 @@ public partial class ShellViewModel : ObservableObject,
{
Logger.LogDebug($"Invoking command");
// PowerToysTelemetry.Log.WriteEvent(new BeginInvoke()); // TODO!
WeakReferenceMessenger.Default.Send<BeginInvokeMessage>();
StartInvoke(message, invokable);
}
}
@@ -346,7 +346,7 @@ public partial class ShellViewModel : ObservableObject,
var kind = result.Kind;
Logger.LogDebug($"handling {kind.ToString()}");
// PowerToysTelemetry.Log.WriteEvent(new CmdPalInvokeResult(kind)); // TODO!
WeakReferenceMessenger.Default.Send<CmdPalInvokeResultMessage>(new(kind));
switch (kind)
{
case CommandResultKind.Dismiss:

View File

@@ -142,6 +142,8 @@ public partial class App : Application
services.AddSingleton<IExtensionService, ExtensionService>();
services.AddSingleton<TrayIconService>();
services.AddSingleton(new TelemetryForwarder());
// ViewModels
services.AddSingleton<ShellViewModel>();

View File

@@ -0,0 +1,31 @@
// Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using CommunityToolkit.Mvvm.Messaging;
using Microsoft.CmdPal.UI.Events;
using Microsoft.CmdPal.UI.ViewModels.Messages;
using Microsoft.PowerToys.Telemetry;
namespace Microsoft.CmdPal.UI;
internal sealed class TelemetryForwarder :
IRecipient<BeginInvokeMessage>,
IRecipient<CmdPalInvokeResultMessage>
{
public TelemetryForwarder()
{
WeakReferenceMessenger.Default.Register<BeginInvokeMessage>(this);
WeakReferenceMessenger.Default.Register<CmdPalInvokeResultMessage>(this);
}
public void Receive(CmdPalInvokeResultMessage message)
{
PowerToysTelemetry.Log.WriteEvent(new CmdPalInvokeResult(message.Kind));
}
public void Receive(BeginInvokeMessage message)
{
PowerToysTelemetry.Log.WriteEvent(new BeginInvoke());
}
}

View File

@@ -211,7 +211,6 @@ public sealed partial class ShellPage : Microsoft.UI.Xaml.Controls.Page,
{
// cancel
}
}
private void InitializeConfirmationDialog(ConfirmResultViewModel vm)