Add telemetry event for when the user presses delete within the first 2 seconds of showing the launcher.

This commit is contained in:
ryanbodrug-microsoft 2020-05-05 08:57:01 -07:00
parent 221e153f4c
commit 5cda4135b1

View File

@ -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()