mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-03 17:56:44 +02:00
[General]Add an option for telemetry opt-in and visualization(#34078)
* Data diagnostics opt-in
* [c++] Drop DROP_PII flag
* Bump telemtry package to 2.0.2
* Drop DropPii from custom actions
* Cleanup
* Do not start manually C# EtwTrace. FZ engine exit event.
* ImageResizer, PowerRename, FileLocksmith prev handlers
* Revert C# handlers exe logging
* Revert "Revert C# handlers exe logging"
This reverts commit 4c75a3953b.
* Do not recreate EtwTrace
* consume package
* xaml formatting
* Fix deps.json audit
* Update telem package paths
* Address PR comments
* Fix AdvancedPaste close on PT close
* Override etl file name for explorer loaded dlls
Start/stop tracer when needed for explorer loaded dlls to prevent explorer overload
* Fix setting desc
* Fix missing events
* Add infobar to restart when enable data viewing
* Flush on timer every 30s
* [Settings] Update View Data diagnostic description text
[New+] Add tracer
* Show Restart info bar for both enable/disable data viewer
* Fix newplus
* Fix stuck on restart and terminate AdvPaste exe on destroy()
* [Installer] Add tracer
* Address PR comment
* Add missing tracers
* Exclude etw dir from BugReport
* Fix bad merge
* [Hosts] Proper exit on initial dialog
* [OOBE] Make Data diagnostic setting visible without scroll
* [OOBE] Add hiperlynk to open general settings
* Disable data view on disabling data diagnostics
* Don't disable View data button
* Fix disabling data viewing
* Add missing dot
* Revert formatting
This commit is contained in:
@@ -80,7 +80,6 @@ int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
|
||||
std::wstring keysForShortcutToEdit = L"";
|
||||
std::wstring action = L"";
|
||||
|
||||
|
||||
// do some parsing of the cmdline arg to see if we need to behave different
|
||||
// like, single edit mode, or "delete" mode.
|
||||
// These extra args are from "OpenEditor" in the KeyboardManagerViewModel
|
||||
|
||||
@@ -132,6 +132,9 @@
|
||||
<ProjectReference Include="..\..\..\common\logger\logger.vcxproj">
|
||||
<Project>{d9b8fc84-322a-4f9f-bbb9-20915c47ddfd}</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>
|
||||
|
||||
@@ -8,6 +8,8 @@
|
||||
#include <common/utils/EventLocker.h>
|
||||
#include <common/utils/winapi_error.h>
|
||||
|
||||
#include <common/Telemetry/EtwTrace/EtwTrace.h>
|
||||
|
||||
#include <keyboardmanager/common/KeyboardManagerConstants.h>
|
||||
#include <keyboardmanager/common/MappingConfiguration.h>
|
||||
|
||||
@@ -426,11 +428,15 @@ inline void CreateEditKeyboardWindowImpl(HINSTANCE hInst, KBMEditor::KeyboardMan
|
||||
|
||||
void CreateEditKeyboardWindow(HINSTANCE hInst, KBMEditor::KeyboardManagerState& keyboardManagerState, MappingConfiguration& mappingConfiguration)
|
||||
{
|
||||
Shared::Trace::ETWTrace trace;
|
||||
trace.UpdateState(true);
|
||||
|
||||
// Move implementation into the separate method so resources get destroyed correctly
|
||||
CreateEditKeyboardWindowImpl(hInst, keyboardManagerState, mappingConfiguration);
|
||||
|
||||
// Calling ClearXamlIslands() outside of the message loop is not enough to prevent
|
||||
// Microsoft.UI.XAML.dll from crashing during deinitialization, see https://github.com/microsoft/PowerToys/issues/10906
|
||||
trace.Flush();
|
||||
Logger::trace("Terminating process {}", GetCurrentProcessId());
|
||||
Logger::flush();
|
||||
TerminateProcess(GetCurrentProcess(), 0);
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
#include <common/utils/winapi_error.h>
|
||||
#include <keyboardmanager/common/MappingConfiguration.h>
|
||||
|
||||
#include <common/Telemetry/EtwTrace/EtwTrace.h>
|
||||
|
||||
#include "KeyboardManagerState.h"
|
||||
#include "Dialog.h"
|
||||
#include "KeyDropDownControl.h"
|
||||
@@ -447,11 +449,15 @@ inline void CreateEditShortcutsWindowImpl(HINSTANCE hInst, KBMEditor::KeyboardMa
|
||||
|
||||
void CreateEditShortcutsWindow(HINSTANCE hInst, KBMEditor::KeyboardManagerState& keyboardManagerState, MappingConfiguration& mappingConfiguration, std::wstring keysForShortcutToEdit, std::wstring action)
|
||||
{
|
||||
Shared::Trace::ETWTrace trace;
|
||||
trace.UpdateState(true);
|
||||
|
||||
// Move implementation into the separate method so resources get destroyed correctly
|
||||
CreateEditShortcutsWindowImpl(hInst, keyboardManagerState, mappingConfiguration, keysForShortcutToEdit, action);
|
||||
|
||||
// Calling ClearXamlIslands() outside of the message loop is not enough to prevent
|
||||
// Microsoft.UI.XAML.dll from crashing during deinitialization, see https://github.com/microsoft/PowerToys/issues/10906
|
||||
trace.Flush();
|
||||
Logger::trace("Terminating process {}", GetCurrentProcessId());
|
||||
Logger::flush();
|
||||
TerminateProcess(GetCurrentProcess(), 0);
|
||||
|
||||
@@ -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>
|
||||
|
||||
|
||||
@@ -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),
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -67,6 +67,9 @@
|
||||
<ProjectReference Include="..\..\..\common\SettingsAPI\SettingsAPI.vcxproj">
|
||||
<Project>{6955446d-23f7-4023-9bb3-8657f904af99}</Project>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\..\common\Telemetry\EtwTrace\EtwTrace.vcxproj">
|
||||
<Project>{8f021b46-362b-485c-bfba-ccf83e820cbd}</Project>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\KeyboardManagerEngineLibrary\KeyboardManagerEngineLibrary.vcxproj">
|
||||
<Project>{e496b7fc-1e99-4bab-849b-0e8367040b02}</Project>
|
||||
</ProjectReference>
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
#include "pch.h"
|
||||
#include <common/Telemetry/EtwTrace/EtwTrace.h>
|
||||
#include <common/utils/EventWaiter.h>
|
||||
#include <common/utils/window.h>
|
||||
#include <common/utils/ProcessWaiter.h>
|
||||
#include <common/utils/winapi_error.h>
|
||||
@@ -8,6 +10,7 @@
|
||||
#include <keyboardmanager/common/KeyboardManagerConstants.h>
|
||||
#include <keyboardmanager/KeyboardManagerEngineLibrary/KeyboardManager.h>
|
||||
#include <keyboardmanager/KeyboardManagerEngineLibrary/trace.h>
|
||||
#include <common/interop/shared_constants.h>
|
||||
|
||||
const std::wstring instanceMutexName = L"Local\\PowerToys_KBMEngine_InstanceMutex";
|
||||
|
||||
@@ -19,6 +22,9 @@ int WINAPI wWinMain(_In_ HINSTANCE /*hInstance*/,
|
||||
winrt::init_apartment();
|
||||
LoggerHelpers::init_logger(KeyboardManagerConstants::ModuleName, L"Engine", LogSettings::keyboardManagerLoggerName);
|
||||
|
||||
Shared::Trace::ETWTrace trace;
|
||||
trace.UpdateState(true);
|
||||
|
||||
if (powertoys_gpo::getConfiguredKeyboardManagerEnabledValue() == powertoys_gpo::gpo_rule_configured_disabled)
|
||||
{
|
||||
Logger::warn(L"Tried to start with a GPO policy setting the utility to always be disabled. Please contact your systems administrator.");
|
||||
@@ -42,9 +48,15 @@ int WINAPI wWinMain(_In_ HINSTANCE /*hInstance*/,
|
||||
Trace::RegisterProvider();
|
||||
|
||||
std::wstring pid = std::wstring(lpCmdLine);
|
||||
|
||||
auto mainThreadId = GetCurrentThreadId();
|
||||
|
||||
EventWaiter ev = EventWaiter(CommonSharedConstants::TERMINATE_KBM_SHARED_EVENT, [&](int) {
|
||||
PostThreadMessage(mainThreadId, WM_QUIT, 0, 0);
|
||||
});
|
||||
|
||||
if (!pid.empty())
|
||||
{
|
||||
auto mainThreadId = GetCurrentThreadId();
|
||||
ProcessWaiter::OnProcessTerminate(pid, [mainThreadId](int err) {
|
||||
if (err != ERROR_SUCCESS)
|
||||
{
|
||||
@@ -73,5 +85,7 @@ int WINAPI wWinMain(_In_ HINSTANCE /*hInstance*/,
|
||||
kbm.StopLowlevelKeyboardHook();
|
||||
Trace::UnregisterProvider();
|
||||
|
||||
trace.Flush();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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,74 +11,64 @@ 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(
|
||||
g_hProvider,
|
||||
"KeyboardManager_DailyKeyToKeyRemapInvoked",
|
||||
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
|
||||
TraceLoggingKeyword(PROJECT_KEYWORD_MEASURE));
|
||||
TraceLoggingWriteWrapper(
|
||||
g_hProvider,
|
||||
"KeyboardManager_DailyKeyToKeyRemapInvoked",
|
||||
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
|
||||
TraceLoggingKeyword(PROJECT_KEYWORD_MEASURE));
|
||||
}
|
||||
|
||||
// Log if a key to shortcut remap has been invoked today.
|
||||
void Trace::DailyKeyToShortcutRemapInvoked() noexcept
|
||||
{
|
||||
TraceLoggingWrite(
|
||||
g_hProvider,
|
||||
"KeyboardManager_DailyKeyToShortcutRemapInvoked",
|
||||
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
|
||||
TraceLoggingKeyword(PROJECT_KEYWORD_MEASURE));
|
||||
TraceLoggingWriteWrapper(
|
||||
g_hProvider,
|
||||
"KeyboardManager_DailyKeyToShortcutRemapInvoked",
|
||||
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
|
||||
TraceLoggingKeyword(PROJECT_KEYWORD_MEASURE));
|
||||
}
|
||||
|
||||
// Log if a shortcut to key remap has been invoked today.
|
||||
void Trace::DailyShortcutToKeyRemapInvoked() noexcept
|
||||
{
|
||||
TraceLoggingWrite(
|
||||
g_hProvider,
|
||||
"KeyboardManager_DailyShortcutToKeyRemapInvoked",
|
||||
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
|
||||
TraceLoggingKeyword(PROJECT_KEYWORD_MEASURE));
|
||||
TraceLoggingWriteWrapper(
|
||||
g_hProvider,
|
||||
"KeyboardManager_DailyShortcutToKeyRemapInvoked",
|
||||
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
|
||||
TraceLoggingKeyword(PROJECT_KEYWORD_MEASURE));
|
||||
}
|
||||
|
||||
// Log if a shortcut to shortcut remap has been invoked today.
|
||||
void Trace::DailyShortcutToShortcutRemapInvoked() noexcept
|
||||
{
|
||||
TraceLoggingWrite(
|
||||
g_hProvider,
|
||||
"KeyboardManager_DailyShortcutToShortcutRemapInvoked",
|
||||
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
|
||||
TraceLoggingKeyword(PROJECT_KEYWORD_MEASURE));
|
||||
TraceLoggingWriteWrapper(
|
||||
g_hProvider,
|
||||
"KeyboardManager_DailyShortcutToShortcutRemapInvoked",
|
||||
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
|
||||
TraceLoggingKeyword(PROJECT_KEYWORD_MEASURE));
|
||||
}
|
||||
|
||||
// Log if an app specific shortcut to key remap has been invoked today.
|
||||
void Trace::DailyAppSpecificShortcutToKeyRemapInvoked() noexcept
|
||||
{
|
||||
TraceLoggingWrite(
|
||||
g_hProvider,
|
||||
"KeyboardManager_DailyAppSpecificShortcutToKeyRemapInvoked",
|
||||
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
|
||||
TraceLoggingKeyword(PROJECT_KEYWORD_MEASURE));
|
||||
TraceLoggingWriteWrapper(
|
||||
g_hProvider,
|
||||
"KeyboardManager_DailyAppSpecificShortcutToKeyRemapInvoked",
|
||||
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
|
||||
TraceLoggingKeyword(PROJECT_KEYWORD_MEASURE));
|
||||
}
|
||||
|
||||
// Log if an app specific shortcut to shortcut remap has been invoked today.
|
||||
void Trace::DailyAppSpecificShortcutToShortcutRemapInvoked() noexcept
|
||||
{
|
||||
TraceLoggingWrite(
|
||||
g_hProvider,
|
||||
"KeyboardManager_DailyAppSpecificShortcutToShortcutRemapInvoked",
|
||||
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
|
||||
TraceLoggingKeyword(PROJECT_KEYWORD_MEASURE));
|
||||
TraceLoggingWriteWrapper(
|
||||
g_hProvider,
|
||||
"KeyboardManager_DailyAppSpecificShortcutToShortcutRemapInvoked",
|
||||
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
|
||||
TraceLoggingKeyword(PROJECT_KEYWORD_MEASURE));
|
||||
}
|
||||
|
||||
// Log if a key remap has been invoked (not being used currently, due to being garrulous)
|
||||
@@ -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),
|
||||
@@ -144,7 +136,7 @@ void Trace::ShortcutRemapInvoked(bool isShortcutToShortcut, bool isAppSpecific)
|
||||
}
|
||||
|
||||
// Function to return a human readable string for the shortcut
|
||||
std::wstring GetShortcutHumanReadableString(Shortcut const & shortcut, LayoutMap& keyboardMap)
|
||||
std::wstring GetShortcutHumanReadableString(Shortcut const& shortcut, LayoutMap& keyboardMap)
|
||||
{
|
||||
std::wstring humanReadableShortcut = L"";
|
||||
if (shortcut.winKey != ModifierKey::Disabled)
|
||||
@@ -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),
|
||||
@@ -192,13 +184,12 @@ void Trace::SendKeyAndShortcutRemapLoadedConfiguration(State& remappings) noexce
|
||||
TraceLoggingInt64(keyRemap.first, "KeyRemapFrom"),
|
||||
TraceLoggingInt64(keyRemappedTo, "KeyRemapTo"),
|
||||
TraceLoggingWideString(keyboardMap.GetKeyName(keyRemap.first).c_str(), "HumanRemapFrom"),
|
||||
TraceLoggingWideString(keyboardMap.GetKeyName(keyRemappedTo).c_str(), "HumanRemapTo")
|
||||
);
|
||||
TraceLoggingWideString(keyboardMap.GetKeyName(keyRemappedTo).c_str(), "HumanRemapTo"));
|
||||
}
|
||||
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),
|
||||
@@ -210,8 +201,7 @@ void Trace::SendKeyAndShortcutRemapLoadedConfiguration(State& remappings) noexce
|
||||
TraceLoggingInt8(static_cast<INT8>(shortcutRemappedTo.altKey), "ModifierRemapToAlt"),
|
||||
TraceLoggingInt8(static_cast<INT8>(shortcutRemappedTo.shiftKey), "ModifierRemapToShift"),
|
||||
TraceLoggingWideString(keyboardMap.GetKeyName(keyRemap.first).c_str(), "HumanRemapFrom"),
|
||||
TraceLoggingWideString(GetShortcutHumanReadableString(shortcutRemappedTo, keyboardMap).c_str(), "HumanRemapTo")
|
||||
);
|
||||
TraceLoggingWideString(GetShortcutHumanReadableString(shortcutRemappedTo, keyboardMap).c_str(), "HumanRemapTo"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -221,7 +211,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 +235,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),
|
||||
@@ -263,8 +253,7 @@ void Trace::SendKeyAndShortcutRemapLoadedConfiguration(State& remappings) noexce
|
||||
TraceLoggingInt8(static_cast<INT8>(shortcutRemappedTo.altKey), "ModifierRemapToAlt"),
|
||||
TraceLoggingInt8(static_cast<INT8>(shortcutRemappedTo.shiftKey), "ModifierRemapToShift"),
|
||||
TraceLoggingWideString(GetShortcutHumanReadableString(shortcutRemappedFrom, keyboardMap).c_str(), "HumanRemapFrom"),
|
||||
TraceLoggingWideString(GetShortcutHumanReadableString(shortcutRemappedTo, keyboardMap).c_str(), "HumanRemapTo")
|
||||
);
|
||||
TraceLoggingWideString(GetShortcutHumanReadableString(shortcutRemappedTo, keyboardMap).c_str(), "HumanRemapTo"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -277,7 +266,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),
|
||||
@@ -292,8 +281,7 @@ void Trace::SendKeyAndShortcutRemapLoadedConfiguration(State& remappings) noexce
|
||||
TraceLoggingInt64(keyRemappedTo, "KeyRemapTo"),
|
||||
TraceLoggingWideString(GetShortcutHumanReadableString(shortcutRemappedFrom, keyboardMap).c_str(), "HumanRemapFrom"),
|
||||
TraceLoggingWideString(keyboardMap.GetKeyName(keyRemappedTo).c_str(), "HumanRemapTo"),
|
||||
TraceLoggingWideString(appName.c_str(), "TargetApp")
|
||||
);
|
||||
TraceLoggingWideString(appName.c_str(), "TargetApp"));
|
||||
}
|
||||
else if (shortcutRemap.second.targetShortcut.index() == 1) // 1 - Remapping to shortcut
|
||||
{
|
||||
@@ -303,7 +291,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),
|
||||
@@ -322,8 +310,7 @@ void Trace::SendKeyAndShortcutRemapLoadedConfiguration(State& remappings) noexce
|
||||
TraceLoggingInt8(static_cast<INT8>(shortcutRemappedTo.shiftKey), "ModifierRemapToShift"),
|
||||
TraceLoggingWideString(GetShortcutHumanReadableString(shortcutRemappedFrom, keyboardMap).c_str(), "HumanRemapFrom"),
|
||||
TraceLoggingWideString(GetShortcutHumanReadableString(shortcutRemappedTo, keyboardMap).c_str(), "HumanRemapTo"),
|
||||
TraceLoggingWideString(appName.c_str(), "TargetApp")
|
||||
);
|
||||
TraceLoggingWideString(appName.c_str(), "TargetApp"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -332,18 +319,17 @@ 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),
|
||||
TraceLoggingKeyword(PROJECT_KEYWORD_MEASURE));
|
||||
}
|
||||
|
||||
|
||||
// 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),
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -6,4 +6,3 @@
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
#include <stdlib.h>
|
||||
#include <ProjectTelemetry.h>
|
||||
@@ -8,6 +8,7 @@
|
||||
#include <keyboardmanager/dll/trace.h>
|
||||
#include <shellapi.h>
|
||||
#include <common/utils/logger_helper.h>
|
||||
#include <common/interop/shared_constants.h>
|
||||
|
||||
BOOL APIENTRY DllMain(HMODULE /*hModule*/, DWORD ul_reason_for_call, LPVOID /*lpReserved*/)
|
||||
{
|
||||
@@ -42,6 +43,8 @@ private:
|
||||
|
||||
HANDLE m_hProcess = nullptr;
|
||||
|
||||
HANDLE m_hTerminateEngineEvent = nullptr;
|
||||
|
||||
public:
|
||||
// Constructor
|
||||
KeyboardManager()
|
||||
@@ -51,6 +54,17 @@ public:
|
||||
std::filesystem::path oldLogPath(PTSettingsHelper::get_module_save_folder_location(app_key));
|
||||
oldLogPath.append("Logs");
|
||||
LoggerHelpers::delete_old_log_folder(oldLogPath);
|
||||
|
||||
m_hTerminateEngineEvent = CreateDefaultEvent(CommonSharedConstants::TERMINATE_KBM_SHARED_EVENT);
|
||||
if (!m_hTerminateEngineEvent)
|
||||
{
|
||||
Logger::error(L"Failed to create terminate Engine event");
|
||||
auto message = get_last_error_message(GetLastError());
|
||||
if (message.has_value())
|
||||
{
|
||||
Logger::error(message.value());
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Destroy the powertoy and free memory
|
||||
@@ -158,6 +172,9 @@ public:
|
||||
|
||||
if (m_hProcess)
|
||||
{
|
||||
SetEvent(m_hTerminateEngineEvent);
|
||||
WaitForSingleObject(m_hProcess, 1500);
|
||||
|
||||
TerminateProcess(m_hProcess, 0);
|
||||
m_hProcess = nullptr;
|
||||
}
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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),
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user