Repository navigation
Premium Analytics: Offer an Upgrade to Parse.ly card on the Stats Settings page - #55429
adamwoodnz merged 11 commits into
Conversation
|
Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.
Interested in more tips and information?
|
|
Thank you for your PR! When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:
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:
If you have questions about anything, reach out in #jetpack-developers for guidance! |
Code Coverage SummaryCoverage changed in 4 files.
2 files are newly checked for coverage.
|
a5743e0 to
fbd78d2
Compare
fbd78d2 to
0a9c545
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
Addressing the final review. 1. Testing instructions contradicted the gate. Correct, and the useful catch here. 2. The 3. 4. Changelog. Noted in the body: the plugin entries belong to the PR that turns the flags on, not this one. The stale comment at |
Review cycle summaryRound 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
Round 2
Final review (Claude)
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 |
There was a problem hiding this comment.
This gap looks tight compared to other cards like 'Your current plan'
| <Stack direction="column" gap="md" align="flex-start"> |
There was a problem hiding this comment.
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
left a comment
There was a problem hiding this comment.
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.
40a4921 to
11a8087
Compare
|
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 After the fix, on the same boot: No notice, and The description. It was wrong for a reason worth naming: 55372's new head drops the 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. |
|
Closing the one gap from my last comment: the browser check is done. On the rebased code with the registration on |
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.
11a8087 to
2bcfd0e
Compare
louwie17
left a comment
There was a problem hiding this comment.
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.
Fixes STATS-648
#55372, which ships the promo slot and its
settingsplacement, has merged. This now targetstrunkand 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-promptsfeature flag gates it and defaults off.Proposed changes
cta_variantargument on the promo slot,primary(filled) orsecondary(outlined), defaulting toprimary.Promo_Registry::register()refuses anything else, and the value reaches the button through the script data andPromoCard. Every promo registered today keeps its filled button.src/parsely-signup-url.php, which builds the self-serve URL withutm_source=jetpack, the site's name aspublisher_nameand its host assite_domain, dropping whichever of those a site does not have.src/parsely-promo.php, one promo on thesettingsplacement: the issue's copy, an outlined call to action, no dismiss control, andoffers_parsely_prompts()as its availability rule. It is the slot's first production registrant, so it registers by callingregister_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.
For the reviewer
Everything this depends on is now in
trunk: the promo slot from 55372, andoffers_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 intrunk.Reaching
trunktook real resolution over several rebases, not just textual merging, so that part is worth an eye: 55372 removedrender_module, the registration action,Promo_Registry::get_registered(), theis_availablecallable check, theDataOnlyContentsplit and, last, thejetpack-stats-promosflag. All of them were things this branch had built on. The outlined CTA moved to the flattenedPromoCard, 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
initinstead, 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()storesblognameHTML-escaped, so a site calledSmith & Cowould reach Parse.ly asSmith%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.txtwould advertise something invisible. The PR that turns the flag on is where theplugins/jetpackandplugins/statsentries 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_viewandjetpack_premium_analytics_promo_clicknow fire forparsely/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:
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.https://dash.parsely.com/self-servein a new tab, withutm_source=jetpack,publisher_nameset to the site's title andsite_domainto its host.jetpack-stats-parsely-prompts: the card goes.WP_DEBUGon. The copy is translated, and there is no too-early translation notice.settingspromo locally, turn it off. The slot shows one promo per placement, and a lowerorderwins.Verified
trunk: 984 PHP tests green, the 3 promo Jest suites / 37 tests green, PHPCS clean across the whole package.init. Rather than forcing the gate, the site was made to satisfy its real conditions (acommercialtier and a views figure over the threshold), sooffers_parsely_promptscame back true throughparsely-prompts.phpitself. It renders as the mock does, the link carriesutm_source,publisher_nameandsite_domainfor the real site, it opens in a new tab, and the card contains no button, so no dismiss control. That is the screenshot above.WP_DEBUGon and adoing_it_wrong_trigger_errorfilter reporting what fires. Before the fix: a_load_textdomain_just_in_timenotice, and the card already in the registry atplugins_loaded. After it: no notice, an empty registry atplugins_loaded, the card registered atinit, andget_available_promos()still returning it.wordpress-stubs.php, on untouched packages too), so watch that check here.🤖 Generated with Claude Code