mirror of
https://github.com/microsoft/terminal.git
synced 2025-12-10 00:48:23 -06:00
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.
This commit is contained in:
parent
32feec087b
commit
b50eaa19e0
@ -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));
|
||||
}
|
||||
|
||||
@ -363,7 +363,6 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
|
||||
|
||||
const auto& entryVM = make<ProfileEntryViewModel>(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<SeparatorEntryViewModel>(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<Model::NewTabMenuEntry> 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<Model::ProfileEntry>();
|
||||
OutputDebugString(fmt::format(L"{}Profile: {}\n", prefix, pe.Profile().Name()).c_str());
|
||||
break;
|
||||
}
|
||||
case NewTabMenuEntryType::Action:
|
||||
{
|
||||
const auto& actionEntry = e.as<Model::ActionEntry>();
|
||||
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<Model::FolderEntry>();
|
||||
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<Model::MatchProfilesEntry>();
|
||||
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<Editor::NewTabMenuEntryViewModel> 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<Editor::ProfileEntryViewModel>();
|
||||
OutputDebugString(fmt::format(L"{}Profile: {}\n", prefix, pe.ProfileEntry().Profile().Name()).c_str());
|
||||
break;
|
||||
}
|
||||
case NewTabMenuEntryType::Action:
|
||||
{
|
||||
const auto& actionEntry = e.as<Editor::ActionEntryViewModel>();
|
||||
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<Editor::FolderEntryViewModel>();
|
||||
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<Editor::MatchProfilesEntryViewModel>();
|
||||
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 }
|
||||
{
|
||||
|
||||
@ -68,14 +68,6 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
|
||||
|
||||
static bool _IsRemainingProfilesEntryMissing(const Windows::Foundation::Collections::IVector<Editor::NewTabMenuEntryViewModel>& entries);
|
||||
void _FolderPropertyChanged(const IInspectable& sender, const Windows::UI::Xaml::Data::PropertyChangedEventArgs& args);
|
||||
|
||||
void _PrintAll();
|
||||
#ifdef _DEBUG
|
||||
void _PrintModel(Windows::Foundation::Collections::IVector<Model::NewTabMenuEntry> list, std::wstring prefix = L"");
|
||||
void _PrintModel(const Model::NewTabMenuEntry& e, std::wstring prefix = L"");
|
||||
void _PrintVM(Windows::Foundation::Collections::IVector<Editor::NewTabMenuEntryViewModel> list, std::wstring prefix = L"");
|
||||
void _PrintVM(const Editor::NewTabMenuEntryViewModel& vm, std::wstring prefix = L"");
|
||||
#endif
|
||||
};
|
||||
|
||||
struct FolderTreeViewEntry : FolderTreeViewEntryT<FolderTreeViewEntry>
|
||||
|
||||
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
@ -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;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user