Skip to content

Premium Analytics: Offer an Upgrade to Parse.ly card on the Stats Settings page - #55429

Merged
adamwoodnz merged 11 commits into
trunkfrom
stats-648-add-an-upgrade-to-parsely-card-to-the-bottom-of
Nov 26, 2026
Merged

adamwoodnz merged 11 commits into
trunkfrom
stats-648-add-an-upgrade-to-parsely-card-to-the-bottom-of

Conversation

@adamwoodnz

@adamwoodnz adamwoodnz commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Fixes STATS-648

#55372, which ships the promo slot and its settings placement, has merged. This now targets trunk and is no longer stacked.

Why

A site on a paid Stats plan with real traffic has outgrown what Jetpack Stats shows it, and nothing in the dashboard tells it there is a next step. This puts a persistent, unobtrusive Parse.ly card at the foot of the Stats Settings page: what Parse.ly answers that Stats does not, and one way to the self-serve signup with the site already filled in. It is the quietest of the three Upgrade to Parse.ly prompts, and the only one a reader reaches by going looking.

Nothing is visible yet. The jetpack-stats-parsely-prompts feature flag gates it and defaults off.

Proposed changes

  • A cta_variant argument on the promo slot, primary (filled) or secondary (outlined), defaulting to primary. Promo_Registry::register() refuses anything else, and the value reaches the button through the script data and PromoCard. Every promo registered today keeps its filled button.
  • src/parsely-signup-url.php, which builds the self-serve URL with utm_source=jetpack, the site's name as publisher_name and its host as site_domain, dropping whichever of those a site does not have.
  • src/parsely-promo.php, one promo on the settings placement: the issue's copy, an outlined call to action, no dismiss control, and offers_parsely_prompts() as its availability rule. It is the slot's first production registrant, so it registers by calling register_promo() directly from its configure function, which is the shape left after 55372 dropped the registration action.

The card is outlined because the Settings page already carries a filled Upgrade button for the Jetpack plan, and persistent because the issue asks for it and the mock shows no close control. That makes it and the STATS-647 menu item the two Parse.ly surfaces a reader cannot close.

Screenshots

The card at the foot of the Stats Settings page, with both flags on and the site meeting the gate's own tier and views conditions. The Activation card above it is the page's previous last card.

The foot of the Stats Settings page. Below the Activation card sits a card headed "Parse.ly", with the body "Grow with Parse.ly, the favorite analytics provider for professional brands and media companies. See which stories hold attention, where readers came from, and what they read next, in real time." and an outlined "Upgrade to Parse.ly" button carrying an opens-in-a-new-tab arrow. The card has no close control.

For the reviewer

Everything this depends on is now in trunk: the promo slot from 55372, and offers_parsely_prompts() from #55232. Nothing here waits on an unlanded PR.

There is no function_exists() guard around the gate, on purpose: it would be dead code now that the gate is in trunk.

Reaching trunk took real resolution over several rebases, not just textual merging, so that part is worth an eye: 55372 removed render_module, the registration action, Promo_Registry::get_registered(), the is_available callable check, the DataOnlyContent split and, last, the jetpack-stats-promos flag. All of them were things this branch had built on. The outlined CTA moved to the flattened PromoCard, the registration lost its action and its re-registration guard, and the two tests that covered the removed behaviour went with it.

The card is the first thing in the package to translate at boot, which the removed registration action had been hiding. It registers on init instead, so the copy is translated after the textdomain loads. That is still earlier than the script data filter that publishes the promos, so the card loses nothing by waiting.

The Parse.ly signup URL is taken from #55251, which is on hold. One difference: that version omits wp_specialchars_decode(). sanitize_option() stores blogname HTML-escaped, so a site called Smith & Co would reach Parse.ly as Smith%20%26amp%3B%20Co. Worth folding back if that card is revived.

Changelog

A package entry only, no plugin entries: the flag defaults off, so no plugin's users can see the card on release, and an entry in Jetpack's readme.txt would advertise something invisible. The PR that turns the flag on is where the plugins/jetpack and plugins/stats entries belong.

Related product discussion/links

Does this pull request change what data or activity we track or use?

No new events. The promo slot's existing jetpack_premium_analytics_promo_view and jetpack_premium_analytics_promo_click now fire for parsely/settings-upgrade. No dismiss event, since the card cannot be dismissed. The signup URL carries the site's public name and host as query parameters, both already public.

Testing instructions

The flag, plus two filters that let a local site meet the gate's own tier and views conditions rather than bypassing them:

add_filter( 'jetpack_feature_flag_enabled_jetpack-stats-parsely-prompts', '__return_true' );
add_filter( 'jetpack_premium_analytics_stats_plan_tier', fn () => 'commercial' );
add_filter( 'pre_transient_jetpack_premium_analytics_parsely_views', fn () => array( 'views' => 250000 ) );

Deliberately not add_filter( 'jetpack_premium_analytics_offers_parsely_prompts', '__return_true' ). That filter runs after every condition including the feature flag, so it would keep the card visible through the flag check below and make it untestable.

  • Open Stats v2 and go to Settings. The last card on the page is headed Parse.ly, with the body copy and an outlined Upgrade to Parse.ly button carrying one opens-in-a-new-tab arrow. There is no close control.
  • The button opens https://dash.parsely.com/self-serve in a new tab, with utm_source=jetpack, publisher_name set to the site's title and site_domain to its host.
  • Drop either of the last two filters and the card goes, on a site that does not meet that condition on its own.
  • Turn off jetpack-stats-parsely-prompts: the card goes.
  • Set the site's language to one with Jetpack translations and reload with WP_DEBUG on. The copy is translated, and there is no too-early translation notice.
  • If anything else registers a settings promo locally, turn it off. The slot shows one promo per placement, and a lower order wins.

Verified

  • On trunk: 984 PHP tests green, the 3 promo Jest suites / 37 tests green, PHPCS clean across the whole package.
  • The card was exercised in a browser on a local Jetpack site, on the Settings page itself, on the rebased code with the registration moved to init. Rather than forcing the gate, the site was made to satisfy its real conditions (a commercial tier and a views figure over the threshold), so offers_parsely_prompts came back true through parsely-prompts.php itself. It renders as the mock does, the link carries utm_source, publisher_name and site_domain for the real site, it opens in a new tab, and the card contains no button, so no dismiss control. That is the screenshot above.
  • The translation timing was checked on the same site, with WP_DEBUG on and a doing_it_wrong_trigger_error filter reporting what fires. Before the fix: a _load_textdomain_just_in_time notice, and the card already in the registry at plugins_loaded. After it: no notice, an empty registry at plugins_loaded, the card registered at init, and get_available_promos() still returning it.
  • Phan could not run locally (it crashes in its own parse of wordpress-stubs.php, on untouched packages too), so watch that check here.

🤖 Generated with Claude Code

@adamwoodnz adamwoodnz self-assigned this Nov 25, 2026
@github-actions

github-actions Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.

  • To test on WoA, go to the Plugins menu on a WoA dev site. Click on the "Upload" button and follow the upgrade flow to be able to upload, install, and activate the Jetpack Beta plugin. Once the plugin is active, go to Jetpack > Jetpack Beta, select your plugin (Jetpack), and enable the stats-648-add-an-upgrade-to-parsely-card-to-the-bottom-of branch.
  • To test on Simple, run the following command on your sandbox:
bin/jetpack-downloader test jetpack stats-648-add-an-upgrade-to-parsely-card-to-the-bottom-of

Interested in more tips and information?

  • In your local development environment, use the jetpack rsync command to sync your changes to a WoA dev blog.
  • Read more about our development workflow here: PCYsg-eg0-p2
  • Figure out when your changes will be shipped to customers here: PCYsg-eg5-p2

@github-actions

github-actions Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Thank you for your PR!

When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:

  • ✅ Include a description of your PR changes.
  • ✅ Add a "[Status]" label (In Progress, Needs Review, ...).
  • ✅ Add testing instructions.
  • ✅ Specify whether this PR includes any changes to data or privacy.
  • ✅ Add changelog entries to affected projects

This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖


Follow this PR Review Process:

  1. Ensure all required checks appearing at the bottom of this PR are passing.
  2. Make sure to test your changes on all platforms that it applies to. You're responsible for the quality of the code you ship.
  3. You can use GitHub's Reviewers functionality to request a review.
  4. When it's reviewed and merged, you will be pinged in Slack to deploy the changes to WordPress.com simple once the build is done.

If you have questions about anything, reach out in #jetpack-developers for guidance!

@github-actions github-actions Bot added the [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. label Nov 25, 2026
@jp-launch-control

jp-launch-control Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

Code Coverage Summary

Coverage changed in 4 files.

File Coverage Δ% Δ Uncovered
projects/packages/premium-analytics/packages/widgets-toolkit/src/components/promo-card/promo-cta.tsx 6/7 (85.71%) 2.38% 0 💚
projects/packages/premium-analytics/src/class-analytics.php 218/233 (93.56%) 0.06% 0 💚
projects/packages/premium-analytics/src/class-promo-registry.php 32/35 (91.43%) 0.52% 0 💚
projects/packages/premium-analytics/src/class-promo.php 43/45 (95.56%) 0.32% 0 💚

2 files are newly checked for coverage.

File Coverage
projects/packages/premium-analytics/src/parsely-promo.php 17/20 (85.00%) 💚
projects/packages/premium-analytics/src/parsely-signup-url.php 9/9 (100.00%) 💚

Full summary · PHP report · JS report

@adamwoodnz

This comment has been minimized.

@claude

This comment has been minimized.

@adamwoodnz

Copy link
Copy Markdown
Contributor Author

Addressing the final review.

1. Testing instructions contradicted the gate. Correct, and the useful catch here. offers_parsely_prompts() applies its filter after every condition including the flag, so with __return_true in place the two flag steps proved nothing. Rewritten: the instructions now qualify the site through the gate's own conditions instead, with jetpack_premium_analytics_stats_plan_tier and a primed pre_transient_jetpack_premium_analytics_parsely_views, and say explicitly why the blanket override is not used. The flag steps now really do hide the card. This is also how the screenshot above was produced, so the evidence and the instructions now match.

2. The ButtonLink mock. Keeping it, for the reason the review allows. @wordpress/ui carries the variant as a hashed CSS-module class and tests/style-stub.cjs stubs CSS modules to {}, so with the real component there is nothing stable to assert the outlined style against. The mock is what makes cta_variant observable at all. The accessible-label coverage it gives up belongs to ButtonLink's own tests rather than this card's.

3. offers_parsely_prompts() running twice per request. Agreed, and left alone. The views lookup is transient-cached, so the second call costs an option read, and the two callers are independent on purpose: the script-data flag and the promo's own rule.

4. parsely_signup_url() at registration time. Agreed, left alone. get_bloginfo() and home_url() on a dashboard render is not worth gating.

Changelog. Noted in the body: the plugin entries belong to the PR that turns the flags on, not this one.

The stale comment at class-promo.php:143 is a good catch and belongs to 55372, not here, since that PR removed the registry check the comment describes. Raising it there rather than editing another PR's file from this branch.

@adamwoodnz adamwoodnz added [Status] Needs Review This PR is ready for review. and removed [Status] In Progress labels Nov 25, 2026
@adamwoodnz
adamwoodnz marked this pull request as ready for review November 25, 2026 22:14
@adamwoodnz
adamwoodnz requested a review from a team as a code owner November 25, 2026 22:14
@adamwoodnz

Copy link
Copy Markdown
Contributor Author

Review cycle summary

Round reviewer: Codex, 2 rounds, then one final round with Claude. Codex reviews run locally and are not posted, so the findings are listed here.

Round 1

  • P2-1 Add plugin changelog entries for the settings card. Declined. Both flags default off, so no plugin's users can see the card on release, and the entry would reach readme.txt where they would read about something invisible. 55372 ships the promo card itself behind the same default-off flag and adds package-level entries only. The plugin entries belong to the PR that turns the flags on, which the description now says.
  • CI: PHP Code Sniffer failed on a stray blank line left by the rebase conflict resolution in Promo_Registry_Test.php. Fixed in 009b9d7. PHPCS then clean across the whole package, not only the changed files.

Round 2

  • P2-1 The same finding, reworded. Declined on the same grounds. No commits, so the round phase ended here rather than running a third pass over identical code.

Final review (Claude)

  • Found the one real defect of the cycle, in the testing instructions rather than the code: offers_parsely_prompts() applies its override filter after every condition including the feature flag, so the two flag steps could never have hidden the card while that override was on. The instructions now qualify the site through the gate's own tier and views conditions instead, which is also how the screenshot was produced.
  • Three further points, all answered and left as they are: the ButtonLink mock (the variant is a hashed CSS-module class, so there is nothing stable to assert against the real component), offers_parsely_prompts() running twice per request (transient-cached), and parsely_signup_url() being built at registration time.
  • It also spotted a stale comment at class-promo.php:143, which belongs to 55372 since that PR removed the check the comment describes. Raised there rather than edited from this branch.

Status: clean. No open addressable comments, no failing checks. Still pending are the code-coverage check, which has no parent-commit data because this PR is stacked, and the WordPress.com tests.

Unaddressed human comments: none.

Marked ready for review. Note for whoever picks it up: the base is 55372, not trunk, and this PR needs retargeting once that merges.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This gap looks tight compared to other cards like 'Your current plan'

Suggested change
<Stack direction="column" gap="md" align="flex-start">

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Applied in 40a4921. You are right about the comparison: plan-usage-card.tsx stacks its content on md and lg and never sm, so the promo card was the only one on the page reading tight.

Worth a second pair of eyes on one thing, since PromoCard is 55372's component rather than this PR's: this changes the spacing for every promo drawn as a card, not just the Parse.ly one. That is almost certainly what you want, given the complaint is about the shared card, but it does mean 55372 may conflict here if it touches the same line.

Screenshot in the description is updated.

@dognose24 dognose24 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.

One thing before this goes in. configure_parsely_promo() calls __() directly, and it runs from Analytics::init() on plugins_loaded. That is earlier than the textdomain can load, which is the same reason the plugin wrapper passes no menu_title and the sections register on their registry action. Since #55372 dropped the registration action, this card is the first thing translating that early. I expect the title, body and button to stay in English on a non-English site, with a too-early textdomain notice under WP_DEBUG. I read this from the code and did not run it.

Registering on init, or anywhere after it and before the script data filter, should be enough.

Small one, the description still says two feature flags gate the card.

@adamwoodnz
adamwoodnz added this pull request to stack #55478 November 26, 2026 02:41
@adamwoodnz
adamwoodnz force-pushed the stats-648-add-an-upgrade-to-parsely-card-to-the-bottom-of branch from 40a4921 to 11a8087 Compare November 26, 2026 02:45
@adamwoodnz

Copy link
Copy Markdown
Contributor Author

Both right. Fixed in 11a8087, on top of a rebase onto 55372's new head.

The early translation. Reproduced it rather than reading it, on the local site with WP_DEBUG and a doing_it_wrong_trigger_error filter printing what fires:

doing_it_wrong: _load_textdomain_just_in_time - Translation loading for the jetpack-premium-analytics domain was triggered too early...
at plugins_loaded: ["parsely/settings-upgrade"]

After the fix, on the same boot:

at plugins_loaded: []
at init: ["parsely/settings-upgrade"]

No notice, and get_available_promos() still returns the card. configure_parsely_promo() now hooks init and register_parsely_promo() does the work; a host that boots the package after init registers at once instead, so the card cannot silently vanish on a path we have not thought of. Two tests cover the two branches.

The description. It was wrong for a reason worth naming: 55372's new head drops the jetpack-stats-promos flag and the jetpack_premium_analytics_promos filter, so jetpack-stats-parsely-prompts is now the only flag gating the card. The body, the changelog note and the testing instructions are all updated, and the testing instructions gained a step for the translation.

One thing I could not check: the card on the Settings page in a browser after this change. The wp-admin session on the local site expired and signing back in is yours, not mine. The boot-path check above is the substitute, and the rendering is unchanged since the screenshot.

@adamwoodnz

Copy link
Copy Markdown
Contributor Author

Closing the one gap from my last comment: the browser check is done. On the rebased code with the registration on init, the card still renders at the foot of Settings, headed Parse.ly, outlined button, no close control, and the link carries utm_source, publisher_name and site_domain and opens in a new tab. The Verified section in the description now says so.

Base automatically changed from stats-657-add-a-promo-slot-extension-api-to-premium to trunk November 26, 2026 03:13
A promo card always drew a filled button. A card that sits beside another filled button needs the outlined one, so registration takes a cta_variant that the client passes to the call to action.
A promo needs a signup link that arrives with the publisher's name and domain filled in, so the visitor does not retype them.
…page

The Stats Settings page already carries a filled Upgrade button for the Jetpack plan, so the card's button is outlined. The card is not dismissible.
…guard

The registry refuses a duplicate slug anyway, so asserting the first entry stayed proved nothing. The test now asserts the second call raises no doing-it-wrong notice.
Make the Parse.ly promo file require the promo registry it uses, pin the quote decoding and whitespace handling of the signup URL in tests, and make the promo CTA variant lookup a compile error when a new variant is added. Drop a duplicate test, keep each explanation in one docblock, replace a mock that faked the UI library alt text with a marker for the prop the package owns, and put cta_variant in one field order everywhere.
offers_parsely_prompts() is the card's is_available rule, and until now
this file did not require the file that defines it. The card worked only
because class-analytics.php happens to load parsely-prompts.php a few
lines earlier, so reordering two unrelated requires there would have
broken it.

The require was left out on purpose while the gate was still in flight:
a require of a file that does not exist is a fatal on every dashboard
request, where a missing function is only a promo the registry declines.
That gate has now merged to trunk, so the file is always there and the
card can state its own dependency.
The promo slot dropped its registration action when it stopped being an
extension point other packages register into. The card was the only
caller, so it now calls register_promo() directly from the configure
function the dashboard already runs.

That also retires the guard against registering twice. It was there
because an action can fire more than once; a direct call from
configure_script_data() cannot, since both entry points that reach it
return early once Analytics is initialized. Its test goes with it: with
no second caller to write, the only way to make it fail was to call the
function twice by hand, which proved nothing about the code.
Left behind resolving the rebase conflict in this file.
…ent #4701705165)

The Settings page's own cards stack their content on md, and the Your
current plan card right above this one is the closest comparison. On sm
the promo card read as tighter than everything around it.
The package boots on plugins_loaded, so the card's title, body and button
were translated before the textdomain could load: English copy on a
non-English site, and a too-early notice under WP_DEBUG. This is the first
thing in the package to translate at boot. The sections avoid it by
registering on their registry action, and the plugin wrapper by passing no
menu_title.

The registration moves to init, which is still earlier than the script data
filter that publishes the promos, so the card loses nothing by waiting. A
host that boots the package later than init registers at once instead.
@adamwoodnz
adamwoodnz force-pushed the stats-648-add-an-upgrade-to-parsely-card-to-the-bottom-of branch from 11a8087 to 2bcfd0e Compare November 26, 2026 03:13

@louwie17 louwie17 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.

Thanks @adamwoodnz, this tested well and code looks good! On a local Docker site the card shows at the bottom of Settings with the outlined button, the signup link carries the site name and domain and opens in a new tab, and there's no close control. It goes away again with the flag off, on a free tier, or under the views threshold ( the views figure was forced, I didn't test with real 100k+ traffic ). No early translation notice either, and escaping and the capability check look good 👍

LGTM 🚀

Co-reviewed and tested with Claude and Codex.

@adamwoodnz
adamwoodnz merged commit d49b614 into trunk Nov 26, 2026
99 checks passed
@adamwoodnz
adamwoodnz deleted the stats-648-add-an-upgrade-to-parsely-card-to-the-bottom-of branch November 26, 2026 21:35
@github-actions github-actions Bot added [Status] UI Changes Add this to PRs that change the UI so documentation can be updated. and removed [Status] Needs Review This PR is ready for review. [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. [Status] In Progress labels Nov 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Package] Premium Analytics [Status] UI Changes Add this to PRs that change the UI so documentation can be updated. [Tests] Includes Tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants