0

multipaste: Record user action for which menu item was selected on paste

This CL adds user actions for each of clipboard history's five possible
menu items, emitting when that item is pasted. This action will be used
to analyze usage patterns related to the order users paste clipboard
history items.

Bug: 1342294
Change-Id: I65a8d69714cac46de996d6c8ee4548b8f2a9837a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3751870
Commit-Queue: Colin Kincaid <ckincaid@chromium.org>
Reviewed-by: Mark Pearson <mpearson@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1021970}
This commit is contained in:
Colin Kincaid
2022-07-08 02:28:44 +00:00
committed by Chromium LUCI CQ
parent 60595daf49
commit 3639cd094c
2 changed files with 78 additions and 0 deletions
ash/clipboard
tools/metrics/actions

@@ -32,6 +32,8 @@
#include "base/location.h"
#include "base/metrics/histogram_functions.h"
#include "base/metrics/histogram_macros.h"
#include "base/metrics/user_metrics.h"
#include "base/notreached.h"
#include "base/one_shot_event.h"
#include "base/ranges/algorithm.h"
#include "base/strings/utf_string_conversions.h"
@@ -103,6 +105,36 @@ void EncodeBitmapToPNG(
std::move(barrier_callback).Run();
}
// Emits a user action indicating that the clipboard history item at menu index
// `command_id` was pasted.
void RecordMenuIndexPastedUserAction(int command_id) {
// Per guidance in user_metrics.h, use string literals for action names.
switch (command_id) {
case 1:
base::RecordAction(
base::UserMetricsAction("Ash_ClipboardHistory_PastedItem1"));
break;
case 2:
base::RecordAction(
base::UserMetricsAction("Ash_ClipboardHistory_PastedItem2"));
break;
case 3:
base::RecordAction(
base::UserMetricsAction("Ash_ClipboardHistory_PastedItem3"));
break;
case 4:
base::RecordAction(
base::UserMetricsAction("Ash_ClipboardHistory_PastedItem4"));
break;
case 5:
base::RecordAction(
base::UserMetricsAction("Ash_ClipboardHistory_PastedItem5"));
break;
default:
NOTREACHED();
}
}
using ClipboardHistoryPasteType =
ash::ClipboardHistoryControllerImpl::ClipboardHistoryPasteType;
bool IsPlainTextPaste(ClipboardHistoryPasteType paste_type) {
@@ -715,9 +747,15 @@ void ClipboardHistoryControllerImpl::ExecuteCommand(int command_id,
void ClipboardHistoryControllerImpl::PasteMenuItemData(
int command_id,
ClipboardHistoryPasteType paste_type) {
// Record the paste item's history list index in a histogram to get a
// distribution of where in the list users paste from.
UMA_HISTOGRAM_ENUMERATION(
"Ash.ClipboardHistory.ContextMenu.MenuOptionSelected", command_id,
ClipboardHistoryUtil::kMaxCommandId);
// Record the paste item's history list index as a user action to analyze
// usage patterns, e.g., how frequently the same index is pasted multiple
// times in a row.
RecordMenuIndexPastedUserAction(command_id);
// Deactivate ClipboardImageModelFactory prior to pasting to ensure that any
// modifications to the clipboard for HTML rendering purposes are reversed.

@@ -3715,6 +3715,46 @@ should be able to be added at any place in this file.
</description>
</action>
<action name="Ash_ClipboardHistory_PastedItem1">
<owner>ckincaid@chromium.org</owner>
<owner>multipaste@google.com</owner>
<description>
Emitted when a user pastes the first item from their clipboard history.
</description>
</action>
<action name="Ash_ClipboardHistory_PastedItem2">
<owner>ckincaid@chromium.org</owner>
<owner>multipaste@google.com</owner>
<description>
Emitted when a user pastes the second item from their clipboard history.
</description>
</action>
<action name="Ash_ClipboardHistory_PastedItem3">
<owner>ckincaid@chromium.org</owner>
<owner>multipaste@google.com</owner>
<description>
Emitted when a user pastes the third item from their clipboard history.
</description>
</action>
<action name="Ash_ClipboardHistory_PastedItem4">
<owner>ckincaid@chromium.org</owner>
<owner>multipaste@google.com</owner>
<description>
Emitted when a user pastes the fourth item from their clipboard history.
</description>
</action>
<action name="Ash_ClipboardHistory_PastedItem5">
<owner>ckincaid@chromium.org</owner>
<owner>multipaste@google.com</owner>
<description>
Emitted when a user pastes the fifth item from their clipboard history.
</description>
</action>
<action name="Ash_Tablet_BackGesture">
<owner>minch@chromium.org</owner>
<owner>tclaiborne@chromium.org</owner>