Skip to content

Commit ca70e49

Browse files
carlos-zamoraDHowett
authored andcommitted
Add telemetry for settings UI traffic (#19156)
Adds a telemetry provider to the Terminal.Settings.Editor project as well as new telemetry events to track traffic through the settings UI. Specifically, the following events were added: - `NavigatedToPage`: Event emitted when the user navigates to a page in the settings UI - Has a `PageId` parameter that includes the identifier of the page that was navigated to - (conditionally added when PageId = `page.editColorScheme`) `SchemeName` parameter tracks the name of the color scheme that's being edited - conditionally added when PageId = `page.extensions`: - `ExtensionPackageCount`: The number of extension packages displayed - `ProfilesModifiedCount`: The number of profiles modified by enabled extensions - `ProfilesAddedCount`: The number of profiles added by enabled extensions - `ColorSchemesAddedCount`: The number of color schemes added by enabled extensions - conditionally added when PageId = `page.extensions.extensionView`: - `FragmentSource`: The source of the fragment included in this extension package - `FragmentCount`: The number of fragments included in this extension package - `Enabled`: The enabled status of the extension - (conditionally added when PageID = `page.newTabMenu`) if the page is representing a folder view - conditionally added when PageID = `page.profile.*`: - `IsProfileDefaults`: if the modified profile is the profile.defaults object - `ProfileGuid`: the guid of the profile that was navigated to - `ProfileSource`: the source of the profile that was navigated to - conditionally added when PageID = `page.profile` (aka the base profile page): - `Orphaned`: tracks if the profile was orphaned - `Hidden`: tracks if the profile is hidden - (conditionally added when PageID = `page.profile.appearance`) `HasBackgroundImage`: `if the profile has a background image defined` - (conditionally added when PageID = `page.profile.appearance`) `HasUnfocusedAppearance`: `if the profile has an unfocused appearance defined` - `AddNewProfile`: Event emitted when the user adds a new profile `IsExtensionView` parameter tracks if the page is representing a view of an extension - Has a `Type` parameter that represents the type of the creation method (i.e. empty profile, duplicate) - `ResetApplicationState`: Event emitted when the user resets their application state (via the UI) - `ResetToDefaultSettings`: Event emitted when the user resets their settings to their default value (via the UI) - `OpenJson`: Event emitted when the user clicks the Open JSON button in the settings UI - Has a `SettingsTarget` parameter that represents the target settings file (i.e. settings.json vs defaults.json) - `CreateUnfocusedAppearance`: Event emitted when the user creates an unfocused appearance for a profile - `IsProfileDefaults`: if the modified profile is the profile.defaults object - `ProfileGuid`: the guid of the profile that was navigated to - `ProfileSource`: the source of the profile that was navigated to - `DeleteProfile`: Event emitted when the user deletes a profile - also includes `ProfileGuid`, `ProfileSource`, `Orphaned` from the `NavigatedToPage` section above The page ids can be reused later as a serialized reference to the page. We already use the one for the extensions page for the "new" badge. (cherry picked from commit 7578209) Service-Card-Id: PVTI_lADOAF3p4s4Axadtzgc2p-8 Service-Version: 1.23
1 parent ee9198c commit ca70e49

21 files changed

+233
-4
lines changed

src/cascadia/TerminalSettingsEditor/Actions.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,14 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
6666
}
6767
}
6868
});
69+
70+
TraceLoggingWrite(
71+
g_hTerminalSettingsEditorProvider,
72+
"NavigatedToPage",
73+
TraceLoggingDescription("Event emitted when the user navigates to a page in the settings UI"),
74+
TraceLoggingValue("actions", "PageId", "The identifier of the page that was navigated to"),
75+
TraceLoggingKeyword(MICROSOFT_KEYWORD_MEASURES),
76+
TelemetryPrivacyDataTag(PDT_ProductAndServiceUsage));
6977
}
7078

7179
void Actions::AddNew_Click(const IInspectable& /*sender*/, const RoutedEventArgs& /*eventArgs*/)

src/cascadia/TerminalSettingsEditor/AddProfile.cpp

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,27 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
2929
void AddProfile::OnNavigatedTo(const NavigationEventArgs& e)
3030
{
3131
_State = e.Parameter().as<Editor::AddProfilePageNavigationState>();
32+
33+
TraceLoggingWrite(
34+
g_hTerminalSettingsEditorProvider,
35+
"NavigatedToPage",
36+
TraceLoggingDescription("Event emitted when the user navigates to a page in the settings UI"),
37+
TraceLoggingValue("addProfile", "PageId", "The identifier of the page that was navigated to"),
38+
TraceLoggingKeyword(MICROSOFT_KEYWORD_MEASURES),
39+
TelemetryPrivacyDataTag(PDT_ProductAndServiceUsage));
3240
}
3341

3442
void AddProfile::AddNewClick(const IInspectable& /*sender*/,
3543
const Windows::UI::Xaml::RoutedEventArgs& /*eventArgs*/)
3644
{
45+
TraceLoggingWrite(
46+
g_hTerminalSettingsEditorProvider,
47+
"AddNewProfile",
48+
TraceLoggingDescription("Event emitted when the user adds a new profile"),
49+
TraceLoggingValue("EmptyProfile", "Type", "The type of the creation method (i.e. empty profile, duplicate)"),
50+
TraceLoggingKeyword(MICROSOFT_KEYWORD_MEASURES),
51+
TelemetryPrivacyDataTag(PDT_ProductAndServiceUsage));
52+
3753
_State.RequestAddNew();
3854
}
3955

@@ -42,7 +58,17 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
4258
{
4359
if (const auto selected = Profiles().SelectedItem())
4460
{
45-
_State.RequestDuplicate(selected.try_as<Model::Profile>().Guid());
61+
const auto selectedProfile = selected.as<Model::Profile>();
62+
TraceLoggingWrite(
63+
g_hTerminalSettingsEditorProvider,
64+
"AddNewProfile",
65+
TraceLoggingDescription("Event emitted when the user adds a new profile"),
66+
TraceLoggingValue("Duplicate", "Type", "The type of the creation method (i.e. empty profile, duplicate)"),
67+
TraceLoggingValue(!selectedProfile.Source().empty(), "SourceProfileHasSource", "True, if the source profile has a source (i.e. dynamic profile generator namespace, fragment). Otherwise, False, indicating it's based on a custom profile."),
68+
TraceLoggingKeyword(MICROSOFT_KEYWORD_MEASURES),
69+
TelemetryPrivacyDataTag(PDT_ProductAndServiceUsage));
70+
71+
_State.RequestDuplicate(selectedProfile.Guid());
4672
}
4773
}
4874

src/cascadia/TerminalSettingsEditor/ColorSchemes.cpp

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

4545
ColorSchemeListView().Focus(FocusState::Programmatic);
4646
});
47+
48+
TraceLoggingWrite(
49+
g_hTerminalSettingsEditorProvider,
50+
"NavigatedToPage",
51+
TraceLoggingDescription("Event emitted when the user navigates to a page in the settings UI"),
52+
TraceLoggingValue("colorSchemes", "PageId", "The identifier of the page that was navigated to"),
53+
TraceLoggingKeyword(MICROSOFT_KEYWORD_MEASURES),
54+
TelemetryPrivacyDataTag(PDT_ProductAndServiceUsage));
4755
}
4856

4957
void ColorSchemes::AddNew_Click(const IInspectable& /*sender*/, const RoutedEventArgs& /*e*/)

src/cascadia/TerminalSettingsEditor/Compatibility.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,13 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
3131
void Compatibility::OnNavigatedTo(const NavigationEventArgs& e)
3232
{
3333
_ViewModel = e.Parameter().as<Editor::CompatibilityViewModel>();
34+
35+
TraceLoggingWrite(
36+
g_hTerminalSettingsEditorProvider,
37+
"NavigatedToPage",
38+
TraceLoggingDescription("Event emitted when the user navigates to a page in the settings UI"),
39+
TraceLoggingValue("compatibility", "PageId", "The identifier of the page that was navigated to"),
40+
TraceLoggingKeyword(MICROSOFT_KEYWORD_MEASURES),
41+
TelemetryPrivacyDataTag(PDT_ProductAndServiceUsage));
3442
}
3543
}

src/cascadia/TerminalSettingsEditor/EditColorScheme.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,17 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
4242
{
4343
_ViewModel = e.Parameter().as<Editor::ColorSchemeViewModel>();
4444

45-
NameBox().Text(_ViewModel.Name());
45+
const auto schemeName = _ViewModel.Name();
46+
NameBox().Text(schemeName);
47+
48+
TraceLoggingWrite(
49+
g_hTerminalSettingsEditorProvider,
50+
"NavigatedToPage",
51+
TraceLoggingDescription("Event emitted when the user navigates to a page in the settings UI"),
52+
TraceLoggingValue("colorSchemes.editColorScheme", "PageId", "The identifier of the page that was navigated to"),
53+
TraceLoggingValue(schemeName.data(), "SchemeName", "The name of the color scheme that's being edited"),
54+
TraceLoggingKeyword(MICROSOFT_KEYWORD_MEASURES),
55+
TelemetryPrivacyDataTag(PDT_ProductAndServiceUsage));
4656
}
4757

4858
void EditColorScheme::ColorPickerChanged(const IInspectable& sender,

src/cascadia/TerminalSettingsEditor/GlobalAppearance.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,13 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
2525
void GlobalAppearance::OnNavigatedTo(const NavigationEventArgs& e)
2626
{
2727
_ViewModel = e.Parameter().as<Editor::GlobalAppearanceViewModel>();
28+
29+
TraceLoggingWrite(
30+
g_hTerminalSettingsEditorProvider,
31+
"NavigatedToPage",
32+
TraceLoggingDescription("Event emitted when the user navigates to a page in the settings UI"),
33+
TraceLoggingValue("globalAppearance", "PageId", "The identifier of the page that was navigated to"),
34+
TraceLoggingKeyword(MICROSOFT_KEYWORD_MEASURES),
35+
TelemetryPrivacyDataTag(PDT_ProductAndServiceUsage));
2836
}
2937
}

src/cascadia/TerminalSettingsEditor/Interaction.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,13 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
1818
void Interaction::OnNavigatedTo(const NavigationEventArgs& e)
1919
{
2020
_ViewModel = e.Parameter().as<Editor::InteractionViewModel>();
21+
22+
TraceLoggingWrite(
23+
g_hTerminalSettingsEditorProvider,
24+
"NavigatedToPage",
25+
TraceLoggingDescription("Event emitted when the user navigates to a page in the settings UI"),
26+
TraceLoggingValue("interaction", "PageId", "The identifier of the page that was navigated to"),
27+
TraceLoggingKeyword(MICROSOFT_KEYWORD_MEASURES),
28+
TelemetryPrivacyDataTag(PDT_ProductAndServiceUsage));
2129
}
2230
}

src/cascadia/TerminalSettingsEditor/Launch.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,5 +43,13 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
4343
_ViewModel = e.Parameter().as<Editor::LaunchViewModel>();
4444
auto innerViewModel{ winrt::get_self<Editor::implementation::LaunchViewModel>(_ViewModel) };
4545
/* coroutine dispatch */ innerViewModel->PrepareStartOnUserLoginSettings();
46+
47+
TraceLoggingWrite(
48+
g_hTerminalSettingsEditorProvider,
49+
"NavigatedToPage",
50+
TraceLoggingDescription("Event emitted when the user navigates to a page in the settings UI"),
51+
TraceLoggingValue("startup", "PageId", "The identifier of the page that was navigated to"),
52+
TraceLoggingKeyword(MICROSOFT_KEYWORD_MEASURES),
53+
TelemetryPrivacyDataTag(PDT_ProductAndServiceUsage));
4654
}
4755
}

src/cascadia/TerminalSettingsEditor/MainPage.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,15 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
333333
const auto altPressed = WI_IsFlagSet(lAltState, CoreVirtualKeyStates::Down) ||
334334
WI_IsFlagSet(rAltState, CoreVirtualKeyStates::Down);
335335
const auto target = altPressed ? SettingsTarget::DefaultsFile : SettingsTarget::SettingsFile;
336+
337+
TraceLoggingWrite(
338+
g_hTerminalSettingsEditorProvider,
339+
"OpenJson",
340+
TraceLoggingDescription("Event emitted when the user clicks the Open JSON button in the settings UI"),
341+
TraceLoggingValue(target == SettingsTarget::DefaultsFile ? "DefaultsFile" : "SettingsFile", "SettingsTarget", "The target settings file"),
342+
TraceLoggingKeyword(MICROSOFT_KEYWORD_MEASURES),
343+
TelemetryPrivacyDataTag(PDT_ProductAndServiceUsage));
344+
336345
OpenJson.raise(nullptr, target);
337346
return;
338347
}

src/cascadia/TerminalSettingsEditor/Microsoft.Terminal.Settings.Editor.vcxproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,7 @@
227227
</ItemGroup>
228228
<!-- ========================= Cpp Files ======================== -->
229229
<ItemGroup>
230+
<ClCompile Include="init.cpp" />
230231
<ClCompile Include="Actions.cpp">
231232
<DependentUpon>Actions.xaml</DependentUpon>
232233
</ClCompile>

0 commit comments

Comments
 (0)