OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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.contextualsearch; | 5 package org.chromium.chrome.browser.contextualsearch; |
6 | 6 |
7 import java.net.URL; | 7 import java.net.URL; |
8 | 8 |
9 /** | 9 /** |
10 * An interface for logging to UMA via Ranker. | 10 * An interface for logging to UMA via Ranker. |
11 */ | 11 */ |
12 public interface ContextualSearchRankerLogger { | 12 public interface ContextualSearchRankerLogger { |
13 enum Feature { | 13 enum Feature { |
14 UNKNOWN, | 14 UNKNOWN, |
15 // Outcome labels: | 15 // Outcome labels: |
16 OUTCOME_WAS_PANEL_OPENED, | 16 OUTCOME_WAS_PANEL_OPENED, |
17 OUTCOME_WAS_QUICK_ACTION_CLICKED, | 17 OUTCOME_WAS_QUICK_ACTION_CLICKED, |
18 OUTCOME_WAS_QUICK_ANSWER_SEEN, | 18 OUTCOME_WAS_QUICK_ANSWER_SEEN, |
19 // Features: | 19 // Features: |
20 DURATION_AFTER_SCROLL_MS, | 20 DURATION_AFTER_SCROLL_MS, |
21 DURATION_BEFORE_SCROLL_MS, | |
22 SCREEN_TOP_DPS, | 21 SCREEN_TOP_DPS, |
23 WAS_SCREEN_BOTTOM, | 22 WAS_SCREEN_BOTTOM, |
24 // User usage features: | 23 // User usage features: |
25 PREVIOUS_WEEK_IMPRESSIONS_COUNT, | 24 PREVIOUS_WEEK_IMPRESSIONS_COUNT, |
26 PREVIOUS_WEEK_CTR_PERCENT, | 25 PREVIOUS_WEEK_CTR_PERCENT, |
27 PREVIOUS_28DAY_IMPRESSIONS_COUNT, | 26 PREVIOUS_28DAY_IMPRESSIONS_COUNT, |
28 PREVIOUS_28DAY_CTR_PERCENT | 27 PREVIOUS_28DAY_CTR_PERCENT |
29 } | 28 } |
30 | 29 |
31 /** | 30 /** |
32 * Sets up logging for the page with the given URL. | 31 * Sets up logging for the page with the given URL. |
33 * This method must be called before calling {@link #log} or {@link #logOutc
ome}. | 32 * This method must be called before calling {@link #logFeature} or {@link #
logOutcome}. |
34 * @param basePageUrl The URL of the base page to log with Ranker. | 33 * @param basePageUrl The URL of the base page to log with Ranker. |
35 */ | 34 */ |
36 void setupLoggingForPage(URL basePageUrl); | 35 void setupLoggingForPage(URL basePageUrl); |
37 | 36 |
38 /** | 37 /** |
39 * Logs a particular feature at inference time as a key/value pair. | 38 * Logs a particular feature at inference time as a key/value pair. |
40 * @param feature The feature to log. | 39 * @param feature The feature to log. |
41 * @param value The value to log, which is associated with the given key. | 40 * @param value The value to log, which is associated with the given key. |
42 */ | 41 */ |
43 void log(Feature feature, Object value); | 42 void logFeature(Feature feature, Object value); |
44 | 43 |
45 /** | 44 /** |
46 * Logs an outcome value at training time that indicates an ML label as a ke
y/value pair. | 45 * Logs an outcome value at training time that indicates an ML label as a ke
y/value pair. |
47 * @param feature The feature to log. | 46 * @param feature The feature to log. |
48 * @param value The outcome label value. | 47 * @param value The outcome label value. |
49 */ | 48 */ |
50 void logOutcome(Feature feature, Object value); | 49 void logOutcome(Feature feature, Object value); |
51 | 50 |
52 /** | 51 /** |
| 52 * Infers whether the UI should be suppressed or not, based on the features
already logged. |
| 53 * @return {@code true} if the UI should not be shown. |
| 54 */ |
| 55 boolean inferUiSuppression(); |
| 56 |
| 57 /** |
| 58 * Reports whether the UI <b><i>would have been</i></b> suppressed if the ML
model was active. |
| 59 * TODO(donnd): remove once the Ranker model has been evaluated and launched
-- this is only |
| 60 * needed for evaluation. |
| 61 * @return Whether the UI <b><i>would have been</i></b> suppressed. |
| 62 */ |
| 63 boolean wasUiSuppressionInfered(); |
| 64 |
| 65 /** |
| 66 * Resets the logger so that future log calls accumulate into a new record. |
| 67 * Any accumulated logging for the current record is discarded. |
| 68 */ |
| 69 void reset(); |
| 70 |
| 71 /** |
53 * Writes all the accumulated log entries and resets the logger so that futu
re log calls | 72 * Writes all the accumulated log entries and resets the logger so that futu
re log calls |
54 * accumulate into a new record. | 73 * accumulate into a new record. |
55 * After calling this method another call to {@link #setupLoggingForPage} is
required before | 74 * After calling this method another call to {@link #setupLoggingForPage} is
required before |
56 * additional {@link #log} or {@link #logOutcome} calls. | 75 * additional {@link #logFeature} or {@link #logOutcome} calls. |
57 */ | 76 */ |
58 void writeLogAndReset(); | 77 void writeLogAndReset(); |
59 } | 78 } |
OLD | NEW |