Commit 699171af authored by Alex Newcomer's avatar Alex Newcomer Committed by Commit Bot

cros: Add metrics for index activated in multipaste

Log the index activated in the multipaste menu. Will be used
to help UX determine if we should show more items in the menu.

Bug: 1099338
Change-Id: I28533ed7628fe54fde2e182e76ab5f6466d3b1f7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2427406
Commit-Queue: Alex Newcomer <newcomer@chromium.org>
Reviewed-by: default avatarSteven Holte <holte@chromium.org>
Reviewed-by: default avatarAndrew Xu <andrewxu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#812387}
parent adc7635d
......@@ -16,12 +16,6 @@
namespace ash {
namespace {
constexpr size_t kMaxClipboardItemsShared = 5;
} // namespace
ClipboardHistory::ScopedPause::ScopedPause(ClipboardHistory* clipboard_history)
: clipboard_history_(clipboard_history) {
clipboard_history_->Pause();
......@@ -129,7 +123,7 @@ void ClipboardHistory::MaybeCommitData(ui::ClipboardData data) {
for (auto& observer : observers_)
observer.OnClipboardHistoryItemAdded(history_list_.front());
if (history_list_.size() > kMaxClipboardItemsShared) {
if (history_list_.size() > ClipboardHistoryUtil::kMaxClipboardItemsShared) {
auto removed = std::move(history_list_.back());
history_list_.pop_back();
for (auto& observer : observers_)
......
......@@ -15,6 +15,7 @@
#include "ash/resources/vector_icons/vector_icons.h"
#include "ash/shell.h"
#include "base/location.h"
#include "base/metrics/histogram_macros.h"
#include "base/strings/utf_string_conversions.h"
#include "base/threading/thread_task_runner_handle.h"
#include "ui/aura/window_tree_host.h"
......@@ -245,6 +246,9 @@ void ClipboardHistoryControllerImpl::ShowMenuByAccelerator() {
void ClipboardHistoryControllerImpl::MenuOptionSelected(int command_id,
int event_flags) {
UMA_HISTOGRAM_ENUMERATION(
"Ash.ClipboardHistory.ContextMenu.MenuOptionSelected", command_id,
ClipboardHistoryUtil::kMaxCommandId);
// Force close the context menu. Failure to do so before dispatching our
// synthetic key event will result in the context menu consuming the event.
DCHECK(context_menu_);
......
......@@ -23,6 +23,12 @@ constexpr int kDeleteCommandId = 0;
// The first available command id for normal clipboard history menu items.
constexpr int kFirstItemCommandId = 1;
// The max number of items stored in ClipboardHistory.
constexpr int kMaxClipboardItemsShared = 5;
// The max command ID, used to record histograms.
constexpr int kMaxCommandId = kFirstItemCommandId + kMaxClipboardItemsShared;
// Returns the main format of the specified clipboard `data`.
// NOTE: One `ui::ClipboardData` instance may contain multiple formats.
ASH_EXPORT base::Optional<ui::ClipboardInternalFormat> CalculateMainFormat(
......
......@@ -209,6 +209,16 @@ reviews. Googlers can read more about this at go/gwsq-gerrit.
</summary>
</histogram>
<histogram name="Ash.ClipboardHistory.ContextMenu.MenuOptionSelected"
units="index" expires_after="2021-09-01">
<owner>andrewxu@chromium.org</owner>
<owner>newcomer@chromium.org</owner>
<summary>
The command ID index within the Clipboard History contextual menu that was
selected by the user. Recorded when the menu item is selected.
</summary>
</histogram>
<histogram name="Ash.ClipboardHistory.ContextMenu.NumberOfItemsShown"
units="Items Shown" expires_after="2021-09-01">
<owner>andrewxu@chromium.org</owner>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment