Commit e3afdf4c authored by Alex Newcomer's avatar Alex Newcomer Committed by Chromium LUCI CQ

cros: Record metrics for placeholder strings

UX/PM want to see how often placeholder strings are shown
in Clipboard History. We may design a better solution if they are seen a
lot.

Bug: 1156837
Change-Id: If96e86d244cd05abcbd098ea19e9af0234928046
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2590753
Commit-Queue: Alex Newcomer <newcomer@chromium.org>
Reviewed-by: default avatarWeilun Shi <sweilun@chromium.org>
Reviewed-by: default avatarIlya Sherman <isherman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#839477}
parent 2acbcd75
......@@ -11,6 +11,7 @@
#include "ash/resources/vector_icons/vector_icons.h"
#include "base/bind.h"
#include "base/containers/contains.h"
#include "base/metrics/histogram_functions.h"
#include "base/notreached.h"
#include "base/stl_util.h"
#include "base/strings/escape.h"
......@@ -36,6 +37,17 @@ constexpr int kPlaceholderImageHeight = 74;
constexpr int kPlaceholderImageOutlineCornerRadius = 8;
constexpr int kPlaceholderImageSVGSize = 32;
// Used in histograms, each value corresponds with an underlying placeholder
// string displayed by a ClipboardHistoryTextItemView. Do not reorder entries,
// if you must add to it, add at the end.
enum class ClipboardHistoryPlaceholderStringType {
kBitmap = 0,
kHtml = 1,
kRtf = 2,
kWebSmartPaste = 3,
kMaxValue = 3,
};
// Used to draw the UnrenderedHTMLPlaceholderImage, which is shown while HTML is
// rendering. Drawn in order to turn the square and single colored SVG into a
// multicolored rectangle image.
......@@ -108,6 +120,11 @@ base::string16 GetLabelForCustomData(const ui::ClipboardData& data) {
base::UnescapeRule::SPACES));
}
void RecordPlaceholderString(ClipboardHistoryPlaceholderStringType type) {
base::UmaHistogramEnumeration(
"Ash.ClipboardHistory.ContextMenu.ShowPlaceholderString", type);
}
} // namespace
// ClipboardHistoryResourceManager ---------------------------------------------
......@@ -143,6 +160,7 @@ base::string16 ClipboardHistoryResourceManager::GetLabel(
const ui::ClipboardData& data = item.data();
switch (ClipboardHistoryUtil::CalculateMainFormat(data).value()) {
case ui::ClipboardInternalFormat::kBitmap:
RecordPlaceholderString(ClipboardHistoryPlaceholderStringType::kBitmap);
return GetLocalizedString(IDS_CLIPBOARD_MENU_IMAGE);
case ui::ClipboardInternalFormat::kText:
return base::UTF8ToUTF16(data.text());
......@@ -150,14 +168,18 @@ base::string16 ClipboardHistoryResourceManager::GetLabel(
// Show plain-text if it exists, otherwise show the placeholder.
if (!data.text().empty())
return base::UTF8ToUTF16(data.text());
RecordPlaceholderString(ClipboardHistoryPlaceholderStringType::kHtml);
return GetLocalizedString(IDS_CLIPBOARD_MENU_HTML);
case ui::ClipboardInternalFormat::kSvg:
return base::UTF8ToUTF16(data.svg_data());
case ui::ClipboardInternalFormat::kRtf:
RecordPlaceholderString(ClipboardHistoryPlaceholderStringType::kRtf);
return GetLocalizedString(IDS_CLIPBOARD_MENU_RTF_CONTENT);
case ui::ClipboardInternalFormat::kBookmark:
return base::UTF8ToUTF16(data.bookmark_title());
case ui::ClipboardInternalFormat::kWeb:
RecordPlaceholderString(
ClipboardHistoryPlaceholderStringType::kWebSmartPaste);
return GetLocalizedString(IDS_CLIPBOARD_MENU_WEB_SMART_PASTE);
case ui::ClipboardInternalFormat::kCustom:
return GetLabelForCustomData(data);
......
......@@ -11334,6 +11334,13 @@ histogram as enum -->
<int value="2" label="Html"/>
</enum>
<enum name="ClipboardHistoryPlaceholderStringType">
<int value="0" label="Bitmap"/>
<int value="1" label="Html"/>
<int value="2" label="Rtf"/>
<int value="3" label="Web Smart Paste"/>
</enum>
<enum name="ClockdriftLevel">
<int value="0" label="None"/>
<int value="1" label="Probable"/>
......@@ -387,6 +387,17 @@ reviews. Googlers can read more about this at go/gwsq-gerrit.
</summary>
</histogram>
<histogram name="Ash.ClipboardHistory.ContextMenu.ShowPlaceholderString"
enum="ClipboardHistoryPlaceholderStringType" expires_after="2021-09-01">
<owner>newcomer@chromium.org</owner>
<owner>multipaste@google.com</owner>
<summary>
The number of placeholder strings shown to users in lieu of actual data,
broken down by placeholder string type. Recorded when the label is requested
from ClipboardHistoryResourceManager.
</summary>
</histogram>
<histogram name="Ash.ClipboardHistory.ContextMenu.UserJourneyTime" units="ms"
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