Let every user disable New Stats - #23176
Draft
nbradbury wants to merge 4 commits into
Draft
Conversation
The android_new_stats remote flag did two jobs: it routed users to New Stats, and it hid the "Disable new stats" overflow item whenever it was on. Users on the rollout had no way back. Add an explicit NEW_STATS_USER_OPTED_OUT preference that beats the flag, so routing becomes !optedOut && (flagEnabled || optedIn), and always show the overflow item. The rollout default is unchanged; only the escape hatch is new. Extract the routing decision into NewStatsRouting, which the My Site menu and the Stats widgets now share instead of duplicating the condition. Opting back in clears the opt-out, and the "try new stats" suggestion no longer nags users who deliberately left. Also reuse the experimental-features feedback dialog when New Stats is disabled. FeedbackDialog moves to ui/compose/components with a message parameter, and navigation is deferred until the dialog is answered since finishing the activity would otherwise tear it down.
optOut() reset NEW_STATS_INTRO_SHOWN, and NewStatsActivity.onCreate re-reads that flag on every recreation. Rotating after tapping "Disable new stats" left shouldShowIntro true, so the intro bottom sheet mounted on top of the feedback dialog and looked like the dialog had vanished. This was unreachable until navigation was deferred for the dialog, since the activity used to finish on the same frame. Reset the flag in optIn() instead. Same outcome for the user - the intro shows when they return to New Stats - but it is set from StatsFragment while New Stats is off screen, so it can no longer re-arm under a live NewStatsActivity.
Collaborator
Generated by 🚫 Danger |
Contributor
🤖 Build Failure AnalysisThis build has failures. Claude has analyzed them - check the build annotations for details. |
Three fixes from review: leaveNewStats() bailed out when there was no selected site, after optOut() had already persisted. The dialog closed, no navigation happened and finish() never ran, leaving the user on a screen nothing else routes them to. Only the old Stats launch needs a site, so guard just that and always finish. NEW_STATS_USER_OPTED_OUT was a DeletablePrefKey, which AppPrefs.reset() wipes on sign-out. Since it is the only thing that can override the android_new_stats rollout flag, signing out silently pushed the user back into New Stats. Move it to UndeletablePrefKey, alongside the other "user said no" flags. NewStatsRouting's docstring claimed to be the single source of truth, but shortcuts, deep links, notifications and the activity log all route straight to old Stats. Say so instead.
isNewStatsEnabled() only forwarded to NewStatsRouting. Both call sites now use the injected router directly, removing the indirection the router was added to get rid of.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
The
android_new_statsflag both routed users to New Stats and hid the "Disable new stats" menu item, so anyone on the rollout was stuck there. This adds an opt-out preference that beats the flag and always shows the menu item. The rollout default is unchanged.Disabling also adds a "Share feedback" dialog, re-used with the "Experimental block editor" toggle.
Testing instructions