Skip to content

CMM-2141: Fix subscriber email stats missing for recent posts - #23220

Merged
adalpari merged 6 commits into
trunkfrom
cmm-2141-jetpack-android-app-subscriber-email-stats-not-displayed-for
Aug 14, 2026
Merged

CMM-2141: Fix subscriber email stats missing for recent posts#23220
adalpari merged 6 commits into
trunkfrom
cmm-2141-jetpack-android-app-subscriber-email-stats-not-displayed-for

Conversation

@adalpari

@adalpari adalpari commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Description

Subscriber Stats → Subscribers → Emails did not list recently published/emailed
posts in the app, while the web (Calypso / WP Admin) showed them correctly. The issue was
persistent, survived force-stop / cache-clear / pull-to-refresh, and self-resolved after
~1 week — at which point the post reappeared.

Root cause: the app requested the stats/emails/summary endpoint with parameters that
don't match the web, so a freshly emailed post (few/zero opens) was never in the returned
result set:

  • Classic stats (fluxc) — sent sort_field=POST_ID (the enum's toString(), an
    invalid value the server ignores) and no period, so results came back sorted by the
    server default (opens). Fixed to send period=alltime and the valid sort_field=post_date.
  • New stats (android_new_stats) — hardcoded period=MONTH, sort_field=opens, so the
    Subscribers card/detail only showed the current month's top posts by opens. Fixed to
    period=ALL_TIME and sort_field=POST_DATE.

Both paths now match the web request (period=alltime, sort_field=post_date,
sort_order=desc), so the newest emailed posts appear first.

The new-stats Subscribers Emails card now also requests 10 entries (was 5), matching the
web, so more recent posts are visible without opening the detail list.

Testing instructions

Subscriber email stats show recent posts:

  1. Open the Jetpack app on a site with recently emailed posts.
  2. Go to Stats → Subscribers → Emails.
  • Verify the most recently emailed post appears in the card and matches the web ordering (newest first).
  • Verify the card shows up to 10 email entries.
  1. Tap "View all" to open the Emails detail list.
  • Verify the list is ordered by date (newest first) and includes the latest post.

The Subscribers > Emails panel requested emails sorted by an invalid/opens
field over a limited period, so recently emailed posts fell outside the
returned set and never appeared, while the web listed them by date. Align
both the classic and new-stats paths with the web: period=alltime and
sort_field=post_date.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@dangermattic

dangermattic commented Aug 14, 2026

Copy link
Copy Markdown
Collaborator
1 Warning
⚠️ PR is not assigned to a milestone.

Generated by 🚫 Danger

adalpari and others added 2 commits August 14, 2026 12:03
Match the web, which requests 10 email entries, so more recent posts are
visible in the Subscribers > Emails card without opening the detail list.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…sort

The server already returns emails sorted by post_date desc. Re-sorting by
post id client-side could reorder them away from true recency. Keep the
server order for POST_DATE; only OPENS needs a client-side sort.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@wpmobilebot

wpmobilebot commented Aug 14, 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
Versionpr23220-226b660
Build Number1498
Application IDorg.wordpress.android.prealpha
Commit226b660
Installation URL2it8ahqtq94a8
Automatticians: You can use our internal self-serve MC tool to give yourself access to those builds if needed.

@wpmobilebot

wpmobilebot commented Aug 14, 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
Versionpr23220-226b660
Build Number1498
Application IDcom.jetpack.android.prealpha
Commit226b660
Installation URL0p8a0f4okv518
Automatticians: You can use our internal self-serve MC tool to give yourself access to those builds if needed.

@codecov

codecov Bot commented Aug 14, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 50.00000% with 16 lines in your changes missing coverage. Please review.
✅ Project coverage is 37.93%. Comparing base (00a524f) to head (226b660).
⚠️ Report is 1 commits behind head on trunk.

Files with missing lines Patch % Lines
...ress/android/fluxc/persistence/InsightsSqlUtils.kt 43.75% 9 Missing ⚠️
...dpress/android/fluxc/model/stats/InsightsMapper.kt 0.00% 3 Missing ⚠️
...roid/ui/newstats/datasource/StatsDataSourceImpl.kt 0.00% 2 Missing ⚠️
...droid/fluxc/store/stats/subscribers/EmailsStore.kt 71.42% 0 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##            trunk   #23220      +/-   ##
==========================================
+ Coverage   37.91%   37.93%   +0.02%     
==========================================
  Files        2347     2347              
  Lines      127810   127829      +19     
  Branches    17781    17781              
==========================================
+ Hits        48454    48494      +40     
+ Misses      75389    75367      -22     
- Partials     3967     3968       +1     

☔ 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 block (post_date) and view-all (opens) email lists share one cache
slot, so one response overwrote the other. Include the sort field in the
cache key so each ordering is cached independently.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@adalpari
adalpari marked this pull request as ready for review August 14, 2026 10:46
@adalpari
adalpari requested a review from nbradbury August 14, 2026 10:46
@nbradbury

Copy link
Copy Markdown
Contributor

@adalpari This looks good and I verified email stats match the web, but Claude found a few issues. The first issue is flagged as a "blocker" but I'm not sure about the others.

review-pr23220-cmm2141-emails-stats-2026-08-14.pdf

@adalpari

Copy link
Copy Markdown
Contributor Author

@adalpari This looks good and I verified email stats match the web, but Claude found a few issues. The first issue is flagged as a "blocker" but I'm not sure about the others.

review-pr23220-cmm2141-emails-stats-2026-08-14.pdf

Not a real blocker since it's talking about old stats, which is not the target of the PR.
However, it's interesting that a user reported the error while migrating to the new stats, but it was not reported in the old ones 🤔

Anyway, since it seems that the error was there before, I'm also fixing it.

The classic "View all" list still sorted by opens under the "Latest
emails" header, so recently emailed posts stayed missing there. Sort it
by post date like the block and the web, so both classic paths are
consistent.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@adalpari

Copy link
Copy Markdown
Contributor Author

@nbradbury I also fixed the old stats screen here

@nbradbury nbradbury left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@adalpari
adalpari enabled auto-merge (squash) August 14, 2026 13:54
@adalpari
adalpari merged commit f36006f into trunk Aug 14, 2026
21 of 23 checks passed
@adalpari
adalpari deleted the cmm-2141-jetpack-android-app-subscriber-email-stats-not-displayed-for branch August 14, 2026 14:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants