Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Log action dispatch occurrence #17718

Merged
merged 4 commits into from
Aug 21, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 28 additions & 1 deletion src/cascadia/TerminalApp/ShortcutActionDispatch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,20 @@ using namespace winrt::TerminalApp;

namespace winrt::TerminalApp::implementation
{
std::wstring ExtractAction(const ActionAndArgs& actionAndArgs)
{
// Formatted as "User.{action}" or "User.{action}.{hash}"
const auto id = actionAndArgs.GenerateID();
std::wstring_view remaining{ id };

// Throw away "User."
std::ignore = til::prefix_split(remaining, L'.');

// Get the "{action}" part
const auto actionName = til::prefix_split(remaining, L'.');
return std::wstring{ actionName };
}

// Method Description:
// - Dispatch the appropriate event for the given ActionAndArgs. Constructs
// an ActionEventArgs to hold the IActionArgs payload for the event, and
Expand Down Expand Up @@ -49,7 +63,20 @@ namespace winrt::TerminalApp::implementation
default:
return false;
}
return eventArgs.Handled();
const auto handled = eventArgs.Handled();

if (handled)
{
TraceLoggingWrite(
g_hTerminalAppProvider,
"ActionDispatched",
TraceLoggingDescription("Event emitted when an action was successfully performed"),
TraceLoggingValue(ExtractAction(actionAndArgs).data(), "Action"),
TraceLoggingKeyword(MICROSOFT_KEYWORD_MEASURES),
TelemetryPrivacyDataTag(PDT_ProductAndServiceUsage));
}

return handled;
}

bool ShortcutActionDispatch::DoAction(const ActionAndArgs& actionAndArgs)
Expand Down
2 changes: 2 additions & 0 deletions src/cascadia/TerminalSettingsModel/Command.idl
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ namespace Microsoft.Terminal.Settings.Model

IActionArgs Args;
ShortcutAction Action;

String GenerateID();
};

[default_interface] runtimeclass Command : ISettingsModelObject
Expand Down
Loading