From e29e8ca0a3fe534dcb8ae642fd08f1b85567ed4c Mon Sep 17 00:00:00 2001 From: ryanbodrug-microsoft <56318517+ryanbodrug-microsoft@users.noreply.github.com> Date: Tue, 5 May 2020 09:02:06 -0700 Subject: [PATCH] Add launcher telemetry for show / hide, and query (elapsed time, num chars, num results). --- .../launcher/Wox/ViewModel/MainViewModel.cs | 30 ++++++++++++++++++- src/modules/launcher/Wox/Wox.csproj | 1 + 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/src/modules/launcher/Wox/ViewModel/MainViewModel.cs b/src/modules/launcher/Wox/ViewModel/MainViewModel.cs index 0d9039bb9c..5483ddfb29 100644 --- a/src/modules/launcher/Wox/ViewModel/MainViewModel.cs +++ b/src/modules/launcher/Wox/ViewModel/MainViewModel.cs @@ -17,6 +17,7 @@ using Wox.Infrastructure.Hotkey; using Wox.Infrastructure.Storage; using Wox.Infrastructure.UserSettings; using Wox.Plugin; +using Microsoft.PowerLauncher.Telemetry; using Wox.Storage; namespace Wox.ViewModel @@ -303,7 +304,22 @@ namespace Wox.ViewModel public Visibility ProgressBarVisibility { get; set; } - public Visibility MainWindowVisibility { get; set; } + private Visibility _visibility = Visibility.Collapsed; + public Visibility MainWindowVisibility { + get { return _visibility; } + set { + _visibility = value; + if(value == Visibility.Visible) + { + PowerLauncherTelemetry.Log.WriteEvent(new ShowEvent()); + } + else + { + PowerLauncherTelemetry.Log.WriteEvent(new HideEvent()); + } + + } + } public ICommand EscCommand { get; set; } public ICommand SelectNextItemCommand { get; set; } @@ -380,6 +396,8 @@ namespace Wox.ViewModel { if (!string.IsNullOrEmpty(QueryText)) { + var queryTimer = new System.Diagnostics.Stopwatch(); + queryTimer.Start(); _updateSource?.Cancel(); var currentUpdateSource = new CancellationTokenSource(); _updateSource = currentUpdateSource; @@ -435,6 +453,16 @@ namespace Wox.ViewModel { // update to hidden if this is still the current query ProgressBarVisibility = Visibility.Hidden; } + + queryTimer.Stop(); + var queryEvent = new QueryEvent() + { + QueryTimeMs = queryTimer.ElapsedMilliseconds, + NumResults = Results.Results.Count, + QueryLength = query.RawQuery.Length + }; + PowerLauncherTelemetry.Log.WriteEvent(queryEvent); + }, currentCancellationToken); } } diff --git a/src/modules/launcher/Wox/Wox.csproj b/src/modules/launcher/Wox/Wox.csproj index f3bca0db1b..9a78adbf0c 100644 --- a/src/modules/launcher/Wox/Wox.csproj +++ b/src/modules/launcher/Wox/Wox.csproj @@ -76,6 +76,7 @@ +