Dbrant has uploaded a new change for review.
https://gerrit.wikimedia.org/r/216973
Change subject: Use random number instead of UUID for feature flagging.
......................................................................
Use random number instead of UUID for feature flagging.
Bug: T101833
Change-Id: Ifb4b09fa5787b6c552f36ebf9e8d22b667a8e6cd
---
M wikipedia/res/values/preference_keys.xml
M wikipedia/src/main/java/org/wikipedia/WikipediaApp.java
M wikipedia/src/main/java/org/wikipedia/settings/PrefKeys.java
3 files changed, 20 insertions(+), 8 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/apps/android/wikipedia
refs/changes/73/216973/1
diff --git a/wikipedia/res/values/preference_keys.xml
b/wikipedia/res/values/preference_keys.xml
index 2922cdf..68f609b 100644
--- a/wikipedia/res/values/preference_keys.xml
+++ b/wikipedia/res/values/preference_keys.xml
@@ -13,6 +13,7 @@
<string name="preference_key_feedback">send_feedback</string>
<string name="preference_key_logout">log_out</string>
<string
name="preference_reading_app_install_id">readingAppInstallID</string>
+ <string name="preference_app_install_id_int">appInstallIDInt</string>
<string name="preference_onboard">onboard</string>
<string name="preference_text_size_multiplier">textSizeMultiplier</string>
<string name="preference_color_theme">colorTheme</string>
diff --git a/wikipedia/src/main/java/org/wikipedia/WikipediaApp.java
b/wikipedia/src/main/java/org/wikipedia/WikipediaApp.java
index 8295801..d9c6cbe 100644
--- a/wikipedia/src/main/java/org/wikipedia/WikipediaApp.java
+++ b/wikipedia/src/main/java/org/wikipedia/WikipediaApp.java
@@ -48,6 +48,7 @@
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
+import java.util.Random;
import java.util.UUID;
@ReportsCrashes(
@@ -470,16 +471,20 @@
}
/**
- * Get an integer-valued install ID for this app (based on the last four
hex digits of the
- * actual install ID of the app). Note that this value will *not* be
unique for every install
- * of the app. Instead, this value should be used for feature-flagging and
A/B testing of
- * new features.
- * @return Integer-valued install ID for this app, which can range from 0
to 65535.
+ * Get an integer-valued install ID for this app. Note that this value is
*not* guaranteed
+ * to be unique for every install of the app. Instead, this value should
be used for
+ * feature-flagging and A/B testing of new features.
+ * @return Integer-valued install ID for this app.
*/
public int getAppInstallIDInt() {
- final int hexBase = 16;
- final int uuidSubstrLen = 4;
- return
Integer.parseInt(getAppInstallID().substring(getAppInstallID().length() -
uuidSubstrLen), hexBase);
+ int installID;
+ if (prefs.contains(PrefKeys.getAppInstallIdInt())) {
+ installID = prefs.getInt(PrefKeys.getAppInstallIdInt(), 0);
+ } else {
+ installID = new Random().nextInt();
+ prefs.edit().putInt(PrefKeys.getAppInstallIdInt(),
installID).apply();
+ }
+ return installID;
}
/**
diff --git a/wikipedia/src/main/java/org/wikipedia/settings/PrefKeys.java
b/wikipedia/src/main/java/org/wikipedia/settings/PrefKeys.java
index 9588e9d..4d8e3b7 100644
--- a/wikipedia/src/main/java/org/wikipedia/settings/PrefKeys.java
+++ b/wikipedia/src/main/java/org/wikipedia/settings/PrefKeys.java
@@ -15,6 +15,7 @@
private static String PREFERENCE_EVENTLOGGING_ENABLED;
private static String PREFERENCE_STYLES_LAST_UPDATED;
private static String PREFERENCE_APP_INSTALL_ID;
+ private static String PREFERENCE_APP_INSTALL_ID_INT;
private static String PREFERENCE_ONBOARD;
private static String PREFERENCE_TEXT_SIZE_MULTIPLIER;
private static String PREFERENCE_COLOR_THEME;
@@ -38,6 +39,7 @@
PREFERENCE_STYLES_LAST_UPDATED =
resources.getString(R.string.preference_key_styles_last_updated);
// The app install ID uses readingAppInstallID for backwards
compatibility with analytics
PREFERENCE_APP_INSTALL_ID =
resources.getString(R.string.preference_reading_app_install_id);
+ PREFERENCE_APP_INSTALL_ID_INT =
resources.getString(R.string.preference_app_install_id_int);
PREFERENCE_ONBOARD = resources.getString(R.string.preference_onboard);
PREFERENCE_TEXT_SIZE_MULTIPLIER =
resources.getString(R.string.preference_text_size_multiplier);
PREFERENCE_COLOR_THEME =
resources.getString(R.string.preference_color_theme);
@@ -88,6 +90,10 @@
return PREFERENCE_APP_INSTALL_ID;
}
+ public static String getAppInstallIdInt() {
+ return PREFERENCE_APP_INSTALL_ID_INT;
+ }
+
public static String getOnboard() {
return PREFERENCE_ONBOARD;
}
--
To view, visit https://gerrit.wikimedia.org/r/216973
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ifb4b09fa5787b6c552f36ebf9e8d22b667a8e6cd
Gerrit-PatchSet: 1
Gerrit-Project: apps/android/wikipedia
Gerrit-Branch: master
Gerrit-Owner: Dbrant <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits