Skip to content

Commit

Permalink
[5735] Add scrolling metrics in grid views
Browse files Browse the repository at this point in the history
This CL adds metrics to track scrolling actions in grid views:
- events when the user scrolls;
- cumulative time spent scrolling.

(cherry picked from commit 63e25d1)

Fixed: 1439234
Change-Id: Id5e5c3bb0739359ddd6670f4de10789c3c25ca35
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4466313
Auto-Submit: Louis Romero <lpromero@google.com>
Reviewed-by: Aliona Dangla <alionadangla@chromium.org>
Reviewed-by: Gauthier Ambard <gambard@chromium.org>
Commit-Queue: Louis Romero <lpromero@google.com>
Reviewed-by: Olivier Robin <olivierrobin@chromium.org>
Cr-Original-Commit-Position: refs/heads/main@{#1136168}
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4484223
Commit-Queue: Gauthier Ambard <gambard@chromium.org>
Cr-Commit-Position: refs/branch-heads/5735@{#44}
Cr-Branched-From: 2f562e4-refs/heads/main@{#1135570}
  • Loading branch information
Arcank authored and Chromium LUCI CQ committed Apr 28, 2023
1 parent df3138f commit efe2a7a
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#import "ios/chrome/browser/ui/tab_switcher/tab_grid/grid/grid_view_controller.h"

#import <algorithm>
#import <memory>

#import "base/check_op.h"
#import "base/ios/block_types.h"
Expand Down Expand Up @@ -56,6 +57,18 @@
#error "This file requires ARC support."
#endif

class ScrollingTimeLogger {
public:
ScrollingTimeLogger() : start_(base::TimeTicks::Now()) {}
~ScrollingTimeLogger() {
base::TimeDelta duration = base::TimeTicks::Now() - start_;
base::UmaHistogramTimes("IOS.TabSwitcher.TimeSpentScrolling", duration);
}

private:
base::TimeTicks start_;
};

namespace {

// Constants used in the spring animation when inserting items in the thumb
Expand Down Expand Up @@ -171,10 +184,13 @@ @interface GridViewController () <GridCellDelegate,
@property(nonatomic, assign) NSInteger inactiveTabsDaysThreshold;
// Tracks if a drop action initiated in this grid is in progress.
@property(nonatomic) BOOL localDragActionInProgress;

@end

@implementation GridViewController
@implementation GridViewController {
// Tracks when the grid view is scrolling. Create a new instance to start
// timing and reset to stop and log the associated time histogram.
std::unique_ptr<ScrollingTimeLogger> _scrollingTimeLogger;
}

@synthesize thumbStripEnabled = _thumbStripEnabled;

Expand Down Expand Up @@ -1099,6 +1115,23 @@ - (void)scrollViewDidScroll:(UIScrollView*)scrollView {

- (void)scrollViewWillBeginDragging:(UIScrollView*)scrollView {
[self.delegate gridViewControllerWillBeginDragging:self];
base::RecordAction(base::UserMetricsAction("MobileTabGridUserScrolled"));
_scrollingTimeLogger = std::make_unique<ScrollingTimeLogger>();
}

- (void)scrollViewDidEndDragging:(UIScrollView*)scrollView
willDecelerate:(BOOL)decelerate {
if (!decelerate) {
_scrollingTimeLogger = nullptr;
}
}

- (void)scrollViewDidEndDecelerating:(UIScrollView*)scrollView {
_scrollingTimeLogger = nullptr;
}

- (void)scrollViewDidScrollToTop:(UIScrollView*)scrollView {
base::RecordAction(base::UserMetricsAction("MobileTabGridUserScrolledToTop"));
}

- (void)scrollViewDidChangeAdjustedContentInset:(UIScrollView*)scrollView {
Expand Down
17 changes: 17 additions & 0 deletions tools/metrics/actions/actions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21817,6 +21817,23 @@ should be able to be added at any place in this file.
</description>
</action>

<action name="MobileTabGridUserScrolled">
<owner>lpromero@chromium.org</owner>
<owner>alionadangla@chromium.org</owner>
<owner>chromeleon@google.com</owner>
<description>User in the iOS tab grid scrolled the grid of tabs.</description>
</action>

<action name="MobileTabGridUserScrolledToTop">
<owner>lpromero@chromium.org</owner>
<owner>alionadangla@chromium.org</owner>
<owner>chromeleon@google.com</owner>
<description>
User in the iOS tab grid tapped the status bar to scroll to the top of the
grid of tabs.
</description>
</action>

<action name="MobileTabNewTab">
<owner>ewannpv@chromium.org</owner>
<owner>gambard@chromium.org</owner>
Expand Down
11 changes: 11 additions & 0 deletions tools/metrics/histograms/metadata/ios/histograms.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2347,6 +2347,17 @@ chromium-metrics-reviews@google.com.
</summary>
</histogram>

<histogram name="IOS.TabSwitcher.TimeSpentScrolling" units="ms"
expires_after="2024-05-14">
<owner>lpromero@chromium.org</owner>
<owner>alionadangla@chromium.org</owner>
<owner>chromeleon@google.com</owner>
<summary>
The time spent while the tab grid is scrolled by the user. This includes the
deceleration time.
</summary>
</histogram>

<histogram name="IOS.TextSelection.EntityDetection.DetectedEntityType"
enum="TextSelectionDetectedEntityType" expires_after="2023-10-08">
<owner>rajendrant@chromium.org</owner>
Expand Down

0 comments on commit efe2a7a

Please sign in to comment.