Add in missing telemetry for Keyboard Manager usage (#6393)

* Added key remap invoked telemetry event

* Added queryperformance call

* Added in telemetry for key and shortcut remaps

* Removed redundant if check
This commit is contained in:
Arjun Balgovind
2020-09-08 14:40:02 -07:00
committed by GitHub
parent 1a51f77fce
commit fdd7d6afa4
3 changed files with 79 additions and 1 deletions

View File

@@ -67,3 +67,67 @@ void Trace::AppSpecificShortcutRemapCount(const DWORD shortcutToShortcutCount, c
TraceLoggingValue(shortcutToShortcutCount, "AppSpecificShortcutToShortcutRemapCount"), TraceLoggingValue(shortcutToShortcutCount, "AppSpecificShortcutToShortcutRemapCount"),
TraceLoggingValue(shortcutToKeyCount, "AppSpecificShortcutToKeyRemapCount")); TraceLoggingValue(shortcutToKeyCount, "AppSpecificShortcutToKeyRemapCount"));
} }
// Log if a key remap has been invoked
void Trace::KeyRemapInvoked(bool isKeyToKey) noexcept
{
if (isKeyToKey)
{
TraceLoggingWrite(
g_hProvider,
"KeyboardManager_KeyToKeyRemapInvoked",
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
TraceLoggingKeyword(PROJECT_KEYWORD_MEASURE));
}
else
{
TraceLoggingWrite(
g_hProvider,
"KeyboardManager_KeyToShortcutRemapInvoked",
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
TraceLoggingKeyword(PROJECT_KEYWORD_MEASURE));
}
}
// Log if a shortcut remap has been invoked
void Trace::ShortcutRemapInvoked(bool isShortcutToShortcut, bool isAppSpecific) noexcept
{
if (isAppSpecific)
{
if (isShortcutToShortcut)
{
TraceLoggingWrite(
g_hProvider,
"KeyboardManager_AppSpecificShortcutToShortcutRemapInvoked",
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
TraceLoggingKeyword(PROJECT_KEYWORD_MEASURE));
}
else
{
TraceLoggingWrite(
g_hProvider,
"KeyboardManager_AppSpecificShortcutToKeyRemapInvoked",
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
TraceLoggingKeyword(PROJECT_KEYWORD_MEASURE));
}
}
else
{
if (isShortcutToShortcut)
{
TraceLoggingWrite(
g_hProvider,
"KeyboardManager_OSLevelShortcutToShortcutRemapInvoked",
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
TraceLoggingKeyword(PROJECT_KEYWORD_MEASURE));
}
else
{
TraceLoggingWrite(
g_hProvider,
"KeyboardManager_OSLevelShortcutToKeyRemapInvoked",
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
TraceLoggingKeyword(PROJECT_KEYWORD_MEASURE));
}
}
}

View File

@@ -17,4 +17,10 @@ public:
// Log number of app specific shortcut remaps when the user uses Edit Shortcuts and saves settings // Log number of app specific shortcut remaps when the user uses Edit Shortcuts and saves settings
static void AppSpecificShortcutRemapCount(const DWORD shortcutToShortcutCount, const DWORD shortcutToKeyCount) noexcept; static void AppSpecificShortcutRemapCount(const DWORD shortcutToShortcutCount, const DWORD shortcutToKeyCount) noexcept;
// Log if a key remap has been invoked
static void KeyRemapInvoked(bool isKeyToKey) noexcept;
// Log if a shortcut remap has been invoked
static void ShortcutRemapInvoked(bool isShortcutToShortcut, bool isAppSpecific) noexcept;
}; };

View File

@@ -6,6 +6,7 @@
#include <keyboardmanager/common/KeyboardManagerState.h> #include <keyboardmanager/common/KeyboardManagerState.h>
#include <keyboardmanager/common/InputInterface.h> #include <keyboardmanager/common/InputInterface.h>
#include <keyboardmanager/common/Helpers.h> #include <keyboardmanager/common/Helpers.h>
#include <keyboardmanager/common/trace.h>
namespace KeyboardEventHandlers namespace KeyboardEventHandlers
{ {
@@ -98,9 +99,12 @@ namespace KeyboardEventHandlers
UINT res = ii.SendVirtualInput(key_count, keyEventList, sizeof(INPUT)); UINT res = ii.SendVirtualInput(key_count, keyEventList, sizeof(INPUT));
delete[] keyEventList; delete[] keyEventList;
// If Caps Lock is being remapped to Ctrl/Alt/Shift, then reset the modifier key state to fix issues in certain IME keyboards where the IME shortcut gets invoked since it detects that the modifier and Caps Lock is pressed even though it is suppressed by the hook - More information at the GitHub issue https://github.com/microsoft/PowerToys/issues/3397
if (data->wParam == WM_KEYDOWN || data->wParam == WM_SYSKEYDOWN) if (data->wParam == WM_KEYDOWN || data->wParam == WM_SYSKEYDOWN)
{ {
// Log telemetry event when the key remap is invoked
Trace::KeyRemapInvoked(remapToKey);
// If Caps Lock is being remapped to Ctrl/Alt/Shift, then reset the modifier key state to fix issues in certain IME keyboards where the IME shortcut gets invoked since it detects that the modifier and Caps Lock is pressed even though it is suppressed by the hook - More information at the GitHub issue https://github.com/microsoft/PowerToys/issues/3397
if (remapToKey) if (remapToKey)
{ {
ResetIfModifierKeyForLowerLevelKeyHandlers(ii, target, it->first); ResetIfModifierKeyForLowerLevelKeyHandlers(ii, target, it->first);
@@ -311,6 +315,10 @@ namespace KeyboardEventHandlers
lock.unlock(); lock.unlock();
UINT res = ii.SendVirtualInput((UINT)key_count, keyEventList, sizeof(INPUT)); UINT res = ii.SendVirtualInput((UINT)key_count, keyEventList, sizeof(INPUT));
delete[] keyEventList; delete[] keyEventList;
// Log telemetry event when shortcut remap is invoked
Trace::ShortcutRemapInvoked(remapToShortcut, activatedApp != KeyboardManagerConstants::NoActivatedApp);
return 1; return 1;
} }
} }