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 1 commit
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
36 changes: 35 additions & 1 deletion src/cascadia/TerminalApp/ShortcutActionDispatch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,27 @@ using namespace winrt::TerminalApp;

namespace winrt::TerminalApp::implementation
{
std::wstring ExtractAction(const ActionAndArgs& actionAndArgs)
{
std::wstring id{ actionAndArgs.GenerateID() };
const auto segment1 = id.find(L'.');
const auto segment2 = id.find(L'.', segment1 + 1);
if (segment1 != std::wstring::npos)
{
if (segment2 != std::wstring::npos)
{
return id.substr(segment1 + 1, segment2 - segment1 - 1);
}
else
{
return id.substr(segment1 + 1);
}
}
carlos-zamora marked this conversation as resolved.
Show resolved Hide resolved
// This shouldn't be possible.
// GenerateID() returns L"User.{}" unless it's invalid
return nullptr;
carlos-zamora marked this conversation as resolved.
Show resolved Hide resolved
}

// 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 +70,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