From 5cda4135b1b3adc52807adbbb90ab1eb7630e12e Mon Sep 17 00:00:00 2001 From: ryanbodrug-microsoft <56318517+ryanbodrug-microsoft@users.noreply.github.com> Date: Tue, 5 May 2020 08:57:01 -0700 Subject: [PATCH] Add telemetry event for when the user presses delete within the first 2 seconds of showing the launcher. --- .../launcher/PowerLauncher/MainWindow.xaml.cs | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/modules/launcher/PowerLauncher/MainWindow.xaml.cs b/src/modules/launcher/PowerLauncher/MainWindow.xaml.cs index 022082107c..89bb911eb7 100644 --- a/src/modules/launcher/PowerLauncher/MainWindow.xaml.cs +++ b/src/modules/launcher/PowerLauncher/MainWindow.xaml.cs @@ -26,6 +26,8 @@ using Windows.UI.Xaml.Data; using System.Diagnostics; using Mages.Core.Runtime.Converters; using System.Runtime.InteropServices; +using Microsoft.PowerLauncher.Telemetry; +using System.Timers; namespace PowerLauncher { @@ -41,6 +43,9 @@ namespace PowerLauncher const int ROW_HEIGHT = 75; const int MAX_LIST_HEIGHT = 300; bool isDPIChanged = false; + bool _deletePressed = false; + Timer _firstDeleteTimer = new Timer(); + #endregion @@ -51,7 +56,21 @@ namespace PowerLauncher _settings = settings; InitializeComponent(); + _firstDeleteTimer.Elapsed += CheckForFirstDelete; + _firstDeleteTimer.Interval = 1000; + } + + private void CheckForFirstDelete(object sender, ElapsedEventArgs e) + { + _firstDeleteTimer.Stop(); + if (_deletePressed) + { + PowerLauncherTelemetry.Log.WriteEvent(new FirstDeleteEvent()); + } + + } + public MainWindow() { InitializeComponent(); @@ -202,6 +221,8 @@ namespace PowerLauncher { if (Visibility == System.Windows.Visibility.Visible) { + _deletePressed = false; + _firstDeleteTimer.Start(); Activate(); UpdatePosition(); _settings.ActivateTimes++; @@ -216,6 +237,10 @@ namespace PowerLauncher _launcher.QueryTextBox.SelectAll(); } } + else + { + _firstDeleteTimer.Stop(); + } } else if(e.PropertyName == nameof(MainViewModel.SystemQueryText)) { @@ -307,6 +332,10 @@ namespace PowerLauncher _viewModel.SelectPrevPageCommand.Execute(null); e.Handled = true; } + else if( e.Key == VirtualKey.Back) + { + _deletePressed = true; + } } private void UpdateTextBoxToSelectedItem()