OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 package org.chromium.chrome.browser.compositor.bottombar.contextualsearch; | 5 package org.chromium.chrome.browser.compositor.bottombar.contextualsearch; |
6 | 6 |
7 import org.chromium.chrome.browser.compositor.bottombar.OverlayPanel.PanelState; | 7 import org.chromium.chrome.browser.compositor.bottombar.OverlayPanel.PanelState; |
8 import org.chromium.chrome.browser.compositor.bottombar.OverlayPanel.StateChange
Reason; | 8 import org.chromium.chrome.browser.compositor.bottombar.OverlayPanel.StateChange
Reason; |
9 import org.chromium.chrome.browser.contextualsearch.ContextualSearchHeuristics; | 9 import org.chromium.chrome.browser.contextualsearch.ContextualSearchHeuristics; |
10 import org.chromium.chrome.browser.contextualsearch.ContextualSearchRankerLogger
; | 10 import org.chromium.chrome.browser.contextualsearch.ContextualSearchRankerLogger
; |
11 import org.chromium.chrome.browser.contextualsearch.ContextualSearchRankerLogger
Impl; | 11 import org.chromium.chrome.browser.contextualsearch.ContextualSearchRankerLogger
Impl; |
12 import org.chromium.chrome.browser.contextualsearch.ContextualSearchUma; | 12 import org.chromium.chrome.browser.contextualsearch.ContextualSearchUma; |
13 import org.chromium.chrome.browser.contextualsearch.QuickActionCategory; | 13 import org.chromium.chrome.browser.contextualsearch.QuickActionCategory; |
14 | 14 |
| 15 import java.net.URL; |
| 16 |
15 /** | 17 /** |
16 * This class is responsible for all the logging related to Contextual Search. | 18 * This class is responsible for all the logging related to Contextual Search. |
17 */ | 19 */ |
18 public class ContextualSearchPanelMetrics { | 20 public class ContextualSearchPanelMetrics { |
19 private static final int MILLISECONDS_TO_NANOSECONDS = 1000000; | 21 private static final int MILLISECONDS_TO_NANOSECONDS = 1000000; |
20 | 22 |
21 // The Ranker logger to use to write Tap Suppression Ranker logs to UMA. | 23 // The Ranker logger to use to write Tap Suppression Ranker logs to UMA. |
22 private final ContextualSearchRankerLogger mTapSuppressionRankerLogger; | 24 private final ContextualSearchRankerLogger mTapSuppressionRankerLogger; |
23 | 25 |
24 // Flags for logging. | 26 // Flags for logging. |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 } | 116 } |
115 | 117 |
116 if (mWasContextualCardsDataShown) { | 118 if (mWasContextualCardsDataShown) { |
117 ContextualSearchUma.logContextualCardsResultsSeen(mWasSearchCont
entViewSeen); | 119 ContextualSearchUma.logContextualCardsResultsSeen(mWasSearchCont
entViewSeen); |
118 } | 120 } |
119 if (mWasQuickActionShown) { | 121 if (mWasQuickActionShown) { |
120 ContextualSearchUma.logQuickActionResultsSeen(mWasSearchContentV
iewSeen, | 122 ContextualSearchUma.logQuickActionResultsSeen(mWasSearchContentV
iewSeen, |
121 mQuickActionCategory); | 123 mQuickActionCategory); |
122 ContextualSearchUma.logQuickActionClicked(mWasQuickActionClicked
, | 124 ContextualSearchUma.logQuickActionClicked(mWasQuickActionClicked
, |
123 mQuickActionCategory); | 125 mQuickActionCategory); |
124 mTapSuppressionRankerLogger.log( | 126 mTapSuppressionRankerLogger.logOutcome( |
125 ContextualSearchRankerLogger.Feature.OUTCOME_WAS_QUICK_A
CTION_CLICKED, | 127 ContextualSearchRankerLogger.Feature.OUTCOME_WAS_QUICK_A
CTION_CLICKED, |
126 mWasQuickActionClicked); | 128 mWasQuickActionClicked); |
127 } | 129 } |
128 | 130 |
129 if (mResultsSeenExperiments != null) { | 131 if (mResultsSeenExperiments != null) { |
130 mResultsSeenExperiments.logResultsSeen( | 132 mResultsSeenExperiments.logResultsSeen( |
131 mWasSearchContentViewSeen, mWasActivatedByTap); | 133 mWasSearchContentViewSeen, mWasActivatedByTap); |
132 mResultsSeenExperiments = null; | 134 mResultsSeenExperiments = null; |
133 } | 135 } |
134 | 136 |
135 if (mWasActivatedByTap) { | 137 if (mWasActivatedByTap) { |
136 boolean wasAnySuppressionHeuristicSatisfied = mWasAnyHeuristicSa
tisfiedOnPanelShow; | 138 boolean wasAnySuppressionHeuristicSatisfied = mWasAnyHeuristicSa
tisfiedOnPanelShow; |
137 ContextualSearchUma.logAnyTapSuppressionHeuristicSatisfied( | 139 ContextualSearchUma.logAnyTapSuppressionHeuristicSatisfied( |
138 mWasSearchContentViewSeen, wasAnySuppressionHeuristicSat
isfied); | 140 mWasSearchContentViewSeen, wasAnySuppressionHeuristicSat
isfied); |
139 // Log all the experiments to the Ranker logger. | 141 // Log all the experiments to the Ranker logger. |
140 if (mRankerLogExperiments != null) { | 142 if (mRankerLogExperiments != null) { |
141 mTapSuppressionRankerLogger.logOutcome(mWasSearchContentView
Seen); | 143 mTapSuppressionRankerLogger.logOutcome( |
| 144 ContextualSearchRankerLogger.Feature.OUTCOME_WAS_PAN
EL_OPENED, |
| 145 mWasSearchContentViewSeen); |
142 mRankerLogExperiments.logRankerTapSuppression(mTapSuppressio
nRankerLogger); | 146 mRankerLogExperiments.logRankerTapSuppression(mTapSuppressio
nRankerLogger); |
143 mTapSuppressionRankerLogger.writeLogAndReset(); | |
144 mRankerLogExperiments = null; | 147 mRankerLogExperiments = null; |
145 } | 148 } |
| 149 // Reset writing to Ranker so whatever interactions occurred are
recorded as a |
| 150 // complete record. |
| 151 mTapSuppressionRankerLogger.writeLogAndReset(); |
146 | 152 |
147 ContextualSearchUma.logSelectionLengthResultsSeen( | 153 ContextualSearchUma.logSelectionLengthResultsSeen( |
148 mWasSearchContentViewSeen, mSelectionLength); | 154 mWasSearchContentViewSeen, mSelectionLength); |
149 } | 155 } |
150 } | 156 } |
151 | 157 |
152 if (isExitingPanelOpenedBeyondPeeked) { | 158 if (isExitingPanelOpenedBeyondPeeked) { |
153 assert mPanelOpenedBeyondPeekTimeNs != 0; | 159 assert mPanelOpenedBeyondPeekTimeNs != 0; |
154 long durationPanelOpen = (System.nanoTime() - mPanelOpenedBeyondPeek
TimeNs) | 160 long durationPanelOpen = (System.nanoTime() - mPanelOpenedBeyondPeek
TimeNs) |
155 / MILLISECONDS_TO_NANOSECONDS; | 161 / MILLISECONDS_TO_NANOSECONDS; |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
317 /** | 323 /** |
318 * Sets the experiments to log with results seen. | 324 * Sets the experiments to log with results seen. |
319 * @param resultsSeenExperiments The experiments to log when the panel resul
ts are known. | 325 * @param resultsSeenExperiments The experiments to log when the panel resul
ts are known. |
320 */ | 326 */ |
321 public void setResultsSeenExperiments(ContextualSearchHeuristics resultsSeen
Experiments) { | 327 public void setResultsSeenExperiments(ContextualSearchHeuristics resultsSeen
Experiments) { |
322 mResultsSeenExperiments = resultsSeenExperiments; | 328 mResultsSeenExperiments = resultsSeenExperiments; |
323 } | 329 } |
324 | 330 |
325 /** | 331 /** |
326 * Sets the experiments to log through Ranker with results seen. | 332 * Sets the experiments to log through Ranker with results seen. |
327 * @param rankerLogExperiments The experiments to log through ranker when th
e panel results | 333 * @param rankerLogExperiments The experiments to log through Ranker when th
e panel results |
328 * are known. | 334 * are known. |
| 335 * @param basePageUrl The URL of the base page to log along with Ranker data
. |
329 */ | 336 */ |
330 public void setRankerLogExperiments(ContextualSearchHeuristics rankerLogExpe
riments) { | 337 public void setRankerLogExperiments( |
| 338 ContextualSearchHeuristics rankerLogExperiments, URL basePageUrl) { |
331 mRankerLogExperiments = rankerLogExperiments; | 339 mRankerLogExperiments = rankerLogExperiments; |
| 340 mTapSuppressionRankerLogger.setupLoggingForPage(basePageUrl); |
332 } | 341 } |
333 | 342 |
334 /** | 343 /** |
335 * Determine whether a new contextual search is starting. | 344 * Determine whether a new contextual search is starting. |
336 * @param toState The contextual search state that will be transitioned to. | 345 * @param toState The contextual search state that will be transitioned to. |
337 * @param reason The reason for the search state transition. | 346 * @param reason The reason for the search state transition. |
338 * @return Whether a new contextual search is starting. | 347 * @return Whether a new contextual search is starting. |
339 */ | 348 */ |
340 private boolean isStartingNewContextualSearch(PanelState toState, StateChang
eReason reason) { | 349 private boolean isStartingNewContextualSearch(PanelState toState, StateChang
eReason reason) { |
341 return toState == PanelState.PEEKED | 350 return toState == PanelState.PEEKED |
(...skipping 16 matching lines...) Expand all Loading... |
358 | 367 |
359 /** | 368 /** |
360 * @param fromState The state the panel is transitioning from. | 369 * @param fromState The state the panel is transitioning from. |
361 * @return Whether there is an ongoing contextual search. | 370 * @return Whether there is an ongoing contextual search. |
362 */ | 371 */ |
363 private boolean isOngoingContextualSearch(PanelState fromState) { | 372 private boolean isOngoingContextualSearch(PanelState fromState) { |
364 return fromState != PanelState.UNDEFINED && fromState != PanelState.CLOS
ED; | 373 return fromState != PanelState.UNDEFINED && fromState != PanelState.CLOS
ED; |
365 } | 374 } |
366 } | 375 } |
367 | 376 |
OLD | NEW |