Data diagnostics opt-in

This commit is contained in:
Stefan Markovic
2024-09-24 13:47:38 +02:00
parent 2146dff3bf
commit bea3607ea0
242 changed files with 2546 additions and 1283 deletions

View File

@@ -65,7 +65,7 @@ json::JsonObject load_general_settings()
show_new_updates_toast_notification = loaded.GetNamedBoolean(L"show_new_updates_toast_notification", true);
download_updates_automatically = loaded.GetNamedBoolean(L"download_updates_automatically", true) && check_user_is_admin();
show_whats_new_after_updates = loaded.GetNamedBoolean(L"show_whats_new_after_updates", true);
enable_experimentation = loaded.GetNamedBoolean(L"enable_experimentation",true);
enable_experimentation = loaded.GetNamedBoolean(L"enable_experimentation", true);
enable_warnings_elevated_apps = loaded.GetNamedBoolean(L"enable_warnings_elevated_apps", true);
return loaded;
@@ -241,8 +241,7 @@ void start_enabled_powertoys()
{
std::wstring disable_module_name{ static_cast<std::wstring_view>(disabled_element.Key()) };
if (powertoys_gpo_configuration.find(disable_module_name)!=powertoys_gpo_configuration.end()
&& (powertoys_gpo_configuration[disable_module_name]==powertoys_gpo::gpo_rule_configured_enabled || powertoys_gpo_configuration[disable_module_name]==powertoys_gpo::gpo_rule_configured_disabled))
if (powertoys_gpo_configuration.find(disable_module_name) != powertoys_gpo_configuration.end() && (powertoys_gpo_configuration[disable_module_name] == powertoys_gpo::gpo_rule_configured_enabled || powertoys_gpo_configuration[disable_module_name] == powertoys_gpo::gpo_rule_configured_disabled))
{
// If gpo forces the enabled setting, no need to check the setting for this PowerToy. It will be applied later on this function.
continue;

View File

@@ -14,6 +14,7 @@
#include <common/comUtils/comUtils.h>
#include <common/display/dpi_aware.h>
#include <common/Telemetry/EtwTrace/EtwTrace.h>
#include <common/notifications/notifications.h>
#include <common/notifications/dont_show_again.h>
#include <common/updating/installer.h>
@@ -303,6 +304,9 @@ toast_notification_handler_result toast_notification_handler(const std::wstring_
int WINAPI WinMain(HINSTANCE /*hInstance*/, HINSTANCE /*hPrevInstance*/, LPSTR lpCmdLine, int /*nCmdShow*/)
{
Shared::Trace::ETWTrace trace{ L"{38e8889b-9731-53f5-e901-e8a7c1753074}" };
trace.UpdateState(true);
Gdiplus::GdiplusStartupInput gpStartupInput;
ULONG_PTR gpToken;
GdiplusStartup(&gpToken, &gpStartupInput, NULL);
@@ -437,6 +441,13 @@ int WINAPI WinMain(HINSTANCE /*hInstance*/, HINSTANCE /*hPrevInstance*/, LPSTR l
openScoobe = false;
}
bool dataDiagnosticsDisabledByGpo = powertoys_gpo::getAllowDataDiagnosticsValue() == powertoys_gpo::gpo_rule_configured_disabled;
if (dataDiagnosticsDisabledByGpo)
{
Logger::info(L"Data diagnostics: Data diagnostics is disabled by GPO.");
PTSettingsHelper::save_data_diagnostics(false);
}
if (elevated && with_dont_elevate_arg && !run_elevated_setting)
{
Logger::info("Scheduling restart as non elevated");
@@ -473,6 +484,9 @@ int WINAPI WinMain(HINSTANCE /*hInstance*/, HINSTANCE /*hPrevInstance*/, LPSTR l
result = -1;
}
trace.Flush();
trace.UpdateState(false);
// We need to release the mutexes to be able to restart the application
if (msi_mutex)
{

View File

@@ -26,7 +26,6 @@
#include <unordered_map>
#include <string>
#include <set>
#include <ProjectTelemetry.h>
#include <winrt/Windows.ApplicationModel.h>
#include <winrt/Windows.Networking.Connectivity.h>

View File

@@ -107,6 +107,9 @@
<ProjectReference Include="..\common\notifications\notifications.vcxproj">
<Project>{1d5be09d-78c0-4fd7-af00-ae7c1af7c525}</Project>
</ProjectReference>
<ProjectReference Include="..\common\Telemetry\EtwTrace\EtwTrace.vcxproj">
<Project>{8f021b46-362b-485c-bfba-ccf83e820cbd}</Project>
</ProjectReference>
<ProjectReference Include="..\common\Themes\Themes.vcxproj">
<Project>{98537082-0fdb-40de-abd8-0dc5a4269bab}</Project>
</ProjectReference>

View File

@@ -6,6 +6,7 @@
#include "powertoy_module.h"
#include <common/interop/two_way_pipe_message_ipc.h>
#include <common/interop/shared_constants.h>
#include "tray_icon.h"
#include "general_settings.h"
#include "restart_elevated.h"
@@ -34,6 +35,7 @@ TwoWayPipeMessageIPC* current_settings_ipc = NULL;
std::mutex ipc_mutex;
std::atomic_bool g_isLaunchInProgress = false;
std::atomic_bool isUpdateCheckThreadRunning = false;
HANDLE g_terminateSettingsEvent = CreateEventW(nullptr, false, false, CommonSharedConstants::TERMINATE_SETTINGS_SHARED_EVENT);
json::JsonObject get_power_toys_settings()
{
@@ -622,9 +624,11 @@ void close_settings_window()
{
if (g_settings_process_id != 0)
{
SetEvent(g_terminateSettingsEvent);
wil::unique_handle proc{ OpenProcess(PROCESS_TERMINATE, false, g_settings_process_id) };
if (proc)
{
WaitForSingleObject(proc.get(), 1000);
TerminateProcess(proc.get(), 0);
}
}

View File

@@ -3,6 +3,8 @@
#include "general_settings.h"
#include <common/Telemetry/TraceBase.h>
TRACELOGGING_DEFINE_PROVIDER(
g_hProvider,
"Microsoft.PowerToys",
@@ -10,26 +12,17 @@ TRACELOGGING_DEFINE_PROVIDER(
(0x38e8889b, 0x9731, 0x53f5, 0xe9, 0x01, 0xe8, 0xa7, 0xc1, 0x75, 0x30, 0x74),
TraceLoggingOptionProjectTelemetry());
void Trace::RegisterProvider()
{
TraceLoggingRegister(g_hProvider);
}
void Trace::UnregisterProvider()
{
TraceLoggingUnregister(g_hProvider);
}
void Trace::EventLaunch(const std::wstring& versionNumber, bool isProcessElevated)
{
TraceLoggingWrite(
TraceLoggingWriteWrapper(
g_hProvider,
"Runner_Launch",
TraceLoggingWideString(versionNumber.c_str(), "Version"),
TraceLoggingBoolean(isProcessElevated, "Elevated"),
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
TraceLoggingBoolean(TRUE, "UTCReplace_AppSessionGuid"),
TraceLoggingKeyword(PROJECT_KEYWORD_MEASURE));
TraceLoggingKeyword(PROJECT_KEYWORD_MEASURE),
TraceLoggingEventTag(MICROSOFT_EVENTTAG_DROP_PII));
}
void Trace::SettingsChanged(const GeneralSettings& settings)
@@ -48,7 +41,7 @@ void Trace::SettingsChanged(const GeneralSettings& settings)
}
}
TraceLoggingWrite(
TraceLoggingWriteWrapper(
g_hProvider,
"GeneralSettingsChanged",
TraceLoggingBoolean(settings.isStartupEnabled, "RunAtStartup"),
@@ -61,5 +54,6 @@ void Trace::SettingsChanged(const GeneralSettings& settings)
TraceLoggingWideString(settings.theme.c_str(), "Theme"),
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
TraceLoggingBoolean(TRUE, "UTCReplace_AppSessionGuid"),
TraceLoggingKeyword(PROJECT_KEYWORD_MEASURE));
TraceLoggingKeyword(PROJECT_KEYWORD_MEASURE),
TraceLoggingEventTag(MICROSOFT_EVENTTAG_DROP_PII));
}

View File

@@ -1,12 +1,12 @@
#pragma once
#include <common/Telemetry/TraceBase.h>
struct GeneralSettings;
class Trace
class Trace : public telemetry::TraceBase
{
public:
static void RegisterProvider();
static void UnregisterProvider();
static void EventLaunch(const std::wstring& versionNumber, bool isProcessElevated);
static void SettingsChanged(const GeneralSettings& settings);
};