Skip to content

Commit 820b10f

Browse files
carlos-zamoraDHowett
authored andcommitted
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. (cherry picked from commit b50eaa1) Service-Card-Id: PVTI_lADOAF3p4s4Axadtzgaj8x4 Service-Version: 1.23
1 parent 2801e9a commit 820b10f

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;
@@ -1668,10 +1669,22 @@ void CascadiaSettings::LogSettingChanges(bool isJsonLoad) const
16681669
changes.insert(change);
16691670
}
16701671

1672+
#if defined(WT_BRANDING_RELEASE)
1673+
constexpr uint8_t branding = 3;
1674+
#elif defined(WT_BRANDING_PREVIEW)
1675+
constexpr uint8_t branding = 2;
1676+
#elif defined(WT_BRANDING_CANARY)
1677+
constexpr uint8_t branding = 1;
1678+
#else
1679+
constexpr uint8_t branding = 0;
1680+
#endif
1681+
const uint8_t distribution = IsPackaged() ? 2 :
1682+
IsPortableMode() ? 1 :
1683+
0;
1684+
16711685
// report changes
16721686
for (const auto& change : changes)
16731687
{
1674-
#ifndef _DEBUG
16751688
// A `isJsonLoad ? "JsonSettingsChanged" : "UISettingsChanged"`
16761689
// would be nice, but that apparently isn't allowed in the macro below.
16771690
// Also, there's guidance to not send too much data all in one event,
@@ -1681,7 +1694,9 @@ void CascadiaSettings::LogSettingChanges(bool isJsonLoad) const
16811694
TraceLoggingWrite(g_hSettingsModelProvider,
16821695
"JsonSettingsChanged",
16831696
TraceLoggingDescription("Event emitted when settings.json change"),
1684-
TraceLoggingValue(change.data()),
1697+
TraceLoggingValue(change.data(), "Setting"),
1698+
TraceLoggingValue(branding, "Branding"),
1699+
TraceLoggingValue(distribution, "Distribution"),
16851700
TraceLoggingKeyword(MICROSOFT_KEYWORD_MEASURES),
16861701
TelemetryPrivacyDataTag(PDT_ProductAndServiceUsage));
16871702
}
@@ -1690,14 +1705,11 @@ void CascadiaSettings::LogSettingChanges(bool isJsonLoad) const
16901705
TraceLoggingWrite(g_hSettingsModelProvider,
16911706
"UISettingsChanged",
16921707
TraceLoggingDescription("Event emitted when settings change via the UI"),
1693-
TraceLoggingValue(change.data()),
1708+
TraceLoggingValue(change.data(), "Setting"),
1709+
TraceLoggingValue(branding, "Branding"),
1710+
TraceLoggingValue(distribution, "Distribution"),
16941711
TraceLoggingKeyword(MICROSOFT_KEYWORD_MEASURES),
16951712
TelemetryPrivacyDataTag(PDT_ProductAndServiceUsage));
16961713
}
1697-
#else
1698-
OutputDebugStringA(isJsonLoad ? "JsonSettingsChanged - " : "UISettingsChanged - ");
1699-
OutputDebugStringA(change.data());
1700-
OutputDebugStringA("\n");
1701-
#endif // !_DEBUG
17021714
}
17031715
}

src/cascadia/WindowsTerminal/WindowEmperor.cpp

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

0 commit comments

Comments
 (0)