diff --git a/src/common/ManagedTelemetry/Telemetry/PowerToysTelemetry.cs b/src/common/ManagedTelemetry/Telemetry/PowerToysTelemetry.cs
index 62baa201df4..0be07c60938 100644
--- a/src/common/ManagedTelemetry/Telemetry/PowerToysTelemetry.cs
+++ b/src/common/ManagedTelemetry/Telemetry/PowerToysTelemetry.cs
@@ -40,7 +40,7 @@ private static bool IsDataDiagnosticsEnabled()
object registryValue = null;
try
{
- registryValue = Registry.GetValue(DataDiagnosticsRegistryKey, DataDiagnosticsRegistryValueName, false);
+ registryValue = Registry.GetValue(DataDiagnosticsRegistryKey, DataDiagnosticsRegistryValueName, 0);
}
catch
{
diff --git a/src/settings-ui/Settings.UI/Helpers/DataDiagnostics.cs b/src/settings-ui/Settings.UI/Helpers/DataDiagnostics.cs
index a999405762f..0067ded22b4 100644
--- a/src/settings-ui/Settings.UI/Helpers/DataDiagnostics.cs
+++ b/src/settings-ui/Settings.UI/Helpers/DataDiagnostics.cs
@@ -12,13 +12,14 @@ public static class DataDiagnostics
{
private static readonly string DataDiagnosticsRegistryKey = @"HKEY_CURRENT_USER\Software\Classes\PowerToys\";
private static readonly string DataDiagnosticsRegistryValueName = @"AllowDataDiagnostics";
+ private static readonly string DataDiagnosticsDataDiagnosticsUserActionRegistryValueName = @"DataDiagnosticsUserAction";
public static bool GetValue()
{
object registryValue = null;
try
{
- registryValue = Registry.GetValue(DataDiagnosticsRegistryKey, DataDiagnosticsRegistryValueName, false);
+ registryValue = Registry.GetValue(DataDiagnosticsRegistryKey, DataDiagnosticsRegistryValueName, 0);
}
catch
{
@@ -43,5 +44,36 @@ public static void SetValue(bool value)
Logger.LogError($"Failed to set the Data Diagnostics value in the registry: {ex.Message}");
}
}
+
+ public static bool GetUserActionValue()
+ {
+ object registryValue = null;
+ try
+ {
+ registryValue = Registry.GetValue(DataDiagnosticsRegistryKey, DataDiagnosticsDataDiagnosticsUserActionRegistryValueName, 0);
+ }
+ catch
+ {
+ }
+
+ if (registryValue is not null)
+ {
+ return (int)registryValue == 1 ? true : false;
+ }
+
+ return false;
+ }
+
+ public static void SetUserActionValue(bool value)
+ {
+ try
+ {
+ Registry.SetValue(DataDiagnosticsRegistryKey, DataDiagnosticsDataDiagnosticsUserActionRegistryValueName, value ? 1 : 0);
+ }
+ catch (Exception ex)
+ {
+ Logger.LogError($"Failed to set the Data Diagnostics user action value in the registry: {ex.Message}");
+ }
+ }
}
}
diff --git a/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/OobeWhatsNew.xaml b/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/OobeWhatsNew.xaml
index f84b6a4b5f8..b0ea91103d4 100644
--- a/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/OobeWhatsNew.xaml
+++ b/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/OobeWhatsNew.xaml
@@ -6,6 +6,8 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:tk7controls="using:CommunityToolkit.WinUI.UI.Controls"
+ xmlns:tkcontrols="using:CommunityToolkit.WinUI.Controls"
+ xmlns:ui="using:CommunityToolkit.WinUI"
Loaded="Page_Loaded"
mc:Ignorable="d">
@@ -17,27 +19,39 @@
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
+
+
+
+
+
+
+
GetIsDataDiagnosticsInfoBarEnabled();
+ public bool ShowDataDiagnosticsInfoBar => GetShowDataDiagnosticsInfoBar();
///
/// Initializes a new instance of the class.
@@ -60,7 +61,7 @@ public OobeWhatsNew()
DataContext = ViewModel;
}
- private bool GetIsDataDiagnosticsInfoBarEnabled()
+ private bool GetShowDataDiagnosticsInfoBar()
{
var isDataDiagnosticsGpoDisallowed = GPOWrapper.GetAllowDataDiagnosticsValue() == GpoRuleConfigured.Disabled;
@@ -69,6 +70,13 @@ private bool GetIsDataDiagnosticsInfoBarEnabled()
return false;
}
+ bool userActed = DataDiagnostics.GetUserActionValue();
+
+ if (userActed)
+ {
+ return false;
+ }
+
bool registryValue = DataDiagnostics.GetValue();
bool isFirstRunAfterUpdate = (App.Current as Microsoft.PowerToys.Settings.UI.App).ShowScoobe;
@@ -194,20 +202,64 @@ private void ReleaseNotesMarkdown_LinkClicked(object sender, LinkClickedEventArg
}
}
- private void EnableDataDiagnostics_Click(object sender, Microsoft.UI.Xaml.RoutedEventArgs e)
+ private void DataDiagnostics_InfoBar_YesNo_Click(object sender, Microsoft.UI.Xaml.RoutedEventArgs e)
{
+ string commandArg = string.Empty;
+ if (sender is Button senderBtn)
+ {
+ commandArg = senderBtn.CommandParameter.ToString();
+ }
+ else if (sender is HyperlinkButton senderLink)
+ {
+ commandArg = senderLink.CommandParameter.ToString();
+ }
+
+ if (string.IsNullOrEmpty(commandArg))
+ {
+ return;
+ }
+
// Update UI
- DataDiagnosticsInfoBar.Title = ResourceLoaderInstance.ResourceLoader.GetString("Oobe_WhatsNew_DataDiagnostics_Enabled_InfoBar_Title");
- DataDiagnosticsInfoBarDesc.Content = ResourceLoaderInstance.ResourceLoader.GetString("Oobe_WhatsNew_DataDiagnostics_Enabled_InfoBar_Desc");
- DataDiagnosticsInfoBar.ActionButton.Visibility = Microsoft.UI.Xaml.Visibility.Collapsed;
+ if (commandArg == "Yes")
+ {
+ WhatsNewDataDiagnosticsInfoBar.Header = ResourceLoaderInstance.ResourceLoader.GetString("Oobe_WhatsNew_DataDiagnostics_Yes_Click_InfoBar_Title");
+ }
+ else
+ {
+ WhatsNewDataDiagnosticsInfoBar.Header = ResourceLoaderInstance.ResourceLoader.GetString("Oobe_WhatsNew_DataDiagnostics_No_Click_InfoBar_Title");
+ }
+
+ WhatsNewDataDiagnosticsInfoBarDescText.Visibility = Microsoft.UI.Xaml.Visibility.Collapsed;
+ WhatsNewDataDiagnosticsInfoBarDescTextYesClicked.Visibility = Microsoft.UI.Xaml.Visibility.Visible;
+ DataDiagnosticsButtonYes.Visibility = Microsoft.UI.Xaml.Visibility.Collapsed;
+ DataDiagnosticsButtonNo.Visibility = Microsoft.UI.Xaml.Visibility.Collapsed;
+
+ // Set Data Diagnostics registry values
+ if (commandArg == "Yes")
+ {
+ DataDiagnostics.SetValue(true);
+ }
+ else
+ {
+ DataDiagnostics.SetValue(false);
+ }
- // Enable Data Diagnostics
- DataDiagnostics.SetValue(true);
+ DataDiagnostics.SetUserActionValue(true);
this.DispatcherQueue.TryEnqueue(Microsoft.UI.Dispatching.DispatcherQueuePriority.Normal, () =>
{
ShellPage.ShellHandler?.SignalGeneralDataUpdate();
});
}
+
+ private void DataDiagnostics_InfoBar_Close_Click(object sender, Microsoft.UI.Xaml.RoutedEventArgs e)
+ {
+ WhatsNewDataDiagnosticsInfoBar.Visibility = Microsoft.UI.Xaml.Visibility.Collapsed;
+ }
+
+ private void DataDiagnostics_OpenSettings_Click(Microsoft.UI.Xaml.Documents.Hyperlink sender, Microsoft.UI.Xaml.Documents.HyperlinkClickEventArgs args)
+ {
+ Common.UI.SettingsDeepLink.OpenSettings(Common.UI.SettingsDeepLink.SettingsWindow.Overview, true);
+ }
}
}
diff --git a/src/settings-ui/Settings.UI/Strings/en-us/Resources.resw b/src/settings-ui/Settings.UI/Strings/en-us/Resources.resw
index ce77a4b197b..970391486c6 100644
--- a/src/settings-ui/Settings.UI/Strings/en-us/Resources.resw
+++ b/src/settings-ui/Settings.UI/Strings/en-us/Resources.resw
@@ -2102,20 +2102,32 @@ Take a moment to preview the various utilities listed or view our comprehensive
Helps inform bug fixes, performance, and product decisions
-
+
Turn on diagnostic data to help us improve PowerToys?
-
+
PowerToys diagnostic data is completely optional.
Enable
-
+
Thank you for helping to make PowerToys better!
-
- You can change this at any time from settings.
+
+ Preference updated.
+
+
+ You can change this at any time from
+
+
+ settings.
+
+
+ Yes
+
+
+ No
Release notes