Chromium Code Reviews| Index: chrome/android/java/src/org/chromium/chrome/browser/compositor/bottombar/contextualsearch/ContextualSearchPanelMetrics.java |
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/compositor/bottombar/contextualsearch/ContextualSearchPanelMetrics.java b/chrome/android/java/src/org/chromium/chrome/browser/compositor/bottombar/contextualsearch/ContextualSearchPanelMetrics.java |
| index db79b6fc42aad80f60ee86b1d2112f952d2013dc..9a5b5c8ced570c4a71c0d880915293af96c107bf 100644 |
| --- a/chrome/android/java/src/org/chromium/chrome/browser/compositor/bottombar/contextualsearch/ContextualSearchPanelMetrics.java |
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/compositor/bottombar/contextualsearch/ContextualSearchPanelMetrics.java |
| @@ -8,21 +8,15 @@ import org.chromium.chrome.browser.compositor.bottombar.OverlayPanel.PanelState; |
| import org.chromium.chrome.browser.compositor.bottombar.OverlayPanel.StateChangeReason; |
| import org.chromium.chrome.browser.contextualsearch.ContextualSearchHeuristics; |
| import org.chromium.chrome.browser.contextualsearch.ContextualSearchRankerLogger; |
| -import org.chromium.chrome.browser.contextualsearch.ContextualSearchRankerLoggerImpl; |
| import org.chromium.chrome.browser.contextualsearch.ContextualSearchUma; |
| import org.chromium.chrome.browser.contextualsearch.QuickActionCategory; |
| -import java.net.URL; |
| - |
| /** |
| * This class is responsible for all the logging related to Contextual Search. |
| */ |
| public class ContextualSearchPanelMetrics { |
| private static final int MILLISECONDS_TO_NANOSECONDS = 1000000; |
| - // The Ranker logger to use to write Tap Suppression Ranker logs to UMA. |
| - private final ContextualSearchRankerLogger mTapSuppressionRankerLogger; |
| - |
| // Flags for logging. |
| private boolean mDidSearchInvolvePromo; |
| private boolean mWasSearchContentViewSeen; |
| @@ -58,14 +52,7 @@ public class ContextualSearchPanelMetrics { |
| private ContextualSearchHeuristics mResultsSeenExperiments; |
| // The current set of heuristics to be logged through ranker with results seen when the panel |
| // closes. |
| - private ContextualSearchHeuristics mRankerLogExperiments; |
| - |
| - /** |
| - * Constructs an object to track metrics for the Contextual Search Overlay Panel. |
| - */ |
| - ContextualSearchPanelMetrics() { |
| - mTapSuppressionRankerLogger = new ContextualSearchRankerLoggerImpl(); |
| - } |
| + private ContextualSearchRankerLogger mRankerLogger; |
| /** |
| * Log information when the panel's state has changed. |
| @@ -97,8 +84,6 @@ public class ContextualSearchPanelMetrics { |
| (System.nanoTime() - mPanelTriggerTimeFromTapNs) / MILLISECONDS_TO_NANOSECONDS; |
| ContextualSearchUma.logDurationBetweenTriggerAndScroll( |
| durationMs, mWasSearchContentViewSeen); |
| - mTapSuppressionRankerLogger.log( |
| - ContextualSearchRankerLogger.Feature.DURATION_BEFORE_SCROLL_MS, durationMs); |
| } |
| if (isEndingSearch) { |
| @@ -123,9 +108,11 @@ public class ContextualSearchPanelMetrics { |
| mQuickActionCategory); |
| ContextualSearchUma.logQuickActionClicked(mWasQuickActionClicked, |
| mQuickActionCategory); |
| - mTapSuppressionRankerLogger.logOutcome( |
| - ContextualSearchRankerLogger.Feature.OUTCOME_WAS_QUICK_ACTION_CLICKED, |
| - mWasQuickActionClicked); |
| + if (mRankerLogger != null) { |
| + mRankerLogger.logOutcome( |
| + ContextualSearchRankerLogger.Feature.OUTCOME_WAS_QUICK_ACTION_CLICKED, |
| + mWasQuickActionClicked); |
| + } |
| } |
| if (mResultsSeenExperiments != null) { |
| @@ -138,21 +125,24 @@ public class ContextualSearchPanelMetrics { |
| boolean wasAnySuppressionHeuristicSatisfied = mWasAnyHeuristicSatisfiedOnPanelShow; |
| ContextualSearchUma.logAnyTapSuppressionHeuristicSatisfied( |
| mWasSearchContentViewSeen, wasAnySuppressionHeuristicSatisfied); |
| - // Log all the experiments to the Ranker logger. |
| - if (mRankerLogExperiments != null) { |
| - mTapSuppressionRankerLogger.logOutcome( |
| + // Update The Ranker logger. |
|
Theresa
2017/05/30 20:25:24
nit: s/The/the
Donn Denman
2017/05/30 23:13:24
Done.
|
| + if (mRankerLogger != null) { |
| + // Tell Ranker about the primary outcome. |
| + mRankerLogger.logOutcome( |
| ContextualSearchRankerLogger.Feature.OUTCOME_WAS_PANEL_OPENED, |
| mWasSearchContentViewSeen); |
| - mRankerLogExperiments.logRankerTapSuppression(mTapSuppressionRankerLogger); |
| - mRankerLogExperiments = null; |
| + // UMA-Log the Ranker inference signal for Tap only. |
| + ContextualSearchUma.logRankerInferenceResultsSeen( |
| + mWasSearchContentViewSeen, mRankerLogger.wasUiSuppressionInfered()); |
| } |
| - // Reset writing to Ranker so whatever interactions occurred are recorded as a |
| - // complete record. |
| - mTapSuppressionRankerLogger.writeLogAndReset(); |
| - |
| ContextualSearchUma.logSelectionLengthResultsSeen( |
| mWasSearchContentViewSeen, mSelectionLength); |
| } |
| + |
| + // Reset writing to Ranker so whatever interactions occurred are recorded as a |
| + // complete record. |
| + if (mRankerLogger != null) mRankerLogger.writeLogAndReset(); |
| + mRankerLogger = null; |
| } |
| if (isExitingPanelOpenedBeyondPeeked) { |
| @@ -329,15 +319,12 @@ public class ContextualSearchPanelMetrics { |
| } |
| /** |
| - * Sets the experiments to log through Ranker with results seen. |
| - * @param rankerLogExperiments The experiments to log through Ranker when the panel results |
| - * are known. |
| - * @param basePageUrl The URL of the base page to log along with Ranker data. |
| + * Sets up logging through Ranker for outcomes. |
| + * @param rankerLogger The {@link ContextualSearchRankerLogger} currently being used to measure |
| + * or suppress the UI by Ranker. |
|
Theresa
2017/05/30 20:25:24
nit: align "or" with "The" on the previous line
Donn Denman
2017/05/30 23:13:24
Oh, Thanks for pointing this out! I've been doing
|
| */ |
| - public void setRankerLogExperiments( |
| - ContextualSearchHeuristics rankerLogExperiments, URL basePageUrl) { |
| - mRankerLogExperiments = rankerLogExperiments; |
| - mTapSuppressionRankerLogger.setupLoggingForPage(basePageUrl); |
| + public void setRankerLogger(ContextualSearchRankerLogger rankerLogger) { |
| + mRankerLogger = rankerLogger; |
| } |
| /** |