Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(788)

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/widget/bottomsheet/BottomSheetMetrics.java

Issue 2868553003: [Home] Add more descriptive user actions for opening/closing the bottom sheet (Closed)
Patch Set: animations can end immediately Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/android/java/src/org/chromium/chrome/browser/widget/bottomsheet/BottomSheetMetrics.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/widget/bottomsheet/BottomSheetMetrics.java b/chrome/android/java/src/org/chromium/chrome/browser/widget/bottomsheet/BottomSheetMetrics.java
index e5136e077037926ea834596f701c29c7e51f15f4..27a567d87d338709d3e7965b92ec0b1b293481e0 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/widget/bottomsheet/BottomSheetMetrics.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/widget/bottomsheet/BottomSheetMetrics.java
@@ -32,12 +32,29 @@ public class BottomSheetMetrics extends EmptyBottomSheetObserver {
public static final int OPENED_BY_EXPAND_BUTTON = 3;
private static final int OPENED_BY_BOUNDARY = 4;
+ /** The different ways that the bottom sheet can be closed. */
+ @IntDef({CLOSED_BY_NONE, CLOSED_BY_SWIPE, CLOSED_BY_NTP_CLOSE_BUTTON, CLOSED_BY_TAP_SCRIM,
+ CLOSED_BY_NAVIGATION})
+ public @interface SheetCloseReason {}
+ private static final int CLOSED_BY_NONE = -1;
+ public static final int CLOSED_BY_SWIPE = 0;
+ public static final int CLOSED_BY_NTP_CLOSE_BUTTON = 1;
+ public static final int CLOSED_BY_TAP_SCRIM = 2;
+ public static final int CLOSED_BY_NAVIGATION = 3;
+
/** Whether the sheet is currently open. */
private boolean mIsSheetOpen;
/** The last {@link BottomSheetContent} that was displayed. */
private BottomSheetContent mLastContent;
+ /**
+ * The current reason the sheet might become closed. This may change before the sheet actually
+ * reaches the closed state.
+ */
+ @SheetCloseReason
+ private int mSheetCloseReason;
+
/** When this class was created. Used as a proxy for when the app was started. */
private long mCreationTime;
@@ -54,7 +71,6 @@ public class BottomSheetMetrics extends EmptyBottomSheetObserver {
@Override
public void onSheetOpened() {
mIsSheetOpen = true;
- RecordUserAction.record("Android.ChromeHome.Opened");
boolean isFirstOpen = mLastOpenTime == 0;
mLastOpenTime = System.currentTimeMillis();
@@ -72,7 +88,8 @@ public class BottomSheetMetrics extends EmptyBottomSheetObserver {
@Override
public void onSheetClosed() {
mIsSheetOpen = false;
- RecordUserAction.record("Android.ChromeHome.Closed");
+ recordSheetCloseReason(mSheetCloseReason);
+ mSheetCloseReason = CLOSED_BY_NONE;
mLastCloseTime = System.currentTimeMillis();
RecordHistogram.recordMediumTimesHistogram("Android.ChromeHome.DurationOpen",
@@ -115,11 +132,58 @@ public class BottomSheetMetrics extends EmptyBottomSheetObserver {
}
/**
+ * Set the reason the bottom sheet is currently closing. This value is not recorded until after
+ * the sheet is actually closed.
+ * @param reason The {@link SheetCloseReason} that the sheet is closing.
+ */
+ public void setSheetCloseReason(@SheetCloseReason int reason) {
+ mSheetCloseReason = reason;
+ }
+
+ /**
* Records the reason the sheet was opened.
* @param reason The {@link SheetOpenReason} that caused the bottom sheet to open.
*/
public void recordSheetOpenReason(@SheetOpenReason int reason) {
+ switch (reason) {
+ case OPENED_BY_SWIPE:
+ RecordUserAction.record("Android.ChromeHome.OpenedBySwipe");
+ break;
+ case OPENED_BY_OMNIBOX_FOCUS:
+ RecordUserAction.record("Android.ChromeHome.OpenedByOmnibox");
+ break;
+ case OPENED_BY_NEW_TAB_CREATION:
+ RecordUserAction.record("Android.ChromeHome.OpenedByNTP");
+ break;
+ case OPENED_BY_EXPAND_BUTTON:
+ RecordUserAction.record("Android.ChromeHome.OpenedByExpandButton");
+ break;
+ }
RecordHistogram.recordEnumeratedHistogram(
"Android.ChromeHome.OpenReason", reason, OPENED_BY_BOUNDARY);
}
+
+ /**
+ * Records the reason the sheet was closed.
+ * @param reason The {@link SheetCloseReason} that cause the bottom sheet to close.
+ */
+ public void recordSheetCloseReason(@SheetCloseReason int reason) {
+ switch (reason) {
+ case CLOSED_BY_SWIPE:
+ RecordUserAction.record("Android.ChromeHome.ClosedBySwipe");
+ break;
+ case CLOSED_BY_NTP_CLOSE_BUTTON:
+ RecordUserAction.record("Android.ChromeHome.ClosedByNTPCloseButton");
+ break;
+ case CLOSED_BY_TAP_SCRIM:
+ RecordUserAction.record("Android.ChromeHome.ClosedByTapScrim");
+ break;
+ case CLOSED_BY_NAVIGATION:
+ RecordUserAction.record("Android.ChromeHome.ClosedByNavigation");
+ break;
+ case CLOSED_BY_NONE:
+ default:
+ RecordUserAction.record("Android.ChromeHome.Closed");
+ }
+ }
}

Powered by Google App Engine
This is Rietveld 408576698