[cmdpal] WIP add telemetry (#38032)

Related to https://github.com/microsoft/PowerToys/pull/37908

Closes https://github.com/zadjii-msft/PowerToys/issues/520
---------

Co-authored-by: Mike Griese <migrie@microsoft.com>
This commit is contained in:
Stefan Markovic
2025-03-20 21:36:58 +01:00
committed by GitHub
parent 14919dff10
commit 3e9a6a1e64
16 changed files with 210 additions and 5 deletions

View File

@@ -3,6 +3,8 @@
// See the LICENSE file in the project root for more information.
using ManagedCommon;
using Microsoft.CmdPal.UI.Events;
using Microsoft.PowerToys.Telemetry;
using Microsoft.Windows.AppLifecycle;
namespace Microsoft.CmdPal.UI;
@@ -30,9 +32,10 @@ internal sealed class Program
Logger.InitializeLogger("\\CmdPal\\Logs\\");
Logger.LogDebug($"Starting at {DateTime.UtcNow}");
PowerToysTelemetry.Log.WriteEvent(new CmdPalProcessStarted());
WinRT.ComWrappersSupport.InitializeComWrappers();
bool isRedirect = DecideRedirection();
var isRedirect = DecideRedirection();
if (!isRedirect)
{
Microsoft.UI.Xaml.Application.Start((p) =>
@@ -48,17 +51,19 @@ internal sealed class Program
private static bool DecideRedirection()
{
bool isRedirect = false;
AppActivationArguments args = AppInstance.GetCurrent().GetActivatedEventArgs();
AppInstance keyInstance = AppInstance.FindOrRegisterForKey("randomKey");
var isRedirect = false;
var args = AppInstance.GetCurrent().GetActivatedEventArgs();
var keyInstance = AppInstance.FindOrRegisterForKey("randomKey");
if (keyInstance.IsCurrent)
{
PowerToysTelemetry.Log.WriteEvent(new ColdLaunch());
keyInstance.Activated += OnActivated;
}
else
{
isRedirect = true;
PowerToysTelemetry.Log.WriteEvent(new ReactivateInstance());
keyInstance.RedirectActivationToAsync(args).AsTask().ConfigureAwait(false);
}