From 5dea1980adf0c0c5d6e9819fff2632c54dcb4389 Mon Sep 17 00:00:00 2001 From: Mike Griese Date: Fri, 27 Feb 2026 12:22:14 -0600 Subject: [PATCH] CmdPal: some dock data (#45832) we want to know what the people want re: #45584 --- .../Dock/DockViewModel.cs | 18 ++++++ .../TelemetryDockConfigurationMessage.cs | 11 ++++ .../Events/CmdPalDockConfiguration.cs | 60 +++++++++++++++++++ .../Helpers/TelemetryForwarder.cs | 14 ++++- 4 files changed, 102 insertions(+), 1 deletion(-) create mode 100644 src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Messages/TelemetryDockConfigurationMessage.cs create mode 100644 src/modules/cmdpal/Microsoft.CmdPal.UI/Events/CmdPalDockConfiguration.cs diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Dock/DockViewModel.cs b/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Dock/DockViewModel.cs index d4ee715f33..e819f887a3 100644 --- a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Dock/DockViewModel.cs +++ b/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Dock/DockViewModel.cs @@ -45,6 +45,8 @@ public sealed partial class DockViewModel _pageContext = new(this); _topLevelCommandManager.DockBands.CollectionChanged += DockBands_CollectionChanged; + + EmitDockConfiguration(); } private void DockBands_CollectionChanged(object? sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) @@ -612,6 +614,22 @@ public sealed partial class DockViewModel } } + private void EmitDockConfiguration() + { + var isDockEnabled = _settingsModel.EnableDock; + var dockSide = isDockEnabled ? _settings.Side.ToString().ToLowerInvariant() : "none"; + + static string FormatBands(List bands) => + string.Join("\n", bands.Select(b => $"{b.ProviderId}/{b.CommandId}")); + + var startBands = isDockEnabled ? FormatBands(_settings.StartBands) : string.Empty; + var centerBands = isDockEnabled ? FormatBands(_settings.CenterBands) : string.Empty; + var endBands = isDockEnabled ? FormatBands(_settings.EndBands) : string.Empty; + + WeakReferenceMessenger.Default.Send(new TelemetryDockConfigurationMessage( + isDockEnabled, dockSide, startBands, centerBands, endBands)); + } + /// /// Provides an empty page context, for the dock's own context menu. We're /// building the context menu for the dock using literally our own cmdpal diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Messages/TelemetryDockConfigurationMessage.cs b/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Messages/TelemetryDockConfigurationMessage.cs new file mode 100644 index 0000000000..185e38bcd1 --- /dev/null +++ b/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Messages/TelemetryDockConfigurationMessage.cs @@ -0,0 +1,11 @@ +// 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; + +/// +/// Telemetry message sent when the dock is initialized. +/// Captures the dock configuration for telemetry tracking. +/// +public record TelemetryDockConfigurationMessage(bool IsDockEnabled, string DockSide, string StartBands, string CenterBands, string EndBands); diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI/Events/CmdPalDockConfiguration.cs b/src/modules/cmdpal/Microsoft.CmdPal.UI/Events/CmdPalDockConfiguration.cs new file mode 100644 index 0000000000..9664a229c8 --- /dev/null +++ b/src/modules/cmdpal/Microsoft.CmdPal.UI/Events/CmdPalDockConfiguration.cs @@ -0,0 +1,60 @@ +// 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 System.Diagnostics.CodeAnalysis; +using System.Diagnostics.Tracing; +using Microsoft.PowerToys.Telemetry; +using Microsoft.PowerToys.Telemetry.Events; + +namespace Microsoft.CmdPal.UI.Events; + +/// +/// Tracks the dock configuration at startup. +/// Purpose: Understand how users configure their dock - which side, which bands, and whether it's enabled. +/// +[EventData] +[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicProperties)] +public class CmdPalDockConfiguration : EventBase, IEvent +{ + /// + /// Gets or sets whether the dock is enabled. + /// + public bool IsDockEnabled { get; set; } + + /// + /// Gets or sets the dock side (top, bottom, left, right, none). + /// "none" when the dock is disabled. + /// + public string DockSide { get; set; } + + /// + /// Gets or sets the start bands as a newline-delimited list of "{ProviderId}/{CommandId}". + /// Empty if the dock is disabled. + /// + public string StartBands { get; set; } + + /// + /// Gets or sets the center bands as a newline-delimited list of "{ProviderId}/{CommandId}". + /// Empty if the dock is disabled. + /// + public string CenterBands { get; set; } + + /// + /// Gets or sets the end bands as a newline-delimited list of "{ProviderId}/{CommandId}". + /// Empty if the dock is disabled. + /// + public string EndBands { get; set; } + + public CmdPalDockConfiguration(bool isDockEnabled, string dockSide, string startBands, string centerBands, string endBands) + { + EventName = "CmdPal_DockConfiguration"; + IsDockEnabled = isDockEnabled; + DockSide = dockSide; + StartBands = startBands; + CenterBands = centerBands; + EndBands = endBands; + } + + public PartA_PrivTags PartA_PrivTags => PartA_PrivTags.ProductAndServiceUsage; +} diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI/Helpers/TelemetryForwarder.cs b/src/modules/cmdpal/Microsoft.CmdPal.UI/Helpers/TelemetryForwarder.cs index ba2803049d..747f083208 100644 --- a/src/modules/cmdpal/Microsoft.CmdPal.UI/Helpers/TelemetryForwarder.cs +++ b/src/modules/cmdpal/Microsoft.CmdPal.UI/Helpers/TelemetryForwarder.cs @@ -20,13 +20,15 @@ internal sealed class TelemetryForwarder : ITelemetryService, IRecipient, IRecipient, - IRecipient + IRecipient, + IRecipient { public TelemetryForwarder() { WeakReferenceMessenger.Default.Register(this); WeakReferenceMessenger.Default.Register(this); WeakReferenceMessenger.Default.Register(this); + WeakReferenceMessenger.Default.Register(this); } // Message handlers for telemetry events from core layer @@ -56,6 +58,16 @@ internal sealed class TelemetryForwarder : } } + public void Receive(TelemetryDockConfigurationMessage message) + { + PowerToysTelemetry.Log.WriteEvent(new CmdPalDockConfiguration( + message.IsDockEnabled, + message.DockSide, + message.StartBands, + message.CenterBands, + message.EndBands)); + } + // Static method for logging session duration from UI layer public static void LogSessionDuration( ulong durationMs,