mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-01-15 06:20:41 +00:00
Bug 1404460: Add POCKET_ENABLED_TO_LOCALE to asUserPrefs telemetry. r=liuche
After speaking with liuche, we decided it'd be better to add a bit to determine this rather than combining it with the isPocketEnabled field (which would be loss of data) or cross-referencing the locale of the submitted event when checking the Pocket value during telemetry analysis (which is hard to get right and likely to get out of date). MozReview-Commit-ID: JKFrdEsEbyp --HG-- extra : rebase_source : bc20193ca29238cbde5361a840cbd367b492a346
This commit is contained in:
parent
8d7c0b37f0
commit
3e9f59b825
@ -5,6 +5,7 @@
|
||||
|
||||
package org.mozilla.gecko.activitystream;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.res.Resources;
|
||||
import android.support.annotation.NonNull;
|
||||
@ -13,6 +14,7 @@ import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
import org.mozilla.gecko.R;
|
||||
import org.mozilla.gecko.activitystream.homepanel.ActivityStreamConfiguration;
|
||||
import org.mozilla.gecko.activitystream.homepanel.ActivityStreamPanel;
|
||||
import org.mozilla.gecko.db.BrowserContract;
|
||||
import org.mozilla.gecko.activitystream.homepanel.model.TopSite;
|
||||
@ -69,6 +71,7 @@ public class ActivityStreamTelemetry {
|
||||
private final static int POCKET_ENABLED_VALUE = 4;
|
||||
private final static int VISITED_ENABLED_VALUE = 8;
|
||||
private final static int BOOKMARKED_ENABLED_VALUE = 16;
|
||||
private final static int POCKET_ENABLED_BY_LOCALE = 32;
|
||||
|
||||
/**
|
||||
* Calculates the bit-packed value of the user's Activity Stream preferences (e.g. enabled/disabled sections).
|
||||
@ -76,10 +79,14 @@ public class ActivityStreamTelemetry {
|
||||
* @param sharedPreferences SharedPreferences of this profile
|
||||
* @return bit-packed value of the user's AS preferences, which is the sum of the values of the enabled preferences.
|
||||
*/
|
||||
public static int getASUserPreferencesValue(final SharedPreferences sharedPreferences, final Resources res) {
|
||||
public static int getASUserPreferencesValue(final Context context, final SharedPreferences sharedPreferences) {
|
||||
final Resources res = context.getResources();
|
||||
int bitPackedPrefValue = 0;
|
||||
|
||||
// todo: Add bit for isPocketAllowedByLocale.
|
||||
if (ActivityStreamConfiguration.isPocketEnabledByLocale(context)) {
|
||||
bitPackedPrefValue += POCKET_ENABLED_BY_LOCALE;
|
||||
}
|
||||
|
||||
if (sharedPreferences.getBoolean(ActivityStreamPanel.PREF_POCKET_ENABLED, res.getBoolean(R.bool.pref_activitystream_pocket_enabled_default))) {
|
||||
bitPackedPrefValue += POCKET_ENABLED_VALUE;
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ public class ActivityStreamHomeFragment
|
||||
|| TextUtils.equals(s, ActivityStreamPanel.PREF_POCKET_ENABLED);
|
||||
|
||||
if (shouldReload) {
|
||||
activityStreamPanel.reload(getLoaderManager(), sharedPreferences, this.getResources());
|
||||
activityStreamPanel.reload(getLoaderManager(), getContext(), sharedPreferences);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -91,13 +91,13 @@ public class ActivityStreamPanel extends FrameLayout {
|
||||
FirefoxAccounts.firefoxAccountsExist(context)
|
||||
);
|
||||
|
||||
updateSharedPreferencesGlobalExtras(sharedPreferences, context.getResources());
|
||||
updateSharedPreferencesGlobalExtras(context, sharedPreferences);
|
||||
}
|
||||
|
||||
private void updateSharedPreferencesGlobalExtras(final SharedPreferences sharedPreferences, final Resources res) {
|
||||
private void updateSharedPreferencesGlobalExtras(final Context context, final SharedPreferences sharedPreferences) {
|
||||
ActivityStreamTelemetry.Extras.setGlobal(
|
||||
ActivityStreamTelemetry.Contract.AS_USER_PREFERENCES,
|
||||
ActivityStreamTelemetry.getASUserPreferencesValue(sharedPreferences, res)
|
||||
ActivityStreamTelemetry.getASUserPreferencesValue(context, sharedPreferences)
|
||||
);
|
||||
}
|
||||
|
||||
@ -124,10 +124,10 @@ public class ActivityStreamPanel extends FrameLayout {
|
||||
adapter.swapTopSitesCursor(null);
|
||||
}
|
||||
|
||||
public void reload(LoaderManager lm, SharedPreferences sharedPreferences, Resources res) {
|
||||
public void reload(final LoaderManager lm, final Context context, final SharedPreferences sharedPreferences) {
|
||||
adapter.clearAndInit();
|
||||
|
||||
updateSharedPreferencesGlobalExtras(sharedPreferences, res);
|
||||
updateSharedPreferencesGlobalExtras(context, sharedPreferences);
|
||||
|
||||
// Destroy loaders so they don't restart loading when returning.
|
||||
lm.destroyLoader(LOADER_ID_HIGHLIGHTS);
|
||||
|
@ -18,13 +18,22 @@ A concept of a "global" extra is meant to support recording certain context info
|
||||
``fx_account_present``, values: true, false
|
||||
Indicates if Firefox Account is currently enabled.
|
||||
|
||||
``as_user_preferences``, values: (bit-packed) value of preferences enabled
|
||||
``as_user_preferences``, values: (bit-packed) value of preferences, and related settings, enabled
|
||||
Each preference is assigned a value that is a unique power of 2, and value of as_user_preferences is the sum of all enabled preferences values.
|
||||
|
||||
The SharedPreferences preferences measured (with their value) are:
|
||||
pref_activitystream_pocket_enabled: 4
|
||||
pref_activitystream_visited_enabled: 8
|
||||
pref_activitystream_recentbookmarks_enabled: 16
|
||||
Some values are taken directly from Android SharedPreferences: these are prefixed with "(SharedPrefs)"". All preferences
|
||||
measured (with their values) are:
|
||||
|
||||
- (SharedPrefs) pref_activitystream_pocket_enabled: 4
|
||||
- (SharedPrefs) pref_activitystream_visited_enabled: 8
|
||||
- (SharedPrefs) pref_activitystream_recentbookmarks_enabled: 16
|
||||
- Is Pocket enabled in the user's current locale: 32
|
||||
|
||||
**Important note on Pocket:** A user's ability to override ``pref_activitystream_pocket_enabled`` will be influenced by whether
|
||||
or not Pocket is shown so when checking that preference, it is also recommended to check whether Pocket is enabled in the user's
|
||||
current locale. We initially limited the locales that get Pocket recommendations in `bug 1404460`_.
|
||||
|
||||
.. _bug 1404460: https://bugzilla.mozilla.org/show_bug.cgi?id=1404460
|
||||
|
||||
Extra information available for various event types
|
||||
===================================================
|
||||
|
Loading…
x
Reference in New Issue
Block a user