From 2ca230ca9a570ac17b7f3fd80e521f0287bc1f0f Mon Sep 17 00:00:00 2001 From: Ewann Pelle Date: Thu, 9 Mar 2023 09:56:54 +0000 Subject: [PATCH] [iOS][PT] Add overflow metrics MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Commit-Queue: Ewann Pellé Reviewed-by: Luc Nguyen Reviewed-by: Gauthier Ambard Cr-Commit-Position: refs/heads/main@{#1115026} --- .../overflow_menu/overflow_menu_mediator.mm | 2 ++ .../ui/popup_menu/popup_menu_coordinator.mm | 20 +++++++---- tools/metrics/actions/actions.xml | 34 +++++++++++++++++++ 3 files changed, 49 insertions(+), 7 deletions(-) diff --git a/ios/chrome/browser/ui/popup_menu/overflow_menu/overflow_menu_mediator.mm b/ios/chrome/browser/ui/popup_menu/overflow_menu/overflow_menu_mediator.mm index 5e29baf37631bb..26b21cb75adc2e 100644 --- a/ios/chrome/browser/ui/popup_menu/overflow_menu/overflow_menu_mediator.mm +++ b/ios/chrome/browser/ui/popup_menu/overflow_menu/overflow_menu_mediator.mm @@ -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]; @@ -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]; diff --git a/ios/chrome/browser/ui/popup_menu/popup_menu_coordinator.mm b/ios/chrome/browser/ui/popup_menu/popup_menu_coordinator.mm index 37cfe6cf139f89..41b9a2f8bd428a 100644 --- a/ios/chrome/browser/ui/popup_menu/popup_menu_coordinator.mm +++ b/ios/chrome/browser/ui/popup_menu/popup_menu_coordinator.mm @@ -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) { @@ -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]; } @@ -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]; } @@ -263,7 +264,6 @@ - (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; @@ -271,6 +271,12 @@ - (void)showSnackbarForPinnedState:(BOOL)pinnedState base::WeakPtr weakBrowser = self.browser->AsWeakPtr(); void (^undoAction)() = ^{ + if (pinnedState) { + RecordAction(UserMetricsAction("MobileSnackbarUndoPinAction")); + } else { + RecordAction(UserMetricsAction("MobileSnackbarUndoUnpinAction")); + } + Browser* browser = weakBrowser.get(); if (!browser) { return; diff --git a/tools/metrics/actions/actions.xml b/tools/metrics/actions/actions.xml index 5a5d56484675f4..1b6e17cf4d2816 100644 --- a/tools/metrics/actions/actions.xml +++ b/tools/metrics/actions/actions.xml @@ -19623,6 +19623,14 @@ should be able to be added at any place in this file. User pressed 'Paste and Go' in the app menu. + + ewannpv@chromium.org + pakzhygitov@google.com + + User tapped on the 'Pin Tab' action in the iOS overflow menu. + + + danieltwhite@google.com ajuma@chromium.org @@ -19763,6 +19771,14 @@ should be able to be added at any place in this file. User pressed the unfollow option in the app menu. + + ewannpv@chromium.org + pakzhygitov@google.com + + User tapped on the 'Unpin Tab' action in the iOS overflow menu. + + + gambard@chromium.org User pressed 'Voice Search' in the app menu. @@ -20945,6 +20961,24 @@ should be able to be added at any place in this file. + + ewannpv@chromium.org + pakzhygitov@google.com + + User tapped on the UNDO button of the snackbar displayed after pinning a tab + from the iOS overflow menu. + + + + + ewannpv@chromium.org + pakzhygitov@google.com + + User tapped on the UNDO button of the snackbar displayed after unpinning a + tab from the iOS overflow menu. + + + Please list the metric's owners. Add more owner tags as needed. Please enter the description of this user action.