@@ -239,6 +239,14 @@ namespace winrt::TerminalApp::implementation
239239 _newTabButton.Click ([weakThis{ get_weak () }](auto &&, auto &&) {
240240 if (auto page{ weakThis.get () })
241241 {
242+ TraceLoggingWrite (
243+ g_hTerminalAppProvider,
244+ " NewTabMenuDefaultButtonClicked" ,
245+ TraceLoggingDescription (" Event emitted when the default button from the new tab split button is invoked" ),
246+ TraceLoggingValue (page->NumberOfTabs (), " TabCount" , " The count of tabs currently opened in this window" ),
247+ TraceLoggingKeyword (MICROSOFT_KEYWORD_MEASURES),
248+ TelemetryPrivacyDataTag (PDT_ProductAndServiceUsage));
249+
242250 page->_OpenNewTerminalViaDropdown (NewTerminalArgs ());
243251 }
244252 });
@@ -880,14 +888,36 @@ namespace winrt::TerminalApp::implementation
880888 // Since the previous focus location might be discarded in the background,
881889 // e.g., the command palette will be dismissed by the menu,
882890 // and then closing the fly-out will move the focus to wrong location.
883- newTabFlyout.Opening ([this ](auto &&, auto &&) {
884- _FocusCurrentTab (true );
891+ newTabFlyout.Opening ([weakThis{ get_weak () }](auto &&, auto &&) {
892+ if (auto page{ weakThis.get () })
893+ {
894+ page->_FocusCurrentTab (true );
895+
896+ TraceLoggingWrite (
897+ g_hTerminalAppProvider,
898+ " NewTabMenuOpened" ,
899+ TraceLoggingDescription (" Event emitted when the new tab menu is opened" ),
900+ TraceLoggingValue (page->NumberOfTabs (), " TabCount" , " The Count of tabs currently opened in this window" ),
901+ TraceLoggingKeyword (MICROSOFT_KEYWORD_MEASURES),
902+ TelemetryPrivacyDataTag (PDT_ProductAndServiceUsage));
903+ }
885904 });
886905 // Necessary for fly-out sub items to get focus on a tab before collapsing. Related to #15049
887- newTabFlyout.Closing ([this ](auto &&, auto &&) {
888- if (! _commandPaletteIs (Visibility::Visible) )
906+ newTabFlyout.Closing ([weakThis{ get_weak () } ](auto &&, auto &&) {
907+ if (auto page{ weakThis. get () } )
889908 {
890- _FocusCurrentTab (true );
909+ if (!page->_commandPaletteIs (Visibility::Visible))
910+ {
911+ page->_FocusCurrentTab (true );
912+ }
913+
914+ TraceLoggingWrite (
915+ g_hTerminalAppProvider,
916+ " NewTabMenuClosed" ,
917+ TraceLoggingDescription (" Event emitted when the new tab menu is closed" ),
918+ TraceLoggingValue (page->NumberOfTabs (), " TabCount" , " The Count of tabs currently opened in this window" ),
919+ TraceLoggingKeyword (MICROSOFT_KEYWORD_MEASURES),
920+ TelemetryPrivacyDataTag (PDT_ProductAndServiceUsage));
891921 }
892922 });
893923 _newTabButton.Flyout (newTabFlyout);
@@ -1092,6 +1122,15 @@ namespace winrt::TerminalApp::implementation
10921122 profileMenuItem.Click ([profileIndex, weakThis{ get_weak () }](auto &&, auto &&) {
10931123 if (auto page{ weakThis.get () })
10941124 {
1125+ TraceLoggingWrite (
1126+ g_hTerminalAppProvider,
1127+ " NewTabMenuItemClicked" ,
1128+ TraceLoggingDescription (" Event emitted when an item from the new tab menu is invoked" ),
1129+ TraceLoggingValue (page->NumberOfTabs (), " TabCount" , " The count of tabs currently opened in this window" ),
1130+ TraceLoggingValue (" Profile" , " ItemType" , " The type of item that was clicked in the new tab menu" ),
1131+ TraceLoggingKeyword (MICROSOFT_KEYWORD_MEASURES),
1132+ TelemetryPrivacyDataTag (PDT_ProductAndServiceUsage));
1133+
10951134 NewTerminalArgs newTerminalArgs{ profileIndex };
10961135 page->_OpenNewTerminalViaDropdown (newTerminalArgs);
10971136 }
@@ -1137,6 +1176,15 @@ namespace winrt::TerminalApp::implementation
11371176 actionMenuItem.Click ([action, weakThis{ get_weak () }](auto &&, auto &&) {
11381177 if (auto page{ weakThis.get () })
11391178 {
1179+ TraceLoggingWrite (
1180+ g_hTerminalAppProvider,
1181+ " NewTabMenuItemClicked" ,
1182+ TraceLoggingDescription (" Event emitted when an item from the new tab menu is invoked" ),
1183+ TraceLoggingValue (page->NumberOfTabs (), " TabCount" , " The count of tabs currently opened in this window" ),
1184+ TraceLoggingValue (" Action" , " ItemType" , " The type of item that was clicked in the new tab menu" ),
1185+ TraceLoggingKeyword (MICROSOFT_KEYWORD_MEASURES),
1186+ TelemetryPrivacyDataTag (PDT_ProductAndServiceUsage));
1187+
11401188 page->_actionDispatch ->DoAction (action.ActionAndArgs ());
11411189 }
11421190 });
@@ -1198,6 +1246,7 @@ namespace winrt::TerminalApp::implementation
11981246
11991247 const auto dispatchToElevatedWindow = ctrlPressed && !IsRunningElevated ();
12001248
1249+ auto sessionType = " " ;
12011250 if ((shiftPressed || dispatchToElevatedWindow) && !debugTap)
12021251 {
12031252 // Manually fill in the evaluated profile.
@@ -1215,10 +1264,12 @@ namespace winrt::TerminalApp::implementation
12151264 if (dispatchToElevatedWindow)
12161265 {
12171266 _OpenElevatedWT (newTerminalArgs);
1267+ sessionType = " ElevatedWindow" ;
12181268 }
12191269 else
12201270 {
12211271 _OpenNewWindow (newTerminalArgs);
1272+ sessionType = " Window" ;
12221273 }
12231274 }
12241275 else
@@ -1237,12 +1288,23 @@ namespace winrt::TerminalApp::implementation
12371288 SplitDirection::Automatic,
12381289 0 .5f ,
12391290 newPane);
1291+ sessionType = " Pane" ;
12401292 }
12411293 else
12421294 {
12431295 _CreateNewTabFromPane (newPane);
1296+ sessionType = " Tab" ;
12441297 }
12451298 }
1299+
1300+ TraceLoggingWrite (
1301+ g_hTerminalAppProvider,
1302+ " NewTabMenuCreatedNewTerminalSession" ,
1303+ TraceLoggingDescription (" Event emitted when a new terminal was created via the new tab menu" ),
1304+ TraceLoggingValue (NumberOfTabs (), " NewTabCount" , " The count of tabs currently opened in this window" ),
1305+ TraceLoggingValue (sessionType, " SessionType" , " The type of session that was created" ),
1306+ TraceLoggingKeyword (MICROSOFT_KEYWORD_MEASURES),
1307+ TelemetryPrivacyDataTag (PDT_ProductAndServiceUsage));
12461308 }
12471309
12481310 std::wstring TerminalPage::_evaluatePathForCwd (const std::wstring_view path)
@@ -1449,6 +1511,30 @@ namespace winrt::TerminalApp::implementation
14491511 {
14501512 target = SettingsTarget::DefaultsFile;
14511513 }
1514+
1515+ const auto targetAsString = [&target]() {
1516+ switch (target)
1517+ {
1518+ case SettingsTarget::SettingsFile:
1519+ return " SettingsFile" ;
1520+ case SettingsTarget::DefaultsFile:
1521+ return " DefaultsFile" ;
1522+ case SettingsTarget::SettingsUI:
1523+ default :
1524+ return " UI" ;
1525+ }
1526+ }();
1527+
1528+ TraceLoggingWrite (
1529+ g_hTerminalAppProvider,
1530+ " NewTabMenuItemClicked" ,
1531+ TraceLoggingDescription (" Event emitted when an item from the new tab menu is invoked" ),
1532+ TraceLoggingValue (NumberOfTabs (), " TabCount" , " The count of tabs currently opened in this window" ),
1533+ TraceLoggingValue (" Settings" , " ItemType" , " The type of item that was clicked in the new tab menu" ),
1534+ TraceLoggingValue (targetAsString, " SettingsTarget" , " The target settings file or UI" ),
1535+ TraceLoggingKeyword (MICROSOFT_KEYWORD_MEASURES),
1536+ TelemetryPrivacyDataTag (PDT_ProductAndServiceUsage));
1537+
14521538 _LaunchSettings (target);
14531539 }
14541540
@@ -1460,6 +1546,15 @@ namespace winrt::TerminalApp::implementation
14601546 auto p = LoadCommandPalette ();
14611547 p.EnableCommandPaletteMode (CommandPaletteLaunchMode::Action);
14621548 p.Visibility (Visibility::Visible);
1549+
1550+ TraceLoggingWrite (
1551+ g_hTerminalAppProvider,
1552+ " NewTabMenuItemClicked" ,
1553+ TraceLoggingDescription (" Event emitted when an item from the new tab menu is invoked" ),
1554+ TraceLoggingValue (NumberOfTabs (), " TabCount" , " The count of tabs currently opened in this window" ),
1555+ TraceLoggingValue (" CommandPalette" , " ItemType" , " The type of item that was clicked in the new tab menu" ),
1556+ TraceLoggingKeyword (MICROSOFT_KEYWORD_MEASURES),
1557+ TelemetryPrivacyDataTag (PDT_ProductAndServiceUsage));
14631558 }
14641559
14651560 // Method Description:
@@ -1472,6 +1567,15 @@ namespace winrt::TerminalApp::implementation
14721567 const RoutedEventArgs&)
14731568 {
14741569 _ShowAboutDialog ();
1570+
1571+ TraceLoggingWrite (
1572+ g_hTerminalAppProvider,
1573+ " NewTabMenuItemClicked" ,
1574+ TraceLoggingDescription (" Event emitted when an item from the new tab menu is invoked" ),
1575+ TraceLoggingValue (NumberOfTabs (), " TabCount" , " The count of tabs currently opened in this window" ),
1576+ TraceLoggingValue (" About" , " ItemType" , " The type of item that was clicked in the new tab menu" ),
1577+ TraceLoggingKeyword (MICROSOFT_KEYWORD_MEASURES),
1578+ TelemetryPrivacyDataTag (PDT_ProductAndServiceUsage));
14751579 }
14761580
14771581 // Method Description:
@@ -5381,6 +5485,14 @@ namespace winrt::TerminalApp::implementation
53815485 runAsAdminItem.Click ([profileIndex, weakThis{ get_weak () }](auto &&, auto &&) {
53825486 if (auto page{ weakThis.get () })
53835487 {
5488+ TraceLoggingWrite (
5489+ g_hTerminalAppProvider,
5490+ " NewTabMenuItemElevateSubmenuItemClicked" ,
5491+ TraceLoggingDescription (" Event emitted when the elevate submenu item from the new tab menu is invoked" ),
5492+ TraceLoggingValue (page->NumberOfTabs (), " TabCount" , " The count of tabs currently opened in this window" ),
5493+ TraceLoggingKeyword (MICROSOFT_KEYWORD_MEASURES),
5494+ TelemetryPrivacyDataTag (PDT_ProductAndServiceUsage));
5495+
53845496 NewTerminalArgs args{ profileIndex };
53855497 args.Elevate (true );
53865498 page->_OpenNewTerminalViaDropdown (args);
0 commit comments