diff --git a/src/cascadia/TerminalApp/ShortcutActionDispatch.cpp b/src/cascadia/TerminalApp/ShortcutActionDispatch.cpp index 3f7e509ab1..28cb64b5aa 100644 --- a/src/cascadia/TerminalApp/ShortcutActionDispatch.cpp +++ b/src/cascadia/TerminalApp/ShortcutActionDispatch.cpp @@ -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(actionAndArgs.Action()), "Action"), + TraceLoggingValue(branding, "Branding"), TraceLoggingKeyword(MICROSOFT_KEYWORD_MEASURES), TelemetryPrivacyDataTag(PDT_ProductAndServiceUsage)); } diff --git a/src/cascadia/TerminalSettingsEditor/NewTabMenuViewModel.cpp b/src/cascadia/TerminalSettingsEditor/NewTabMenuViewModel.cpp index 62986177cc..f04c24346e 100644 --- a/src/cascadia/TerminalSettingsEditor/NewTabMenuViewModel.cpp +++ b/src/cascadia/TerminalSettingsEditor/NewTabMenuViewModel.cpp @@ -363,7 +363,6 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation const auto& entryVM = make(profileEntry); CurrentView().Append(entryVM); - _PrintAll(); return entryVM; } return nullptr; @@ -374,8 +373,6 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation Model::SeparatorEntry separatorEntry; const auto& entryVM = make(separatorEntry); CurrentView().Append(entryVM); - - _PrintAll(); return entryVM; } @@ -390,8 +387,6 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation // Reset state after adding the entry AddFolderName({}); _folderTreeCache = nullptr; - - _PrintAll(); return entryVM; } @@ -410,7 +405,6 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation ProfileMatcherSource({}); ProfileMatcherCommandline({}); - _PrintAll(); return entryVM; } @@ -422,7 +416,6 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation _NotifyChanges(L"IsRemainingProfilesEntryMissing"); - _PrintAll(); return entryVM; } @@ -496,134 +489,6 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation return _folderEntry.Icon(); } - void NewTabMenuViewModel::_PrintAll() - { -#ifdef _DEBUG - OutputDebugString(L"---Model:---\n"); - _PrintModel(_Settings.GlobalSettings().NewTabMenu()); - OutputDebugString(L"\n"); - OutputDebugString(L"---VM:---\n"); - _PrintVM(_rootEntries); - OutputDebugString(L"\n"); -#endif - } - -#ifdef _DEBUG - void NewTabMenuViewModel::_PrintModel(Windows::Foundation::Collections::IVector list, std::wstring prefix) - { - if (!list) - { - return; - } - - for (auto&& e : list) - { - _PrintModel(e, prefix); - } - } - - void NewTabMenuViewModel::_PrintModel(const Model::NewTabMenuEntry& e, std::wstring prefix) - { - switch (e.Type()) - { - case NewTabMenuEntryType::Profile: - { - const auto& pe = e.as(); - OutputDebugString(fmt::format(L"{}Profile: {}\n", prefix, pe.Profile().Name()).c_str()); - break; - } - case NewTabMenuEntryType::Action: - { - const auto& actionEntry = e.as(); - OutputDebugString(fmt::format(L"{}Action: {}\n", prefix, actionEntry.ActionId()).c_str()); - break; - } - case NewTabMenuEntryType::Separator: - { - OutputDebugString(fmt::format(L"{}Separator\n", prefix).c_str()); - break; - } - case NewTabMenuEntryType::Folder: - { - const auto& fe = e.as(); - OutputDebugString(fmt::format(L"{}Folder: {}\n", prefix, fe.Name()).c_str()); - _PrintModel(fe.RawEntries(), prefix + L" "); - break; - } - case NewTabMenuEntryType::MatchProfiles: - { - const auto& matchProfilesEntry = e.as(); - OutputDebugString(fmt::format(L"{}MatchProfiles: {}\n", prefix, matchProfilesEntry.Name()).c_str()); - break; - } - case NewTabMenuEntryType::RemainingProfiles: - { - OutputDebugString(fmt::format(L"{}RemainingProfiles\n", prefix).c_str()); - break; - } - default: - break; - } - } - - void NewTabMenuViewModel::_PrintVM(Windows::Foundation::Collections::IVector list, std::wstring prefix) - { - if (!list) - { - return; - } - - for (auto&& e : list) - { - _PrintVM(e, prefix); - } - } - - void NewTabMenuViewModel::_PrintVM(const Editor::NewTabMenuEntryViewModel& e, std::wstring prefix) - { - switch (e.Type()) - { - case NewTabMenuEntryType::Profile: - { - const auto& pe = e.as(); - OutputDebugString(fmt::format(L"{}Profile: {}\n", prefix, pe.ProfileEntry().Profile().Name()).c_str()); - break; - } - case NewTabMenuEntryType::Action: - { - const auto& actionEntry = e.as(); - OutputDebugString(fmt::format(L"{}Action: {}\n", prefix, actionEntry.ActionEntry().ActionId()).c_str()); - break; - } - case NewTabMenuEntryType::Separator: - { - OutputDebugString(fmt::format(L"{}Separator\n", prefix).c_str()); - break; - } - case NewTabMenuEntryType::Folder: - { - const auto& fe = e.as(); - OutputDebugString(fmt::format(L"{}Folder: {}\n", prefix, fe.Name()).c_str()); - _PrintVM(fe.Entries(), prefix + L" "); - break; - } - case NewTabMenuEntryType::MatchProfiles: - { - const auto& matchProfilesEntry = e.as(); - OutputDebugString(fmt::format(L"{}MatchProfiles: {}\n", prefix, matchProfilesEntry.DisplayText()).c_str()); - break; - } - case NewTabMenuEntryType::RemainingProfiles: - { - OutputDebugString(fmt::format(L"{}RemainingProfiles\n", prefix).c_str()); - break; - } - default: - break; - } - } -#endif - NewTabMenuEntryViewModel::NewTabMenuEntryViewModel(const NewTabMenuEntryType type) noexcept : _Type{ type } { diff --git a/src/cascadia/TerminalSettingsEditor/NewTabMenuViewModel.h b/src/cascadia/TerminalSettingsEditor/NewTabMenuViewModel.h index c5486f68b5..9a1ea51e2b 100644 --- a/src/cascadia/TerminalSettingsEditor/NewTabMenuViewModel.h +++ b/src/cascadia/TerminalSettingsEditor/NewTabMenuViewModel.h @@ -68,14 +68,6 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation static bool _IsRemainingProfilesEntryMissing(const Windows::Foundation::Collections::IVector& entries); void _FolderPropertyChanged(const IInspectable& sender, const Windows::UI::Xaml::Data::PropertyChangedEventArgs& args); - - void _PrintAll(); -#ifdef _DEBUG - void _PrintModel(Windows::Foundation::Collections::IVector list, std::wstring prefix = L""); - void _PrintModel(const Model::NewTabMenuEntry& e, std::wstring prefix = L""); - void _PrintVM(Windows::Foundation::Collections::IVector list, std::wstring prefix = L""); - void _PrintVM(const Editor::NewTabMenuEntryViewModel& vm, std::wstring prefix = L""); -#endif }; struct FolderTreeViewEntry : FolderTreeViewEntryT diff --git a/src/cascadia/TerminalSettingsModel/CascadiaSettingsSerialization.cpp b/src/cascadia/TerminalSettingsModel/CascadiaSettingsSerialization.cpp index 5fdb390b5a..2efcc1de39 100644 --- a/src/cascadia/TerminalSettingsModel/CascadiaSettingsSerialization.cpp +++ b/src/cascadia/TerminalSettingsModel/CascadiaSettingsSerialization.cpp @@ -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; @@ -1685,10 +1686,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, @@ -1698,7 +1711,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)); } @@ -1707,14 +1722,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 } } diff --git a/src/cascadia/WindowsTerminal/WindowEmperor.cpp b/src/cascadia/WindowsTerminal/WindowEmperor.cpp index e57256cb2a..1a750af650 100644 --- a/src/cascadia/WindowsTerminal/WindowEmperor.cpp +++ b/src/cascadia/WindowsTerminal/WindowEmperor.cpp @@ -399,10 +399,24 @@ void WindowEmperor::HandleCommandlineArgs(int nCmdShow) { if (!loggedInteraction) { +#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 : + _app.Logic().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;