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

Reland "Add three UMA metrics for bookmarks addition."

This is a reland of a7fc60bd

Original change's description:
> 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: Peter Boström <pbos@chromium.org>
> Reviewed-by: Mark Pearson <mpearson@chromium.org>
> Reviewed-by: Elly Fong-Jones <ellyjones@chromium.org>
> Reviewed-by: Ramin Halavati <rhalavati@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#699859}

Bug: 966747, 1006145
Change-Id: I656d44090fdba00ca794006dd82700c375ea704d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1823855
Commit-Queue: Rohit Agarwal <roagarwal@chromium.org>
Reviewed-by: default avatarMark Pearson <mpearson@chromium.org>
Reviewed-by: default avatarElly Fong-Jones <ellyjones@chromium.org>
Reviewed-by: default avatarPeter Boström <pbos@chromium.org>
Cr-Commit-Position: refs/heads/master@{#701088}
parent 1ffa1d68
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include "build/build_config.h" #include "build/build_config.h"
#include "chrome/browser/bookmarks/bookmark_model_factory.h" #include "chrome/browser/bookmarks/bookmark_model_factory.h"
#include "chrome/browser/profiles/profile.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 "chrome/browser/undo/bookmark_undo_service_factory.h"
#include "components/bookmarks/browser/bookmark_client.h" #include "components/bookmarks/browser/bookmark_client.h"
#include "components/bookmarks/browser/bookmark_model.h" #include "components/bookmarks/browser/bookmark_model.h"
...@@ -42,6 +43,7 @@ int DropBookmarks(Profile* profile, ...@@ -42,6 +43,7 @@ int DropBookmarks(Profile* profile,
const BookmarkNode* parent_node, const BookmarkNode* parent_node,
size_t index, size_t index,
bool copy) { bool copy) {
DCHECK(profile);
BookmarkModel* model = BookmarkModelFactory::GetForBrowserContext(profile); BookmarkModel* model = BookmarkModelFactory::GetForBrowserContext(profile);
#if !defined(OS_ANDROID) #if !defined(OS_ANDROID)
bookmarks::ScopedGroupBookmarkActions group_drops(model); bookmarks::ScopedGroupBookmarkActions group_drops(model);
...@@ -66,6 +68,7 @@ int DropBookmarks(Profile* profile, ...@@ -66,6 +68,7 @@ int DropBookmarks(Profile* profile,
} }
return ui::DragDropTypes::DRAG_NONE; return ui::DragDropTypes::DRAG_NONE;
} }
RecordBookmarksAdded(profile);
// Dropping a folder from different profile. Always accept. // Dropping a folder from different profile. Always accept.
bookmarks::CloneBookmarkNode(model, data.elements, parent_node, index, true); bookmarks::CloneBookmarkNode(model, data.elements, parent_node, index, true);
return ui::DragDropTypes::DRAG_COPY; return ui::DragDropTypes::DRAG_COPY;
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
// found in the LICENSE file. // found in the LICENSE file.
#include "chrome/browser/ui/bookmarks/bookmark_stats.h" #include "chrome/browser/ui/bookmarks/bookmark_stats.h"
#include "chrome/browser/profiles/profile.h"
#include "base/metrics/histogram_macros.h" #include "base/metrics/histogram_macros.h"
#include "base/metrics/user_metrics.h" #include "base/metrics/user_metrics.h"
...@@ -18,6 +19,14 @@ bool IsBookmarkBarLocation(BookmarkLaunchLocation location) { ...@@ -18,6 +19,14 @@ bool IsBookmarkBarLocation(BookmarkLaunchLocation location) {
location == BOOKMARK_LAUNCH_LOCATION_BAR_SUBFOLDER; 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 } // namespace
void RecordBookmarkLaunch(BookmarkLaunchLocation location, void RecordBookmarkLaunch(BookmarkLaunchLocation location,
...@@ -55,3 +64,19 @@ void RecordBookmarkAppsPageOpen(BookmarkLaunchLocation location) { ...@@ -55,3 +64,19 @@ void RecordBookmarkAppsPageOpen(BookmarkLaunchLocation location) {
base::UserMetricsAction("ClickedBookmarkBarAppsShortcutButton")); base::UserMetricsAction("ClickedBookmarkBarAppsShortcutButton"));
} }
} }
void RecordBookmarksAdded(const Profile* profile) {
profile_metrics::BrowserProfileType profile_type = GetMetricProfile(profile);
UMA_HISTOGRAM_ENUMERATION("Bookmarks.AddedPerProfileType", profile_type);
}
void RecordBookmarkAllTabsWithTabsCount(const Profile* profile, int count) {
profile_metrics::BrowserProfileType 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,7 +7,11 @@ ...@@ -7,7 +7,11 @@
#include "components/profile_metrics/browser_profile_type.h" #include "components/profile_metrics/browser_profile_type.h"
class Profile;
// This enum is used for the Bookmarks.EntryPoint histogram. // 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 { enum BookmarkEntryPoint {
BOOKMARK_ENTRY_POINT_ACCELERATOR, BOOKMARK_ENTRY_POINT_ACCELERATOR,
BOOKMARK_ENTRY_POINT_STAR_GESTURE, BOOKMARK_ENTRY_POINT_STAR_GESTURE,
...@@ -18,6 +22,8 @@ enum BookmarkEntryPoint { ...@@ -18,6 +22,8 @@ enum BookmarkEntryPoint {
}; };
// This enum is used for the Bookmarks.LaunchLocation histogram. // 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 { enum BookmarkLaunchLocation {
BOOKMARK_LAUNCH_LOCATION_NONE, BOOKMARK_LAUNCH_LOCATION_NONE,
BOOKMARK_LAUNCH_LOCATION_ATTACHED_BAR = 0, BOOKMARK_LAUNCH_LOCATION_ATTACHED_BAR = 0,
...@@ -55,4 +61,13 @@ void RecordBookmarkFolderOpen(BookmarkLaunchLocation location); ...@@ -55,4 +61,13 @@ void RecordBookmarkFolderOpen(BookmarkLaunchLocation location);
// Records the user opening the apps page for UMA purposes. // Records the user opening the apps page for UMA purposes.
void RecordBookmarkAppsPageOpen(BookmarkLaunchLocation location); 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_ #endif // CHROME_BROWSER_UI_BOOKMARKS_BOOKMARK_STATS_H_
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
#include "chrome/browser/ui/accelerator_utils.h" #include "chrome/browser/ui/accelerator_utils.h"
#include "chrome/browser/ui/autofill/payments/manage_migration_ui_controller.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/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.h"
#include "chrome/browser/ui/bookmarks/bookmark_utils_desktop.h" #include "chrome/browser/ui/bookmarks/bookmark_utils_desktop.h"
#include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser.h"
...@@ -840,6 +841,9 @@ void BookmarkCurrentTabIgnoringExtensionOverrides(Browser* browser) { ...@@ -840,6 +841,9 @@ void BookmarkCurrentTabIgnoringExtensionOverrides(Browser* browser) {
// weird situations where the bubble is deleted as soon as it is shown. // weird situations where the bubble is deleted as soon as it is shown.
browser->window()->ShowBookmarkBubble(url, was_bookmarked_by_user); browser->window()->ShowBookmarkBubble(url, was_bookmarked_by_user);
} }
if (!was_bookmarked_by_user && is_bookmarked_by_user)
RecordBookmarksAdded(browser->profile());
} }
void BookmarkCurrentTabAllowingExtensionOverrides(Browser* browser) { void BookmarkCurrentTabAllowingExtensionOverrides(Browser* browser) {
...@@ -873,6 +877,10 @@ bool CanBookmarkCurrentTab(const Browser* browser) { ...@@ -873,6 +877,10 @@ bool CanBookmarkCurrentTab(const Browser* browser) {
void BookmarkAllTabs(Browser* browser) { void BookmarkAllTabs(Browser* browser) {
base::RecordAction(UserMetricsAction("BookmarkAllTabs")); 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); chrome::ShowBookmarkAllTabsDialog(browser);
} }
......
...@@ -17864,6 +17864,35 @@ uploading your change for review. ...@@ -17864,6 +17864,35 @@ uploading your change for review.
</summary> </summary>
</histogram> </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"> <histogram name="Bookmarks.BookmarksInFolder" units="bookmarks">
<owner>calamity@chromium.org</owner> <owner>calamity@chromium.org</owner>
<summary> <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