Skip to content

CMM-2201: Enable clicking referrers, link, tags, and categories from new stats - #23175

Draft
nbradbury wants to merge 6 commits into
trunkfrom
issue/CMM-2201-read-only-stats-referrers
Draft

CMM-2201: Enable clicking referrers, link, tags, and categories from new stats#23175
nbradbury wants to merge 6 commits into
trunkfrom
issue/CMM-2201-read-only-stats-referrers

Conversation

@nbradbury

@nbradbury nbradbury commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Description

Fixes CMM-2201 and CMM-2202

In the old stats, clicking a referrer, link, tag, or category would open its URL in the browser (Chrome Custom Tab). This PR adds that behavior to new stats.

Testing instructions

Referrers card:

  1. Open Stats → Traffic with new Stats enabled.
  2. Pick a period with several referrers (e.g. Last 30 days).
  3. Scroll to the Referrers card.
  • Verify a referrer row with no expand chevron shows an "open in new" icon.
  • Verify tapping that row opens the referrer's link in a Custom Tab.
  • Verify a group row such as Search Engines still expands instead of navigating.
  1. Expand a group row.
  • Verify child rows still open their links as before.

Clicks card:

  1. Tap Add Card and add Clicks.
  • Verify a click row with no expand chevron shows an "open in new" icon and opens its link in a Custom Tab.
  • If your site has a grouped click source, verify it expands and its child links open.

Tags and Categories card:

  1. Switch to the Insights tab (this card is not on Traffic) and scroll to Tags and Categories.
  • Verify a row holding a single tag or category shows an "open in new" icon.
  • Verify tapping that row opens the tag's archive page in a Custom Tab.
  1. Tap Show All on the card.
  • Verify the same behaviour on the detail screen, with position numbers intact.

Note: some sites don't serve /tag/... archives, so a tag link may land on the site's 404 page while category links resolve. The URL is passed through from the API unchanged, and old stats behaved the same way — it isn't a regression.

New stats dropped the referrer group's own URL when mapping the API
response, so a standalone referrer row had nothing to open and was
inert. Carry the URL through the data source, repository and UI state,
and make a row without children open it.

A row now either expands or opens a link, never both, matching old
stats: a group header only expands, a standalone referrer navigates.
@nbradbury nbradbury added the Stats label Aug 4, 2026
@dangermattic

dangermattic commented Aug 4, 2026

Copy link
Copy Markdown
Collaborator
1 Warning
⚠️ This PR is larger than 300 lines of changes. Please consider splitting it into smaller PRs for easier and faster reviews.
1 Message
📖 This PR is still a Draft: some checks will be skipped.

Generated by 🚫 Danger

@wpmobilebot

wpmobilebot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

App Icon📲 You can test the changes from this Pull Request in WordPress Android by scanning the QR code below to install the corresponding build.

App NameWordPress Android
Build TypeDebug
Versionpr23175-aa038f4
Build Number1498
Application IDorg.wordpress.android.prealpha
Commitaa038f4
Installation URL57nbibep2riqo
Automatticians: You can use our internal self-serve MC tool to give yourself access to those builds if needed.

@wpmobilebot

wpmobilebot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

App Icon📲 You can test the changes from this Pull Request in Jetpack Android by scanning the QR code below to install the corresponding build.

App NameJetpack Android
Build TypeDebug
Versionpr23175-aa038f4
Build Number1498
Application IDcom.jetpack.android.prealpha
Commitaa038f4
Installation URL240m9l16pai48
Automatticians: You can use our internal self-serve MC tool to give yourself access to those builds if needed.

@codecov

codecov Bot commented Aug 4, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 51.68539% with 43 lines in your changes missing coverage. Please review.
✅ Project coverage is 37.84%. Comparing base (6d9ff29) to head (aa038f4).
⚠️ Report is 2 commits behind head on trunk.

Files with missing lines Patch % Lines
...newstats/mostviewed/MostViewedCommonComposables.kt 0.00% 20 Missing ⚠️
...roid/ui/newstats/datasource/StatsDataSourceImpl.kt 0.00% 10 Missing ⚠️
.../wordpress/android/ui/newstats/NewStatsActivity.kt 0.00% 7 Missing ⚠️
...s/android/ui/newstats/mostviewed/MostViewedCard.kt 0.00% 4 Missing ⚠️
...ui/newstats/mostviewed/MostViewedDetailActivity.kt 0.00% 2 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##            trunk   #23175   +/-   ##
=======================================
  Coverage   37.84%   37.84%           
=======================================
  Files        2345     2345           
  Lines      127530   127579   +49     
  Branches    17716    17722    +6     
=======================================
+ Hits        48258    48285   +27     
- Misses      75313    75335   +22     
  Partials     3959     3959           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

The clicks response carries both a url and child links per entry, and
both were being discarded, leaving every clicks row inert. Carry them
through the same way referrers now do, so a click row without children
opens its link and a grouped one expands.

Also fixes BaseStatsCardViewModel dropping children on the way to the
card, which would have swallowed click groups, and collapses the two
duplicate ClickItemData.toDetailItem mappers into one.
@nbradbury nbradbury changed the title CMM-2201: Open referrer links from new stats CMM-2201: Open referrer and click links from new stats Aug 4, 2026
Drop a redundant detail-VM test (the card test already covers the same
mapper), reuse the existing clicks fixture helper instead of building
results inline, and cut KDoc that restated the signature.

Also removes a comment on MostViewedItemData that went stale when clicks
gained a url.
Tags and categories were read-only in new stats: the archive link was
discarded when mapping the API response, so the rows did nothing. Carry
it through and make a lone tag open its archive page, while a group of
several tags keeps expanding rather than navigating — matching old stats.
Children inside an expanded group each open their own link.

This is the first URL navigation on the Insights tab, so onStatsUrlClick
is now threaded into InsightsTabContent and TagsAndCategoriesDetailActivity
gains an ActivityNavigator.

The open-link icon moves out of the MostViewed namespace to
StatsOpenLinkIcon in StatsCardCommon, since two features now share it.
@nbradbury nbradbury changed the title CMM-2201: Open referrer and click links from new stats CMM-2201: Enable clicking referrers, link, tags, and categories from new stats Aug 4, 2026
@wpmobilebot

wpmobilebot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

🤖 Build Failure Analysis

This build has failures. Claude has analyzed them - check the build annotations for details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants