Repository navigation
Premium Analytics: Add promo cards to the Stats options menu and Settings - #55372
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 3 files.
8 files are newly checked for coverage. Only the first 5 are listed here.
|
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment was marked as resolved.
This comment was marked as resolved.
Review cycle summaryRound reviewer: Codex ( Round 1, Codex: 2 findings, both fixed
Round 2, Codex: no findings
Final round, Claude: 7 findings, all fixed
Two existing refusal tests turned out to be passing on the wrong rule once the title check landed, since their fixtures registered a settings promo with no title. They carry one now, so each fails on the rule it names. CIAll 83 checks pass, including both Phan runs, which failed at the start of the cycle on two errors in this branch and were fixed in ThreadsTwo comments minimized as resolved: the final review and its request. No inline threads were opened, and no human reviewer comments are outstanding. Status: clean. |
There was a problem hiding this comment.
Thanks @adamwoodnz, this is really well put together, and the docs are great. Tested on a local Docker site: the options menu item, the Settings card in both the plain and module versions, dismissing and reloading, and turning jetpack_show_promotions off all worked as described. The early read cache and the final dismissal cases I only read in code.
I left a few inline comments. The three I think we should fix are the menu promo without a URL hiding every other menu promo, the public cache in Promo_Registry, and the view event firing for the Settings card before anyone scrolls to it. The rest are smaller and fine as follow ups. Escaping looked good to me, the copy renders as text and every CTA goes through safeHttpUrl.
My bigger question is whether this should be JITM instead of a new framework. STATS-657 rules out /notices, but I couldn't find JITM discussed, and it already covers most of what the registry does here. The copy and targeting live on WordPress.com, so a new promo or a rule change doesn't need a plugin release. It can target by role, it has snooze then final built in (the jetpack_manage_ad JITM on My Jetpack uses expires of 42 days with max_dismissal of 2, which is the same shape as snooze_days here), and it already works on Simple. A Parse.ly rule could also lean on the traffic data WordPress.com already has, rather than working it out locally.
For reference, this is that JITM on My Jetpack, rendered through JitmSlot:
What JITM is missing is mostly support for the new SPA pages, which feels like a good opportunity, as every page moving to that setup (Forms, Newsletter, Social, Backup, My Jetpack) would benefit, not just Stats:
JitmSlottaking its own message path, so a page can have more than one slot (Settings footer, options menu, section footer). Today there's one#jp-admin-noticesper page and a new card replaces the last one.- Route aware message paths for boot pages. My Jetpack already gets this through a special case, we could generalise it from the
pparam. - Rendering in React with named templates the page registers (a card, a menu item), instead of the single vanilla
defaulttemplate.PromoCard,PromoCtaand the error boundary from this PR would fit nicely there, and sticking to named templates means WordPress.com can't point a page at an arbitrary script module. - Opt in per user dismissal using the
core/preferenceslogic from this PR, keeping site wide as the default for existing JITMs. - Allowing JITMs on the Stats page again,
stats-adminturns them off at the moment.
Not from this PR, but FYI: JITM dismissal is site wide and the dismiss endpoint only checks read, so any logged in user can hide a JITM for the admins too. Worth fixing if we go this way.
I'd rather we extend JITM than ship a second system that does the same thing, so I'd hold off on locking in PROMO_API_VERSION 1.0.0 until we've talked it through. Happy to be convinced otherwise though, let me know what you think.
Co-reviewed and tested with Claude and Codex.
|
|
||
| $promo = new Promo( $slug, $args ); | ||
|
|
||
| if ( ! in_array( $promo->placement, self::PLACEMENTS, true ) ) { |
There was a problem hiding this comment.
Maybe we can clean these checks up a bit, most of them branch on the placement. A small per placement rules array (required fields, whether it can be dismissed or take a render module) that we loop through would make the section placement in #55375 one more row. It's also a good spot to trim() the required fields, at the moment a single space passes the title and cta_label checks.
There was a problem hiding this comment.
Done in 0bca812: one table of what each placement requires and refuses, so the section placement in #55375 is an entry rather than four more branches. Copy is trimmed before the required-field checks.
There was a problem hiding this comment.
Shrunk again in 47b02bc. With the refusal rules dropped the table holds only the copy each placement cannot render without, which is still the shape the section placement in #55375 plugs into.
| return $this->refuse( __( 'A promo card needs a title. The card is labelled by it.', 'jetpack-premium-analytics-pkg' ) ); | ||
| } | ||
|
|
||
| if ( 'options-menu' === $promo->placement && '' === $promo->cta_label ) { |
There was a problem hiding this comment.
If a menu promo is registered with a label but no URL, it still gets picked first and then the menu drops it, so another plugin's valid menu promo never shows. I could reproduce this in the Stats options menu. Should we refuse a non http(s) cta_url here, and maybe only pick from promos the menu can actually render?
There was a problem hiding this comment.
Good catch, this was a real bug. 2d60abb refuses a cta_label whose cta_url is not http(s) at registration, so the picker never sees one and it cannot take the single menu item away from a valid promo.
| * @param callable $compute Applies the gates to the registered promos. | ||
| * @return Promo[] The gated promos. | ||
| */ | ||
| public function remember_available( callable $compute ) { |
There was a problem hiding this comment.
As this is public and caches whatever the first caller computes, a get_available_promos() call before init caches an empty list for the rest of the request, which the docs say shouldn't latch. It also lets any caller hand in its own list and skip the flag and jetpack_show_promotions. Maybe we keep the memo private in the registry and only cache once it's hydrated? compute_available_promos() and get_registered() also don't have a caller outside the package yet.
There was a problem hiding this comment.
2d60abb gates the memo on hydration: it computes without storing until the registry has hydrated, so a pre-init read cannot become the answer for the request. The rest is answered by dropping the public surface in 554f672, which removes PROMO_API_VERSION, the docs, the SDK types and the fixtures, and marks register_promo() internal.
There was a problem hiding this comment.
Superseded in 47b02bc. With no registration action there is no hydration, so the pre-init latch cannot happen: the memo is a plain per-request cache that only get_available_promos() fills.
| } | ||
|
|
||
| // Latching this early would drop every registrant hooked later, so the read skips the action. | ||
| if ( ! did_action( 'init' ) ) { |
There was a problem hiding this comment.
A small nitpick, Announcement_Registry also skips a read while init is still running ( here ). I assume we want the same, so a read during init doesn't fire the action before later init callbacks have hooked in?
There was a problem hiding this comment.
Matched to Announcement_Registry in 0bca812.
| const { isDismissed, willBeFinal, dismiss } = usePromoDismissal( promo ); | ||
| const trackEvent = useTrackEvent(); | ||
|
|
||
| useEffect( () => { |
There was a problem hiding this comment.
On Settings the card is the last thing on the page, so the view event fires on load even if I never scroll down to it ( on my screen it was well below the fold ). Should we record the view on first intersection instead? Meaning the click through rate registrants look at is based on real impressions.
There was a problem hiding this comment.
2d60abb records the view on the first IntersectionObserver intersection instead.
| const fallback = <DataOnlyContent promo={ promo } trackClick={ trackClick } />; | ||
|
|
||
| return ( | ||
| <aside className={ styles.card } aria-label={ promo.title } data-testid="promo-card"> |
There was a problem hiding this comment.
Every other card on the Settings page is a Card.Root with a Card.Title, so this one ends up with tighter padding and a smaller heading next to them. Could we build the frame from Card.Root instead of the custom styles, keeping the aside if we can?
There was a problem hiding this comment.
d29c9b3 builds the frame from Card.Root with a Card.Title, which now owns the title and labels the region through aria-labelledby as the consent card does, so a render module draws the content region below it rather than its own heading. The aside could not stay: Card.Root types its ref as HTMLDivElement, so the landmark is role="complementary" on its own element.
| const dismiss = useCallback( () => { | ||
| closedPlacements.add( placement ); | ||
| listeners.forEach( listener => listener() ); | ||
| void set( DASHBOARD_PREFERENCES_SCOPE, PREFERENCES_KEY, { |
There was a problem hiding this comment.
If a promo with snooze_days: 0 is closed we track it as final, but only store count: 1, so if the registrant later bumps snooze_days for the same slug it comes back. Maybe store final: true with the record? Also nothing prunes old slugs from dismissedPromos, fine as a follow up.
There was a problem hiding this comment.
764501d records whether the close was final, so raising snooze_days later no longer brings back a promo somebody closed for good. Records written before this still read correctly through the count. Pruning old slugs is still open.
| onCustomize, | ||
| tabs, | ||
| isSiteConnected = true, | ||
| withPromo = true, |
There was a problem hiding this comment.
Should this default to false, with the pages that want a promo opting in? Given a new upsell page would show another plugin's promo next to its own offer unless someone remembers to pass false. Not a blocker.
There was a problem hiding this comment.
Left as it is for now. Eighteen call sites mount the menu bare and want the promo; three opt out, and those three are the screens already selling something. Flipping the default makes eighteen files carry a flag to get the intended behaviour, and a report page added later would silently lose the promo instead. Say the word if you would still rather have it opt-in.
|
|
||
| Write the action as the literal string, not as `Promo_Registry::REGISTER_ACTION`. Another plugin may put an older copy of this package ahead of yours in the autoloader, and reading a constant off a class that copy does not have is a fatal error at `add_action()` time, before any version check inside your callback can run. | ||
|
|
||
| The registry fires the action once, on its first read after `init`, whichever request makes that read: the dashboard page, or a REST request that runs later than `init`. A registrant hooked on `init` reaches one path and misses the other. A read before `init` is a `_doing_it_wrong()` and does not latch, so a registrant hooked later still runs on the first read after `init`. |
There was a problem hiding this comment.
I don't think the REST path works yet, promos.php is only loaded from load_dashboard_components(), so on a REST request get_available_promos() isn't defined and nothing fires the action. Should we drop that part for now?
There was a problem hiding this comment.
The doc is gone with the rest of the public surface in 554f672.
| 'cta_label' => __( 'Try Acme', 'acme' ), | ||
| 'cta_url' => 'https://example.com/acme', | ||
| 'dismissible' => false, | ||
| 'is_available' => true, |
There was a problem hiding this comment.
With is_available => true this shows to everyone who can open Stats, which can include editors and authors depending on the Stats roles setting, so they'd see an upgrade link they can't act on. Should the examples check manage_options? Or maybe the registry takes a capability like announcements does, defaulting to manage_options.
There was a problem hiding this comment.
Taken as you suggested in 0bca812: a registry capability option defaulting to manage_options. Worth more than the examples, since the gate was live in code: an editor or author the Stats roles setting lets into the dashboard was being offered a checkout they cannot complete.
|
Thanks for testing it @louwie17, and for the JITM write-up. I agree with the destination. Copy and targeting on WordPress.com, no plugin release to change a promo, role targeting and snooze already built: that is a better home for this than a registry in Premium Analytics, and your five changes are the right list. The problem is ordering. We are aiming to have these promos in place by November 30, and that list is multi-slot support, route aware message paths, React named templates, opt in per user dismissal, and re-enabling JITMs on the Stats page. I think we'll struggle to land all that in time. What makes me think the two are not in competition is that you have already picked out the pieces. So, on your actual ask: I will drop Two things I ran into that are worth knowing for the JITM work. The admin shell that #55075 teaches JITM about is still behind a feature flag that is off by default. And Premium Analytics renders no Your instinct on detection is right, and it goes further than traffic data. A Parse.ly account is keyed on the site's domain, so WordPress.com can answer "is this site already a customer" with no artifact on the site at all. #55232 can only see a customer who wired their account up through wp-parsely. STATS-671 tracks it. It needs Parse.ly, so it is not a November 30 item, and #55232 is correct without it: it never offers the prompt to a customer it can see. Last thing, and this is retrofox's point rather than yours: the PR straight after this one moves Parse.ly's rule, copy and signup URL into Does that work as a sequence? |
|
Thanks for the review. All of it is in, apart from one I pushed back on.
|
dognose24
left a comment
There was a problem hiding this comment.
Nice work, and the changes from the first round all hold up in the code. No blockers from me, just four small notes inline. I read the code and CI results; I didn't run it locally.
Two things on the description:
- The last Verified point still talks about
packages/sdk/src/conformance.ts, which went out with the SDK types in554f672. That paragraph and theCovered by non-unit testslabel can probably go. - The PR carries both
[Status] In Progressand[Status] Needs Review.
One for the follow-up, not this PR: when the Parse.ly package registers through this, it will want a function_exists() guard around register_promo(). promos.php only loads on admin screens, and another plugin can bring an older copy of this package that doesn't know a newer placement like section.
| * @return void | ||
| */ | ||
| function configure_promos() { | ||
| Feature_Flags::register( |
There was a problem hiding this comment.
Could the flag register in boot_shared_services() instead, next to Dashboard_Announcements::configure()? configure_promos() runs from load_dashboard_components(), which is admin screens only, so under WP-CLI the flag isn't registered: wp companion feature-flag list doesn't show it and enable warns that nothing registered it. The two filters can stay where they are.
There was a problem hiding this comment.
Done in 47b02bc, next to Parsely_Prompts::register_feature_flag() and for the same reason. promos.php is required there too, so register_promo() is defined on every request rather than only the ones that render the dashboard.
| * Promos: the registry helpers and the gates a registered promo passes before it shows. | ||
| * | ||
| * Internal to this package. The dashboard renders what is registered here; nothing outside the | ||
| * package registers through it, so there is no versioned contract to hold. |
There was a problem hiding this comment.
nit: A few comments still describe the earlier public version. This one says nothing outside the package registers, while the Promo class docblock, the require comment in class-analytics.php, the promos comment in jetpack-script-data.d.ts and the flag description all say other packages register here. Could we bring them in line?
The d.ts comment also says the field is absent until the registry hydrates, but it is absent whenever the request isn't rendering the dashboard.
There was a problem hiding this comment.
Rewritten across 47b02bc and d7fb750: the file header, the Promo class docblock, the require comment in class-analytics.php and the promos comment in the script-data types. They describe an internal registry now, which is what it is.
| href={ safeHref } | ||
| variant={ variant === 'primary' ? 'solid' : 'outline' } | ||
| openInNewTab | ||
| onClick={ () => trackClick( label ) } |
There was a problem hiding this comment.
nit: For the default card and the menu item, label is the translated cta_label, so one promo reports a different label per locale. slug still identifies it, so counts are fine, but grouping by label splits. Would a fixed value like cta work for the default CTA, leaving free labels to render modules?
There was a problem hiding this comment.
Taken in d7fb750: the CTA reports a fixed cta. With the render-module path gone there are no caller-supplied links left to tell apart, so the label is constant by construction rather than by convention.
The Stats roles setting can let an editor or an author open the dashboard, and an upgrade is not theirs to buy: they would be shown a prompt to a checkout they cannot complete. Promos now default to manage_options, and a registrant that wants a wider audience says which capability instead. Registration also trims the copy before the required-field checks, so a title or cta_label of nothing but spaces no longer passes as present and render as an empty card, and it refuses an empty capability rather than silently showing the promo to everyone. The per-placement checks move into one table of what each placement requires and refuses, so adding the section-footer placement is an entry rather than four more branches. A read while init is still running now answers without hydrating, matching Announcement_Registry: registrants hooked later on init itself would otherwise be dropped.
Every other card on Settings is a Card.Root with a Card.Title, and this one hand-rolled the same surface from its own padding, border and background. The two drifted apart the moment a token changed, and the card read as almost-but-not-quite a sibling of the ones above it. The frame now owns the title, so it labels the region through aria-labelledby the way the consent card does, and a render module draws the content region below it rather than repeating a heading. Closing the card also parked focus on <body>, because the close control lives inside the subtree that unmounts: the next Tab started again at the top of Settings. The surrounding region catches it instead, which is what WidgetState does for a widget whose children unmount.
A close under snooze_days 0 is final, but the record stored only count 1, and whether that counted as final was re-derived on every later read from the registrant's current snooze_days. Raising the value afterwards turned every one of those records back into an unexpired snooze, so a promo somebody had closed for good reappeared for them. The close now stores what it decided. Older records, written before this, still read correctly through the count.
The close control sat directly inside Card.Root, ahead of Card.Header, so the header was no longer the card first child and the design system gave it 24px 24px 0px instead of 24px all round. On screen the promo card title sat tight against its description while the Activation card above it had the usual gap, which is the sibling mismatch the Card.Root work was meant to remove. Moving the control inside the header restores the padding. It is still positioned against the card, which is what carries position: relative.
The control was pinned to the card corner with absolute positioning, which left it sitting above the title rather than beside it. The mock has the two vertically aligned, so the header now lays them out as a row with the title and the control at either end, which is how the consent card already places its badge. The stylesheet went with it: the positioning was all it held, and the relative positioning on the card existed only to anchor it.
Every other widgets-toolkit component story sits under Widgets Toolkit / Components; this one sat a level above it, away from the components it belongs beside in the sidebar. Its description also still told the reader a promo comes from another plugin and that the card keeps only its frame, neither of which is true now. Storybook renders that text, so it says what the card actually owns.
The fallback it rendered is the data-only card, so the story was pixel for pixel the DataOnly story beside it and showed a reader nothing. The behaviour is covered by promo-card.test.tsx, which drives the same throwing module through the error boundary. Both fallback tests were asserting on the title, which the card frame has drawn for itself since the move to Card.Root, so they passed whether or not the fallback ran. They assert the description now, which only the data-only content draws.
a925980 to
993a260
Compare
Nothing outside this package registers a promo, and nothing is scheduled to. The Traffic banner that would have been the second placement is on hold, and the Blaze promo this was modelled on is neither scheduled nor planned against this API. An extension point with one in-package caller holds a contract it cannot exercise, so this drops what only an outside registrant needed: the registration action and the hydration it required, the slug and type checks, and the render-module field. What stays is what the package's own promos need. A duplicate-slug guard, a known placement, the copy each placement cannot render without, and the http(s) check on a CTA URL, which stops one bad promo from taking the single item the options menu offers. The flag now registers at package boot instead of alongside the promos, so Feature_Flags::all() lists it on requests that never render the dashboard.
The render-module path let a promo replace the card's content region with a lazily imported script module. With the slot now internal there is nobody to ship such a module, so the Suspense boundary, the error boundary and the module resolver were three failure modes guarding a feature with no user. The card always draws the registered description and call to action. Click tracking sent the translated button label, so the same click grouped differently per locale. It sends a fixed value instead.
Phan reads the two identical adjacent calls the memo tests need as a copy-paste mistake. Keeping each result and comparing them answers the sniff and asserts the half the call count cannot: that the second caller is handed the first one's list rather than an equal one computed again.
|
The extension point is gone. Nothing outside the package registers a promo and nothing is scheduled to, so Out with it: the registration action and the hydration step it needed, The validation that remains is what the package's own promos need: a duplicate slug, an unknown placement, a placement's missing copy, and the http(s) check on a Also in this round: the flag registers in The body's testing snippet registers on |
It said registration refuses anything that is not a bool or a callable, so reaching the fallback meant a callable had stopped resolving. Registration stopped checking is_available when the validation went, so the fallback is now the ordinary path for a bad value and the comment pointed a reader at a guard that is not there.
Nothing hooks jetpack_premium_analytics_promos outside the tests written for it, and with the registry internal nothing outside this package can. It was the last of the extension-point surface, and the argument for dropping the registration action covers it unchanged: a hook with no caller is a contract we cannot exercise. Two of the three tests it cost existed only to prove the gated list survived a filter returning null or a non-Promo, which no longer has a way to happen. Promos now come straight from the gates, re-indexed and sorted.
Both Parse.ly promos route availability through offers_parsely_prompts(), which short-circuits on jetpack-stats-parsely-prompts ahead of every other condition. That flag already turns the whole mechanism off: with nothing available the slot publishes an empty list and the client mounts nothing. A second flag in front of it was a third control on one card, and two switches off by default is how a launch gets missed. The one thing it did that the surviving flag does not is return before the registry runs, which would mask a fatal in registration or in an is_available callback. Tests cover that instead.
dognose24
left a comment
There was a problem hiding this comment.
Looks good after the trim. Three small things, none blocking.
The comment above the promos.php require in class-analytics.php still says other packages register into the slot, and the configure_promos() docblock still says the flag registers earlier. Both are left over from before a88094314.
The options menu item reports promo.cta_label as the click label, while the card reports a fixed cta. The menu value is translated, so the Tracks property will change with the site language. A fixed value there would match the card.
Heads up that this and #55476 both touch the same lines in class-analytics.php, so whichever lands second needs a rebase.
The options menu sent the menu item's own text as the Tracks click label, and that text is translated, so the property would have grouped by site language and fragmented the event across locales. It reports 'cta' now, the same value the card sends. The placement already tells the two apart. Also two comments left over from the flag removal: the promos require no longer says other packages register into the slot, and configure_promos() no longer says a flag registers earlier.
|
Thanks, all three addressed in 0398540. The Tracks label was the one with a real consequence, and it was worse than cosmetic: Both leftover comments are gone: the On the rebase: agreed, and #55476 is the one that will move. It deletes the block in 971 PHP tests and the 23 options-menu JS tests pass; PHPCS clean on both changed PHP files. |
|
Thanks @adamwoodnz, appreciate the updates and iterations on this! |
Fixes STATS-657
A third placement, a card at the foot of a dashboard section, is held back for #55375 (STATS-668), which is stacked on this branch. It arrives as one more entry in the per-placement table of required copy.
Why
No user-visible change. The promo cards the "Upgrade to Parse.ly" prompts will render land here, and this PR registers no promo of its own, so the slot publishes an empty list and the client mounts nothing.
What they give a reader, once a promo is registered and available, is one consistent promotion: Premium Analytics owns the card frame, the close control, the dismissal memory and the view, click and dismiss events, so a prompt looks and behaves the same wherever it comes from, and closing one keeps it closed.
This started out as a versioned extension point other plugins would register through. Nothing outside the package registers a promo, and nothing is scheduled to: the Traffic banner is on hold, and the Blaze promo this was modelled on is neither scheduled nor planned against this API. So the registry is internal.
register_promo()is marked@internal, carries no version, and fires on no action. What remains is a seam a later placement or promo plugs into, not a contract this PR has to keep.Proposed changes
projects/packages/premium-analytics/src/. The package's own promos callregister_promo()directly; there is no registration action and no hydration step. The slot carries no feature flag of its own: every promo declares anis_availablerule, and the Parse.ly prompts stacked above this PR route theirs throughoffers_parsely_prompts(), which the mergedjetpack-stats-parsely-promptsflag already gates. A second flag in front of that would be a third control on one card.cta_labelwhosecta_urlis not http(s). That last one is a real bug the review caught: a menu promo the client cannot link still took the single item the menu offers, hiding a valid one.Card.Rootwith aCard.Title, matching the other cards on Settings. The title labels the region througharia-labelledby, and closing the card parks focus on the surrounding region rather than dropping it to<body>.jetpack_show_promotionsfilter that Gutenberg, plugin search, Search and the old Stats nudges all honour, the promo'scapability(manage_optionsby default, because the Stats roles setting can let an editor or an author open the dashboard and an upgrade is not theirs to buy), and the promo's ownis_availablerule. A promo that declares nois_availablerule is never available, which is deliberate: a promo is an interruption, so the caller has to say who it is for.core/preferencesscopejetpack-premium-analytics/dashboard: the first close snoozes forsnooze_days(90 by default), the second is final, and the record stores which of the two it was so raisingsnooze_dayslater cannot bring back a promo somebody closed for good. One promo shows per placement per page load, and closing one leaves that placement empty until the next load rather than swapping a card under the reader's cursor.Screenshots
Both placements on a Jurassic Ninja site running this branch's build, from the two promos the snippet below registers.
The Settings shot keeps the Activation card above it in frame, because matching those siblings is the point: same border, same radius, same padding, same heading size and the same gap under the title.
settingsplacementoptions-menuplacementRelated product discussion/links
Does this pull request change what data or activity we track or use?
Yes, three new Tracks events, each carrying the promo's
slugandplacement:jetpack_premium_analytics_promo_view— a card first comes into view, once per placement per page load; for an options-menu promo, each time the menu opens with the promo in it.jetpack_premium_analytics_promo_click— the reader follows the call to action. Carrieslabel, a fixed value rather than the translated button text, so the same click groups across locales.jetpack_premium_analytics_promo_dismiss— the reader closes a card. Carriesdismissal, eithersnoozeorfinal.No new user data is collected. The dismissal record (a count, a timestamp and whether the close was final, per promo slug) is a user preference stored through
core/preferences, local to this dashboard.Testing instructions
Nothing renders until a promo is registered, and this PR registers none of its own. Register two by hand from an mu-plugin or a code snippet. Any hook after
initand before the admin scripts are enqueued will do;admin_initis the simple one:pixel.wp.com. Nojetpack_premium_analytics_promo_viewrequest goes out until you scroll the card into view.dismissedPromosfrom thejetpack-premium-analytics/dashboardpreferences scope to get it back.acme/menuacta_urlofjavascript:alert(1). It never registers, the options menu has no promo item, and the Settings promo still shows. WithWP_DEBUGon, a_doing_it_wrong()notice says why.premium_analytics.promosis an empty array in the script data.Verified
pnpm run typecheckexits 0. ESLint clean; PHPCS, Prettier and stylelint ran on every commit through the pre-commit hook.jpis not installed on this machine and the host PHP is ahead of the repo matrix), so watch that check here.ge549571b), with the trunk copy of the plugin deactivated so the autoloader could not serve trunk's packages instead. The screenshots are that run. Also checked there: both promos reachpremium_analytics.promosin the script data when registered onadmin_init; closing the Settings card parks focus on the surrounding region rather than<body>, and the card is still gone after a reload while the menu promo is unaffected. Thejavascript:step is the one bullet not run end to end, because that host's plugin file editor silently discards saves; the seven data-provider cases inPromo_Registry_Testcover the same refusal. Capturing it caught two things the unit tests could not. The close control sat ahead ofCard.HeaderinsideCard.Root, which cost the header its first-child padding and left the title tight against the description beside a sibling card that was not (b6577fb). It was then still pinned to the card corner by absolute positioning rather than aligned with the title as the mock has it, so the header now lays the two out as a row and the stylesheet is gone (255266d). Title and control centre on the same pixel.🤖 Generated with Claude Code