Commit e9e3e678 authored by edchin's avatar edchin Committed by Commit Bot

[ios] Metrics for tab grid

This CL implements these metrics in tab grid:

MobileStackViewCloseTab 	when a tab is closed via the X
MobileToolbarStackViewNewTab	when a new tab is created (only through the + button.)
MobileTabReturnedToCurrentTab	when users exit the tab switcher to return to the
                                current foreground tab
MobileStackViewNormalMode	when user switches between regular & incognito
MobileStackViewIncognitoMode	when user switches between regular & incognito


Bug: 818452
Cq-Include-Trybots: luci.chromium.try:ios-simulator-full-configs;master.tryserver.chromium.mac:ios-simulator-cronet
Change-Id: I570a31af65bc929f646d005789cecb1a0afca442
Reviewed-on: https://chromium-review.googlesource.com/1116284Reviewed-by: default avataredchin <edchin@chromium.org>
Reviewed-by: default avatarMark Cogan <marq@chromium.org>
Commit-Queue: edchin <edchin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#570758}
parent 2b24d355
...@@ -7,6 +7,8 @@ ...@@ -7,6 +7,8 @@
#include "base/ios/block_types.h" #include "base/ios/block_types.h"
#import "base/logging.h" #import "base/logging.h"
#import "base/mac/foundation_util.h" #import "base/mac/foundation_util.h"
#include "base/metrics/user_metrics.h"
#include "base/metrics/user_metrics_action.h"
#import "base/numerics/safe_conversions.h" #import "base/numerics/safe_conversions.h"
#include "ios/chrome/browser/procedural_block_types.h" #include "ios/chrome/browser/procedural_block_types.h"
#import "ios/chrome/browser/ui/tab_grid/grid/grid_cell.h" #import "ios/chrome/browser/ui/tab_grid/grid/grid_cell.h"
...@@ -279,6 +281,8 @@ NSIndexPath* CreateIndexPath(NSInteger index) { ...@@ -279,6 +281,8 @@ NSIndexPath* CreateIndexPath(NSInteger index) {
DCHECK_LT(index, self.items.count); DCHECK_LT(index, self.items.count);
NSString* itemID = self.items[index].identifier; NSString* itemID = self.items[index].identifier;
[self.delegate gridViewController:self didCloseItemWithID:itemID]; [self.delegate gridViewController:self didCloseItemWithID:itemID];
// Record when a tab is closed via the X.
base::RecordAction(base::UserMetricsAction("MobileStackViewCloseTab"));
} }
#pragma mark - GridConsumer #pragma mark - GridConsumer
......
...@@ -4,6 +4,8 @@ ...@@ -4,6 +4,8 @@
#import "ios/chrome/browser/ui/tab_grid/tab_grid_view_controller.h" #import "ios/chrome/browser/ui/tab_grid/tab_grid_view_controller.h"
#include "base/metrics/user_metrics.h"
#include "base/metrics/user_metrics_action.h"
#include "base/strings/sys_string_conversions.h" #include "base/strings/sys_string_conversions.h"
#import "ios/chrome/browser/ui/recent_tabs/recent_tabs_table_view_controller.h" #import "ios/chrome/browser/ui/recent_tabs/recent_tabs_table_view_controller.h"
#import "ios/chrome/browser/ui/rtl_geometry.h" #import "ios/chrome/browser/ui/rtl_geometry.h"
...@@ -208,6 +210,8 @@ NSUInteger GetPageIndexFromPage(TabGridPage page) { ...@@ -208,6 +210,8 @@ NSUInteger GetPageIndexFromPage(TabGridPage page) {
if (page != _currentPage) { if (page != _currentPage) {
_currentPage = page; _currentPage = page;
[self configureButtonsForActiveAndCurrentPage]; [self configureButtonsForActiveAndCurrentPage];
// Records when the user drags the scrollView to switch pages.
[self recordActionSwitchingToPage:_currentPage];
} }
} }
} }
...@@ -767,6 +771,24 @@ NSUInteger GetPageIndexFromPage(TabGridPage page) { ...@@ -767,6 +771,24 @@ NSUInteger GetPageIndexFromPage(TabGridPage page) {
completion:cleanup]; completion:cleanup];
} }
// Records when the user switches between incognito and regular pages in the tab
// grid. Switching to a different TabGridPage can either be driven by dragging
// the scrollView or tapping on the pageControl.
- (void)recordActionSwitchingToPage:(TabGridPage)page {
switch (page) {
case TabGridPageIncognitoTabs:
base::RecordAction(
base::UserMetricsAction("MobileStackViewIncognitoMode"));
break;
case TabGridPageRegularTabs:
base::RecordAction(base::UserMetricsAction("MobileStackViewNormalMode"));
break;
case TabGridPageRemoteTabs:
// This action is not recorded.
break;
}
}
#pragma mark - GridViewControllerDelegate #pragma mark - GridViewControllerDelegate
- (void)gridViewController:(GridViewController*)gridViewController - (void)gridViewController:(GridViewController*)gridViewController
...@@ -825,6 +847,10 @@ NSUInteger GetPageIndexFromPage(TabGridPage page) { ...@@ -825,6 +847,10 @@ NSUInteger GetPageIndexFromPage(TabGridPage page) {
// disabled. Ensure that action is only taken on a valid state. // disabled. Ensure that action is only taken on a valid state.
if (![[self gridViewControllerForPage:newActivePage] isGridEmpty]) { if (![[self gridViewControllerForPage:newActivePage] isGridEmpty]) {
[self.tabPresentationDelegate showActiveTabInPage:newActivePage]; [self.tabPresentationDelegate showActiveTabInPage:newActivePage];
// Record when users exit the tab grid to return to the current foreground
// tab.
base::RecordAction(
base::UserMetricsAction("MobileTabReturnedToCurrentTab"));
} }
} }
...@@ -865,6 +891,8 @@ NSUInteger GetPageIndexFromPage(TabGridPage page) { ...@@ -865,6 +891,8 @@ NSUInteger GetPageIndexFromPage(TabGridPage page) {
} }
self.activePage = self.currentPage; self.activePage = self.currentPage;
[self.tabPresentationDelegate showActiveTabInPage:self.currentPage]; [self.tabPresentationDelegate showActiveTabInPage:self.currentPage];
// Record only when a new tab is created through the + button.
base::RecordAction(base::UserMetricsAction("MobileToolbarStackViewNewTab"));
} }
- (void)pageControlChangedValue:(id)sender { - (void)pageControlChangedValue:(id)sender {
...@@ -886,7 +914,10 @@ NSUInteger GetPageIndexFromPage(TabGridPage page) { ...@@ -886,7 +914,10 @@ NSUInteger GetPageIndexFromPage(TabGridPage page) {
} }
- (void)pageControlChangedPage:(id)sender { - (void)pageControlChangedPage:(id)sender {
[self setCurrentPage:self.topToolbar.pageControl.selectedPage animated:YES]; TabGridPage newPage = self.topToolbar.pageControl.selectedPage;
[self setCurrentPage:newPage animated:YES];
// Records when the user taps on the pageControl to switch pages.
[self recordActionSwitchingToPage:newPage];
} }
@end @end
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