mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-04 10:16:24 +02:00
Add telemetry event for measuring time taken to display PT Run (#5201)
* Added LauncherHotkeyEvent * Split into cold state and warm state events
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
// 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 Microsoft.PowerToys.Telemetry;
|
||||
using Microsoft.PowerToys.Telemetry.Events;
|
||||
using System.Diagnostics.Tracing;
|
||||
|
||||
namespace Microsoft.PowerLauncher.Telemetry
|
||||
{
|
||||
[EventData]
|
||||
public class LauncherColdStateHotkeyEvent : EventBase, IEvent
|
||||
{
|
||||
public double HotkeyToVisibleTimeMs { get; set; }
|
||||
|
||||
public PartA_PrivTags PartA_PrivTags => PartA_PrivTags.ProductAndServiceUsage;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
// 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 Microsoft.PowerToys.Telemetry;
|
||||
using Microsoft.PowerToys.Telemetry.Events;
|
||||
using System.Diagnostics.Tracing;
|
||||
|
||||
namespace Microsoft.PowerLauncher.Telemetry
|
||||
{
|
||||
[EventData]
|
||||
public class LauncherWarmStateHotkeyEvent : EventBase, IEvent
|
||||
{
|
||||
public double HotkeyToVisibleTimeMs { get; set; }
|
||||
|
||||
public PartA_PrivTags PartA_PrivTags => PartA_PrivTags.ProductAndServiceUsage;
|
||||
}
|
||||
}
|
||||
@@ -28,6 +28,7 @@ namespace PowerLauncher
|
||||
private bool _isTextSetProgrammatically;
|
||||
bool _deletePressed = false;
|
||||
Timer _firstDeleteTimer = new Timer();
|
||||
bool _coldStateHotkeyPressed = false;
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -371,6 +372,17 @@ namespace PowerLauncher
|
||||
{
|
||||
SearchBox.QueryTextBox.SelectAll();
|
||||
}
|
||||
|
||||
// Log the time taken from pressing the hotkey till launcher is visible as separate events depending on if it's the first hotkey invoke or second
|
||||
if (!_coldStateHotkeyPressed)
|
||||
{
|
||||
PowerToysTelemetry.Log.WriteEvent(new LauncherColdStateHotkeyEvent() { HotkeyToVisibleTimeMs = _viewModel.GetHotkeyEventTimeMs() });
|
||||
_coldStateHotkeyPressed = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
PowerToysTelemetry.Log.WriteEvent(new LauncherWarmStateHotkeyEvent() { HotkeyToVisibleTimeMs = _viewModel.GetHotkeyEventTimeMs() });
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -46,6 +46,7 @@ namespace PowerLauncher.ViewModel
|
||||
private HotkeyManager _hotkeyManager { get; set; }
|
||||
private ushort _hotkeyHandle;
|
||||
private readonly Internationalization _translator = InternationalizationManager.Instance;
|
||||
private System.Diagnostics.Stopwatch hotkeyTimer = new System.Diagnostics.Stopwatch();
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -618,7 +619,12 @@ namespace PowerLauncher.ViewModel
|
||||
{
|
||||
if (!ShouldIgnoreHotkeys())
|
||||
{
|
||||
// If launcher window was hidden and the hotkey was pressed, start telemetry event
|
||||
if (MainWindowVisibility != Visibility.Visible)
|
||||
{
|
||||
|
||||
StartHotkeyTimer();
|
||||
}
|
||||
if (_settings.LastQueryMode == LastQueryMode.Empty)
|
||||
{
|
||||
ChangeQueryText(string.Empty);
|
||||
@@ -811,6 +817,21 @@ namespace PowerLauncher.ViewModel
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
public void StartHotkeyTimer()
|
||||
{
|
||||
hotkeyTimer.Start();
|
||||
}
|
||||
|
||||
public long GetHotkeyEventTimeMs()
|
||||
{
|
||||
hotkeyTimer.Stop();
|
||||
long recordedTime = hotkeyTimer.ElapsedMilliseconds;
|
||||
|
||||
// Reset the stopwatch and return the time elapsed
|
||||
hotkeyTimer.Reset();
|
||||
return recordedTime;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user