Repository navigation
WOOA7S-2294: Premium Analytics: Add Build URL to empty UTM widget - #53458
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: 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. 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. |
Code Coverage SummaryCoverage changed in 1 file.
1 file is newly checked for coverage.
|
chihsuan
left a comment
There was a problem hiding this comment.
Nice work on the URL builder! @Nikschavan I tested the empty state, validation and copy flow, and they work nicely. 👍 I left a few inline notes, mainly around closing the dialog on copy.
32d6f35 to
e1d7ab7
Compare
0c335c3 to
473651a
Compare
chihsuan
left a comment
There was a problem hiding this comment.
Thanks for the updates! @Nikschavan The copy flow and validation work nicely now, approving. 👍 I left a few non-blocking inline notes.
Use InputControl from @wordpress/ui for the builder fields and tell the user when the destination lacks an http(s) protocol. Close the dialog after a successful copy so the snackbar is visible, since a snackbar renders under an open dialog. A failed copy keeps the dialog open and shows an error notice inside it.
…tion Copy goes through useCopyToClipboard, so it also works on HTTP sites where navigator.clipboard is undefined. The hook has no failure callback, so the failed-copy notice is removed. The destination error uses ValidatedInputControl and shows after the field loses focus, not on the first keystroke. Headings and paragraphs in the dialog use Text, as the rest of the package does.
Closing the dialog on copy cleared the form, so a second URL for the same campaign meant typing every field again. The dialog now stays open and the button confirms the copy for four seconds, or until a field changes, so it never confirms a URL that was not copied. The snackbar and its notices dispatch are removed. The Build URL test asserted on the widget while the open dialog hid it from role queries, so it passed with any empty state. It now closes the dialog first. The widget declares @wordpress/compose, which the dialog imports.
28ee048 to
65cfa76
Compare
With UTM fields filled and no valid destination, the preview still asked for campaign parameters, so nothing pointed at the field that was missing. It now asks for the destination URL in that case. The preview wraps with overflow-wrap, because break-all also split the placeholder sentence in the middle of a word on a narrow screen.
The message said the same as the generic empty state, so nothing explained what Build URL was for. It now tells the reader to build a URL to start tracking a campaign.
chihsuan
left a comment
There was a problem hiding this comment.
Thank you! @Nikschavan LGTM 🚢
Fixes WOOA7S-2294
Proposed changes
When Top UTM has no visits in the selected period, I offer Build URL in the empty state. The action opens a URL builder so someone can create a tagged link without leaving the dashboard. The existing View all link remains available.
I used the shared empty-state action and Gutenberg dialog components. The builder preserves existing query parameters and URL fragments. The empty-state text refers to visits in the selected period because the stats response cannot tell whether someone has created a tracked URL.
The builder only accepts an
httporhttpsdestination, and it needs at least one UTM value before Copy to clipboard is enabled. A destination without a protocol, such asexample.com, gets an error under the field once the field loses focus, because the Stats v1 builder accepted that input and people will type it. A UTM value the destination already carries is replaced by the value from its field, and removed when that field is left empty.Copy to clipboard sits in the dialog footer, so it stays visible when the content scrolls on a small screen. The prototype has it as an outline button under the URL box. It uses
useCopyToClipboardfrom@wordpress/compose, which falls back toexecCommandon HTTP sites wherenavigator.clipboarddoes not exist. After a successful copy the dialog closes and a snackbar confirms it, because a snackbar renders underneath an open@wordpress/uidialog and would not be seen. The hook has no failure callback, so a failed copy shows nothing. I am still checking the footer position and the close-on-copy behaviour with design, so both may change.Copying closes the dialog and shows the snackbar on the dashboard:
utm-builder-copy-closes-dialog.mp4
Related product discussion/links
Does this pull request change what data or activity we track or use?
No.
Testing instructions
example.comas the destination and move to the next field. An error under the field should ask for a full URL, and Copy to clipboard should stay disabled.I tested the copy flow on my local site in Chrome. I did not test a failed copy or an HTTP site.