[KBM]Send daily activation telemetry (#31593)

* [KBM]Send daily activation telemetry

* Update src/modules/keyboardmanager/KeyboardManagerEngineLibrary/KeyboardEventHandlers.cpp

Co-authored-by: Stefan Markovic <57057282+stefansjfw@users.noreply.github.com>

---------

Co-authored-by: Stefan Markovic <57057282+stefansjfw@users.noreply.github.com>
This commit is contained in:
Jaime Bernardo 2024-02-27 16:24:50 +00:00 committed by GitHub
parent a55b89e251
commit 561545af71
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 148 additions and 0 deletions

View File

@ -118,6 +118,28 @@ namespace KeyboardEventHandlers
ResetIfModifierKeyForLowerLevelKeyHandlers(ii, itSk, it->first);
}
}
// Send daily telemetry event for Keyboard Manager key activation.
if (remapToKey)
{
static int dayWeLastSentKeyToKeyTelemetryOn = -1;
auto currentDay = std::chrono::duration_cast<std::chrono::days>(std::chrono::system_clock::now().time_since_epoch()).count();
if (dayWeLastSentKeyToKeyTelemetryOn != currentDay)
{
Trace::DailyKeyToKeyRemapInvoked();
dayWeLastSentKeyToKeyTelemetryOn = currentDay;
}
}
else
{
static int dayWeLastSentKeyToShortcutTelemetryOn = -1;
auto currentDay = std::chrono::duration_cast<std::chrono::days>(std::chrono::system_clock::now().time_since_epoch()).count();
if (dayWeLastSentKeyToShortcutTelemetryOn != currentDay)
{
Trace::DailyKeyToShortcutRemapInvoked();
dayWeLastSentKeyToShortcutTelemetryOn = currentDay;
}
}
}
return 1;
@ -348,6 +370,54 @@ namespace KeyboardEventHandlers
UINT res = ii.SendVirtualInput(static_cast<UINT>(key_count), keyEventList, sizeof(INPUT));
delete[] keyEventList;
// Send daily telemetry event for Keyboard Manager key activation.
if (activatedApp.has_value())
{
if (remapToKey)
{
static int dayWeLastSentAppSpecificShortcutToKeyTelemetryOn = -1;
auto currentDay = std::chrono::duration_cast<std::chrono::days>(std::chrono::system_clock::now().time_since_epoch()).count();
if (dayWeLastSentAppSpecificShortcutToKeyTelemetryOn != currentDay)
{
Trace::DailyAppSpecificShortcutToKeyRemapInvoked();
dayWeLastSentAppSpecificShortcutToKeyTelemetryOn = currentDay;
}
}
else if (remapToShortcut)
{
static int dayWeLastSentAppSpecificShortcutToShortcutTelemetryOn = -1;
auto currentDay = std::chrono::duration_cast<std::chrono::days>(std::chrono::system_clock::now().time_since_epoch()).count();
if (dayWeLastSentAppSpecificShortcutToShortcutTelemetryOn != currentDay)
{
Trace::DailyAppSpecificShortcutToShortcutRemapInvoked();
dayWeLastSentAppSpecificShortcutToShortcutTelemetryOn = currentDay;
}
}
}
else
{
if (remapToKey)
{
static int dayWeLastSentShortcutToKeyTelemetryOn = -1;
auto currentDay = std::chrono::duration_cast<std::chrono::days>(std::chrono::system_clock::now().time_since_epoch()).count();
if (dayWeLastSentShortcutToKeyTelemetryOn != currentDay)
{
Trace::DailyShortcutToKeyRemapInvoked();
dayWeLastSentShortcutToKeyTelemetryOn = currentDay;
}
}
else if (remapToShortcut)
{
static int dayWeLastSentShortcutToShortcutTelemetryOn = -1;
auto currentDay = std::chrono::duration_cast<std::chrono::days>(std::chrono::system_clock::now().time_since_epoch()).count();
if (dayWeLastSentShortcutToShortcutTelemetryOn != currentDay)
{
Trace::DailyShortcutToShortcutRemapInvoked();
dayWeLastSentShortcutToShortcutTelemetryOn = currentDay;
}
}
}
return 1;
}
}

View File

@ -19,6 +19,66 @@ 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));
}
// 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));
}
// 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));
}
// 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));
}
// 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));
}
// 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));
}
// Log if a key remap has been invoked (not being used currently, due to being garrulous)
void Trace::KeyRemapInvoked(bool isKeyToKey) noexcept
{

View File

@ -8,6 +8,24 @@ public:
static void RegisterProvider() noexcept;
static void UnregisterProvider() noexcept;
// Log if a key to key remap has been invoked today.
static void DailyKeyToKeyRemapInvoked() noexcept;
// Log if a key to shortcut remap has been invoked today.
static void DailyKeyToShortcutRemapInvoked() noexcept;
// Log if a shortcut to key remap has been invoked today.
static void DailyShortcutToKeyRemapInvoked() noexcept;
// Log if a shortcut to shortcut remap has been invoked today.
static void DailyShortcutToShortcutRemapInvoked() noexcept;
// Log if an app specific shortcut to key remap has been invoked today.
static void DailyAppSpecificShortcutToKeyRemapInvoked() noexcept;
// Log if an app specific shortcut to shortcut remap has been invoked today.
static void DailyAppSpecificShortcutToShortcutRemapInvoked() noexcept;
// Log if a key remap has been invoked (not being used currently, due to being garrulous)
static void KeyRemapInvoked(bool isKeyToKey) noexcept;