Skip to content

Commit

Permalink
[Telemetry] Fix show hide events on PT Run cold boot (#12796)
Browse files Browse the repository at this point in the history
* [Telemetry] fix show hide events on PT Run boot

* Fix spellchecker error
  • Loading branch information
jaimecbernardo committed Aug 18, 2021
1 parent 784a464 commit 8639740
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
1 change: 1 addition & 0 deletions src/modules/launcher/PowerLauncher/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ private void OnLoaded(object sender, RoutedEventArgs e)
ListBox.SuggestionsList.PreviewMouseLeftButtonUp += SuggestionsList_PreviewMouseLeftButtonUp;
_viewModel.PropertyChanged += ViewModel_PropertyChanged;
_viewModel.MainWindowVisibility = Visibility.Collapsed;
_viewModel.LoadedAtLeastOnce = true;

BringProcessToForeground();
}
Expand Down
24 changes: 15 additions & 9 deletions src/modules/launcher/PowerLauncher/ViewModel/MainViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,8 @@ private ResultsViewModel SelectedResults
}
}

public bool LoadedAtLeastOnce { get; set; }

private Visibility _visibility;

public Visibility MainWindowVisibility
Expand All @@ -390,16 +392,20 @@ public Visibility MainWindowVisibility
if (_visibility != value)
{
_visibility = value;
OnPropertyChanged(nameof(MainWindowVisibility));
}
if (LoadedAtLeastOnce)
{
// Don't trigger telemetry on cold boot. Must have been loaded at least once.
if (value == Visibility.Visible)
{
PowerToysTelemetry.Log.WriteEvent(new LauncherShowEvent());
}
else
{
PowerToysTelemetry.Log.WriteEvent(new LauncherHideEvent());
}
}

if (value == Visibility.Visible)
{
PowerToysTelemetry.Log.WriteEvent(new LauncherShowEvent());
}
else
{
PowerToysTelemetry.Log.WriteEvent(new LauncherHideEvent());
OnPropertyChanged(nameof(MainWindowVisibility));
}
}
}
Expand Down

0 comments on commit 8639740

Please sign in to comment.