Commit a7fc60bd authored by Rohit Agarwal's avatar Rohit Agarwal Committed by Commit Bot

Add three UMA metrics for bookmarks addition.

First metric collects stats on bookmark addition
sliced on profile. Second and third metric collects stats
on the count of open tabs during bookmark all tabs, for
regular and incognito users.

Bug: 966747, 1006145
Change-Id: I29add57c472cf5344951b4a91be465872db45485
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1793184
Commit-Queue: Rohit Agarwal <roagarwal@chromium.org>
Reviewed-by: default avatarPeter Boström <pbos@chromium.org>
Reviewed-by: default avatarMark Pearson <mpearson@chromium.org>
Reviewed-by: default avatarElly Fong-Jones <ellyjones@chromium.org>
Reviewed-by: default avatarRamin Halavati <rhalavati@chromium.org>
Cr-Commit-Position: refs/heads/master@{#699859}
parent f195a967
......@@ -9,12 +9,14 @@
#include "build/build_config.h"
#include "chrome/browser/bookmarks/bookmark_model_factory.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/bookmarks/bookmark_stats.h"
#include "chrome/browser/undo/bookmark_undo_service_factory.h"
#include "components/bookmarks/browser/bookmark_client.h"
#include "components/bookmarks/browser/bookmark_model.h"
#include "components/bookmarks/browser/bookmark_node_data.h"
#include "components/bookmarks/browser/bookmark_utils.h"
#include "components/bookmarks/browser/scoped_group_bookmark_actions.h"
#include "components/profile_metrics/browser_profile_type.h"
#include "components/undo/bookmark_undo_service.h"
#include "ui/base/dragdrop/drag_drop_types.h"
......@@ -42,6 +44,7 @@ int DropBookmarks(Profile* profile,
const BookmarkNode* parent_node,
size_t index,
bool copy) {
DCHECK(profile);
BookmarkModel* model = BookmarkModelFactory::GetForBrowserContext(profile);
#if !defined(OS_ANDROID)
bookmarks::ScopedGroupBookmarkActions group_drops(model);
......@@ -66,6 +69,7 @@ int DropBookmarks(Profile* profile,
}
return ui::DragDropTypes::DRAG_NONE;
}
RecordBookmarksAdded(profile);
// Dropping a folder from different profile. Always accept.
bookmarks::CloneBookmarkNode(model, data.elements, parent_node, index, true);
return ui::DragDropTypes::DRAG_COPY;
......
......@@ -3,6 +3,7 @@
// found in the LICENSE file.
#include "chrome/browser/ui/bookmarks/bookmark_stats.h"
#include "chrome/browser/profiles/profile.h"
#include "base/metrics/histogram_macros.h"
#include "base/metrics/user_metrics.h"
......@@ -18,6 +19,14 @@ bool IsBookmarkBarLocation(BookmarkLaunchLocation location) {
location == BOOKMARK_LAUNCH_LOCATION_BAR_SUBFOLDER;
}
auto GetMetricProfile(const Profile* profile) {
DCHECK(profile);
DCHECK(profile->IsRegularProfile() || profile->IsIncognitoProfile());
return profile->IsRegularProfile()
? profile_metrics::BrowserProfileType::kRegular
: profile_metrics::BrowserProfileType::kIncognito;
}
} // namespace
void RecordBookmarkLaunch(BookmarkLaunchLocation location,
......@@ -55,3 +64,19 @@ void RecordBookmarkAppsPageOpen(BookmarkLaunchLocation location) {
base::UserMetricsAction("ClickedBookmarkBarAppsShortcutButton"));
}
}
void RecordBookmarksAdded(const Profile* profile) {
auto profile_type = GetMetricProfile(profile);
UMA_HISTOGRAM_ENUMERATION("Bookmarks.AddedPerProfileType", profile_type);
}
void RecordBookmarkAllTabsWithTabsCount(const Profile* profile, int count) {
auto profile_type = GetMetricProfile(profile);
if (profile_type == profile_metrics::BrowserProfileType::kRegular) {
UMA_HISTOGRAM_COUNTS_100("Bookmarks.BookmarkAllTabsWithTabsCount.Regular",
count);
} else {
UMA_HISTOGRAM_COUNTS_100("Bookmarks.BookmarkAllTabsWithTabsCount.Incognito",
count);
}
}
......@@ -7,38 +7,44 @@
#include "components/profile_metrics/browser_profile_type.h"
class Profile;
// This enum is used for the Bookmarks.EntryPoint histogram.
// These values are persisted to logs. Entries should not be renumbered and
// numeric values should never be reused.
enum BookmarkEntryPoint {
BOOKMARK_ENTRY_POINT_ACCELERATOR,
BOOKMARK_ENTRY_POINT_STAR_GESTURE,
BOOKMARK_ENTRY_POINT_STAR_KEY,
BOOKMARK_ENTRY_POINT_STAR_MOUSE,
BOOKMARK_ENTRY_POINT_ACCELERATOR = 0,
BOOKMARK_ENTRY_POINT_STAR_GESTURE = 1,
BOOKMARK_ENTRY_POINT_STAR_KEY = 2,
BOOKMARK_ENTRY_POINT_STAR_MOUSE = 3,
BOOKMARK_ENTRY_POINT_LIMIT // Keep this last.
BOOKMARK_ENTRY_POINT_LIMIT = 4 // Keep this last.
};
// This enum is used for the Bookmarks.LaunchLocation histogram.
// These values are persisted to logs. Entries should not be renumbered and
// numeric values should never be reused.
enum BookmarkLaunchLocation {
BOOKMARK_LAUNCH_LOCATION_NONE,
BOOKMARK_LAUNCH_LOCATION_ATTACHED_BAR = 0,
BOOKMARK_LAUNCH_LOCATION_DETACHED_BAR,
BOOKMARK_LAUNCH_LOCATION_NONE = 0,
BOOKMARK_LAUNCH_LOCATION_ATTACHED_BAR = 1,
BOOKMARK_LAUNCH_LOCATION_DETACHED_BAR = 2,
// These two are kind of sub-categories of the bookmark bar. Generally
// a launch from a context menu or subfolder could be classified in one of
// the other two bar buckets, but doing so is difficult because the menus
// don't know of their greater place in Chrome.
BOOKMARK_LAUNCH_LOCATION_BAR_SUBFOLDER,
BOOKMARK_LAUNCH_LOCATION_CONTEXT_MENU,
BOOKMARK_LAUNCH_LOCATION_BAR_SUBFOLDER = 3,
BOOKMARK_LAUNCH_LOCATION_CONTEXT_MENU = 4,
// Bookmarks menu within app menu.
BOOKMARK_LAUNCH_LOCATION_APP_MENU,
BOOKMARK_LAUNCH_LOCATION_APP_MENU = 5,
// Bookmark manager.
BOOKMARK_LAUNCH_LOCATION_MANAGER,
BOOKMARK_LAUNCH_LOCATION_MANAGER = 6,
// Autocomplete suggestion.
BOOKMARK_LAUNCH_LOCATION_OMNIBOX,
BOOKMARK_LAUNCH_LOCATION_OMNIBOX = 7,
// System application menu (e.g. on Mac).
BOOKMARK_LAUNCH_LOCATION_TOP_MENU,
BOOKMARK_LAUNCH_LOCATION_TOP_MENU = 8,
BOOKMARK_LAUNCH_LOCATION_LIMIT // Keep this last.
BOOKMARK_LAUNCH_LOCATION_LIMIT = 9 // Keep this last.
};
// Records the launch of a bookmark for UMA purposes.
......@@ -55,4 +61,13 @@ void RecordBookmarkFolderOpen(BookmarkLaunchLocation location);
// Records the user opening the apps page for UMA purposes.
void RecordBookmarkAppsPageOpen(BookmarkLaunchLocation location);
// Records the user adding a bookmark via star action, drag and drop, via
// Bookmark this tab... and Bookmark all tabs... buttons. For the Bookmark
// open tabs... the action is recorded only once and not as many times as
// count of tabs that were bookmarked.
void RecordBookmarksAdded(const Profile* profile);
// Records the user bookmarking all tabs, along with the open tabs count.
void RecordBookmarkAllTabsWithTabsCount(const Profile* profile, int count);
#endif // CHROME_BROWSER_UI_BOOKMARKS_BOOKMARK_STATS_H_
......@@ -33,6 +33,7 @@
#include "chrome/browser/ui/accelerator_utils.h"
#include "chrome/browser/ui/autofill/payments/manage_migration_ui_controller.h"
#include "chrome/browser/ui/autofill/payments/save_card_bubble_controller_impl.h"
#include "chrome/browser/ui/bookmarks/bookmark_stats.h"
#include "chrome/browser/ui/bookmarks/bookmark_utils.h"
#include "chrome/browser/ui/bookmarks/bookmark_utils_desktop.h"
#include "chrome/browser/ui/browser.h"
......@@ -840,6 +841,9 @@ void BookmarkCurrentTabIgnoringExtensionOverrides(Browser* browser) {
// weird situations where the bubble is deleted as soon as it is shown.
browser->window()->ShowBookmarkBubble(url, was_bookmarked_by_user);
}
if (!was_bookmarked_by_user && is_bookmarked_by_user)
RecordBookmarksAdded(browser->profile());
}
void BookmarkCurrentTabAllowingExtensionOverrides(Browser* browser) {
......@@ -873,6 +877,10 @@ bool CanBookmarkCurrentTab(const Browser* browser) {
void BookmarkAllTabs(Browser* browser) {
base::RecordAction(UserMetricsAction("BookmarkAllTabs"));
RecordBookmarkAllTabsWithTabsCount(browser->profile(),
browser->tab_strip_model()->count());
// We record the profile that invoked this option.
RecordBookmarksAdded(browser->profile());
chrome::ShowBookmarkAllTabsDialog(browser);
}
......
......@@ -17828,6 +17828,35 @@ uploading your change for review.
</summary>
</histogram>
<histogram name="Bookmarks.AddedPerProfileType" enum="BrowserProfileType"
expires_after="M85">
<owner>rhalavati@chromium.org</owner>
<owner>chrome-privacy-core@google.com</owner>
<summary>
This histogram records when a bookmark is added sliced on profile type.
</summary>
</histogram>
<histogram name="Bookmarks.BookmarkAllTabsWithTabsCount.Incognito" units="tabs"
expires_after="M85">
<owner>rhalavati@chromium.org</owner>
<owner>chrome-privacy-core@google.com</owner>
<summary>
This histogram records the count of tabs when a user bookmarks all open
tabs, in incognito mode.
</summary>
</histogram>
<histogram name="Bookmarks.BookmarkAllTabsWithTabsCount.Regular" units="tabs"
expires_after="M85">
<owner>rhalavati@chromium.org</owner>
<owner>chrome-privacy-core@google.com</owner>
<summary>
This histogram records the count of tabs when a user bookmarks all open
tabs, in regular mode.
</summary>
</histogram>
<histogram name="Bookmarks.BookmarksInFolder" units="bookmarks">
<owner>calamity@chromium.org</owner>
<summary>
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