Data diagnostics opt-in

This commit is contained in:
Stefan Markovic 2024-07-26 15:36:52 +02:00
parent 3a080f5efd
commit 90e36eaf19
139 changed files with 816 additions and 654 deletions

View File

@ -298,6 +298,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Telemetry", "Telemetry", "{
src\common\Telemetry\ProjectTelemetry.h = src\common\Telemetry\ProjectTelemetry.h
src\common\Telemetry\TelemetryBase.cs = src\common\Telemetry\TelemetryBase.cs
src\common\Telemetry\TraceLoggingDefines.h = src\common\Telemetry\TraceLoggingDefines.h
src\common\Telemetry\TraceBase.h = src\common\Telemetry\TraceBase.h
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Common.UI", "src\common\Common.UI\Common.UI.csproj", "{C3A17DCA-217B-462C-BB0C-BE086AF80081}"

View File

@ -38,6 +38,48 @@ const DWORD USERNAME_LEN = UNLEN + 1; // User Name + '\0'
static const wchar_t* POWERTOYS_EXE_COMPONENT = L"{A2C66D91-3485-4D00-B04D-91844E6B345B}";
static const wchar_t* POWERTOYS_UPGRADE_CODE = L"{42B84BF7-5FBF-473B-9C8B-049DC16F7708}";
constexpr inline const wchar_t* DataDiagnosticsRegKey = L"Software\\Classes\\PowerToys";
constexpr inline const wchar_t* DataDiagnosticsRegValueName = L"AllowDataDiagnostics";
#define TraceLoggingWriteWrapper(provider, eventName, ...) \
if (isDataDiagnosticEnabled()) \
{ \
TraceLoggingWrite(provider, eventName, __VA_ARGS__); \
}
inline bool isDataDiagnosticEnabled()
{
HKEY key{};
if (RegOpenKeyExW(HKEY_CURRENT_USER,
DataDiagnosticsRegKey,
0,
KEY_READ,
&key) != ERROR_SUCCESS)
{
return false;
}
bool isDataDiagnosticsEnabled;
DWORD boolSize = static_cast<DWORD>(sizeof(bool));
if (RegGetValueW(
key,
DataDiagnosticsRegValueName,
nullptr,
RRF_RT_REG_QWORD,
nullptr,
&isDataDiagnosticsEnabled,
&boolSize) != ERROR_SUCCESS)
{
RegCloseKey(key);
return false;
}
RegCloseKey(key);
return isDataDiagnosticsEnabled;
}
HRESULT getInstallFolder(MSIHANDLE hInstall, std::wstring& installationDir)
{
DWORD len = 0;
@ -793,7 +835,7 @@ UINT __stdcall TelemetryLogInstallSuccessCA(MSIHANDLE hInstall)
hr = WcaInitialize(hInstall, "TelemetryLogInstallSuccessCA");
ExitOnFailure(hr, "Failed to initialize");
TraceLoggingWrite(
TraceLoggingWriteWrapper(
g_hProvider,
"Install_Success",
TraceLoggingWideString(get_product_version().c_str(), "Version"),
@ -814,7 +856,7 @@ UINT __stdcall TelemetryLogInstallCancelCA(MSIHANDLE hInstall)
hr = WcaInitialize(hInstall, "TelemetryLogInstallCancelCA");
ExitOnFailure(hr, "Failed to initialize");
TraceLoggingWrite(
TraceLoggingWriteWrapper(
g_hProvider,
"Install_Cancel",
TraceLoggingWideString(get_product_version().c_str(), "Version"),
@ -835,7 +877,7 @@ UINT __stdcall TelemetryLogInstallFailCA(MSIHANDLE hInstall)
hr = WcaInitialize(hInstall, "TelemetryLogInstallFailCA");
ExitOnFailure(hr, "Failed to initialize");
TraceLoggingWrite(
TraceLoggingWriteWrapper(
g_hProvider,
"Install_Fail",
TraceLoggingWideString(get_product_version().c_str(), "Version"),
@ -856,7 +898,7 @@ UINT __stdcall TelemetryLogUninstallSuccessCA(MSIHANDLE hInstall)
hr = WcaInitialize(hInstall, "TelemetryLogUninstallSuccessCA");
ExitOnFailure(hr, "Failed to initialize");
TraceLoggingWrite(
TraceLoggingWriteWrapper(
g_hProvider,
"UnInstall_Success",
TraceLoggingWideString(get_product_version().c_str(), "Version"),
@ -877,7 +919,7 @@ UINT __stdcall TelemetryLogUninstallCancelCA(MSIHANDLE hInstall)
hr = WcaInitialize(hInstall, "TelemetryLogUninstallCancelCA");
ExitOnFailure(hr, "Failed to initialize");
TraceLoggingWrite(
TraceLoggingWriteWrapper(
g_hProvider,
"UnInstall_Cancel",
TraceLoggingWideString(get_product_version().c_str(), "Version"),
@ -898,7 +940,7 @@ UINT __stdcall TelemetryLogUninstallFailCA(MSIHANDLE hInstall)
hr = WcaInitialize(hInstall, "TelemetryLogUninstallFailCA");
ExitOnFailure(hr, "Failed to initialize");
TraceLoggingWrite(
TraceLoggingWriteWrapper(
g_hProvider,
"UnInstall_Fail",
TraceLoggingWideString(get_product_version().c_str(), "Version"),
@ -919,7 +961,7 @@ UINT __stdcall TelemetryLogRepairCancelCA(MSIHANDLE hInstall)
hr = WcaInitialize(hInstall, "TelemetryLogRepairCancelCA");
ExitOnFailure(hr, "Failed to initialize");
TraceLoggingWrite(
TraceLoggingWriteWrapper(
g_hProvider,
"Repair_Cancel",
TraceLoggingWideString(get_product_version().c_str(), "Version"),
@ -940,7 +982,7 @@ UINT __stdcall TelemetryLogRepairFailCA(MSIHANDLE hInstall)
hr = WcaInitialize(hInstall, "TelemetryLogRepairFailCA");
ExitOnFailure(hr, "Failed to initialize");
TraceLoggingWrite(
TraceLoggingWriteWrapper(
g_hProvider,
"Repair_Fail",
TraceLoggingWideString(get_product_version().c_str(), "Version"),

View File

@ -212,4 +212,8 @@ namespace winrt::PowerToys::GPOWrapper::implementation
// Convert std::wstring to winrt::hstring
return to_hstring(rules.c_str());
}
GpoRuleConfigured GPOWrapper::GetAllowDataDiagnosticsValue()
{
return static_cast<GpoRuleConfigured>(powertoys_gpo::getAllowDataDiagnosticsValue());
}
}

View File

@ -58,6 +58,7 @@ namespace winrt::PowerToys::GPOWrapper::implementation
static GpoRuleConfigured GetConfiguredMwbValidateRemoteIpValue();
static GpoRuleConfigured GetConfiguredMwbDisableUserDefinedIpMappingRulesValue();
static winrt::hstring GPOWrapper::GetConfiguredMwbPolicyDefinedIpMappingRules();
static GpoRuleConfigured GetAllowDataDiagnosticsValue();
};
}

View File

@ -62,6 +62,7 @@ namespace PowerToys
static GpoRuleConfigured GetConfiguredMwbValidateRemoteIpValue();
static GpoRuleConfigured GetConfiguredMwbDisableUserDefinedIpMappingRulesValue();
static String GetConfiguredMwbPolicyDefinedIpMappingRules();
static GpoRuleConfigured GetAllowDataDiagnosticsValue();
}
}
}

View File

@ -3,7 +3,7 @@
<Import Project="..\..\..\Version.props" />
<PropertyGroup>
<TargetFramework>net8.0-windows</TargetFramework>
<RuntimeIdentifiers>win-x64;win-arm64</RuntimeIdentifiers>
<RuntimeIdentifiers>win-x64;win-arm64</RuntimeIdentifiers>
<Version>$(Version).0</Version>
<Authors>Microsoft Corporation</Authors>
<Product>PowerToys</Product>
@ -14,5 +14,4 @@
<ItemGroup>
<Compile Include="..\..\Telemetry\TelemetryBase.cs" Link="TelemetryBase.cs" />
</ItemGroup>
</Project>

View File

@ -2,8 +2,10 @@
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using System.Diagnostics.Tracing;
using Microsoft.PowerToys.Telemetry.Events;
using Microsoft.Win32;
namespace Microsoft.PowerToys.Telemetry
{
@ -12,6 +14,9 @@ namespace Microsoft.PowerToys.Telemetry
/// </summary>
public class PowerToysTelemetry : TelemetryBase
{
private static readonly string DataDiagnosticsRegistryKey = @"HKEY_CURRENT_USER\Software\Classes\PowerToys\";
private static readonly string DataDiagnosticsRegistryValueName = @"AllowDataDiagnostics";
/// <summary>
/// Name for ETW event.
/// </summary>
@ -30,20 +35,42 @@ namespace Microsoft.PowerToys.Telemetry
/// </summary>
public static PowerToysTelemetry Log { get; } = new PowerToysTelemetry();
private static bool IsDataDiagnosticsEnabled()
{
object registryValue = null;
try
{
registryValue = Registry.GetValue(DataDiagnosticsRegistryKey, DataDiagnosticsRegistryValueName, false);
}
catch
{
}
if (registryValue is not null)
{
return (int)registryValue == 1 ? true : false;
}
return false;
}
/// <summary>
/// Publishes ETW event when an action is triggered on
/// </summary>
public void WriteEvent<T>(T telemetryEvent)
where T : EventBase, IEvent
{
this.Write<T>(
telemetryEvent.EventName,
new EventSourceOptions()
{
Keywords = ProjectKeywordMeasure,
Tags = ProjectTelemetryTagProductAndServicePerformance,
},
telemetryEvent);
if (IsDataDiagnosticsEnabled())
{
this.Write<T>(
telemetryEvent.EventName,
new EventSourceOptions()
{
Keywords = ProjectKeywordMeasure,
Tags = ProjectTelemetryTagProductAndServicePerformance,
},
telemetryEvent);
}
}
}
}

View File

@ -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);
}
}

View File

@ -24,4 +24,6 @@ namespace PTSettingsHelper
void save_oobe_opened_state();
std::wstring get_last_version_run();
void save_last_version_run(const std::wstring& version);
void save_data_diagnostics(bool enabled);
}

View File

@ -0,0 +1,63 @@
#pragma once
#include "ProjectTelemetry.h"
#define TraceLoggingWriteWrapper(provider, eventName, ...) \
if (IsDataDiagnosticsEnabled()) \
{ \
TraceLoggingWrite(provider, eventName, __VA_ARGS__); \
}
namespace telemetry
{
constexpr inline const wchar_t* DataDiagnosticsRegKey = L"Software\\Classes\\PowerToys";
constexpr inline const wchar_t* DataDiagnosticsRegValueName = L"AllowDataDiagnostics";
class TraceBase
{
public:
static void RegisterProvider()
{
TraceLoggingRegister(g_hProvider);
}
static void UnregisterProvider()
{
TraceLoggingUnregister(g_hProvider);
}
static bool IsDataDiagnosticsEnabled()
{
HKEY key{};
if (RegOpenKeyExW(HKEY_CURRENT_USER,
DataDiagnosticsRegKey,
0,
KEY_READ,
&key) != ERROR_SUCCESS)
{
return false;
}
bool isDataDiagnosticsEnabled;
DWORD boolSize = static_cast<DWORD>(sizeof(bool));
if (RegGetValueW(
key,
DataDiagnosticsRegValueName,
nullptr,
RRF_RT_REG_QWORD,
nullptr,
&isDataDiagnosticsEnabled,
&boolSize) != ERROR_SUCCESS)
{
RegCloseKey(key);
return false;
}
RegCloseKey(key);
return isDataDiagnosticsEnabled;
}
};
} // namespace telemetry

View File

@ -70,6 +70,7 @@ namespace powertoys_gpo {
// The registry value names for other PowerToys policies.
const std::wstring POLICY_ALLOW_EXPERIMENTATION = L"AllowExperimentation";
const std::wstring POLICY_ALLOW_DATA_DIAGNOSTICS = L"AllowDataDiagnostics";
const std::wstring POLICY_CONFIGURE_ENABLED_POWER_LAUNCHER_ALL_PLUGINS = L"PowerLauncherAllPluginsEnabledState";
const std::wstring POLICY_ALLOW_ADVANCED_PASTE_ONLINE_AI_MODELS = L"AllowPowerToysAdvancedPasteOnlineAIModels";
const std::wstring POLICY_MWB_CLIPBOARD_SHARING_ENABLED = L"MwbClipboardSharingEnabled";
@ -454,6 +455,11 @@ namespace powertoys_gpo {
return getConfiguredValue(POLICY_ALLOW_EXPERIMENTATION);
}
inline gpo_rule_configured_t getAllowDataDiagnosticsValue()
{
return getConfiguredValue(POLICY_ALLOW_DATA_DIAGNOSTICS);
}
inline gpo_rule_configured_t getRunPluginEnabledValue(std::string pluginID)
{
if (pluginID == "" || pluginID == " ")

View File

@ -1,11 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) Microsoft Corporation.
Licensed under the MIT License. -->
<policyDefinitions xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" revision="1.11" schemaVersion="1.0" xmlns="http://schemas.microsoft.com/GroupPolicy/2006/07/PolicyDefinitions">
<policyDefinitions xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" revision="1.12" schemaVersion="1.0" xmlns="http://schemas.microsoft.com/GroupPolicy/2006/07/PolicyDefinitions">
<policyNamespaces>
<target prefix="powertoys" namespace="Microsoft.Policies.PowerToys" />
</policyNamespaces>
<resources minRequiredRevision="1.11"/><!-- Last changed with PowerToys v0.83.0 -->
<resources minRequiredRevision="1.12"/><!-- Last changed with PowerToys v0.84.0 -->
<supportedOn>
<definitions>
<definition name="SUPPORTED_POWERTOYS_0_64_0" displayName="$(string.SUPPORTED_POWERTOYS_0_64_0)"/>
@ -20,6 +20,7 @@
<definition name="SUPPORTED_POWERTOYS_0_81_0" displayName="$(string.SUPPORTED_POWERTOYS_0_81_0)"/>
<definition name="SUPPORTED_POWERTOYS_0_81_1" displayName="$(string.SUPPORTED_POWERTOYS_0_81_1)"/>
<definition name="SUPPORTED_POWERTOYS_0_83_0" displayName="$(string.SUPPORTED_POWERTOYS_0_83_0)"/>
<definition name="SUPPORTED_POWERTOYS_0_84_0" displayName="$(string.SUPPORTED_POWERTOYS_0_84_0)"/>
</definitions>
</supportedOn>
<categories>
@ -484,6 +485,16 @@
<decimal value="0" />
</disabledValue>
</policy>
<policy name="AllowDiagnosticData" class="Both" displayName="$(string.AllowDiagnosticData)" explainText="$(string.AllowDiagnosticDataDescription)" key="Software\Policies\PowerToys" valueName="AllowDataDiagnostics">
<parentCategory ref="PowerToys" />
<supportedOn ref="SUPPORTED_POWERTOYS_0_84_0" />
<enabledValue>
<decimal value="1" />
</enabledValue>
<disabledValue>
<decimal value="0" />
</disabledValue>
</policy>
<policy name="PowerToysRunAllPluginsEnabledState" class="Both" displayName="$(string.PowerToysRunAllPluginsEnabledState)" explainText="$(string.PowerToysRunAllPluginsEnabledStateDescription)" key="Software\Policies\PowerToys" valueName="PowerLauncherAllPluginsEnabledState">
<parentCategory ref="PowerToysRun" />
<supportedOn ref="SUPPORTED_POWERTOYS_0_75_0" />

View File

@ -25,6 +25,7 @@
<string id="SUPPORTED_POWERTOYS_0_81_0">PowerToys version 0.81.0 or later</string>
<string id="SUPPORTED_POWERTOYS_0_81_1">PowerToys version 0.81.1 or later</string>
<string id="SUPPORTED_POWERTOYS_0_83_0">PowerToys version 0.83.0 or later</string>
<string id="SUPPORTED_POWERTOYS_0_84_0">PowerToys version 0.84.0 or later</string>
<string id="ConfigureAllUtilityGlobalEnabledStateDescription">This policy configures the enabled state for all PowerToys utilities.
@ -98,6 +99,12 @@ If disabled or not configured, the user can control this in the settings of Powe
If this setting is enabled or not configured, the user can control experimentation in the PowerToys settings menu.
If this setting is disabled, experimentation is not allowed.
</string>
<string id="AllowDiagnosticDataDescription">This policy configures whether sending of PowerToys diagnostic data is allowed. With diagnostic data sending allowed the user helps inform bug fixes, performance and improvements.
If this setting is enabled or not configured, the user can control diagnostic data sending in the PowerToys settings menu.
If this setting is disabled, diagnostic data sending is not allowed.
</string>
<string id="PowerToysRunAllPluginsEnabledStateDescription">This policy configures the enabled state for all PowerToys Run plugins. All plugins will have the same state.
@ -244,6 +251,8 @@ If you disable or don't configure this policy, no predefined rules are applied.
<string id="MwbValidateRemoteIp">Validate remote machine IP Address</string>
<string id="MwbDisableUserDefinedIpMappingRules">Disable user defined IP Address mapping rules</string>
<string id="MwbPolicyDefinedIpMappingRules">Predefined IP Address mapping rules</string>
<string id="AllowPowerToysAdvancedPasteOnlineAIModels">Advanced Paste: Allow using online AI models</string>
<string id="AllowDiagnosticData">Allow sending diagnostic data</string>
</stringTable>
<presentationTable>

View File

@ -2,7 +2,6 @@
#include <windows.h>
#include <winrt/Windows.Foundation.h>
#include <winrt/Windows.Foundation.Collections.h>
#include <ProjectTelemetry.h>
#include <shellapi.h>
#include <Shlwapi.h>
#include <filesystem>

View File

@ -8,20 +8,10 @@ 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);
}
// Log if the user has AdvancedPaste enabled or disabled
void Trace::AdvancedPaste_Enable(const bool enabled) noexcept
{
TraceLoggingWrite(
TraceLoggingWriteWrapper(
g_hProvider,
"AdvancedPaste_EnableAdvancedPaste",
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
@ -32,7 +22,7 @@ void Trace::AdvancedPaste_Enable(const bool enabled) noexcept
// Log if the user has invoked AdvancedPaste
void Trace::AdvancedPaste_Invoked(std::wstring mode) noexcept
{
TraceLoggingWrite(
TraceLoggingWriteWrapper(
g_hProvider,
"AdvancedPaste_InvokeAdvancedPaste",
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
@ -43,7 +33,7 @@ void Trace::AdvancedPaste_Invoked(std::wstring mode) noexcept
// Log if an error occurs in AdvancedPaste
void Trace::AdvancedPaste_Error(const DWORD errorCode, std::wstring errorMessage, std::wstring methodName) noexcept
{
TraceLoggingWrite(
TraceLoggingWriteWrapper(
g_hProvider,
"AdvancedPaste_Error",
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
@ -88,7 +78,7 @@ void Trace::AdvancedPaste_SettingsTelemetry(const PowertoyModuleIface::Hotkey& p
std::wstring(pasteJsonHotkey.alt ? L"Alt + " : L"") +
std::wstring(L"VK ") + std::to_wstring(pasteJsonHotkey.key);
TraceLoggingWrite(
TraceLoggingWriteWrapper(
g_hProvider,
"AdvancedPaste_Settings",
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),

View File

@ -1,12 +1,10 @@
#pragma once
#include <common/Telemetry/TraceBase.h>
#include <interface/powertoy_module_interface.h>
class Trace
class Trace : public telemetry::TraceBase
{
public:
static void RegisterProvider();
static void UnregisterProvider();
// Log if the user has AdvancedPaste enabled or disabled
static void AdvancedPaste_Enable(const bool enabled) noexcept;

View File

@ -74,7 +74,6 @@
#include "WindowRectUtil.h"
// PowerToys
#include <ProjectTelemetry.h>
#include <common/logger/logger.h>
// Application resources

View File

@ -11,19 +11,9 @@ TRACELOGGING_DEFINE_PROVIDER(
(0x38e8889b, 0x9731, 0x53f5, 0xe9, 0x01, 0xe8, 0xa7, 0xc1, 0x75, 0x30, 0x74),
TraceLoggingOptionProjectTelemetry());
void Trace::RegisterProvider() noexcept
{
TraceLoggingRegister(g_hProvider);
}
void Trace::UnregisterProvider() noexcept
{
TraceLoggingUnregister(g_hProvider);
}
void Trace::CropAndLock::Enable(bool enabled) noexcept
{
TraceLoggingWrite(
TraceLoggingWriteWrapper(
g_hProvider,
"CropAndLock_EnableCropAndLock",
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
@ -33,7 +23,7 @@ void Trace::CropAndLock::Enable(bool enabled) noexcept
void Trace::CropAndLock::ActivateReparent() noexcept
{
TraceLoggingWrite(
TraceLoggingWriteWrapper(
g_hProvider,
"CropAndLock_ActivateReparent",
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
@ -42,7 +32,7 @@ void Trace::CropAndLock::ActivateReparent() noexcept
void Trace::CropAndLock::ActivateThumbnail() noexcept
{
TraceLoggingWrite(
TraceLoggingWriteWrapper(
g_hProvider,
"CropAndLock_ActivateThumbnail",
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
@ -51,7 +41,7 @@ void Trace::CropAndLock::ActivateThumbnail() noexcept
void Trace::CropAndLock::CreateReparentWindow() noexcept
{
TraceLoggingWrite(
TraceLoggingWriteWrapper(
g_hProvider,
"CropAndLock_CreateReparentWindow",
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
@ -60,7 +50,7 @@ void Trace::CropAndLock::CreateReparentWindow() noexcept
void Trace::CropAndLock::CreateThumbnailWindow() noexcept
{
TraceLoggingWrite(
TraceLoggingWriteWrapper(
g_hProvider,
"CropAndLock_CreateThumbnailWindow",
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
@ -84,7 +74,7 @@ void Trace::CropAndLock::SettingsTelemetry(PowertoyModuleIface::Hotkey& reparent
std::wstring(thumbnailHotkey.alt ? L"Alt + " : L"") +
std::wstring(L"VK ") + std::to_wstring(thumbnailHotkey.key);
TraceLoggingWrite(
TraceLoggingWriteWrapper(
g_hProvider,
"CropAndLock_Settings",
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),

View File

@ -1,13 +1,12 @@
#pragma once
#include <common/Telemetry/TraceBase.h>
#include <modules/interface/powertoy_module_interface.h>
class Trace
{
public:
static void RegisterProvider() noexcept;
static void UnregisterProvider() noexcept;
class CropAndLock
class CropAndLock : public telemetry::TraceBase
{
public:
static void Enable(bool enabled) noexcept;

View File

@ -40,13 +40,13 @@ BOOL APIENTRY DllMain( HMODULE /*hModule*/,
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
Trace::RegisterProvider();
Trace::CropAndLock::RegisterProvider();
break;
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
break;
case DLL_PROCESS_DETACH:
Trace::UnregisterProvider();
Trace::CropAndLock::UnregisterProvider();
break;
}
return TRUE;

View File

@ -6,7 +6,5 @@
#include <winrt/base.h>
#include <winrt/Windows.Foundation.h>
#include <winrt/Windows.Foundation.Collections.h>
#include <ProjectTelemetry.h>
#include <TraceLoggingActivity.h>
#include <wil\common.h>
#include <wil\result.h>

View File

@ -10,7 +10,6 @@
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
// Windows Header Files
#include <windows.h>
#include <ProjectTelemetry.h>
#include <optional>
#include <string>

View File

@ -1,6 +1,8 @@
#include "pch.h"
#include "trace.h"
#include <common/Telemetry/TraceBase.h>
TRACELOGGING_DEFINE_PROVIDER(
g_hProvider,
"Microsoft.PowerToys",
@ -8,20 +10,10 @@ TRACELOGGING_DEFINE_PROVIDER(
(0x38e8889b, 0x9731, 0x53f5, 0xe9, 0x01, 0xe8, 0xa7, 0xc1, 0x75, 0x30, 0x74),
TraceLoggingOptionProjectTelemetry());
void Trace::RegisterProvider() noexcept
{
TraceLoggingRegister(g_hProvider);
}
void Trace::UnregisterProvider() noexcept
{
TraceLoggingUnregister(g_hProvider);
}
// Log if the user has Environment Variables enabled or disabled
void Trace::EnableEnvironmentVariables(const bool enabled) noexcept
{
TraceLoggingWrite(
TraceLoggingWriteWrapper(
g_hProvider,
"EnvironmentVariables_EnableEnvironmentVariables",
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
@ -32,7 +24,7 @@ void Trace::EnableEnvironmentVariables(const bool enabled) noexcept
// Log that the user tried to activate the editor
void Trace::ActivateEnvironmentVariables() noexcept
{
TraceLoggingWrite(
TraceLoggingWriteWrapper(
g_hProvider,
"EnvironmentVariables_Activate",
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),

View File

@ -1,11 +1,10 @@
#pragma once
class Trace
#include <common/Telemetry/TraceBase.h>
class Trace : public telemetry::TraceBase
{
public:
static void RegisterProvider() noexcept;
static void UnregisterProvider() noexcept;
// Log if the user has EnvironmentVariables enabled or disabled
static void EnableEnvironmentVariables(const bool enabled) noexcept;

View File

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project ToolsVersion="4.0"
xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>

View File

@ -1,7 +1,8 @@
#include "pch.h"
#include "Trace.h"
#include "../common/Telemetry/ProjectTelemetry.h"
#include <common/Telemetry/TraceBase.h>
TRACELOGGING_DEFINE_PROVIDER(
g_hProvider,
@ -10,19 +11,9 @@ TRACELOGGING_DEFINE_PROVIDER(
(0x38e8889b, 0x9731, 0x53f5, 0xe9, 0x01, 0xe8, 0xa7, 0xc1, 0x75, 0x30, 0x74),
TraceLoggingOptionProjectTelemetry());
void Trace::RegisterProvider() noexcept
{
TraceLoggingRegister(g_hProvider);
}
void Trace::UnregisterProvider() noexcept
{
TraceLoggingUnregister(g_hProvider);
}
void Trace::EnableFileLocksmith(_In_ bool enabled) noexcept
{
TraceLoggingWrite(
TraceLoggingWriteWrapper(
g_hProvider,
"FileLocksmith_EnableFileLocksmith",
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
@ -32,7 +23,7 @@ void Trace::EnableFileLocksmith(_In_ bool enabled) noexcept
void Trace::Invoked() noexcept
{
TraceLoggingWrite(
TraceLoggingWriteWrapper(
g_hProvider,
"FileLocksmith_Invoked",
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
@ -41,7 +32,7 @@ void Trace::Invoked() noexcept
void Trace::InvokedRet(_In_ HRESULT hr) noexcept
{
TraceLoggingWrite(
TraceLoggingWriteWrapper(
g_hProvider,
"FileLocksmith_InvokedRet",
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
@ -51,7 +42,7 @@ void Trace::InvokedRet(_In_ HRESULT hr) noexcept
void Trace::QueryContextMenuError(_In_ HRESULT hr) noexcept
{
TraceLoggingWrite(
TraceLoggingWriteWrapper(
g_hProvider,
"FileLocksmith_QueryContextMenuError",
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),

View File

@ -2,11 +2,11 @@
#include "pch.h"
class Trace
#include <common/Telemetry/TraceBase.h>
class Trace : public telemetry::TraceBase
{
public:
static void RegisterProvider() noexcept;
static void UnregisterProvider() noexcept;
static void EnableFileLocksmith(_In_ bool enabled) noexcept;
static void Invoked() noexcept;
static void InvokedRet(_In_ HRESULT hr) noexcept;

View File

@ -2,4 +2,3 @@
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <ProjectTelemetry.h>

View File

@ -1,6 +1,8 @@
#include "pch.h"
#include "trace.h"
#include <common/Telemetry/TraceBase.h>
TRACELOGGING_DEFINE_PROVIDER(
g_hProvider,
"Microsoft.PowerToys",
@ -8,20 +10,10 @@ TRACELOGGING_DEFINE_PROVIDER(
(0x38e8889b, 0x9731, 0x53f5, 0xe9, 0x01, 0xe8, 0xa7, 0xc1, 0x75, 0x30, 0x74),
TraceLoggingOptionProjectTelemetry());
void Trace::RegisterProvider() noexcept
{
TraceLoggingRegister(g_hProvider);
}
void Trace::UnregisterProvider() noexcept
{
TraceLoggingUnregister(g_hProvider);
}
// Log if the user has HostsFileEditor enabled or disabled
void Trace::EnableHostsFileEditor(const bool enabled) noexcept
{
TraceLoggingWrite(
TraceLoggingWriteWrapper(
g_hProvider,
"HostsFileEditor_EnableHostsFileEditor",
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
@ -32,7 +24,7 @@ void Trace::EnableHostsFileEditor(const bool enabled) noexcept
// Log that the user tried to activate the editor
void Trace::ActivateEditor() noexcept
{
TraceLoggingWrite(
TraceLoggingWriteWrapper(
g_hProvider,
"HostsFileEditor_Activate",
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),

View File

@ -1,11 +1,10 @@
#pragma once
class Trace
#include <common/Telemetry/TraceBase.h>
class Trace : public telemetry::TraceBase
{
public:
static void RegisterProvider() noexcept;
static void UnregisterProvider() noexcept;
// Log if the user has HostsFileEditor enabled or disabled
static void EnableHostsFileEditor(const bool enabled) noexcept;

View File

@ -30,7 +30,6 @@
#include <string_view>
#include <chrono>
#include <stdio.h>
#include <ProjectTelemetry.h>
// Undefine GetCurrentTime macro to prevent
// conflict with Storyboard::GetCurrentTime

View File

@ -9,6 +9,5 @@
#include <thread>
#include <winrt/Windows.Foundation.Collections.h>
#include <ProjectTelemetry.h>
#include <common/SettingsAPI/settings_helpers.h>
#include <common/logger/logger.h>

View File

@ -1,6 +1,8 @@
#include "pch.h"
#include "trace.h"
#include <common/Telemetry/TraceBase.h>
TRACELOGGING_DEFINE_PROVIDER(
g_hProvider,
"Microsoft.PowerToys",
@ -8,19 +10,9 @@ TRACELOGGING_DEFINE_PROVIDER(
(0x38e8889b, 0x9731, 0x53f5, 0xe9, 0x01, 0xe8, 0xa7, 0xc1, 0x75, 0x30, 0x74),
TraceLoggingOptionProjectTelemetry());
void Trace::RegisterProvider() noexcept
{
TraceLoggingRegister(g_hProvider);
}
void Trace::UnregisterProvider() noexcept
{
TraceLoggingUnregister(g_hProvider);
}
void Trace::EnableMeasureTool(const bool enabled) noexcept
{
TraceLoggingWrite(
TraceLoggingWriteWrapper(
g_hProvider,
"MeasureTool_EnableMeasureTool",
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
@ -30,7 +22,7 @@ void Trace::EnableMeasureTool(const bool enabled) noexcept
void Trace::BoundsToolActivated() noexcept
{
TraceLoggingWrite(
TraceLoggingWriteWrapper(
g_hProvider,
"MeasureTool_BoundsToolActivated",
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
@ -39,7 +31,7 @@ void Trace::BoundsToolActivated() noexcept
void Trace::MeasureToolActivated() noexcept
{
TraceLoggingWrite(
TraceLoggingWriteWrapper(
g_hProvider,
"MeasureTool_MeasureToolActivated",
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),

View File

@ -1,11 +1,10 @@
#pragma once
class Trace
#include <common/Telemetry/TraceBase.h>
class Trace : public telemetry::TraceBase
{
public:
static void RegisterProvider() noexcept;
static void UnregisterProvider() noexcept;
static void EnableMeasureTool(const bool enabled) noexcept;
static void BoundsToolActivated() noexcept;

View File

@ -15,6 +15,5 @@
#endif
#include <winrt/Windows.Foundation.Collections.h>
#include <ProjectTelemetry.h>
#include <common/SettingsAPI/settings_helpers.h>
#include <common/logger/logger.h>

View File

@ -1,6 +1,8 @@
#include "pch.h"
#include "trace.h"
#include <common/Telemetry/TraceBase.h>
TRACELOGGING_DEFINE_PROVIDER(
g_hProvider,
"Microsoft.PowerToys",
@ -8,20 +10,10 @@ TRACELOGGING_DEFINE_PROVIDER(
(0x38e8889b, 0x9731, 0x53f5, 0xe9, 0x01, 0xe8, 0xa7, 0xc1, 0x75, 0x30, 0x74),
TraceLoggingOptionProjectTelemetry());
void Trace::RegisterProvider() noexcept
{
TraceLoggingRegister(g_hProvider);
}
void Trace::UnregisterProvider() noexcept
{
TraceLoggingUnregister(g_hProvider);
}
// Log if the user has FindMyMouse enabled or disabled
void Trace::EnableFindMyMouse(const bool enabled) noexcept
{
TraceLoggingWrite(
TraceLoggingWriteWrapper(
g_hProvider,
"FindMyMouse_EnableFindMyMouse",
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
@ -32,7 +24,7 @@ void Trace::EnableFindMyMouse(const bool enabled) noexcept
// Log that the user activated the module by focusing the mouse pointer
void Trace::MousePointerFocused() noexcept
{
TraceLoggingWrite(
TraceLoggingWriteWrapper(
g_hProvider,
"FindMyMouse_MousePointerFocused",
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),

View File

@ -1,11 +1,10 @@
#pragma once
class Trace
#include <common/Telemetry/TraceBase.h>
class Trace : public telemetry::TraceBase
{
public:
static void RegisterProvider() noexcept;
static void UnregisterProvider() noexcept;
// Log if the user has FindMyMouse enabled or disabled
static void EnableFindMyMouse(const bool enabled) noexcept;

View File

@ -16,7 +16,6 @@
#include <winrt/Windows.Foundation.Collections.h>
#endif
#include <ProjectTelemetry.h>
#include <common/SettingsAPI/settings_helpers.h>
#include <common/logger/logger.h>
#include <common/utils/logger_helper.h>

View File

@ -1,6 +1,8 @@
#include "pch.h"
#include "trace.h"
#include <common/Telemetry/TraceBase.h>
TRACELOGGING_DEFINE_PROVIDER(
g_hProvider,
"Microsoft.PowerToys",
@ -8,20 +10,10 @@ TRACELOGGING_DEFINE_PROVIDER(
(0x38e8889b, 0x9731, 0x53f5, 0xe9, 0x01, 0xe8, 0xa7, 0xc1, 0x75, 0x30, 0x74),
TraceLoggingOptionProjectTelemetry());
void Trace::RegisterProvider() noexcept
{
TraceLoggingRegister(g_hProvider);
}
void Trace::UnregisterProvider() noexcept
{
TraceLoggingUnregister(g_hProvider);
}
// Log if the user has MouseHighlighter enabled or disabled
void Trace::EnableMouseHighlighter(const bool enabled) noexcept
{
TraceLoggingWrite(
TraceLoggingWriteWrapper(
g_hProvider,
"MouseHighlighter_EnableMouseHighlighter",
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
@ -32,7 +24,7 @@ void Trace::EnableMouseHighlighter(const bool enabled) noexcept
// Log that the user activated the module by starting a highlighting session
void Trace::StartHighlightingSession() noexcept
{
TraceLoggingWrite(
TraceLoggingWriteWrapper(
g_hProvider,
"MouseHighlighter_StartHighlightingSession",
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),

View File

@ -1,11 +1,10 @@
#pragma once
class Trace
#include <common/Telemetry/TraceBase.h>
class Trace : public telemetry::TraceBase
{
public:
static void RegisterProvider() noexcept;
static void UnregisterProvider() noexcept;
// Log if the user has MouseHighlighter enabled or disabled
static void EnableMouseHighlighter(const bool enabled) noexcept;

View File

@ -5,6 +5,5 @@
#include <shellapi.h>
//#include <common/common.h>
#include <ProjectTelemetry.h>
#include <common/SettingsAPI/settings_helpers.h>
#include <common/logger/logger.h>

View File

@ -1,6 +1,8 @@
#include "pch.h"
#include "trace.h"
#include <common/Telemetry/TraceBase.h>
TRACELOGGING_DEFINE_PROVIDER(
g_hProvider,
"Microsoft.PowerToys",
@ -8,19 +10,9 @@ 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::EnableJumpTool(const bool enabled) noexcept
{
TraceLoggingWrite(
TraceLoggingWriteWrapper(
g_hProvider,
"MouseJump_EnableJumpTool",
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
@ -30,7 +22,7 @@ void Trace::EnableJumpTool(const bool enabled) noexcept
void Trace::InvokeJumpTool() noexcept
{
TraceLoggingWrite(
TraceLoggingWriteWrapper(
g_hProvider,
"MouseJump_InvokeJumpTool",
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),

View File

@ -1,11 +1,10 @@
#pragma once
class Trace
#include <common/Telemetry/TraceBase.h>
class Trace : public telemetry::TraceBase
{
public:
static void RegisterProvider();
static void UnregisterProvider();
static void EnableJumpTool(const bool enabled) noexcept;
static void InvokeJumpTool() noexcept;

View File

@ -9,7 +9,6 @@
#include <winrt/Windows.Foundation.Collections.h>
#include <winrt/Windows.System.h>
#include <winrt/Windows.UI.Composition.Desktop.h>
#include <ProjectTelemetry.h>
#include <thread>
#include <common/SettingsAPI/settings_helpers.h>
#include <common/logger/logger.h>

View File

@ -1,6 +1,8 @@
#include "pch.h"
#include "trace.h"
#include <common/Telemetry/TraceBase.h>
TRACELOGGING_DEFINE_PROVIDER(
g_hProvider,
"Microsoft.PowerToys",
@ -8,20 +10,10 @@ TRACELOGGING_DEFINE_PROVIDER(
(0x38e8889b, 0x9731, 0x53f5, 0xe9, 0x01, 0xe8, 0xa7, 0xc1, 0x75, 0x30, 0x74),
TraceLoggingOptionProjectTelemetry());
void Trace::RegisterProvider() noexcept
{
TraceLoggingRegister(g_hProvider);
}
void Trace::UnregisterProvider() noexcept
{
TraceLoggingUnregister(g_hProvider);
}
// Log if the user has MousePointerCrosshairs enabled or disabled
void Trace::EnableMousePointerCrosshairs(const bool enabled) noexcept
{
TraceLoggingWrite(
TraceLoggingWriteWrapper(
g_hProvider,
"MousePointerCrosshairs_EnableMousePointerCrosshairs",
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
@ -32,7 +24,7 @@ void Trace::EnableMousePointerCrosshairs(const bool enabled) noexcept
// Log that the user activated the module by having the crosshairs be drawn
void Trace::StartDrawingCrosshairs() noexcept
{
TraceLoggingWrite(
TraceLoggingWriteWrapper(
g_hProvider,
"MousePointerCrosshairs_StartDrawingCrosshairs",
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),

View File

@ -1,11 +1,10 @@
#pragma once
class Trace
#include <common/Telemetry/TraceBase.h>
class Trace : public telemetry::TraceBase
{
public:
static void RegisterProvider() noexcept;
static void UnregisterProvider() noexcept;
// Log if the user has MousePointerCrosshairs enabled or disabled
static void EnableMousePointerCrosshairs(const bool enabled) noexcept;

View File

@ -22,13 +22,13 @@ BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID /*lpRese
{
case DLL_PROCESS_ATTACH:
g_hInst_MouseWithoutBorders = hModule;
Trace::RegisterProvider();
Trace::MouseWithoutBorders::RegisterProvider();
break;
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
break;
case DLL_PROCESS_DETACH:
Trace::UnregisterProvider();
Trace::MouseWithoutBorders::UnregisterProvider();
break;
}
return TRUE;

View File

@ -9,8 +9,6 @@
#include <winrt/base.h>
#include <winrt/Windows.Foundation.h>
#include <winrt/Windows.Foundation.Collections.h>
#include <ProjectTelemetry.h>
#include <TraceLoggingActivity.h>
#include <wil\common.h>
#include <wil\result.h>

View File

@ -1,6 +1,8 @@
#include "pch.h"
#include "trace.h"
#include <common/Telemetry/TraceBase.h>
// Telemetry strings should not be localized.
#define LoggingProviderKey "Microsoft.PowerToys"
@ -14,19 +16,9 @@ TRACELOGGING_DEFINE_PROVIDER(
(0x38e8889b, 0x9731, 0x53f5, 0xe9, 0x01, 0xe8, 0xa7, 0xc1, 0x75, 0x30, 0x74),
TraceLoggingOptionProjectTelemetry());
void Trace::RegisterProvider() noexcept
{
TraceLoggingRegister(g_hProvider);
}
void Trace::UnregisterProvider() noexcept
{
TraceLoggingUnregister(g_hProvider);
}
void Trace::MouseWithoutBorders::Enable(bool enabled) noexcept
{
TraceLoggingWrite(
TraceLoggingWriteWrapper(
g_hProvider,
EventEnableMouseWithoutBordersKey,
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
@ -36,7 +28,7 @@ void Trace::MouseWithoutBorders::Enable(bool enabled) noexcept
void Trace::MouseWithoutBorders::ToggleServiceRegistration(bool enabled) noexcept
{
TraceLoggingWrite(
TraceLoggingWriteWrapper(
g_hProvider,
"MouseWithoutBorders_ToggleServiceRegistration",
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
@ -46,7 +38,7 @@ void Trace::MouseWithoutBorders::ToggleServiceRegistration(bool enabled) noexcep
void Trace::MouseWithoutBorders::Activate() noexcept
{
TraceLoggingWrite(
TraceLoggingWriteWrapper(
g_hProvider,
"MouseWithoutBorders_Activate",
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
@ -56,7 +48,7 @@ void Trace::MouseWithoutBorders::Activate() noexcept
// Log that the user tried to activate the editor
void Trace::MouseWithoutBorders::AddFirewallRule() noexcept
{
TraceLoggingWrite(
TraceLoggingWriteWrapper(
g_hProvider,
"MouseWithoutBorders_AddFirewallRule",
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),

View File

@ -1,12 +1,11 @@
#pragma once
#include <common/Telemetry/TraceBase.h>
class Trace
{
public:
static void RegisterProvider() noexcept;
static void UnregisterProvider() noexcept;
class MouseWithoutBorders
class MouseWithoutBorders : public telemetry::TraceBase
{
public:
static void Enable(bool enabled) noexcept;

View File

@ -2,6 +2,5 @@
#include <windows.h>
#include <winrt/Windows.Foundation.h>
#include <winrt/Windows.Foundation.Collections.h>
#include <ProjectTelemetry.h>
#include <shellapi.h>
#include <Shlwapi.h>

View File

@ -1,6 +1,8 @@
#include "pch.h"
#include "trace.h"
#include <common/Telemetry/TraceBase.h>
TRACELOGGING_DEFINE_PROVIDER(
g_hProvider,
"Microsoft.PowerToys",
@ -8,20 +10,10 @@ 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);
}
// Log if the user has PowerOCR enabled or disabled
void Trace::EnablePowerOCR(const bool enabled) noexcept
{
TraceLoggingWrite(
TraceLoggingWriteWrapper(
g_hProvider,
"PowerOCR_EnablePowerOCR",
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),

View File

@ -1,10 +1,10 @@
#pragma once
class Trace
#include <common/Telemetry/TraceBase.h>
class Trace : public telemetry::TraceBase
{
public:
static void RegisterProvider();
static void UnregisterProvider();
// Log if the user has PowerOCR enabled or disabled
static void EnablePowerOCR(const bool enabled) noexcept;
};

View File

@ -25,6 +25,5 @@
#include <tuple>
#include <unordered_set>
#include <string>
#include <ProjectTelemetry.h>
#include <filesystem>
#include <common/logger/logger.h>

View File

@ -1,6 +1,8 @@
#include "pch.h"
#include "trace.h"
#include <common/Telemetry/TraceBase.h>
TRACELOGGING_DEFINE_PROVIDER(
g_hProvider,
"Microsoft.PowerToys",
@ -8,19 +10,9 @@ TRACELOGGING_DEFINE_PROVIDER(
(0x38e8889b, 0x9731, 0x53f5, 0xe9, 0x01, 0xe8, 0xa7, 0xc1, 0x75, 0x30, 0x74),
TraceLoggingOptionProjectTelemetry());
void Trace::RegisterProvider() noexcept
{
TraceLoggingRegister(g_hProvider);
}
void Trace::UnregisterProvider() noexcept
{
TraceLoggingUnregister(g_hProvider);
}
void Trace::SendGuideSession(const __int64 duration_ms, const wchar_t* close_type) noexcept
{
TraceLoggingWrite(
TraceLoggingWriteWrapper(
g_hProvider,
"ShortcutGuide_GuideSession",
TraceLoggingInt64(duration_ms, "DurationInMs"),
@ -32,7 +24,7 @@ void Trace::SendGuideSession(const __int64 duration_ms, const wchar_t* close_typ
void Trace::SendSettings(ShortcutGuideSettings settings) noexcept
{
TraceLoggingWrite(
TraceLoggingWriteWrapper(
g_hProvider,
"ShortcutGuide_Settings",
TraceLoggingWideString(settings.hotkey.c_str(), "Hotkey"),

View File

@ -1,11 +1,11 @@
#pragma once
#include "ShortcutGuideSettings.h"
class Trace
#include <common/Telemetry/TraceBase.h>
class Trace : public telemetry::TraceBase
{
public:
static void RegisterProvider() noexcept;
static void UnregisterProvider() noexcept;
static void SendGuideSession(const __int64 duration_ms, const wchar_t* close_type) noexcept;
static void SendSettings(ShortcutGuideSettings settings) noexcept;
};

View File

@ -2,7 +2,6 @@
#define NOMINMAX
#include <winrt/base.h>
#include <Windows.h>
#include <ProjectTelemetry.h>
#include <filesystem>
#include <common/logger/logger.h>
#include <common/utils/resources.h>

View File

@ -58,13 +58,13 @@ int WINAPI wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance,
});
}
Trace::RegisterProvider();
Trace::AlwaysOnTop::RegisterProvider();
AlwaysOnTop app(!pid.empty());
run_message_loop();
Trace::UnregisterProvider();
Trace::AlwaysOnTop::UnregisterProvider();
return 0;
}

View File

@ -4,7 +4,6 @@
#include <winrt/base.h>
#include <wil/resource.h>
#include <wil/filesystem.h>
#include <ProjectTelemetry.h>
#include <common/logger/logger.h>
#include <functional>

View File

@ -1,6 +1,8 @@
#include "pch.h"
#include "trace.h"
#include <common/Telemetry/TraceBase.h>
// Telemetry strings should not be localized.
#define LoggingProviderKey "Microsoft.PowerToys"
@ -16,19 +18,9 @@ TRACELOGGING_DEFINE_PROVIDER(
(0x38e8889b, 0x9731, 0x53f5, 0xe9, 0x01, 0xe8, 0xa7, 0xc1, 0x75, 0x30, 0x74),
TraceLoggingOptionProjectTelemetry());
void Trace::RegisterProvider() noexcept
{
TraceLoggingRegister(g_hProvider);
}
void Trace::UnregisterProvider() noexcept
{
TraceLoggingUnregister(g_hProvider);
}
void Trace::AlwaysOnTop::Enable(bool enabled) noexcept
{
TraceLoggingWrite(
TraceLoggingWriteWrapper(
g_hProvider,
EventEnableAlwaysOnTopKey,
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
@ -38,7 +30,7 @@ void Trace::AlwaysOnTop::Enable(bool enabled) noexcept
void Trace::AlwaysOnTop::PinWindow() noexcept
{
TraceLoggingWrite(
TraceLoggingWriteWrapper(
g_hProvider,
EventPinWindowKey,
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
@ -47,7 +39,7 @@ void Trace::AlwaysOnTop::PinWindow() noexcept
void Trace::AlwaysOnTop::UnpinWindow() noexcept
{
TraceLoggingWrite(
TraceLoggingWriteWrapper(
g_hProvider,
EventUnpinWindowKey,
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),

View File

@ -1,12 +1,11 @@
#pragma once
#include <common/Telemetry/TraceBase.h>
class Trace
{
public:
static void RegisterProvider() noexcept;
static void UnregisterProvider() noexcept;
class AlwaysOnTop
class AlwaysOnTop : public telemetry::TraceBase
{
public:
static void Enable(bool enabled) noexcept;

View File

@ -35,7 +35,7 @@ BOOL APIENTRY DllMain(HMODULE /*hModule*/, DWORD ul_reason_for_call, LPVOID /*lp
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
Trace::RegisterProvider();
Trace::AlwaysOnTop::RegisterProvider();
break;
case DLL_THREAD_ATTACH:
@ -43,7 +43,7 @@ BOOL APIENTRY DllMain(HMODULE /*hModule*/, DWORD ul_reason_for_call, LPVOID /*lp
break;
case DLL_PROCESS_DETACH:
Trace::UnregisterProvider();
Trace::AlwaysOnTop::UnregisterProvider();
break;
}
return TRUE;

View File

@ -5,7 +5,5 @@
#include <winrt/base.h>
#include <winrt/Windows.Foundation.h>
#include <winrt/Windows.Foundation.Collections.h>
#include <ProjectTelemetry.h>
#include <TraceLoggingActivity.h>
#include <wil\common.h>
#include <wil\result.h>

View File

@ -2,6 +2,5 @@
#include <windows.h>
#include <winrt/Windows.Foundation.h>
#include <winrt/Windows.Foundation.Collections.h>
#include <ProjectTelemetry.h>
#include <shellapi.h>
#include <Shlwapi.h>

View File

@ -1,6 +1,8 @@
#include "pch.h"
#include "trace.h"
#include <common/Telemetry/TraceBase.h>
TRACELOGGING_DEFINE_PROVIDER(
g_hProvider,
"Microsoft.PowerToys",
@ -8,20 +10,10 @@ 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);
}
// Log if the user has Awake enabled or disabled
void Trace::EnableAwake(const bool enabled) noexcept
{
TraceLoggingWrite(
TraceLoggingWriteWrapper(
g_hProvider,
"Awake_EnableAwake",
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),

View File

@ -1,11 +1,10 @@
#pragma once
class Trace
#include <common/Telemetry/TraceBase.h>
class Trace : public telemetry::TraceBase
{
public:
static void RegisterProvider();
static void UnregisterProvider();
// Log if the user has Awake enabled or disabled
static void EnableAwake(const bool enabled) noexcept;
};

View File

@ -11,6 +11,4 @@
// Windows Header Files
#include <windows.h>
#include <ProjectTelemetry.h>
#endif //PCH_H

View File

@ -1,6 +1,8 @@
#include "pch.h"
#include "trace.h"
#include <common/Telemetry/TraceBase.h>
TRACELOGGING_DEFINE_PROVIDER(
g_hProvider,
"Microsoft.PowerToys",
@ -8,20 +10,10 @@ 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);
}
// Log if the user has CmdNotFound enabled or disabled
void Trace::EnableCmdNotFoundGpo(const bool enabled) noexcept
{
TraceLoggingWrite(
TraceLoggingWriteWrapper(
g_hProvider,
"CmdNotFound_EnableCmdNotFound",
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),

View File

@ -1,11 +1,10 @@
#pragma once
class Trace
#include <common/Telemetry/TraceBase.h>
class Trace : public telemetry::TraceBase
{
public:
static void RegisterProvider();
static void UnregisterProvider();
// Log if the user has CmdNotFound enabled or disabled
static void EnableCmdNotFoundGpo(const bool enabled) noexcept;
};

View File

@ -2,6 +2,5 @@
#include <windows.h>
#include <winrt/Windows.Foundation.h>
#include <winrt/Windows.Foundation.Collections.h>
#include <ProjectTelemetry.h>
#include <shellapi.h>
#include <Shlwapi.h>

View File

@ -1,6 +1,8 @@
#include "pch.h"
#include "trace.h"
#include <common/Telemetry/TraceBase.h>
TRACELOGGING_DEFINE_PROVIDER(
g_hProvider,
"Microsoft.PowerToys",
@ -8,20 +10,10 @@ 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);
}
// Log if ColorPicker is enabled or disabled
void Trace::EnableColorPicker(const bool enabled) noexcept
{
TraceLoggingWrite(
TraceLoggingWriteWrapper(
g_hProvider,
"ColorPicker_EnableColorPicker",
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),

View File

@ -1,10 +1,10 @@
#pragma once
class Trace
#include <common/Telemetry/TraceBase.h>
class Trace : public telemetry::TraceBase
{
public:
static void RegisterProvider();
static void UnregisterProvider();
// Log if ColorPicker is enabled or disabled
static void EnableColorPicker(const bool enabled) noexcept;

View File

@ -1,7 +1,6 @@
#pragma once
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <ProjectTelemetry.h>
#include <shlwapi.h>
#include <stdexcept>
#include <winrt/base.h>

View File

@ -8,11 +8,9 @@
#include <windows.h>
#include <windowsx.h>
#include <dwmapi.h>
#include <ProjectTelemetry.h>
#include <shellapi.h>
#include <ShellScalingApi.h>
#include <strsafe.h>
#include <TraceLoggingActivity.h>
#include <wil/filesystem.h>
#include <wil/resource.h>
#include <wil/result.h>

View File

@ -10,6 +10,8 @@
#include "FancyZonesLib/FancyZonesDataTypes.h"
#include "FancyZonesLib/util.h"
#include <common/Telemetry/TraceBase.h>
// Telemetry strings should not be localized.
#define LoggingProviderKey "Microsoft.PowerToys"
@ -108,19 +110,9 @@ ZoneSetInfo GetZoneSetInfo(_In_opt_ Layout* layout, const LayoutAssignedWindows&
return info;
}
void Trace::RegisterProvider() noexcept
{
TraceLoggingRegister(g_hProvider);
}
void Trace::UnregisterProvider() noexcept
{
TraceLoggingUnregister(g_hProvider);
}
void Trace::FancyZones::EnableFancyZones(bool enabled) noexcept
{
TraceLoggingWrite(
TraceLoggingWriteWrapper(
g_hProvider,
EventEnableFancyZonesKey,
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
@ -130,7 +122,7 @@ void Trace::FancyZones::EnableFancyZones(bool enabled) noexcept
void Trace::FancyZones::OnKeyDown(DWORD vkCode, bool win, bool control, bool inMoveSize) noexcept
{
TraceLoggingWrite(
TraceLoggingWriteWrapper(
g_hProvider,
EventKeyDownKey,
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
@ -211,7 +203,7 @@ void Trace::FancyZones::DataChanged() noexcept
activeZoneSetInfo += L", custom zone data was deleted";
}
}
TraceLoggingWrite(
TraceLoggingWriteWrapper(
g_hProvider,
EventZoneSettingsChangedKey,
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
@ -226,7 +218,7 @@ void Trace::FancyZones::DataChanged() noexcept
void Trace::FancyZones::EditorLaunched(int value) noexcept
{
TraceLoggingWrite(
TraceLoggingWriteWrapper(
g_hProvider,
EventEditorLaunchKey,
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
@ -237,7 +229,7 @@ void Trace::FancyZones::EditorLaunched(int value) noexcept
// Log if an error occurs in FZ
void Trace::FancyZones::Error(const DWORD errorCode, std::wstring errorMessage, std::wstring methodName) noexcept
{
TraceLoggingWrite(
TraceLoggingWriteWrapper(
g_hProvider,
"FancyZones_Error",
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
@ -249,7 +241,7 @@ void Trace::FancyZones::Error(const DWORD errorCode, std::wstring errorMessage,
void Trace::FancyZones::QuickLayoutSwitched(bool shortcutUsed) noexcept
{
TraceLoggingWrite(
TraceLoggingWriteWrapper(
g_hProvider,
EventQuickLayoutSwitchKey,
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
@ -260,7 +252,7 @@ void Trace::FancyZones::QuickLayoutSwitched(bool shortcutUsed) noexcept
void Trace::FancyZones::SnapNewWindowIntoZone(Layout* activeLayout, const LayoutAssignedWindows& layoutWindows) noexcept
{
auto const zoneInfo = GetZoneSetInfo(activeLayout, layoutWindows);
TraceLoggingWrite(
TraceLoggingWriteWrapper(
g_hProvider,
EventSnapNewWindowIntoZone,
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
@ -273,7 +265,7 @@ void Trace::FancyZones::SnapNewWindowIntoZone(Layout* activeLayout, const Layout
void Trace::FancyZones::KeyboardSnapWindowToZone(Layout* activeLayout, const LayoutAssignedWindows& layoutWindows) noexcept
{
auto const zoneInfo = GetZoneSetInfo(activeLayout, layoutWindows);
TraceLoggingWrite(
TraceLoggingWriteWrapper(
g_hProvider,
EventKeyboardSnapWindowToZone,
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
@ -299,7 +291,7 @@ void Trace::SettingsTelemetry(const Settings& settings) noexcept
auto nextTabHotkeyStr = HotKeyToString(settings.nextTabHotkey);
auto prevTabHotkeyStr = HotKeyToString(settings.prevTabHotkey);
TraceLoggingWrite(
TraceLoggingWriteWrapper(
g_hProvider,
EventSettingsKey,
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
@ -337,7 +329,7 @@ void Trace::SettingsTelemetry(const Settings& settings) noexcept
void Trace::VirtualDesktopChanged() noexcept
{
TraceLoggingWrite(
TraceLoggingWriteWrapper(
g_hProvider,
EventDesktopChangedKey,
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
@ -346,7 +338,7 @@ void Trace::VirtualDesktopChanged() noexcept
void Trace::WorkArea::KeyUp(WPARAM wParam) noexcept
{
TraceLoggingWrite(
TraceLoggingWriteWrapper(
g_hProvider,
EventWorkAreaKeyUpKey,
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
@ -357,7 +349,7 @@ void Trace::WorkArea::KeyUp(WPARAM wParam) noexcept
void Trace::WorkArea::MoveOrResizeStarted(_In_opt_ Layout* activeLayout, const LayoutAssignedWindows& layoutWindows) noexcept
{
auto const zoneInfo = GetZoneSetInfo(activeLayout, layoutWindows);
TraceLoggingWrite(
TraceLoggingWriteWrapper(
g_hProvider,
EventMoveOrResizeStartedKey,
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
@ -370,7 +362,7 @@ void Trace::WorkArea::MoveOrResizeStarted(_In_opt_ Layout* activeLayout, const L
void Trace::WorkArea::MoveOrResizeEnd(_In_opt_ Layout* activeLayout, const LayoutAssignedWindows& layoutWindows) noexcept
{
auto const zoneInfo = GetZoneSetInfo(activeLayout, layoutWindows);
TraceLoggingWrite(
TraceLoggingWriteWrapper(
g_hProvider,
EventMoveOrResizeEndedKey,
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
@ -383,7 +375,7 @@ void Trace::WorkArea::MoveOrResizeEnd(_In_opt_ Layout* activeLayout, const Layou
void Trace::WorkArea::CycleActiveZoneSet(_In_opt_ Layout* activeLayout, const LayoutAssignedWindows& layoutWindows, InputMode mode) noexcept
{
auto const zoneInfo = GetZoneSetInfo(activeLayout, layoutWindows);
TraceLoggingWrite(
TraceLoggingWriteWrapper(
g_hProvider,
EventCycleActiveZoneSetKey,
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),

View File

@ -1,16 +1,15 @@
#pragma once
#include <common/Telemetry/TraceBase.h>
struct Settings;
class Layout;
class LayoutAssignedWindows;
class Trace
class Trace : public telemetry::TraceBase
{
public:
static void RegisterProvider() noexcept;
static void UnregisterProvider() noexcept;
class FancyZones
class FancyZones : public telemetry::TraceBase
{
public:
static void EnableFancyZones(bool enabled) noexcept;
@ -26,7 +25,7 @@ public:
static void SettingsTelemetry(const Settings& settings) noexcept;
static void VirtualDesktopChanged() noexcept;
class WorkArea
class WorkArea : public telemetry::TraceBase
{
public:
enum class InputMode

View File

@ -5,7 +5,5 @@
#include <winrt/base.h>
#include <winrt/Windows.Foundation.h>
#include <winrt/Windows.Foundation.Collections.h>
#include <ProjectTelemetry.h>
#include <TraceLoggingActivity.h>
#include <wil\common.h>
#include <wil\result.h>

View File

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project DefaultTargets="Build"
xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\..\..\..\..\packages\Microsoft.Windows.CppWinRT.2.0.240111.5\build\native\Microsoft.Windows.CppWinRT.props" Condition="Exists('..\..\..\..\..\packages\Microsoft.Windows.CppWinRT.2.0.240111.5\build\native\Microsoft.Windows.CppWinRT.props')" />
<PropertyGroup Label="Globals">
<VCProjectVersion>16.0</VCProjectVersion>
@ -83,6 +84,7 @@
<ItemGroup>
<ResourceCompile Include="UnitTests-FancyZones.rc" />
</ItemGroup>
<Import Project="..\..\..\..\..\deps\spdlog.props" />
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
<Import Project="..\..\..\..\..\packages\Microsoft.Windows.CppWinRT.2.0.240111.5\build\native\Microsoft.Windows.CppWinRT.targets" Condition="Exists('..\..\..\..\..\packages\Microsoft.Windows.CppWinRT.2.0.240111.5\build\native\Microsoft.Windows.CppWinRT.targets')" />

View File

@ -13,6 +13,4 @@
#include <string>
#include <Shlwapi.h>
#include <ProjectTelemetry.h>
#endif //PCH_H

View File

@ -1,6 +1,8 @@
#include "pch.h"
#include "trace.h"
#include <common/Telemetry/TraceBase.h>
TRACELOGGING_DEFINE_PROVIDER(
g_hProvider,
"Microsoft.PowerToys",
@ -8,19 +10,9 @@ TRACELOGGING_DEFINE_PROVIDER(
(0x38e8889b, 0x9731, 0x53f5, 0xe9, 0x01, 0xe8, 0xa7, 0xc1, 0x75, 0x30, 0x74),
TraceLoggingOptionProjectTelemetry());
void Trace::RegisterProvider() noexcept
{
TraceLoggingRegister(g_hProvider);
}
void Trace::UnregisterProvider() noexcept
{
TraceLoggingUnregister(g_hProvider);
}
void Trace::EnableImageResizer(_In_ bool enabled) noexcept
{
TraceLoggingWrite(
TraceLoggingWriteWrapper(
g_hProvider,
"ImageResizer_EnableImageResizer",
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
@ -31,7 +23,7 @@ void Trace::EnableImageResizer(_In_ bool enabled) noexcept
void Trace::Invoked() noexcept
{
TraceLoggingWrite(
TraceLoggingWriteWrapper(
g_hProvider,
"ImageResizer_Invoked",
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
@ -40,7 +32,7 @@ void Trace::Invoked() noexcept
void Trace::InvokedRet(_In_ HRESULT hr) noexcept
{
TraceLoggingWrite(
TraceLoggingWriteWrapper(
g_hProvider,
"ImageResizer_InvokedRet",
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
@ -50,7 +42,7 @@ void Trace::InvokedRet(_In_ HRESULT hr) noexcept
void Trace::QueryContextMenuError(_In_ HRESULT hr) noexcept
{
TraceLoggingWrite(
TraceLoggingWriteWrapper(
g_hProvider,
"ImageResizer_QueryContextMenuError",
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),

View File

@ -1,10 +1,10 @@
#pragma once
class Trace
#include <common/Telemetry/TraceBase.h>
class Trace : public telemetry::TraceBase
{
public:
static void RegisterProvider() noexcept;
static void UnregisterProvider() noexcept;
static void EnableImageResizer(_In_ bool enabled) noexcept;
static void Invoked() noexcept;
static void InvokedRet(_In_ HRESULT hr) noexcept;

View File

@ -22,4 +22,3 @@
#include <windows.h>
#include <ShlObj.h>
#include <ProjectTelemetry.h>

View File

@ -29,8 +29,6 @@
#include <common/logger/logger.h>
#include <common/utils/resources.h>
#include <ProjectTelemetry.h>
#include <keyboardmanager/KeyboardManagerEditor/Generated Files/resource.h>
//#include <Generated Files/resource.h>

View File

@ -1,6 +1,8 @@
#include "pch.h"
#include "trace.h"
#include <common/Telemetry/TraceBase.h>
TRACELOGGING_DEFINE_PROVIDER(
g_hProvider,
"Microsoft.PowerToys",
@ -8,20 +10,10 @@ TRACELOGGING_DEFINE_PROVIDER(
(0x38e8889b, 0x9731, 0x53f5, 0xe9, 0x01, 0xe8, 0xa7, 0xc1, 0x75, 0x30, 0x74),
TraceLoggingOptionProjectTelemetry());
void Trace::RegisterProvider() noexcept
{
TraceLoggingRegister(g_hProvider);
}
void Trace::UnregisterProvider() noexcept
{
TraceLoggingUnregister(g_hProvider);
}
// Log number of key remaps when the user uses Edit Keyboard and saves settings
void Trace::KeyRemapCount(const DWORD keyToKeyCount, const DWORD keyToShortcutCount, const DWORD keyToTextCount) noexcept
{
TraceLoggingWrite(
TraceLoggingWriteWrapper(
g_hProvider,
"KeyboardManager_KeyRemapCount",
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
@ -35,7 +27,7 @@ void Trace::KeyRemapCount(const DWORD keyToKeyCount, const DWORD keyToShortcutCo
// Log number of os level shortcut remaps when the user uses Edit Shortcuts and saves settings
void Trace::OSLevelShortcutRemapCount(const DWORD shortcutToShortcutCount, const DWORD shortcutToKeyCount) noexcept
{
TraceLoggingWrite(
TraceLoggingWriteWrapper(
g_hProvider,
"KeyboardManager_OSLevelShortcutRemapCount",
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
@ -48,7 +40,7 @@ void Trace::OSLevelShortcutRemapCount(const DWORD shortcutToShortcutCount, const
// Log number of app specific shortcut remaps when the user uses Edit Shortcuts and saves settings
void Trace::AppSpecificShortcutRemapCount(const DWORD shortcutToShortcutCount, const DWORD shortcutToKeyCount) noexcept
{
TraceLoggingWrite(
TraceLoggingWriteWrapper(
g_hProvider,
"KeyboardManager_AppSpecificShortcutRemapCount",
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
@ -61,7 +53,7 @@ void Trace::AppSpecificShortcutRemapCount(const DWORD shortcutToShortcutCount, c
// Log if an error occurs in KBM
void Trace::Error(const DWORD errorCode, std::wstring errorMessage, std::wstring methodName) noexcept
{
TraceLoggingWrite(
TraceLoggingWriteWrapper(
g_hProvider,
"KeyboardManager_Error",
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),

View File

@ -1,11 +1,10 @@
#pragma once
class Trace
#include <common/Telemetry/TraceBase.h>
class Trace : public telemetry::TraceBase
{
public:
static void RegisterProvider() noexcept;
static void UnregisterProvider() noexcept;
// Log number of key remaps when the user uses Edit Keyboard and saves settings
static void KeyRemapCount(const DWORD keyToKeyCount, const DWORD keyToShortcutCount, const DWORD keyToTextCount) noexcept;

View File

@ -1,7 +1,6 @@
#pragma once
#define WIN32_LEAN_AND_MEAN
#include <Windows.h>
#include <ProjectTelemetry.h>
#include <shlwapi.h>
#include <stdexcept>
#include <unordered_set>

View File

@ -1,7 +1,6 @@
#pragma once
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <ProjectTelemetry.h>
#include <shlwapi.h>
#include <stdexcept>
#include <winrt/base.h>

View File

@ -1,7 +1,6 @@
#pragma once
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <ProjectTelemetry.h>
#include <shlwapi.h>
#include <shellapi.h>
#include <stdexcept>

View File

@ -2,6 +2,8 @@
#include "trace.h"
#include <common/interop/keyboard_layout.h>
#include <common/Telemetry/TraceBase.h>
TRACELOGGING_DEFINE_PROVIDER(
g_hProvider,
"Microsoft.PowerToys",
@ -9,20 +11,10 @@ TRACELOGGING_DEFINE_PROVIDER(
(0x38e8889b, 0x9731, 0x53f5, 0xe9, 0x01, 0xe8, 0xa7, 0xc1, 0x75, 0x30, 0x74),
TraceLoggingOptionProjectTelemetry());
void Trace::RegisterProvider() noexcept
{
TraceLoggingRegister(g_hProvider);
}
void Trace::UnregisterProvider() noexcept
{
TraceLoggingUnregister(g_hProvider);
}
// Log if a key to key remap has been invoked today.
void Trace::DailyKeyToKeyRemapInvoked() noexcept
{
TraceLoggingWrite(
TraceLoggingWriteWrapper(
g_hProvider,
"KeyboardManager_DailyKeyToKeyRemapInvoked",
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
@ -32,7 +24,7 @@ void Trace::DailyKeyToKeyRemapInvoked() noexcept
// Log if a key to shortcut remap has been invoked today.
void Trace::DailyKeyToShortcutRemapInvoked() noexcept
{
TraceLoggingWrite(
TraceLoggingWriteWrapper(
g_hProvider,
"KeyboardManager_DailyKeyToShortcutRemapInvoked",
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
@ -42,7 +34,7 @@ void Trace::DailyKeyToShortcutRemapInvoked() noexcept
// Log if a shortcut to key remap has been invoked today.
void Trace::DailyShortcutToKeyRemapInvoked() noexcept
{
TraceLoggingWrite(
TraceLoggingWriteWrapper(
g_hProvider,
"KeyboardManager_DailyShortcutToKeyRemapInvoked",
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
@ -52,7 +44,7 @@ void Trace::DailyShortcutToKeyRemapInvoked() noexcept
// Log if a shortcut to shortcut remap has been invoked today.
void Trace::DailyShortcutToShortcutRemapInvoked() noexcept
{
TraceLoggingWrite(
TraceLoggingWriteWrapper(
g_hProvider,
"KeyboardManager_DailyShortcutToShortcutRemapInvoked",
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
@ -62,7 +54,7 @@ void Trace::DailyShortcutToShortcutRemapInvoked() noexcept
// Log if an app specific shortcut to key remap has been invoked today.
void Trace::DailyAppSpecificShortcutToKeyRemapInvoked() noexcept
{
TraceLoggingWrite(
TraceLoggingWriteWrapper(
g_hProvider,
"KeyboardManager_DailyAppSpecificShortcutToKeyRemapInvoked",
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
@ -72,7 +64,7 @@ void Trace::DailyAppSpecificShortcutToKeyRemapInvoked() noexcept
// Log if an app specific shortcut to shortcut remap has been invoked today.
void Trace::DailyAppSpecificShortcutToShortcutRemapInvoked() noexcept
{
TraceLoggingWrite(
TraceLoggingWriteWrapper(
g_hProvider,
"KeyboardManager_DailyAppSpecificShortcutToShortcutRemapInvoked",
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
@ -84,7 +76,7 @@ void Trace::KeyRemapInvoked(bool isKeyToKey) noexcept
{
if (isKeyToKey)
{
TraceLoggingWrite(
TraceLoggingWriteWrapper(
g_hProvider,
"KeyboardManager_KeyToKeyRemapInvoked",
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
@ -92,7 +84,7 @@ void Trace::KeyRemapInvoked(bool isKeyToKey) noexcept
}
else
{
TraceLoggingWrite(
TraceLoggingWriteWrapper(
g_hProvider,
"KeyboardManager_KeyToShortcutRemapInvoked",
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
@ -107,7 +99,7 @@ void Trace::ShortcutRemapInvoked(bool isShortcutToShortcut, bool isAppSpecific)
{
if (isShortcutToShortcut)
{
TraceLoggingWrite(
TraceLoggingWriteWrapper(
g_hProvider,
"KeyboardManager_AppSpecificShortcutToShortcutRemapInvoked",
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
@ -115,7 +107,7 @@ void Trace::ShortcutRemapInvoked(bool isShortcutToShortcut, bool isAppSpecific)
}
else
{
TraceLoggingWrite(
TraceLoggingWriteWrapper(
g_hProvider,
"KeyboardManager_AppSpecificShortcutToKeyRemapInvoked",
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
@ -126,7 +118,7 @@ void Trace::ShortcutRemapInvoked(bool isShortcutToShortcut, bool isAppSpecific)
{
if (isShortcutToShortcut)
{
TraceLoggingWrite(
TraceLoggingWriteWrapper(
g_hProvider,
"KeyboardManager_OSLevelShortcutToShortcutRemapInvoked",
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
@ -134,7 +126,7 @@ void Trace::ShortcutRemapInvoked(bool isShortcutToShortcut, bool isAppSpecific)
}
else
{
TraceLoggingWrite(
TraceLoggingWriteWrapper(
g_hProvider,
"KeyboardManager_OSLevelShortcutToKeyRemapInvoked",
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
@ -184,7 +176,7 @@ void Trace::SendKeyAndShortcutRemapLoadedConfiguration(State& remappings) noexce
if (keyRemap.second.index() == 0) // 0 - Remapping to key
{
DWORD keyRemappedTo = std::get<DWORD>(keyRemap.second);
TraceLoggingWrite(
TraceLoggingWriteWrapper(
g_hProvider,
"KeyboardManager_KeyRemapConfigurationLoaded",
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
@ -198,7 +190,7 @@ void Trace::SendKeyAndShortcutRemapLoadedConfiguration(State& remappings) noexce
else if (keyRemap.second.index() == 1) // 1 - Remapping to shortcut
{
Shortcut shortcutRemappedTo = std::get<Shortcut>(keyRemap.second);
TraceLoggingWrite(
TraceLoggingWriteWrapper(
g_hProvider,
"KeyboardManager_KeyRemapConfigurationLoaded",
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
@ -221,7 +213,7 @@ void Trace::SendKeyAndShortcutRemapLoadedConfiguration(State& remappings) noexce
if (shortcutRemap.second.targetShortcut.index() == 0) // 0 - Remapping to key
{
DWORD keyRemappedTo = std::get<DWORD>(shortcutRemap.second.targetShortcut);
TraceLoggingWrite(
TraceLoggingWriteWrapper(
g_hProvider,
"KeyboardManager_ShortcutRemapConfigurationLoaded",
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
@ -245,7 +237,7 @@ void Trace::SendKeyAndShortcutRemapLoadedConfiguration(State& remappings) noexce
// Don't include Start app or Open URI mappings in this telemetry.
continue;
}
TraceLoggingWrite(
TraceLoggingWriteWrapper(
g_hProvider,
"KeyboardManager_ShortcutRemapConfigurationLoaded",
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
@ -277,7 +269,7 @@ void Trace::SendKeyAndShortcutRemapLoadedConfiguration(State& remappings) noexce
if (shortcutRemap.second.targetShortcut.index() == 0) // 0 - Remapping to key
{
DWORD keyRemappedTo = std::get<DWORD>(shortcutRemap.second.targetShortcut);
TraceLoggingWrite(
TraceLoggingWriteWrapper(
g_hProvider,
"KeyboardManager_AppSpecificShortcutRemapConfigurationLoaded",
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
@ -303,7 +295,7 @@ void Trace::SendKeyAndShortcutRemapLoadedConfiguration(State& remappings) noexce
// Don't include Start app or Open URI mappings in this telemetry.
continue;
}
TraceLoggingWrite(
TraceLoggingWriteWrapper(
g_hProvider,
"KeyboardManager_AppSpecificShortcutRemapConfigurationLoaded",
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
@ -332,7 +324,7 @@ void Trace::SendKeyAndShortcutRemapLoadedConfiguration(State& remappings) noexce
// Log an error while trying to send remappings telemetry.
void Trace::ErrorSendingKeyAndShortcutRemapLoadedConfiguration() noexcept
{
TraceLoggingWrite(
TraceLoggingWriteWrapper(
g_hProvider,
"KeyboardManager_ErrorSendingKeyAndShortcutRemapLoadedConfiguration",
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
@ -343,7 +335,7 @@ void Trace::ErrorSendingKeyAndShortcutRemapLoadedConfiguration() noexcept
// Log if an error occurs in KBM
void Trace::Error(const DWORD errorCode, std::wstring errorMessage, std::wstring methodName) noexcept
{
TraceLoggingWrite(
TraceLoggingWriteWrapper(
g_hProvider,
"KeyboardManager_Error",
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),

View File

@ -2,12 +2,11 @@
#include "State.h"
class Trace
#include <common/Telemetry/TraceBase.h>
class Trace : public telemetry::TraceBase
{
public:
static void RegisterProvider() noexcept;
static void UnregisterProvider() noexcept;
// Log if a key to key remap has been invoked today.
static void DailyKeyToKeyRemapInvoked() noexcept;

View File

@ -1,7 +1,6 @@
#pragma once
#define WIN32_LEAN_AND_MEAN
#include <Windows.h>
#include <ProjectTelemetry.h>
#include <shlwapi.h>
#include <stdexcept>
#include <unordered_set>

View File

@ -6,4 +6,3 @@
#include <vector>
#include <algorithm>
#include <stdlib.h>
#include <ProjectTelemetry.h>

View File

@ -1,7 +1,6 @@
#pragma once
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <ProjectTelemetry.h>
#include <shlwapi.h>
#include <stdexcept>
#include <unordered_set>

View File

@ -1,6 +1,8 @@
#include "pch.h"
#include "trace.h"
#include <common/Telemetry/TraceBase.h>
TRACELOGGING_DEFINE_PROVIDER(
g_hProvider,
"Microsoft.PowerToys",
@ -8,20 +10,10 @@ TRACELOGGING_DEFINE_PROVIDER(
(0x38e8889b, 0x9731, 0x53f5, 0xe9, 0x01, 0xe8, 0xa7, 0xc1, 0x75, 0x30, 0x74),
TraceLoggingOptionProjectTelemetry());
void Trace::RegisterProvider() noexcept
{
TraceLoggingRegister(g_hProvider);
}
void Trace::UnregisterProvider() noexcept
{
TraceLoggingUnregister(g_hProvider);
}
// Log if the user has KBM enabled or disabled - Can also be used to see how often users have to restart the keyboard hook
void Trace::EnableKeyboardManager(const bool enabled) noexcept
{
TraceLoggingWrite(
TraceLoggingWriteWrapper(
g_hProvider,
"KeyboardManager_EnableKeyboardManager",
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),

View File

@ -1,11 +1,10 @@
#pragma once
class Trace
#include <common/Telemetry/TraceBase.h>
class Trace : public telemetry::TraceBase
{
public:
static void RegisterProvider() noexcept;
static void UnregisterProvider() noexcept;
// Log if the user has KBM enabled or disabled - Can also be used to see how often users have to restart the keyboard hook
static void EnableKeyboardManager(const bool enabled) noexcept;
};

View File

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project DefaultTargets="Build" ToolsVersion="15.0"
xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\..\..\..\packages\Microsoft.Windows.CppWinRT.2.0.240111.5\build\native\Microsoft.Windows.CppWinRT.props" Condition="Exists('..\..\..\..\packages\Microsoft.Windows.CppWinRT.2.0.240111.5\build\native\Microsoft.Windows.CppWinRT.props')" />
<Target Name="GenerateResourceFiles" BeforeTargets="PrepareForBuild">
<Exec Command="powershell -NonInteractive -executionpolicy Unrestricted $(SolutionDir)tools\build\convert-resx-to-rc.ps1 $(MSBuildThisFileDirectory) resource.base.h resource.h Microsoft.Launcher.base.rc Microsoft.Launcher.rc" />
@ -46,14 +47,12 @@
<ClInclude Include="pch.h" />
<ClInclude Include="Generated Files\resource.h" />
<None Include="resource.base.h" />
<ClInclude Include="trace.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="dllmain.cpp" />
<ClCompile Include="pch.cpp">
<PrecompiledHeader Condition="'$(UsePrecompiledHeaders)' != 'false'">Create</PrecompiledHeader>
</ClCompile>
<ClCompile Include="trace.cpp" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\common\logger\logger.vcxproj">

View File

@ -3,11 +3,9 @@
<ItemGroup>
<ClCompile Include="pch.cpp" />
<ClCompile Include="dllmain.cpp" />
<ClCompile Include="trace.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="pch.h" />
<ClInclude Include="trace.h" />
<ClInclude Include="Generated Files\resource.h">
<Filter>Generated Files</Filter>
</ClInclude>

View File

@ -2,7 +2,6 @@
#include <interface/powertoy_module_interface.h>
#include <common/SettingsAPI/settings_objects.h>
#include <common/interop/shared_constants.h>
#include "trace.h"
#include "Generated Files/resource.h"
#include <launcher\Microsoft.Launcher\LauncherConstants.h>
#include <common/logger/logger.h>
@ -34,13 +33,11 @@ BOOL APIENTRY DllMain(HMODULE /*hModule*/, DWORD ul_reason_for_call, LPVOID /*lp
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
Trace::RegisterProvider();
break;
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
break;
case DLL_PROCESS_DETACH:
Trace::UnregisterProvider();
break;
}

View File

@ -3,6 +3,5 @@
#include <windows.h>
#include <winrt/Windows.Foundation.h>
#include <winrt/Windows.Foundation.Collections.h>
#include <ProjectTelemetry.h>
#include <shellapi.h>
#include <Shlwapi.h>

View File

@ -1,17 +0,0 @@
#include "pch.h"
#include "trace.h"
TRACELOGGING_DEFINE_PROVIDER(
g_hProvider,
"Microsoft.PowerToys",
// {38e8889b-9731-53f5-e901-e8a7c1753074}
(0x38e8889b, 0x9731, 0x53f5, 0xe9, 0x01, 0xe8, 0xa7, 0xc1, 0x75, 0x30, 0x74),
TraceLoggingOptionProjectTelemetry());
void Trace::RegisterProvider() {
TraceLoggingRegister(g_hProvider);
}
void Trace::UnregisterProvider() {
TraceLoggingUnregister(g_hProvider);
}

Some files were not shown because too many files have changed in this diff Show More