mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-02-24 04:00:02 +01: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:
@@ -8,6 +8,8 @@ namespace PTSettingsHelper
|
||||
constexpr inline const wchar_t* last_version_run_filename = L"last_version_run.json";
|
||||
constexpr inline const wchar_t* opened_at_first_launch_json_field_name = L"openedAtFirstLaunch";
|
||||
constexpr inline const wchar_t* last_version_json_field_name = L"last_version";
|
||||
constexpr inline const wchar_t* DataDiagnosticsRegKey = L"Software\\Classes\\PowerToys";
|
||||
constexpr inline const wchar_t* DataDiagnosticsRegValueName = L"AllowDataDiagnostics";
|
||||
|
||||
std::wstring get_root_save_folder_location()
|
||||
{
|
||||
@@ -25,7 +27,7 @@ namespace PTSettingsHelper
|
||||
return result;
|
||||
}
|
||||
|
||||
std::wstring get_local_low_folder_location()
|
||||
std::wstring get_local_low_folder_location()
|
||||
{
|
||||
PWSTR local_app_path;
|
||||
winrt::check_hresult(SHGetKnownFolderPath(FOLDERID_LocalAppDataLow, 0, NULL, &local_app_path));
|
||||
@@ -112,7 +114,7 @@ namespace PTSettingsHelper
|
||||
bool opened = saved_settings->GetNamedBoolean(opened_at_first_launch_json_field_name, false);
|
||||
return opened;
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -124,12 +126,11 @@ namespace PTSettingsHelper
|
||||
json::JsonObject obj;
|
||||
obj.SetNamedValue(opened_at_first_launch_json_field_name, json::value(true));
|
||||
|
||||
json::to_file(oobePath.c_str(), obj);
|
||||
json::to_file(oobePath.c_str(), obj);
|
||||
}
|
||||
|
||||
std::wstring get_last_version_run()
|
||||
{
|
||||
|
||||
std::filesystem::path lastVersionRunPath(PTSettingsHelper::get_root_save_folder_location());
|
||||
lastVersionRunPath = lastVersionRunPath.append(last_version_run_filename);
|
||||
if (std::filesystem::exists(lastVersionRunPath))
|
||||
@@ -157,4 +158,29 @@ namespace PTSettingsHelper
|
||||
json::to_file(lastVersionRunPath.c_str(), obj);
|
||||
}
|
||||
|
||||
void save_data_diagnostics(bool enabled)
|
||||
{
|
||||
HKEY key{};
|
||||
if (RegCreateKeyExW(HKEY_CURRENT_USER,
|
||||
DataDiagnosticsRegKey,
|
||||
0,
|
||||
nullptr,
|
||||
REG_OPTION_NON_VOLATILE,
|
||||
KEY_ALL_ACCESS,
|
||||
nullptr,
|
||||
&key,
|
||||
nullptr) != ERROR_SUCCESS)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
const bool value = enabled;
|
||||
const size_t buf_size = sizeof(bool);
|
||||
if (RegSetValueExW(key, DataDiagnosticsRegValueName, 0, REG_QWORD, reinterpret_cast<const BYTE*>(&value), buf_size) != ERROR_SUCCESS)
|
||||
{
|
||||
RegCloseKey(key);
|
||||
return;
|
||||
}
|
||||
RegCloseKey(key);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user