Route stats deep links to New Stats when enabled - #23183
Open
nbradbury wants to merge 8 commits into
Open
Conversation
The New Stats rollout gated the My Site menu, the post-login path, the Today's Stats card and the two widget intents, but not deep links. A user on the rollout tapping wordpress://stats or an emailed stats link landed in old Stats. The gate lives in ActivityNavigator rather than at the call sites, since it is already injected into both DeepLinkNavigator and WPMainActivity and already owns the TaskStackBuilder-over-WPMainActivity pattern. openStats covers the site-less links (which must keep relaunching WPMainActivity so back lands on My Site) and openStatsInNewStack the site-qualified ones. A null site falls through to the old path on purpose, which reports STATS_ACCESS_ERROR and toasts. New Stats could not open on a given tab, which /stats/insights/ and /stats/subscribers/ need, so StatsTab moves out of NewStatsActivity into its own file and NewStatsScreen takes an initialTab. NewStatsTarget maps the old-stats StatsTimeframe onto the closest tab and period; nothing maps to Last6Months. Shortcuts, notifications and the activity log still go to old Stats.
Routing the site-qualified stats deep links through ActivityNavigator.openStatsInNewStack left the three-argument viewStatsInNewStack with no callers - DeepLinkNavigator's OpenStatsForSite arm was the only one. The four- and five-argument overloads and the context-only variant are all still in use.
Collaborator
Generated by 🚫 Danger |
Contributor
|
|
Contributor
|
|
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## trunk #23183 +/- ##
=======================================
Coverage 37.90% 37.91%
=======================================
Files 2348 2350 +2
Lines 127693 127716 +23
Branches 17734 17739 +5
=======================================
+ Hits 48408 48421 +13
- Misses 75326 75335 +9
- Partials 3959 3960 +1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
New Stats had no launch-source intake and fired no open event, so every route into it - widgets, the My Site menu, the Today's Stats card and now deep links - was invisible in analytics. During the rollout that reads as stats traffic falling off rather than moving. NewStatsActivity now takes a launchedFrom extra and reports STATS_ACCESSED through the same trackStatsAccessed helper StatsViewModel uses, so the two screens stay comparable. Tracking is guarded on savedInstanceState so a rotation doesn't double-count; the activity is launchMode standard, so the widgets' CLEAR_TOP recreates it and is correctly counted as a new launch. launchedFrom is a required parameter rather than a defaulted one, since a default is how this came to be dropped in the first place. buildIntent now takes a localSiteId instead of a SiteModel, which lets the two widget paths stop hand-rolling their intents and pick up the source for free. Each call site reports what its old-stats twin already reported.
WidgetUtils passes the NewStatsActivity Intent to setPendingIntentTemplate, and the per-row fill-in that supplies LOCAL_SITE_ID is merged by system_server, which has no classloader for StatsTab or StatsLaunchedFrom. Intent.fillIn catches the unmarshalling failure and logs it rather than rethrowing, so the merge would be dropped silently and a widget row tap would open whichever site was previously selected - the multi-site bug the comment above getPendingSelfIntent already warns about. Both extras now travel as names, matching how StatsPeriod already crosses this boundary via toTypeString(). Lazy bundle unparcelling from API 33 likely hid this on newer devices; minSdk is 26.
nbradbury
marked this pull request as ready for review
August 7, 2026 18:17
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
Even when new stats are enabled, deep links continued to open old stats. This PR resolves the problem and updates related analytics tracking.
Testing instructions
Testing this PR may seem tedious, but you can point Claude at this PR and ask it to do the testing steps for you.
Custom scheme links
jetpack://stats→ New Stats, Traffic tab, persisted period/stats/day→ Traffic, Today/stats/month→ Traffic, Last 30 days/stats/insights→ Insights tab/stats/subscribers→ Subscribers tabWeb links
Replace
YOURSITE.combelow with a domain that actually exists in your account. App Links aren't verified on a debug build, so a baream startmay hand off to Chrome. Target the alias explicitly (com.jetpack.android.prealphaforjetpackDebug,org.wordpress.android.prealphaforwordpressDebug):Swap the last segment through each timeframe:
https://wordpress.com/stats/day/YOURSITE.com→ that site, Traffic, Todayhttps://wordpress.com/stats/week/YOURSITE.com→ Traffic, Last 7 dayshttps://wordpress.com/stats/month/YOURSITE.com→ Traffic, Last 30 dayshttps://wordpress.com/stats/year/YOURSITE.com→ Traffic, Last 12 monthshttps://wordpress.com/stats/insights/YOURSITE.com→ Insights tabhttps://wordpress.com/stats/subscribers/YOURSITE.com→ Subscribers tab