mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-03 17:56:44 +02:00
[General]Add an option for telemetry opt-in and visualization(#34078)
* Data diagnostics opt-in
* [c++] Drop DROP_PII flag
* Bump telemtry package to 2.0.2
* Drop DropPii from custom actions
* Cleanup
* Do not start manually C# EtwTrace. FZ engine exit event.
* ImageResizer, PowerRename, FileLocksmith prev handlers
* Revert C# handlers exe logging
* Revert "Revert C# handlers exe logging"
This reverts commit 4c75a3953b.
* Do not recreate EtwTrace
* consume package
* xaml formatting
* Fix deps.json audit
* Update telem package paths
* Address PR comments
* Fix AdvancedPaste close on PT close
* Override etl file name for explorer loaded dlls
Start/stop tracer when needed for explorer loaded dlls to prevent explorer overload
* Fix setting desc
* Fix missing events
* Add infobar to restart when enable data viewing
* Flush on timer every 30s
* [Settings] Update View Data diagnostic description text
[New+] Add tracer
* Show Restart info bar for both enable/disable data viewer
* Fix newplus
* Fix stuck on restart and terminate AdvPaste exe on destroy()
* [Installer] Add tracer
* Address PR comment
* Add missing tracers
* Exclude etw dir from BugReport
* Fix bad merge
* [Hosts] Proper exit on initial dialog
* [OOBE] Make Data diagnostic setting visible without scroll
* [OOBE] Add hiperlynk to open general settings
* Disable data view on disabling data diagnostics
* Don't disable View data button
* Fix disabling data viewing
* Add missing dot
* Revert formatting
This commit is contained in:
@@ -137,24 +137,32 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
||||
|
||||
public void ModuleEnabledChangedOnSettingsPage()
|
||||
{
|
||||
ActiveModules.Clear();
|
||||
DisabledModules.Clear();
|
||||
generalSettingsConfig = _settingsRepository.SettingsConfig;
|
||||
foreach (DashboardListItem item in _allModules)
|
||||
try
|
||||
{
|
||||
item.IsEnabled = ModuleHelper.GetIsModuleEnabled(generalSettingsConfig, item.Tag);
|
||||
if (item.IsEnabled)
|
||||
{
|
||||
ActiveModules.Add(item);
|
||||
}
|
||||
else
|
||||
{
|
||||
DisabledModules.Add(item);
|
||||
}
|
||||
}
|
||||
ActiveModules.Clear();
|
||||
DisabledModules.Clear();
|
||||
|
||||
OnPropertyChanged(nameof(ActiveModules));
|
||||
OnPropertyChanged(nameof(DisabledModules));
|
||||
generalSettingsConfig = _settingsRepository.SettingsConfig;
|
||||
foreach (DashboardListItem item in _allModules)
|
||||
{
|
||||
item.IsEnabled = ModuleHelper.GetIsModuleEnabled(generalSettingsConfig, item.Tag);
|
||||
if (item.IsEnabled)
|
||||
{
|
||||
ActiveModules.Add(item);
|
||||
}
|
||||
else
|
||||
{
|
||||
DisabledModules.Add(item);
|
||||
}
|
||||
}
|
||||
|
||||
OnPropertyChanged(nameof(ActiveModules));
|
||||
OnPropertyChanged(nameof(DisabledModules));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.LogError($"Updating active/disabled modules list failed: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
private ObservableCollection<DashboardModuleItem> GetModuleItems(ModuleType moduleType)
|
||||
|
||||
@@ -16,11 +16,13 @@ using System.Threading.Tasks;
|
||||
|
||||
using global::PowerToys.GPOWrapper;
|
||||
using ManagedCommon;
|
||||
using Microsoft.PowerToys.Settings.UI.Helpers;
|
||||
using Microsoft.PowerToys.Settings.UI.Library;
|
||||
using Microsoft.PowerToys.Settings.UI.Library.Helpers;
|
||||
using Microsoft.PowerToys.Settings.UI.Library.Interfaces;
|
||||
using Microsoft.PowerToys.Settings.UI.Library.Utilities;
|
||||
using Microsoft.PowerToys.Settings.UI.Library.ViewModels.Commands;
|
||||
using Microsoft.PowerToys.Telemetry;
|
||||
|
||||
namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
||||
{
|
||||
@@ -143,12 +145,29 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
||||
_autoDownloadUpdatesIsGpoDisabled = GPOWrapper.GetDisableAutomaticUpdateDownloadValue() == GpoRuleConfigured.Enabled;
|
||||
_experimentationIsGpoDisallowed = GPOWrapper.GetAllowExperimentationValue() == GpoRuleConfigured.Disabled;
|
||||
_showWhatsNewAfterUpdatesIsGpoDisabled = GPOWrapper.GetDisableShowWhatsNewAfterUpdatesValue() == GpoRuleConfigured.Enabled;
|
||||
_enableDataDiagnosticsIsGpoDisallowed = GPOWrapper.GetAllowDataDiagnosticsValue() == GpoRuleConfigured.Disabled;
|
||||
|
||||
if (_enableDataDiagnosticsIsGpoDisallowed)
|
||||
{
|
||||
_enableDataDiagnostics = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
_enableDataDiagnostics = DataDiagnosticsSettings.GetEnabledValue();
|
||||
}
|
||||
|
||||
_enableViewDataDiagnostics = DataDiagnosticsSettings.GetViewEnabledValue();
|
||||
_enableViewDataDiagnosticsOnLoad = _enableViewDataDiagnostics;
|
||||
|
||||
if (dispatcherAction != null)
|
||||
{
|
||||
_fileWatcher = Helper.GetFileWatcher(string.Empty, UpdatingSettings.SettingsFile, dispatcherAction);
|
||||
}
|
||||
|
||||
// Diagnostic data retention policy
|
||||
string etwDirPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Microsoft\\PowerToys\\etw");
|
||||
DeleteDiagnosticDataOlderThan28Days(etwDirPath);
|
||||
|
||||
InitializeLanguages();
|
||||
}
|
||||
|
||||
@@ -196,6 +215,11 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
||||
private bool _showWhatsNewAfterUpdatesIsGpoDisabled;
|
||||
private bool _enableExperimentation;
|
||||
private bool _experimentationIsGpoDisallowed;
|
||||
private bool _enableDataDiagnostics;
|
||||
private bool _enableDataDiagnosticsIsGpoDisallowed;
|
||||
private bool _enableViewDataDiagnostics;
|
||||
private bool _enableViewDataDiagnosticsOnLoad;
|
||||
private bool _viewDiagnosticDataViewerChanged;
|
||||
|
||||
private UpdatingSettings.UpdatingState _updatingState = UpdatingSettings.UpdatingState.UpToDate;
|
||||
private string _newAvailableVersion = string.Empty;
|
||||
@@ -429,11 +453,74 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
||||
}
|
||||
}
|
||||
|
||||
public bool EnableDataDiagnostics
|
||||
{
|
||||
get
|
||||
{
|
||||
return _enableDataDiagnostics;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (_enableDataDiagnostics != value)
|
||||
{
|
||||
_enableDataDiagnostics = value;
|
||||
|
||||
if (_enableDataDiagnostics == false)
|
||||
{
|
||||
EnableViewDataDiagnostics = false;
|
||||
}
|
||||
|
||||
DataDiagnosticsSettings.SetEnabledValue(_enableDataDiagnostics);
|
||||
NotifyPropertyChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool ViewDiagnosticDataViewerChanged
|
||||
{
|
||||
get => _viewDiagnosticDataViewerChanged;
|
||||
}
|
||||
|
||||
public bool EnableViewDataDiagnostics
|
||||
{
|
||||
get
|
||||
{
|
||||
return _enableViewDataDiagnostics;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (_enableViewDataDiagnostics != value)
|
||||
{
|
||||
_enableViewDataDiagnostics = value;
|
||||
|
||||
if (_enableViewDataDiagnostics != _enableViewDataDiagnosticsOnLoad)
|
||||
{
|
||||
_viewDiagnosticDataViewerChanged = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
_viewDiagnosticDataViewerChanged = false;
|
||||
}
|
||||
|
||||
DataDiagnosticsSettings.SetViewEnabledValue(_enableViewDataDiagnostics);
|
||||
OnPropertyChanged(nameof(EnableViewDataDiagnostics));
|
||||
OnPropertyChanged(nameof(ViewDiagnosticDataViewerChanged));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsExperimentationGpoDisallowed
|
||||
{
|
||||
get => _experimentationIsGpoDisallowed;
|
||||
}
|
||||
|
||||
public bool IsDataDiagnosticsGPOManaged
|
||||
{
|
||||
get => _enableDataDiagnosticsIsGpoDisallowed;
|
||||
}
|
||||
|
||||
public string SettingsBackupAndRestoreDir
|
||||
{
|
||||
get
|
||||
@@ -1129,5 +1216,54 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
||||
|
||||
SendConfigMSG(outsettings.ToString());
|
||||
}
|
||||
|
||||
internal void RefreshSettingsOnExternalChange()
|
||||
{
|
||||
EnableDataDiagnostics = DataDiagnosticsSettings.GetEnabledValue();
|
||||
|
||||
NotifyPropertyChanged(nameof(EnableDataDiagnostics));
|
||||
}
|
||||
|
||||
// Per retention policy
|
||||
private void DeleteDiagnosticDataOlderThan28Days(string etwDirPath)
|
||||
{
|
||||
if (!Directory.Exists(etwDirPath))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var directoryInfo = new DirectoryInfo(etwDirPath);
|
||||
var cutoffDate = DateTime.Now.AddDays(-28);
|
||||
|
||||
foreach (var file in directoryInfo.GetFiles())
|
||||
{
|
||||
if (file.LastWriteTime < cutoffDate)
|
||||
{
|
||||
try
|
||||
{
|
||||
file.Delete();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.LogError($"Failed to delete file: {file.FullName}. Error: {ex.Message}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal void ViewDiagnosticData()
|
||||
{
|
||||
string etwDirPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Microsoft\\PowerToys\\etw");
|
||||
string tracerptPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Windows), "system32");
|
||||
|
||||
ETLConverter converter = new ETLConverter(etwDirPath, tracerptPath);
|
||||
Task.Run(() => converter.ConvertDiagnosticsETLsAsync()).Wait();
|
||||
|
||||
if (Directory.Exists(etwDirPath))
|
||||
{
|
||||
// Open etw dir in FileExplorer
|
||||
Process.Start("explorer.exe", etwDirPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user