Repository navigation
Premium Analytics: Add a dismissible Upgrade to Parse.ly card to the Traffic tab - #55375
adamwoodnz wants to merge 19 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! Jetpack plugin: The Jetpack plugin has different release cadences depending on the platform:
If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack. Premium Analytics plugin: No scheduled milestone found for this plugin. If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack. Stats Data plugin: No scheduled milestone found for this plugin. If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack. |
Code Coverage SummaryCoverage changed in 9 files. Only the first 5 are listed here.
2 files are newly checked for coverage.
|
a925980 to
993a260
Compare
… card Record the dismissible Upgrade to Parse.ly card in the package and the three plugins that load it, and update the promo note in AGENTS.md for section-footer targets and render modules.
Eight call sites each kept their own hand-written copy of the twelve-field promo payload, and they had already drifted: the dashboard stage's copy was missing cta_variant, which a loose Record type hid. One factory in tests/js, beside the package's other shared mocks, leaves one place to add a field. The Parse.ly Traffic payload joins it, so the test and the story that need the registration's own copy read it from one place rather than two. Also restores window.JetpackScriptData after the stage's promo tests, which only got away with leaking it because that block runs last in the file.
The per-load closed latch was keyed by placement alone, so closing the Traffic card would have closed the footer of every other section for that load too. Inert while one section-footer promo is registered, wrong as soon as a second is, and free to fix now. Also puts the only bare English literal among the package's _doing_it_wrong() messages behind __(), trims a promo's target as the other string fields are already trimmed, so a padded one is not refused with a message about a pattern it looks like it matches, and brings the comment above the promo slot's boot line up to date with the footer placement.
A reader entering the Parse.ly card met the same sentence three times: the landmark's name, a visually hidden h3 the frame kept so the card stayed in the heading outline, and the module's own visible h4 carrying a second copy of the string. It was also the last user-visible string the branch left written out in both PHP and JS, with nothing to catch the two drifting apart. The frame now names the card from the registered title and renders a heading only when it draws the content itself. A module owns the heading of the region it draws, and reads the title off the promo rather than carrying one, so the string is registered in one place. The copy the frame falls back to carries a heading whenever a module was expected, which covers the instant before the module arrives and both ways it can fail to draw. The new test is the only one that mounts the module inside the real frame, with the payload the registration publishes, and it counts the headings: one, in every state. The PHP side pins the title in the registration test, which is now what guards it. The 30+ metrics placeholder is renamed to <strong>, which is what it renders as. A translator reading <em> would have expected italics.
The SDK's type declarations changed on this branch, and that project has its own changelog gate: without an entry of its own the pre-push hook and the linting CI job both refuse the branch. The entries said "Traffic section", which is our word for it. A reader sees a tab, which is the word the Stats plugin's own entries use. The Stats plugin's entry takes the Premium Analytics prefix after all. Every recent Premium Analytics entry in that changelog carries it, including features that only exist there, and one CHANGELOG holding both conventions reads worse than a prefix that repeats what the reader already knows.
The frame stops rendering a heading when a module draws, so the published contract and the package notes now say the module draws it from promo.title. Also keep test support out of the Storybook graph by giving the promo stories their own fixtures, drop a stale comment about the placement latch, and restore IntersectionObserver after the Parse.ly card suite.
The list ends on "and much more", which named six capabilities and then asked the reader to take the rest on trust. The only way on was the CTA, which opens a signup form: a reader who wants to know what the rest is before they buy had nowhere to go. It points at the Jetpack landing page Parse.ly maintains, and reports as "features" so its clicks can be told apart from the CTA's.
A single column put the pitch, the metrics and the call to action one under another, so on a wide dashboard the card ran to the depth of a section's worth of widgets for six short lines of copy, and the reader had to travel the whole height to reach the button. The pitch, the metrics and the button now sit side by side once the card has the room for them, and stack again when it does not. The feature names become badges that wrap within their own column rather than a bulleted list that only ever ran downwards. A container query decides this, not the viewport: the card's width is set by the dashboard's own grid and the collapsible admin menu, neither of which the window size predicts.
45cf5dd to
e13ccc4
Compare
The Parse.ly card's kicker lived in its render module, which fills the card's content region. The dismiss control is frame chrome and sits in the header above that region, so the two could never share a row and the card opened on a line holding nothing but a close button. A promo can now register an eyebrow, and the frame draws it in the header beside the dismiss. Whichever of the eyebrow and the module is absent leaves the title to the header, so a card still carries its heading exactly once however it is built.
Fixes STATS-646
Fixes STATS-668
Why
A site owner on the Traffic tab who has outgrown what Stats counts has nowhere to go from the numbers themselves. The Parse.ly offer reaches them only through the Stats options menu and the Settings page, neither of which is beside the data the offer is about. This adds a dismissible card at the foot of the Traffic tab that says what Parse.ly measures that Stats does not, and links to signup. Closing it hides it for 90 days; closing it a second time hides it for good.
Nothing is visible yet on a real site: the card is behind the same gate as the other two Parse.ly prompts, and WordPress.com holds that gate shut.
Proposed changes
section-footerplacement (STATS-668). The promo names the section it attaches to as itstarget, in the namespaced formregister_dashboard_section()takes, such asanalytics/traffic. A bare slug is refused at registration._doing_it_wrong()naming both.render_module, a script module that draws the card's content region and its heading. The card keeps the frame, the dismiss control, the snooze rule, the Tracks events and the promo's own copy as a fallback if the module never loads. The module reaches the page through the dashboard's import map, added by the same boot-dependency filter the widget modules use.eyebrow, which the card draws in its header beside the dismiss control. Whichever of the eyebrow and the module is absent leaves the title to the header, so the card carries its heading exactly once however it is built.parsely-promo-card, draws the Traffic card: the metrics headline, the feature badges and the call to action. Its three columns collapse to one on a narrow card, driven by a container query rather than the viewport, because the card's width comes from the dashboard grid and the collapsible admin menu.offers_parsely_promptsgate as the other two.usePromoSlot()takes the target it is drawing for, and keys its one-per-slot latch by placement and target, so two section footers on one page cannot claim each other's promo.PromoRecord,PromoRenderPropsand thePromoCtacomponent, so a promo module outside this package can draw the same button.Screenshots
The card at the foot of the Traffic tab, drawn by its render module.
Narrowed, the columns stack and the badges wrap.
Related product discussion/links
Does this pull request change what data or activity we track or use?
No new events. The three promo events already on trunk now also fire for
section-footer, withplacementset to it, and the card's module records its own clicks through the same event withlabelset toctaorfeatures.Testing instructions
The card is gated on
offers_parsely_prompts, which requires a plan tier, a views threshold, no Parse.ly integration already installed, and a WordPress.com flag that is currently false for every site. Force it open with a mu-plugin:wp_persisted_preferencesrecords{"count":1,"final":false}forparsely/traffic-upgradeunderjetpack-premium-analytics/dashboard→dismissedPromos. Clearing that record brings the card back.section-footerpromo with'target' => 'traffic'instead of'analytics/traffic': registration is refused with a notice naming the expected form.Verified
final: truewas not exercised in a browser. It would need the 90-day snooze faked out, and it is pre-existing behaviour with its own tests.PARSELY_PROMO_CARD_MODULE_IDto the module id wp-build emits. They agree today; if the build's naming changes, the card falls back to its own copy rather than failing loudly.🤖 Generated with Claude Code