Add branding and unpackaged metadata to a few telemetry events (#18926)

Adds branding and distribution metadata to the following telemetry
events:
- ActionDispatched (branding only)
- JsonSettingsChanged
- UISettingsChanged
- SessionBecameInteractive

Also removes the settings logger output from the debugger and some
leftover debugging functions.
Adds a label to the XSettingsChanged settings value to make it easier to
read on the backend.

(cherry picked from commit b50eaa19e0cfa396d40d2359c1b64e73e2d6af4f)
Service-Card-Id: PVTI_lADOAF3p4s4AmhmQzgaj8x8
Service-Version: 1.22
This commit is contained in:
Carlos Zamora 2025-05-22 16:56:00 -07:00 committed by Dustin L. Howett
parent 32e69d7163
commit e21b2c6643
3 changed files with 47 additions and 8 deletions

View File

@ -3,6 +3,7 @@
#include "pch.h"
#include "ShortcutActionDispatch.h"
#include "WtExeUtils.h"
#include "ShortcutActionDispatch.g.cpp"
@ -53,11 +54,22 @@ namespace winrt::TerminalApp::implementation
if (handled)
{
#if defined(WT_BRANDING_RELEASE)
constexpr uint8_t branding = 3;
#elif defined(WT_BRANDING_PREVIEW)
constexpr uint8_t branding = 2;
#elif defined(WT_BRANDING_CANARY)
constexpr uint8_t branding = 1;
#else
constexpr uint8_t branding = 0;
#endif
TraceLoggingWrite(
g_hTerminalAppProvider,
"ActionDispatched",
TraceLoggingDescription("Event emitted when an action was successfully performed"),
TraceLoggingValue(static_cast<int>(actionAndArgs.Action()), "Action"),
TraceLoggingValue(branding, "Branding"),
TraceLoggingKeyword(MICROSOFT_KEYWORD_MEASURES),
TelemetryPrivacyDataTag(PDT_ProductAndServiceUsage));
}

View File

@ -27,6 +27,7 @@
#include "ProfileEntry.h"
#include "FolderEntry.h"
#include "MatchProfilesEntry.h"
#include "WtExeUtils.h"
using namespace winrt::Windows::Foundation::Collections;
using namespace winrt::Windows::ApplicationModel::AppExtensions;
@ -1668,10 +1669,22 @@ void CascadiaSettings::LogSettingChanges(bool isJsonLoad) const
changes.insert(change);
}
#if defined(WT_BRANDING_RELEASE)
constexpr uint8_t branding = 3;
#elif defined(WT_BRANDING_PREVIEW)
constexpr uint8_t branding = 2;
#elif defined(WT_BRANDING_CANARY)
constexpr uint8_t branding = 1;
#else
constexpr uint8_t branding = 0;
#endif
const uint8_t distribution = IsPackaged() ? 2 :
IsPortableMode() ? 1 :
0;
// report changes
for (const auto& change : changes)
{
#ifndef _DEBUG
// A `isJsonLoad ? "JsonSettingsChanged" : "UISettingsChanged"`
// would be nice, but that apparently isn't allowed in the macro below.
// Also, there's guidance to not send too much data all in one event,
@ -1681,7 +1694,9 @@ void CascadiaSettings::LogSettingChanges(bool isJsonLoad) const
TraceLoggingWrite(g_hSettingsModelProvider,
"JsonSettingsChanged",
TraceLoggingDescription("Event emitted when settings.json change"),
TraceLoggingValue(change.data()),
TraceLoggingValue(change.data(), "Setting"),
TraceLoggingValue(branding, "Branding"),
TraceLoggingValue(distribution, "Distribution"),
TraceLoggingKeyword(MICROSOFT_KEYWORD_MEASURES),
TelemetryPrivacyDataTag(PDT_ProductAndServiceUsage));
}
@ -1690,14 +1705,11 @@ void CascadiaSettings::LogSettingChanges(bool isJsonLoad) const
TraceLoggingWrite(g_hSettingsModelProvider,
"UISettingsChanged",
TraceLoggingDescription("Event emitted when settings change via the UI"),
TraceLoggingValue(change.data()),
TraceLoggingValue(change.data(), "Setting"),
TraceLoggingValue(branding, "Branding"),
TraceLoggingValue(distribution, "Distribution"),
TraceLoggingKeyword(MICROSOFT_KEYWORD_MEASURES),
TelemetryPrivacyDataTag(PDT_ProductAndServiceUsage));
}
#else
OutputDebugStringA(isJsonLoad ? "JsonSettingsChanged - " : "UISettingsChanged - ");
OutputDebugStringA(change.data());
OutputDebugStringA("\n");
#endif // !_DEBUG
}
}

View File

@ -195,10 +195,25 @@ int WindowThread::_messagePump()
if (!_loggedInteraction && (message.message == WM_KEYDOWN || message.message == WM_SYSKEYDOWN))
{
#if defined(WT_BRANDING_RELEASE)
constexpr uint8_t branding = 3;
#elif defined(WT_BRANDING_PREVIEW)
constexpr uint8_t branding = 2;
#elif defined(WT_BRANDING_CANARY)
constexpr uint8_t branding = 1;
#else
constexpr uint8_t branding = 0;
#endif
const uint8_t distribution = IsPackaged() ? 2 :
_appLogic.Settings().IsPortableMode() ? 1 :
0;
TraceLoggingWrite(
g_hWindowsTerminalProvider,
"SessionBecameInteractive",
TraceLoggingDescription("Event emitted when the session was interacted with"),
TraceLoggingValue(branding, "Branding"),
TraceLoggingValue(distribution, "Distribution"),
TraceLoggingKeyword(MICROSOFT_KEYWORD_MEASURES),
TelemetryPrivacyDataTag(PDT_ProductAndServiceUsage));
_loggedInteraction = true;