Gate New Stats behind remote feature flag#22996
Conversation
Replace the local NEW_STATS experimental flag with a server-controlled remote feature flag so the New Stats rollout can be managed remotely. Because the remote flag is read-only, the manual opt-in/opt-out toggles are removed and the flag is now the single source of truth. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Generated by 🚫 Danger |
|
|
|
|
🤖 Build Failure AnalysisThis build has failures. Claude has analyzed them - check the build annotations for details. |
…rrors The previous commit removed the New Stats opt-in/opt-out strings from the default locale but left them in the translation files, causing 204 ExtraTranslation lint errors. Remove the orphaned translations. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## trunk #22996 +/- ##
==========================================
- Coverage 37.44% 37.44% -0.01%
==========================================
Files 2325 2326 +1
Lines 125520 125529 +9
Branches 17227 17229 +2
==========================================
+ Hits 47007 47008 +1
- Misses 74693 74701 +8
Partials 3820 3820 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Re-add the "Try new stats" toolbar menu and suggestion dialog on the classic Stats screen, and the "Disable new stats" overflow on the new Stats screen. The latter is shown only when the android_new_stats remote flag is off, so users on the rollout cannot switch back. Controls are plain navigation now; the remote flag remains the routing source of truth (no local ExperimentalFeatures flag is reintroduced). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…o companion The previous cleanup removed translations for eight New Stats string keys, but only two (experimental_new_stats, experimental_new_stats_description) are actually orphaned. The other six are still rendered by the kept controls (stats_try_new_stats, stats_switch_to_old_stats, and the four stats_new_stats_suggestion_* strings), so deleting their translations made non-English users see English text. Restore those six across all locales while keeping the two genuinely-orphaned experimental keys removed. Also move NEW_STATS_REMOTE_FIELD into a companion object const referenced from @feature, matching the convention used by the other FeatureConfig classes. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Show New Stats when the remote feature flag is on or the user has opted in locally. Opting in via the old Stats screen sets the preference, and switching back to old Stats clears it. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
From Claude:
|
Good catch! It seems like the PR description was outdated. I've updated it now. |


Description
The New Stats experience was previously gated by a local experimental
feature flag (
ExperimentalFeatures.Feature.NEW_STATS), toggled both from theexperimental-features settings screen and from in-app "Try new stats" /
"Disable new stats" controls.
This PR replaces that local experimental flag with a new remote feature
flag,
android_new_stats, so the rollout can be controlled server-side, andkeeps a local opt-in preference so users can move between the classic and new
experiences.
Routing (which Stats screen opens by default) is decided by either signal:
the New Stats screen opens when the remote flag
android_new_statsis on(the rollout default) or the user has opted in locally
(
NEW_STATS_USER_OPTED_IN). The remote flag is the rollout default, not thesole source of truth — a local opt-in is honored even when the remote flag
resolves to
false(offline / not yet fetched / not segmented in). The remoteflag defaults to
falsewhen its value is unavailable.The in-app switch controls persist the local opt-in preference:
NEW_STATS_USER_OPTED_IN = trueand opens the new experience. The opt-inpersists across launches, so Stats keeps opening the new screen on
subsequent launches.
NEW_STATS_USER_OPTED_IN = falseand returns to the classic experience.The "Disable new stats" action is gated on the remote flag: it is shown only
when
android_new_statsis off. When the remote flag is on, the newexperience is the rollout default, the action is hidden, and the user cannot
switch back (the local opt-in cannot be cleared from the UI while the rollout
flag is on).
Changes
NewStatsFeatureConfig(@Feature("android_new_stats", false))and the
NEW_STATSbuildConfigField. The@Featureannotation auto-registersthe default in the KSP-generated
RemoteFeatureConfigDefaults.NEW_STATS_USER_OPTED_IN(
AppPrefs/AppPrefsWrapper), a persisted boolean that defaults tofalse.ListItemActionHandlernow opens New Stats whennewStatsFeatureConfig.isEnabled() || appPrefsWrapper.getNewStatsUserOptedIn()(tests updated/added accordingly).
NEW_STATSentry fromExperimentalFeatures(it disappears from the experimental-features settingsscreen automatically).
(
res/menu/stats_toolbar_menu.xml) and the "new Stats experience" suggestiondialog in
StatsFragmentremain. Selecting them sets the opt-in preference totrueand launchesNewStatsActivity.overflow action in
NewStatsActivityis shown only whennewStatsFeatureConfig.isEnabled()isfalse. When the remote flag istruethe action is hidden, so users on the rollout cannot switch back. Selecting it
clears the opt-in preference (
false) and launches the classicStatsActivity.AppPrefs/AppPrefsWrapper), baseEnglish strings, and the
STATS_NEW_STATS_ENABLED/STATS_NEW_STATS_DISABLEDanalytics events used by these controls.
Testing instructions
1. The experimental flag is gone
2. a8c user → New Stats is presented and locked in
android_new_statsresolves to on).3. Random (non-a8c) user → ~90% see classic Stats, can opt in, and the opt-in persists
NEW_STATS_USER_OPTED_IN = true).NEW_STATS_USER_OPTED_IN = false).