Skip to content

Commit

Permalink
[iOS][PT] Add overflow metrics
Browse files Browse the repository at this point in the history
This CL records a metric when the pin/unpin action from the overflow
menu is tapped.
It also records a metric when the UNDO button from the pinned tab snackbar is tapped.

Bug: 1408726
Change-Id: I6d6b037f5a22b6f627cc1bd90e574fc662aa44df
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4315062
Reviewed-by: Petro Akzhygitov <pakzhygitov@google.com>
Commit-Queue: Ewann Pellé <ewannpv@chromium.org>
Reviewed-by: Luc Nguyen <lucnguyen@google.com>
Reviewed-by: Gauthier Ambard <gambard@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1115026}
  • Loading branch information
Ewann Pelle authored and Chromium LUCI CQ committed Mar 9, 2023
1 parent b9f1646 commit 2ca230c
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1723,6 +1723,7 @@ - (void)openNewWindow {

// Dismisses the menu and pins the tab.
- (void)pinTab {
RecordAction(UserMetricsAction("MobileMenuPinTab"));
[[self class] setTabPinned:YES
webState:self.webState
webStateList:self.webStateList];
Expand All @@ -1733,6 +1734,7 @@ - (void)pinTab {

// Dismisses the menu and unpins the tab.
- (void)unpinTab {
RecordAction(UserMetricsAction("MobileMenuUnpinTab"));
[[self class] setTabPinned:NO
webState:self.webState
webStateList:self.webStateList];
Expand Down
20 changes: 13 additions & 7 deletions ios/chrome/browser/ui/popup_menu/popup_menu_coordinator.mm
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@
#error "This file requires ARC support."
#endif

using base::RecordAction;
using base::UserMetricsAction;

namespace {
// Returns the corresponding command type for a Popup menu `type`.
PopupMenuCommandType CommandTypeFromPopupType(PopupMenuType type) {
Expand Down Expand Up @@ -180,15 +183,13 @@ - (void)startPopupMenuHelpCoordinator {
#pragma mark - PopupMenuCommands

- (void)showNavigationHistoryBackPopupMenu {
base::RecordAction(
base::UserMetricsAction("MobileToolbarShowTabHistoryMenu"));
RecordAction(UserMetricsAction("MobileToolbarShowTabHistoryMenu"));
[self presentPopupOfType:PopupMenuTypeNavigationBackward
fromLayoutGuideNamed:kBackButtonGuide];
}

- (void)showNavigationHistoryForwardPopupMenu {
base::RecordAction(
base::UserMetricsAction("MobileToolbarShowTabHistoryMenu"));
RecordAction(UserMetricsAction("MobileToolbarShowTabHistoryMenu"));
[self presentPopupOfType:PopupMenuTypeNavigationForward
fromLayoutGuideNamed:kForwardButtonGuide];
}
Expand All @@ -200,13 +201,13 @@ - (void)showToolsMenuPopup {
}

- (void)showTabGridButtonPopup {
base::RecordAction(base::UserMetricsAction("MobileToolbarShowTabGridMenu"));
RecordAction(UserMetricsAction("MobileToolbarShowTabGridMenu"));
[self presentPopupOfType:PopupMenuTypeTabGrid
fromLayoutGuideNamed:kTabSwitcherGuide];
}

- (void)showNewTabButtonPopup {
base::RecordAction(base::UserMetricsAction("MobileToolbarShowNewTabMenu"));
RecordAction(UserMetricsAction("MobileToolbarShowNewTabMenu"));
[self presentPopupOfType:PopupMenuTypeNewTab
fromLayoutGuideNamed:kNewTabButtonGuide];
}
Expand Down Expand Up @@ -263,14 +264,19 @@ - (void)dismissPopupMenuAnimated:(BOOL)animated {
- (void)showSnackbarForPinnedState:(BOOL)pinnedState
webState:(web::WebState*)webState {
DCHECK(IsPinnedTabsOverflowEnabled());

int messageId = pinnedState ? IDS_IOS_SNACKBAR_MESSAGE_PINNED_TAB
: IDS_IOS_SNACKBAR_MESSAGE_UNPINNED_TAB;

base::WeakPtr<web::WebState> weakWebState = webState->GetWeakPtr();
base::WeakPtr<Browser> weakBrowser = self.browser->AsWeakPtr();

void (^undoAction)() = ^{
if (pinnedState) {
RecordAction(UserMetricsAction("MobileSnackbarUndoPinAction"));
} else {
RecordAction(UserMetricsAction("MobileSnackbarUndoUnpinAction"));
}

Browser* browser = weakBrowser.get();
if (!browser) {
return;
Expand Down
34 changes: 34 additions & 0 deletions tools/metrics/actions/actions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19623,6 +19623,14 @@ should be able to be added at any place in this file.
<description>User pressed 'Paste and Go' in the app menu.</description>
</action>

<action name="MobileMenuPinTab">
<owner>ewannpv@chromium.org</owner>
<owner>pakzhygitov@google.com</owner>
<description>
User tapped on the 'Pin Tab' action in the iOS overflow menu.
</description>
</action>

<action name="MobileMenuPriceNotifications">
<owner>danieltwhite@google.com</owner>
<owner>ajuma@chromium.org</owner>
Expand Down Expand Up @@ -19763,6 +19771,14 @@ should be able to be added at any place in this file.
<description>User pressed the unfollow option in the app menu.</description>
</action>

<action name="MobileMenuUnpinTab">
<owner>ewannpv@chromium.org</owner>
<owner>pakzhygitov@google.com</owner>
<description>
User tapped on the 'Unpin Tab' action in the iOS overflow menu.
</description>
</action>

<action name="MobileMenuVoiceSearch">
<owner>gambard@chromium.org</owner>
<description>User pressed 'Voice Search' in the app menu.</description>
Expand Down Expand Up @@ -20945,6 +20961,24 @@ should be able to be added at any place in this file.
</description>
</action>

<action name="MobileSnackbarUndoPinAction">
<owner>ewannpv@chromium.org</owner>
<owner>pakzhygitov@google.com</owner>
<description>
User tapped on the UNDO button of the snackbar displayed after pinning a tab
from the iOS overflow menu.
</description>
</action>

<action name="MobileSnackbarUndoUnpinAction">
<owner>ewannpv@chromium.org</owner>
<owner>pakzhygitov@google.com</owner>
<description>
User tapped on the UNDO button of the snackbar displayed after unpinning a
tab from the iOS overflow menu.
</description>
</action>

<action name="MobileStackViewCloseTab">
<owner>Please list the metric's owners. Add more owner tags as needed.</owner>
<description>Please enter the description of this user action.</description>
Expand Down

0 comments on commit 2ca230c

Please sign in to comment.