Skip to content

Commit b50eaa1

Browse files
Add branding and unpackaged metadata to a few telemetry events (#18926)
## Summary of the Pull Request 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.
1 parent 32feec0 commit b50eaa1

File tree

5 files changed

+46
-151
lines changed

5 files changed

+46
-151
lines changed

src/cascadia/TerminalApp/ShortcutActionDispatch.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
#include "pch.h"
55
#include "ShortcutActionDispatch.h"
6+
#include "WtExeUtils.h"
67

78
#include "ShortcutActionDispatch.g.cpp"
89

@@ -53,11 +54,22 @@ namespace winrt::TerminalApp::implementation
5354

5455
if (handled)
5556
{
57+
#if defined(WT_BRANDING_RELEASE)
58+
constexpr uint8_t branding = 3;
59+
#elif defined(WT_BRANDING_PREVIEW)
60+
constexpr uint8_t branding = 2;
61+
#elif defined(WT_BRANDING_CANARY)
62+
constexpr uint8_t branding = 1;
63+
#else
64+
constexpr uint8_t branding = 0;
65+
#endif
66+
5667
TraceLoggingWrite(
5768
g_hTerminalAppProvider,
5869
"ActionDispatched",
5970
TraceLoggingDescription("Event emitted when an action was successfully performed"),
6071
TraceLoggingValue(static_cast<int>(actionAndArgs.Action()), "Action"),
72+
TraceLoggingValue(branding, "Branding"),
6173
TraceLoggingKeyword(MICROSOFT_KEYWORD_MEASURES),
6274
TelemetryPrivacyDataTag(PDT_ProductAndServiceUsage));
6375
}

src/cascadia/TerminalSettingsEditor/NewTabMenuViewModel.cpp

Lines changed: 0 additions & 135 deletions
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,6 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
363363

364364
const auto& entryVM = make<ProfileEntryViewModel>(profileEntry);
365365
CurrentView().Append(entryVM);
366-
_PrintAll();
367366
return entryVM;
368367
}
369368
return nullptr;
@@ -374,8 +373,6 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
374373
Model::SeparatorEntry separatorEntry;
375374
const auto& entryVM = make<SeparatorEntryViewModel>(separatorEntry);
376375
CurrentView().Append(entryVM);
377-
378-
_PrintAll();
379376
return entryVM;
380377
}
381378

@@ -390,8 +387,6 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
390387
// Reset state after adding the entry
391388
AddFolderName({});
392389
_folderTreeCache = nullptr;
393-
394-
_PrintAll();
395390
return entryVM;
396391
}
397392

@@ -410,7 +405,6 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
410405
ProfileMatcherSource({});
411406
ProfileMatcherCommandline({});
412407

413-
_PrintAll();
414408
return entryVM;
415409
}
416410

@@ -422,7 +416,6 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
422416

423417
_NotifyChanges(L"IsRemainingProfilesEntryMissing");
424418

425-
_PrintAll();
426419
return entryVM;
427420
}
428421

@@ -496,134 +489,6 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
496489
return _folderEntry.Icon();
497490
}
498491

499-
void NewTabMenuViewModel::_PrintAll()
500-
{
501-
#ifdef _DEBUG
502-
OutputDebugString(L"---Model:---\n");
503-
_PrintModel(_Settings.GlobalSettings().NewTabMenu());
504-
OutputDebugString(L"\n");
505-
OutputDebugString(L"---VM:---\n");
506-
_PrintVM(_rootEntries);
507-
OutputDebugString(L"\n");
508-
#endif
509-
}
510-
511-
#ifdef _DEBUG
512-
void NewTabMenuViewModel::_PrintModel(Windows::Foundation::Collections::IVector<Model::NewTabMenuEntry> list, std::wstring prefix)
513-
{
514-
if (!list)
515-
{
516-
return;
517-
}
518-
519-
for (auto&& e : list)
520-
{
521-
_PrintModel(e, prefix);
522-
}
523-
}
524-
525-
void NewTabMenuViewModel::_PrintModel(const Model::NewTabMenuEntry& e, std::wstring prefix)
526-
{
527-
switch (e.Type())
528-
{
529-
case NewTabMenuEntryType::Profile:
530-
{
531-
const auto& pe = e.as<Model::ProfileEntry>();
532-
OutputDebugString(fmt::format(L"{}Profile: {}\n", prefix, pe.Profile().Name()).c_str());
533-
break;
534-
}
535-
case NewTabMenuEntryType::Action:
536-
{
537-
const auto& actionEntry = e.as<Model::ActionEntry>();
538-
OutputDebugString(fmt::format(L"{}Action: {}\n", prefix, actionEntry.ActionId()).c_str());
539-
break;
540-
}
541-
case NewTabMenuEntryType::Separator:
542-
{
543-
OutputDebugString(fmt::format(L"{}Separator\n", prefix).c_str());
544-
break;
545-
}
546-
case NewTabMenuEntryType::Folder:
547-
{
548-
const auto& fe = e.as<Model::FolderEntry>();
549-
OutputDebugString(fmt::format(L"{}Folder: {}\n", prefix, fe.Name()).c_str());
550-
_PrintModel(fe.RawEntries(), prefix + L" ");
551-
break;
552-
}
553-
case NewTabMenuEntryType::MatchProfiles:
554-
{
555-
const auto& matchProfilesEntry = e.as<Model::MatchProfilesEntry>();
556-
OutputDebugString(fmt::format(L"{}MatchProfiles: {}\n", prefix, matchProfilesEntry.Name()).c_str());
557-
break;
558-
}
559-
case NewTabMenuEntryType::RemainingProfiles:
560-
{
561-
OutputDebugString(fmt::format(L"{}RemainingProfiles\n", prefix).c_str());
562-
break;
563-
}
564-
default:
565-
break;
566-
}
567-
}
568-
569-
void NewTabMenuViewModel::_PrintVM(Windows::Foundation::Collections::IVector<Editor::NewTabMenuEntryViewModel> list, std::wstring prefix)
570-
{
571-
if (!list)
572-
{
573-
return;
574-
}
575-
576-
for (auto&& e : list)
577-
{
578-
_PrintVM(e, prefix);
579-
}
580-
}
581-
582-
void NewTabMenuViewModel::_PrintVM(const Editor::NewTabMenuEntryViewModel& e, std::wstring prefix)
583-
{
584-
switch (e.Type())
585-
{
586-
case NewTabMenuEntryType::Profile:
587-
{
588-
const auto& pe = e.as<Editor::ProfileEntryViewModel>();
589-
OutputDebugString(fmt::format(L"{}Profile: {}\n", prefix, pe.ProfileEntry().Profile().Name()).c_str());
590-
break;
591-
}
592-
case NewTabMenuEntryType::Action:
593-
{
594-
const auto& actionEntry = e.as<Editor::ActionEntryViewModel>();
595-
OutputDebugString(fmt::format(L"{}Action: {}\n", prefix, actionEntry.ActionEntry().ActionId()).c_str());
596-
break;
597-
}
598-
case NewTabMenuEntryType::Separator:
599-
{
600-
OutputDebugString(fmt::format(L"{}Separator\n", prefix).c_str());
601-
break;
602-
}
603-
case NewTabMenuEntryType::Folder:
604-
{
605-
const auto& fe = e.as<Editor::FolderEntryViewModel>();
606-
OutputDebugString(fmt::format(L"{}Folder: {}\n", prefix, fe.Name()).c_str());
607-
_PrintVM(fe.Entries(), prefix + L" ");
608-
break;
609-
}
610-
case NewTabMenuEntryType::MatchProfiles:
611-
{
612-
const auto& matchProfilesEntry = e.as<Editor::MatchProfilesEntryViewModel>();
613-
OutputDebugString(fmt::format(L"{}MatchProfiles: {}\n", prefix, matchProfilesEntry.DisplayText()).c_str());
614-
break;
615-
}
616-
case NewTabMenuEntryType::RemainingProfiles:
617-
{
618-
OutputDebugString(fmt::format(L"{}RemainingProfiles\n", prefix).c_str());
619-
break;
620-
}
621-
default:
622-
break;
623-
}
624-
}
625-
#endif
626-
627492
NewTabMenuEntryViewModel::NewTabMenuEntryViewModel(const NewTabMenuEntryType type) noexcept :
628493
_Type{ type }
629494
{

src/cascadia/TerminalSettingsEditor/NewTabMenuViewModel.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -68,14 +68,6 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
6868

6969
static bool _IsRemainingProfilesEntryMissing(const Windows::Foundation::Collections::IVector<Editor::NewTabMenuEntryViewModel>& entries);
7070
void _FolderPropertyChanged(const IInspectable& sender, const Windows::UI::Xaml::Data::PropertyChangedEventArgs& args);
71-
72-
void _PrintAll();
73-
#ifdef _DEBUG
74-
void _PrintModel(Windows::Foundation::Collections::IVector<Model::NewTabMenuEntry> list, std::wstring prefix = L"");
75-
void _PrintModel(const Model::NewTabMenuEntry& e, std::wstring prefix = L"");
76-
void _PrintVM(Windows::Foundation::Collections::IVector<Editor::NewTabMenuEntryViewModel> list, std::wstring prefix = L"");
77-
void _PrintVM(const Editor::NewTabMenuEntryViewModel& vm, std::wstring prefix = L"");
78-
#endif
7971
};
8072

8173
struct FolderTreeViewEntry : FolderTreeViewEntryT<FolderTreeViewEntry>

src/cascadia/TerminalSettingsModel/CascadiaSettingsSerialization.cpp

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include "ProfileEntry.h"
2828
#include "FolderEntry.h"
2929
#include "MatchProfilesEntry.h"
30+
#include "WtExeUtils.h"
3031

3132
using namespace winrt::Windows::Foundation::Collections;
3233
using namespace winrt::Windows::ApplicationModel::AppExtensions;
@@ -1685,10 +1686,22 @@ void CascadiaSettings::LogSettingChanges(bool isJsonLoad) const
16851686
changes.insert(change);
16861687
}
16871688

1689+
#if defined(WT_BRANDING_RELEASE)
1690+
constexpr uint8_t branding = 3;
1691+
#elif defined(WT_BRANDING_PREVIEW)
1692+
constexpr uint8_t branding = 2;
1693+
#elif defined(WT_BRANDING_CANARY)
1694+
constexpr uint8_t branding = 1;
1695+
#else
1696+
constexpr uint8_t branding = 0;
1697+
#endif
1698+
const uint8_t distribution = IsPackaged() ? 2 :
1699+
IsPortableMode() ? 1 :
1700+
0;
1701+
16881702
// report changes
16891703
for (const auto& change : changes)
16901704
{
1691-
#ifndef _DEBUG
16921705
// A `isJsonLoad ? "JsonSettingsChanged" : "UISettingsChanged"`
16931706
// would be nice, but that apparently isn't allowed in the macro below.
16941707
// Also, there's guidance to not send too much data all in one event,
@@ -1698,7 +1711,9 @@ void CascadiaSettings::LogSettingChanges(bool isJsonLoad) const
16981711
TraceLoggingWrite(g_hSettingsModelProvider,
16991712
"JsonSettingsChanged",
17001713
TraceLoggingDescription("Event emitted when settings.json change"),
1701-
TraceLoggingValue(change.data()),
1714+
TraceLoggingValue(change.data(), "Setting"),
1715+
TraceLoggingValue(branding, "Branding"),
1716+
TraceLoggingValue(distribution, "Distribution"),
17021717
TraceLoggingKeyword(MICROSOFT_KEYWORD_MEASURES),
17031718
TelemetryPrivacyDataTag(PDT_ProductAndServiceUsage));
17041719
}
@@ -1707,14 +1722,11 @@ void CascadiaSettings::LogSettingChanges(bool isJsonLoad) const
17071722
TraceLoggingWrite(g_hSettingsModelProvider,
17081723
"UISettingsChanged",
17091724
TraceLoggingDescription("Event emitted when settings change via the UI"),
1710-
TraceLoggingValue(change.data()),
1725+
TraceLoggingValue(change.data(), "Setting"),
1726+
TraceLoggingValue(branding, "Branding"),
1727+
TraceLoggingValue(distribution, "Distribution"),
17111728
TraceLoggingKeyword(MICROSOFT_KEYWORD_MEASURES),
17121729
TelemetryPrivacyDataTag(PDT_ProductAndServiceUsage));
17131730
}
1714-
#else
1715-
OutputDebugStringA(isJsonLoad ? "JsonSettingsChanged - " : "UISettingsChanged - ");
1716-
OutputDebugStringA(change.data());
1717-
OutputDebugStringA("\n");
1718-
#endif // !_DEBUG
17191731
}
17201732
}

src/cascadia/WindowsTerminal/WindowEmperor.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -399,10 +399,24 @@ void WindowEmperor::HandleCommandlineArgs(int nCmdShow)
399399
{
400400
if (!loggedInteraction)
401401
{
402+
#if defined(WT_BRANDING_RELEASE)
403+
constexpr uint8_t branding = 3;
404+
#elif defined(WT_BRANDING_PREVIEW)
405+
constexpr uint8_t branding = 2;
406+
#elif defined(WT_BRANDING_CANARY)
407+
constexpr uint8_t branding = 1;
408+
#else
409+
constexpr uint8_t branding = 0;
410+
#endif
411+
const uint8_t distribution = IsPackaged() ? 2 :
412+
_app.Logic().Settings().IsPortableMode() ? 1 :
413+
0;
402414
TraceLoggingWrite(
403415
g_hWindowsTerminalProvider,
404416
"SessionBecameInteractive",
405417
TraceLoggingDescription("Event emitted when the session was interacted with"),
418+
TraceLoggingValue(branding, "Branding"),
419+
TraceLoggingValue(distribution, "Distribution"),
406420
TraceLoggingKeyword(MICROSOFT_KEYWORD_MEASURES),
407421
TelemetryPrivacyDataTag(PDT_ProductAndServiceUsage));
408422
loggedInteraction = true;

0 commit comments

Comments
 (0)