Commit b12f8781 authored by Donn Denman's avatar Donn Denman Committed by Commit Bot

[TTS] Add an engagment Heuristic for ML Tap work.

Adds an Engagement Suppression heuristic that sends several new signals
to the ML model for Tap Suppression.  These signals quantify user
engagment by registering the number of lifetime opens, quick actions
taken, translations shown, etc.

Note that the additional signals in this CL are documented in
http://go/ukm-cs-4 (with privacy approval noted there).

BUG=776156

Change-Id: I1e9457a18a5624ceb97e7236761f99173af6dabe
Reviewed-on: https://chromium-review.googlesource.com/1079810Reviewed-by: default avatarRoger McFarlane <rogerm@chromium.org>
Reviewed-by: default avatarRobert Kaplow <rkaplow@chromium.org>
Reviewed-by: default avatarTheresa <twellington@chromium.org>
Commit-Queue: Donn Denman <donnd@chromium.org>
Cr-Commit-Position: refs/heads/master@{#571210}
parent add506a6
......@@ -10,6 +10,7 @@ import org.chromium.chrome.browser.contextualsearch.ContextualSearchHeuristics;
import org.chromium.chrome.browser.contextualsearch.ContextualSearchIPH;
import org.chromium.chrome.browser.contextualsearch.ContextualSearchRankerLogger;
import org.chromium.chrome.browser.contextualsearch.ContextualSearchUma;
import org.chromium.chrome.browser.contextualsearch.EngagementSuppression;
import org.chromium.chrome.browser.contextualsearch.QuickActionCategory;
import org.chromium.chrome.browser.profiles.Profile;
......@@ -121,12 +122,15 @@ public class ContextualSearchPanelMetrics {
if (mWasContextualCardsDataShown) {
ContextualSearchUma.logContextualCardsResultsSeen(mWasSearchContentViewSeen);
EngagementSuppression.registerContextualCardsImpression(mWasSearchContentViewSeen);
}
if (mWasQuickActionShown) {
ContextualSearchUma.logQuickActionResultsSeen(mWasSearchContentViewSeen,
mQuickActionCategory);
ContextualSearchUma.logQuickActionClicked(mWasQuickActionClicked,
mQuickActionCategory);
EngagementSuppression.registerQuickActionImpression(
mWasSearchContentViewSeen, mWasQuickActionClicked);
}
if (mResultsSeenExperiments != null) {
......
......@@ -55,6 +55,7 @@ public class ContextualSearchFieldTrial {
private static final String SHORT_TEXT_RUN_SUPPRESSION_ENABLED =
"enable_short_text_run_suppression";
private static final String SMALL_TEXT_SUPPRESSION_ENABLED = "enable_small_text_suppression";
static final String ENGAGEMENT_SUPPRESSION_ENABLED = "enable_engagement_suppression";
@VisibleForTesting
static final String NOT_AN_ENTITY_SUPPRESSION_ENABLED = "enable_not_an_entity_suppression";
// The threshold for tap suppression based on duration.
......@@ -99,6 +100,7 @@ public class ContextualSearchFieldTrial {
private static Boolean sIsShortWordSuppressionEnabled;
private static Boolean sIsNotLongWordSuppressionEnabled;
private static Boolean sIsNotAnEntitySuppressionEnabled;
private static Boolean sIsEngagementSuppressionEnabled;
private static Boolean sIsShortTextRunSuppressionEnabled;
private static Boolean sIsSmallTextSuppressionEnabled;
private static Integer sMinimumSelectionLength;
......@@ -280,6 +282,16 @@ public class ContextualSearchFieldTrial {
return sIsNotAnEntitySuppressionEnabled.booleanValue();
}
/**
* @return Whether triggering is suppressed due to lack of engagement with the feature.
*/
static boolean isEngagementSuppressionEnabled() {
if (sIsEngagementSuppressionEnabled == null) {
sIsEngagementSuppressionEnabled = getBooleanParam(ENGAGEMENT_SUPPRESSION_ENABLED);
}
return sIsEngagementSuppressionEnabled.booleanValue();
}
/**
* @return Whether triggering is suppressed for a tap that has a short element run-length.
*/
......
......@@ -6,6 +6,7 @@ package org.chromium.chrome.browser.contextualsearch;
import android.content.Context;
import android.net.Uri;
import android.support.annotation.Nullable;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
......@@ -24,8 +25,6 @@ import java.util.List;
import java.util.Locale;
import java.util.regex.Pattern;
import javax.annotation.Nullable;
/**
* Handles policy decisions for the {@code ContextualSearchManager}.
......@@ -185,23 +184,26 @@ class ContextualSearchPolicy {
promoTapCounter.increment();
}
}
int tapsSinceOpen = mPreferenceManager.getContextualSearchTapCount();
mPreferenceManager.setContextualSearchTapCount(++tapsSinceOpen);
int tapsSinceOpen = mPreferenceManager.incrementInt(
ChromePreferenceManager.CONTEXTUAL_SEARCH_TAP_SINCE_OPEN_COUNT);
if (isUserUndecided()) {
ContextualSearchUma.logTapsSinceOpenForUndecided(tapsSinceOpen);
} else {
ContextualSearchUma.logTapsSinceOpenForDecided(tapsSinceOpen);
}
mPreferenceManager.incrementInt(
ChromePreferenceManager.CONTEXTUAL_SEARCH_ALL_TIME_TAP_COUNT);
}
/**
* Updates all the counters to account for an open-action on the panel.
*/
void updateCountersForOpen() {
// Always completely reset the tap counter, since it just counts taps
// since the last open.
mPreferenceManager.setContextualSearchTapCount(0);
mPreferenceManager.setContextualSearchTapQuickAnswerCount(0);
// Always completely reset the tap counters that accumulate only since the last open.
mPreferenceManager.writeInt(
ChromePreferenceManager.CONTEXTUAL_SEARCH_TAP_SINCE_OPEN_COUNT, 0);
mPreferenceManager.writeInt(
ChromePreferenceManager.CONTEXTUAL_SEARCH_TAP_SINCE_OPEN_QUICK_ANSWER_COUNT, 0);
// Disable the "promo tap" counter, but only if we're using the Opt-out onboarding.
// For Opt-in, we never disable the promo tap counter.
......@@ -209,10 +211,12 @@ class ContextualSearchPolicy {
getPromoTapCounter().disable();
// Bump the total-promo-opens counter.
int count = mPreferenceManager.getContextualSearchPromoOpenCount();
mPreferenceManager.setContextualSearchPromoOpenCount(++count);
int count = mPreferenceManager.incrementInt(
ChromePreferenceManager.CONTEXTUAL_SEARCH_PROMO_OPEN_COUNT);
ContextualSearchUma.logPromoOpenCount(count);
}
mPreferenceManager.incrementInt(
ChromePreferenceManager.CONTEXTUAL_SEARCH_ALL_TIME_OPEN_COUNT);
}
/**
......@@ -223,9 +227,10 @@ class ContextualSearchPolicy {
*/
void updateCountersForQuickAnswer(boolean wasActivatedByTap, boolean doesAnswer) {
if (wasActivatedByTap && doesAnswer) {
int tapsWithAnswerSinceOpen =
mPreferenceManager.getContextualSearchTapQuickAnswerCount();
mPreferenceManager.setContextualSearchTapQuickAnswerCount(++tapsWithAnswerSinceOpen);
mPreferenceManager.incrementInt(
ChromePreferenceManager.CONTEXTUAL_SEARCH_TAP_SINCE_OPEN_QUICK_ANSWER_COUNT);
mPreferenceManager.incrementInt(
ChromePreferenceManager.CONTEXTUAL_SEARCH_ALL_TIME_TAP_QUICK_ANSWER_COUNT);
}
}
......@@ -364,7 +369,8 @@ class ContextualSearchPolicy {
*/
@VisibleForTesting
int getPromoOpenCount() {
return mPreferenceManager.getContextualSearchPromoOpenCount();
return mPreferenceManager.readInt(
ChromePreferenceManager.CONTEXTUAL_SEARCH_PROMO_OPEN_COUNT);
}
/**
......@@ -372,7 +378,8 @@ class ContextualSearchPolicy {
*/
@VisibleForTesting
int getTapCount() {
return mPreferenceManager.getContextualSearchTapCount();
return mPreferenceManager.readInt(
ChromePreferenceManager.CONTEXTUAL_SEARCH_TAP_SINCE_OPEN_COUNT);
}
// --------------------------------------------------------------------------------------------
......
......@@ -45,7 +45,16 @@ public interface ContextualSearchRankerLogger {
IS_HTTP,
IS_ENTITY_ELIGIBLE,
IS_LANGUAGE_MISMATCH,
PORTION_OF_ELEMENT
PORTION_OF_ELEMENT,
// UKM CS v4 features (see go/ukm-cs-4).
TAP_COUNT,
OPEN_COUNT,
QUICK_ANSWER_COUNT,
ENTITY_IMPRESSIONS_COUNT,
ENTITY_OPENS_COUNT,
QUICK_ACTION_IMPRESSIONS_COUNT,
QUICK_ACTIONS_TAKEN_COUNT,
QUICK_ACTIONS_IGNORED_COUNT,
}
/**
......
......@@ -4,6 +4,8 @@
package org.chromium.chrome.browser.contextualsearch;
import android.support.annotation.Nullable;
import org.chromium.base.Log;
import org.chromium.base.VisibleForTesting;
import org.chromium.content_public.browser.WebContents;
......@@ -12,8 +14,6 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import javax.annotation.Nullable;
/**
* Implements the UMA logging for Ranker that's used for Contextual Search Tap Suppression.
*/
......@@ -59,6 +59,15 @@ public class ContextualSearchRankerLoggerImpl implements ContextualSearchRankerL
features.put(Feature.IS_ENTITY_ELIGIBLE, "IsEntityEligible");
features.put(Feature.IS_LANGUAGE_MISMATCH, "IsLanguageMismatch");
features.put(Feature.PORTION_OF_ELEMENT, "PortionOfElement");
// UKM CS v4 features.
features.put(Feature.TAP_COUNT, "TapCount");
features.put(Feature.OPEN_COUNT, "OpenCount");
features.put(Feature.QUICK_ANSWER_COUNT, "QuickAnswerCount");
features.put(Feature.ENTITY_IMPRESSIONS_COUNT, "EntityImpressionsCount");
features.put(Feature.ENTITY_OPENS_COUNT, "EntityOpensCount");
features.put(Feature.QUICK_ACTION_IMPRESSIONS_COUNT, "QuickActionImpressionsCount");
features.put(Feature.QUICK_ACTIONS_TAKEN_COUNT, "QuickActionsTaken");
features.put(Feature.QUICK_ACTIONS_IGNORED_COUNT, "QuickActionsIgnored");
FEATURES = Collections.unmodifiableMap(features);
Map<Feature, String> allNames = new HashMap<Feature, String>();
......
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package org.chromium.chrome.browser.contextualsearch;
import org.chromium.chrome.browser.preferences.ChromePreferenceManager;
/**
* Provides a ContextualSearchHeuristic for Engagement with the feature.
*/
public class EngagementSuppression extends ContextualSearchHeuristic {
private final ChromePreferenceManager mPreferenceManager;
private final boolean mIsConditionSatisfied;
private final boolean mIsEnabled;
/**
* Constructs an object that tracks panel opens and other measures of engagement.
*/
EngagementSuppression() {
mPreferenceManager = ChromePreferenceManager.getInstance();
mIsEnabled = ContextualSearchFieldTrial.isEngagementSuppressionEnabled();
// Used for manual testing; suppress when we've had an entity impression but no open,
// OR had a Quick Action presented but none taken and at least one ignored.
boolean hadEntityImpression =
mPreferenceManager.readInt(
ChromePreferenceManager.CONTEXTUAL_SEARCH_ENTITY_IMPRESSIONS_COUNT)
> 0;
boolean hadEntityOpen =
mPreferenceManager.readInt(
ChromePreferenceManager.CONTEXTUAL_SEARCH_ENTITY_OPENS_COUNT)
> 0;
boolean hadQuickActionImpression =
mPreferenceManager.readInt(
ChromePreferenceManager.CONTEXTUAL_SEARCH_QUICK_ACTION_IMPRESSIONS_COUNT)
> 0;
boolean hadQuickActionTaken =
mPreferenceManager.readInt(
ChromePreferenceManager.CONTEXTUAL_SEARCH_QUICK_ACTIONS_TAKEN_COUNT)
> 0;
boolean hadQuickActionIgnored =
mPreferenceManager.readInt(
ChromePreferenceManager.CONTEXTUAL_SEARCH_QUICK_ACTIONS_IGNORED_COUNT)
> 0;
mIsConditionSatisfied = (hadEntityImpression && !hadEntityOpen)
|| (hadQuickActionImpression && !hadQuickActionTaken && hadQuickActionIgnored);
}
/**
* Registers that the user saw a Quick Action how they engaged with that feature.
* @param wasPanelOpened Whether the panel was opened.
* @param wasActionClicked Whether the user actually did the quick action, e.g. dialed the
* phone number.
*/
public static void registerQuickActionImpression(
boolean wasPanelOpened, boolean wasActionClicked) {
ChromePreferenceManager prefs = ChromePreferenceManager.getInstance();
prefs.incrementInt(
ChromePreferenceManager.CONTEXTUAL_SEARCH_QUICK_ACTION_IMPRESSIONS_COUNT);
if (wasActionClicked) {
prefs.incrementInt(ChromePreferenceManager.CONTEXTUAL_SEARCH_QUICK_ACTIONS_TAKEN_COUNT);
} else if (wasPanelOpened) {
prefs.incrementInt(
ChromePreferenceManager.CONTEXTUAL_SEARCH_QUICK_ACTIONS_IGNORED_COUNT);
}
}
/**
* Registers that the user saw Contextual Cards data, and whether they engaged with the feature
* by opening the panel.
* @param wasPanelOpened Whether the panel was opened.
*/
public static void registerContextualCardsImpression(boolean wasPanelOpened) {
ChromePreferenceManager prefs = ChromePreferenceManager.getInstance();
prefs.incrementInt(ChromePreferenceManager.CONTEXTUAL_SEARCH_ENTITY_IMPRESSIONS_COUNT);
if (wasPanelOpened) {
prefs.incrementInt(ChromePreferenceManager.CONTEXTUAL_SEARCH_ENTITY_OPENS_COUNT);
}
}
// ============================================================================================
// ContextualSearchHeuristic overrides.
// ============================================================================================
@Override
protected boolean isConditionSatisfiedAndEnabled() {
return mIsConditionSatisfied && mIsEnabled;
}
@Override
protected void logRankerTapSuppression(ContextualSearchRankerLogger logger) {
// These counters are updated in ContextualSearchPolcy when taps and opens are registered.
logger.logFeature(ContextualSearchRankerLogger.Feature.TAP_COUNT,
mPreferenceManager.readInt(
ChromePreferenceManager.CONTEXTUAL_SEARCH_ALL_TIME_TAP_COUNT));
logger.logFeature(ContextualSearchRankerLogger.Feature.OPEN_COUNT,
mPreferenceManager.readInt(
ChromePreferenceManager.CONTEXTUAL_SEARCH_ALL_TIME_OPEN_COUNT));
logger.logFeature(ContextualSearchRankerLogger.Feature.QUICK_ANSWER_COUNT,
mPreferenceManager.readInt(
ChromePreferenceManager.CONTEXTUAL_SEARCH_ALL_TIME_TAP_QUICK_ANSWER_COUNT));
// These counters are updated in the #registerX static methods of this class.
logger.logFeature(ContextualSearchRankerLogger.Feature.ENTITY_IMPRESSIONS_COUNT,
mPreferenceManager.readInt(
ChromePreferenceManager.CONTEXTUAL_SEARCH_ENTITY_IMPRESSIONS_COUNT));
logger.logFeature(ContextualSearchRankerLogger.Feature.ENTITY_OPENS_COUNT,
mPreferenceManager.readInt(
ChromePreferenceManager.CONTEXTUAL_SEARCH_ENTITY_OPENS_COUNT));
logger.logFeature(ContextualSearchRankerLogger.Feature.QUICK_ACTION_IMPRESSIONS_COUNT,
mPreferenceManager.readInt(
ChromePreferenceManager.CONTEXTUAL_SEARCH_QUICK_ACTION_IMPRESSIONS_COUNT));
logger.logFeature(ContextualSearchRankerLogger.Feature.QUICK_ACTIONS_TAKEN_COUNT,
mPreferenceManager.readInt(
ChromePreferenceManager.CONTEXTUAL_SEARCH_QUICK_ACTIONS_TAKEN_COUNT));
logger.logFeature(ContextualSearchRankerLogger.Feature.QUICK_ACTIONS_IGNORED_COUNT,
mPreferenceManager.readInt(
ChromePreferenceManager.CONTEXTUAL_SEARCH_QUICK_ACTIONS_IGNORED_COUNT));
}
}
......@@ -31,6 +31,7 @@ public class TapSuppressionHeuristics extends ContextualSearchHeuristics {
super();
mCtrSuppression = new CtrSuppression();
mHeuristics.add(mCtrSuppression);
mHeuristics.add(new EngagementSuppression());
mHeuristics.add(new RecentScrollTapSuppression(selectionController));
mHeuristics.add(new TapFarFromPreviousSuppression(
selectionController, previousTapState, x, y, wasSelectionEmptyBeforeTap));
......
......@@ -20,7 +20,68 @@ import java.util.Set;
* ChromePreferenceManager stores and retrieves various values in Android shared preferences.
*/
public class ChromePreferenceManager {
private static final String TAG = "preferences";
// For new int values with a default of 0, just document the key and its usage, and call
// #readInt and #writeInt directly.
/** An all-time counter of taps that triggered the Contextual Search peeking panel. */
public static final String CONTEXTUAL_SEARCH_ALL_TIME_TAP_COUNT =
"contextual_search_all_time_tap_count";
/** An all-time counter of Contextual Search panel opens triggered by any gesture.*/
public static final String CONTEXTUAL_SEARCH_ALL_TIME_OPEN_COUNT =
"contextual_search_all_time_open_count";
/**
* The number of times a tap gesture caused a Contextual Search Quick Answer to be shown.
* Cumulative, starting at M-69.
*/
public static final String CONTEXTUAL_SEARCH_ALL_TIME_TAP_QUICK_ANSWER_COUNT =
"contextual_search_all_time_tap_quick_answer_count";
/**
* The number of times that a tap triggered the Contextual Search panel to peek since the last
* time the panel was opened. Note legacy string value without "open".
*/
public static final String CONTEXTUAL_SEARCH_TAP_SINCE_OPEN_COUNT =
"contextual_search_tap_count";
/**
* The number of times a tap gesture caused a Contextual Search Quick Answer to be shown since
* the last time the panel was opened. Note legacy string value without "open".
*/
public static final String CONTEXTUAL_SEARCH_TAP_SINCE_OPEN_QUICK_ANSWER_COUNT =
"contextual_search_tap_quick_answer_count";
/**
* The number of times the Contextual Search panel was opened with the opt-in promo visible.
*/
public static final String CONTEXTUAL_SEARCH_PROMO_OPEN_COUNT =
"contextual_search_promo_open_count";
/**
* The entity-data impressions count for Contextual Search, i.e. thumbnails shown in the Bar.
* Cumulative, starting at M-69.
*/
public static final String CONTEXTUAL_SEARCH_ENTITY_IMPRESSIONS_COUNT =
"contextual_search_entity_impressions_count";
/**
* The entity-data opens count for Contextual Search, e.g. Panel opens following thumbnails
* shown in the Bar. Cumulative, starting at M-69.
*/
public static final String CONTEXTUAL_SEARCH_ENTITY_OPENS_COUNT =
"contextual_search_entity_opens_count";
/**
* The Quick Action impressions count for Contextual Search, i.e. actions presented in the Bar.
* Cumulative, starting at M-69.
*/
public static final String CONTEXTUAL_SEARCH_QUICK_ACTION_IMPRESSIONS_COUNT =
"contextual_search_quick_action_impressions_count";
/**
* The Quick Actions taken count for Contextual Search, i.e. phone numbers dialed and similar
* actions. Cumulative, starting at M-69.
*/
public static final String CONTEXTUAL_SEARCH_QUICK_ACTIONS_TAKEN_COUNT =
"contextual_search_quick_actions_taken_count";
/**
* The Quick Actions ignored count, i.e. phone numbers available but not dialed.
* Cumulative, starting at M-69.
*/
public static final String CONTEXTUAL_SEARCH_QUICK_ACTIONS_IGNORED_COUNT =
"contextual_search_quick_actions_ignored_count";
private static final String PROMOS_SKIPPED_ON_FIRST_START = "promos_skipped_on_first_start";
private static final String SIGNIN_PROMO_LAST_SHOWN_MAJOR_VERSION =
......@@ -29,15 +90,10 @@ public class ChromePreferenceManager {
"signin_promo_last_shown_account_names";
private static final String ALLOW_LOW_END_DEVICE_UI = "allow_low_end_device_ui";
private static final String PREF_WEBSITE_SETTINGS_FILTER = "website_settings_filter";
private static final String CONTEXTUAL_SEARCH_PROMO_OPEN_COUNT =
"contextual_search_promo_open_count";
private static final String CONTEXTUAL_SEARCH_TAP_TRIGGERED_PROMO_COUNT =
"contextual_search_tap_triggered_promo_count";
private static final String CONTEXTUAL_SEARCH_TAP_COUNT = "contextual_search_tap_count";
private static final String CONTEXTUAL_SEARCH_LAST_ANIMATION_TIME =
"contextual_search_last_animation_time";
private static final String CONTEXTUAL_SEARCH_TAP_QUICK_ANSWER_COUNT =
"contextual_search_tap_quick_answer_count";
private static final String CONTEXTUAL_SEARCH_CURRENT_WEEK_NUMBER =
"contextual_search_current_week_number";
private static final String CHROME_HOME_ENABLED_KEY = "chrome_home_enabled";
......@@ -226,21 +282,6 @@ public class ChromePreferenceManager {
editor.putStringSet(SIGNIN_PROMO_LAST_SHOWN_ACCOUNT_NAMES, accountNames).apply();
}
/**
* @return Number of times the panel was opened with the promo visible.
*/
public int getContextualSearchPromoOpenCount() {
return mSharedPreferences.getInt(CONTEXTUAL_SEARCH_PROMO_OPEN_COUNT, 0);
}
/**
* Sets the number of times the panel was opened with the promo visible.
* @param count Number of times the panel was opened with a promo visible.
*/
public void setContextualSearchPromoOpenCount(int count) {
writeInt(CONTEXTUAL_SEARCH_PROMO_OPEN_COUNT, count);
}
/**
* @return The last time the search provider icon was animated on tap.
*/
......@@ -276,41 +317,6 @@ public class ChromePreferenceManager {
writeInt(CONTEXTUAL_SEARCH_TAP_TRIGGERED_PROMO_COUNT, count);
}
/**
* @return Number of tap gestures that have been received since the last time the panel was
* opened.
*/
public int getContextualSearchTapCount() {
return mSharedPreferences.getInt(CONTEXTUAL_SEARCH_TAP_COUNT, 0);
}
/**
* Sets the number of tap gestures that have been received since the last time the panel was
* opened.
* @param count Number of taps that have been received since the last time the panel was opened.
*/
public void setContextualSearchTapCount(int count) {
writeInt(CONTEXTUAL_SEARCH_TAP_COUNT, count);
}
/**
* @return Number of Tap triggered Quick Answers (that "do answer") that have been shown since
* the last time the panel was opened.
*/
public int getContextualSearchTapQuickAnswerCount() {
return mSharedPreferences.getInt(CONTEXTUAL_SEARCH_TAP_QUICK_ANSWER_COUNT, 0);
}
/**
* Sets the number of tap triggered Quick Answers (that "do answer") that have been shown since
* the last time the panel was opened.
* @param count Number of Tap triggered Quick Answers (that "do answer") that have been shown
* since the last time the panel was opened.
*/
public void setContextualSearchTapQuickAnswerCount(int count) {
writeInt(CONTEXTUAL_SEARCH_TAP_QUICK_ANSWER_COUNT, count);
}
/**
* @return The current week number, persisted for weekly CTR recording.
*/
......@@ -481,7 +487,7 @@ public class ChromePreferenceManager {
writeBoolean(COMMAND_LINE_ON_NON_ROOTED_ENABLED_KEY, isEnabled);
}
/** Retunr whether command line on non-rooted devices is enabled. */
/** Returns whether command line on non-rooted devices is enabled. */
public boolean getCommandLineOnNonRootedEnabled() {
return mSharedPreferences.getBoolean(COMMAND_LINE_ON_NON_ROOTED_ENABLED_KEY, false);
}
......@@ -575,7 +581,7 @@ public class ChromePreferenceManager {
}
/**
* Reads the given int value from the named shared preference.
* Reads the given int value from the named shared preference, defaulting to 0 if not found.
* @param key The name of the preference to return.
* @return The value of the preference.
*/
......@@ -583,6 +589,18 @@ public class ChromePreferenceManager {
return mSharedPreferences.getInt(key, 0);
}
/**
* Increments the integer value specified by the given key. If no initial value is present then
* an initial value of 0 is assumed and incremented, so a new value of 1 is set.
* @param key The key specifying which integer value to increment.
* @return The newly incremented value.
*/
public int incrementInt(String key) {
int value = mSharedPreferences.getInt(key, 0);
writeInt(key, ++value);
return value;
}
/**
* Writes the given long to the named shared preference.
*
......@@ -606,18 +624,6 @@ public class ChromePreferenceManager {
return mSharedPreferences.getLong(key, defaultValue);
}
/**
* Writes the given String to the named shared preference.
*
* @param key The name of the preference to modify.
* @param value The new value for the preference.
*/
private void writeString(String key, String value) {
SharedPreferences.Editor ed = mSharedPreferences.edit();
ed.putString(key, value);
ed.apply();
}
/**
* Writes the given boolean to the named shared preference.
*
......
......@@ -305,6 +305,7 @@ chrome_java_sources = [
"java/src/org/chromium/chrome/browser/contextualsearch/ContextualSearchUma.java",
"java/src/org/chromium/chrome/browser/contextualsearch/CtrSuppression.java",
"java/src/org/chromium/chrome/browser/contextualsearch/DisableablePromoTapCounter.java",
"java/src/org/chromium/chrome/browser/contextualsearch/EngagementSuppression.java",
"java/src/org/chromium/chrome/browser/contextualsearch/NearTopTapSuppression.java",
"java/src/org/chromium/chrome/browser/contextualsearch/QuickAnswersHeuristic.java",
"java/src/org/chromium/chrome/browser/contextualsearch/RecentScrollTapSuppression.java",
......
......@@ -36,6 +36,8 @@ const base::flat_set<std::string>* GetContextualSearchFeatureWhitelist() {
static auto* kContextualSearchFeatureWhitelist =
new base::flat_set<std::string>({"DidOptIn",
"DurationAfterScrollMs",
"EntityImpressionsCount",
"EntityOpensCount",
"FontSize",
"IsEntity",
"IsEntityEligible",
......@@ -45,6 +47,7 @@ const base::flat_set<std::string>* GetContextualSearchFeatureWhitelist() {
"IsSecondTapOverride",
"IsShortWord",
"IsWordEdge",
"OpenCount",
"OutcomeRankerDidPredict",
"OutcomeRankerPrediction",
"OutcomeWasCardsDataShown",
......@@ -56,7 +59,12 @@ const base::flat_set<std::string>* GetContextualSearchFeatureWhitelist() {
"Previous28DayImpressionsCount",
"PreviousWeekCtrPercent",
"PreviousWeekImpressionsCount",
"QuickActionImpressionsCount",
"QuickActionsIgnored",
"QuickActionsTaken",
"QuickAnswerCount",
"ScreenTopDps",
"TapCount",
"TapDurationMs",
"WasScreenBottom"});
return kContextualSearchFeatureWhitelist;
......
......@@ -584,6 +584,20 @@ be describing additional metrics about the same event.
not recorded if there was no subsequent scroll.
</summary>
</metric>
<metric name="EntityImpressionsCount">
<summary>
Emits an integer in the range of 0 - N that represents the number of
impressions of an Entity that were shown in the Bar, aggregated in Android
device storage for this user, starting in M-69.
</summary>
</metric>
<metric name="EntityOpensCount">
<summary>
Emits an integer in the range of 0 - N that represents the number of times
an Entity was shown in the Bar and the panel was opened, aggregated in
Android device storage for this user, starting in M-69.
</summary>
</metric>
<metric name="FontSize">
<summary>
Emits a value from 0-10 representing the effective font size on the
......@@ -642,6 +656,13 @@ be describing additional metrics about the same event.
word, rather than in the middle 50% of the word.
</summary>
</metric>
<metric name="OpenCount">
<summary>
Emits an integer in the range of 0 - N that represents the total number of
times the user opened the panel, aggregated in Android device storage for
this user since M-69.
</summary>
</metric>
<metric name="OutcomeRankerDidPredict">
<summary>
Emits a 1 or 0 to indicate whether Ranker was able to make a prediction.
......@@ -687,26 +708,61 @@ be describing additional metrics about the same event.
</metric>
<metric name="Previous28DayCtrPercent">
<summary>
The CTR of the overlay panel for this user, aggregated over a previous 28
day period, expressed as an integer between 0-99.
The CTR of the overlay panel for this user, aggregated in Android device
storage over a previous 28 day period, expressed as an integer between
0-99, since M-60.
</summary>
</metric>
<metric name="Previous28DayImpressionsCount">
<summary>
The count of views of the overlay panel for this user, aggregated over a
previous 28 day period.
The count of views of the overlay panel for this user, aggregated in
Android device storage over a previous 28 day period, since M-60.
</summary>
</metric>
<metric name="PreviousWeekCtrPercent">
<summary>
The CTR of the overlay panel for this user, aggregated over the previous
week, expressed as an integer between 0-99.
The CTR of the overlay panel for this user, aggregated in Android device
storage over the previous week, expressed as an integer between 0-99,
since M-60.
</summary>
</metric>
<metric name="PreviousWeekImpressionsCount">
<summary>
The count of views of the overlay panel for this user, aggregated over the
previous week.
The count of views of the overlay panel for this user, aggregated in
Android device storage over the previous week, since M-60.
</summary>
</metric>
<metric name="QuickActionImpressionsCount">
<summary>
Emits an integer in the range of 0 - N that represents the total number of
times the user saw a quick action in the caption of the Bar, e.g. a phone
number to dial. Aggregated in Android device storage since M-69 for this
user.
</summary>
</metric>
<metric name="QuickActionsIgnored">
<summary>
Emits an integer in the range of 0 - N that represents the total number of
times the user ignored a quick action but opened the Bar instead, e.g. a
phone number was available but not dialed. Aggregated in Android device
storage starting at M-69.
</summary>
</metric>
<metric name="QuickActionsTaken">
<summary>
Emits an integer in the range of 0 - N that represents the total number of
times the user activated a quick action by tapping on a quick action shown
in the Bar, e.g. dialed a phone number. Aggregated in Android device
storage since M-69 for this user.
</summary>
</metric>
<metric name="QuickAnswerCount">
<summary>
Emits an integer in the range of 0 - N that represents the total number of
times the user saw a quick answer in the caption of the Bar. Typically
these quick answers represent an automatic translation of the selection.
Aggregated in Android device storage for all time for this user, since
M-57.
</summary>
</metric>
<metric name="ScreenTopDps">
......@@ -715,6 +771,13 @@ be describing additional metrics about the same event.
DPs.
</summary>
</metric>
<metric name="TapCount">
<summary>
Emits an integer in the range of 0 - N that represents the total number of
taps that triggered the Bar, aggregated in Android device storage for this
user, since M-43.
</summary>
</metric>
<metric name="TapDurationMs">
<summary>
The duration of the tap gesture expressed as an integer in milliseconds.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment