Blaze: warn before disabling active campaigns#49522
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. |
Code Coverage SummaryCoverage changed in 8 files. Only the first 5 are listed here.
|
There was a problem hiding this comment.
Pull request overview
Adds a safety check and UI warning to prevent admins from accidentally disabling the Blaze module while campaigns are still running. This integrates a new Blaze REST endpoint into the Jetpack UI via the JS API client, with accompanying PHP/JS tests and changelog entries.
Changes:
- Add Blaze-side active-campaign status lookup (with transient caching for “active”) and expose it via
GET /wp-json/jetpack/v4/blaze/active-campaigns. - Add a Jetpack JS API client helper for the endpoint and a Jetpack settings modal flow that warns (or warns conservatively on lookup failure) before disabling Blaze.
- Add PHPUnit + JS test coverage and changelog entries across the affected projects.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| projects/plugins/jetpack/changelog/add-ads-1159-blaze-disable-warning | Jetpack plugin changelog entry for the new disable-warning behavior. |
| projects/plugins/jetpack/_inc/client/traffic/blaze/test/component.js | New GUI tests covering disable behavior with/without active campaigns and failure cases. |
| projects/plugins/jetpack/_inc/client/traffic/blaze.jsx | Adds active-campaign check on disable and renders a confirmation modal. |
| projects/packages/blaze/tests/php/REST_Controller_Test.php | New REST controller tests for the active-campaigns endpoint and permissions. |
| projects/packages/blaze/tests/php/Blaze_Test.php | Adds unit tests for Blaze::get_active_campaigns_status() and caching behavior. |
| projects/packages/blaze/src/class-rest-controller.php | Registers the new active-campaigns REST route and supports DI for connection checks. |
| projects/packages/blaze/src/class-blaze.php | Implements active-campaign status lookup and transient caching helpers. |
| projects/packages/blaze/changelog/add-ads-1159-blaze-disable-warning | Blaze package changelog entry for active-campaign status checks. |
| projects/js-packages/api/test/rest-api.jsx | Adds JS API client test for fetchBlazeActiveCampaigns(). |
| projects/js-packages/api/index.jsx | Adds fetchBlazeActiveCampaigns() to the JS API client. |
| projects/js-packages/api/changelog/add-ads-1159-api-helper | JS API package changelog entry for the new helper. |
| <Button | ||
| variant="secondary" | ||
| href={ getBlazeDashboardUrl() } | ||
| onClick={ trackDashboardClick } | ||
| { ...getBlazeDashboardLinkProps() } | ||
| > |
There was a problem hiding this comment.
Update: Addressed by closing the warning modal in the Manage campaigns click handler before recording the dashboard click. The focused Blaze component test covers that path and confirms Blaze stays enabled while the modal closes.
ba333e5 to
7f1561a
Compare
| <ModuleToggle | ||
| slug="blaze" | ||
| activated={ blazeActive } | ||
| disabled={ unavailableInOfflineMode || ! hasConnectedOwner || isSavingAnyOption( 'blaze' ) } | ||
| toggleModule={ toggleModuleNow } | ||
| disabled={ | ||
| unavailableInOfflineMode || | ||
| ! hasConnectedOwner || | ||
| isSavingAnyOption( 'blaze' ) || | ||
| checkingActiveCampaigns | ||
| } | ||
| toggleModule={ handleToggleModule } | ||
| > |
There was a problem hiding this comment.
Update: Addressed in 43bcc17412 by opting Blaze out of ModuleToggle pre-handler tracking and recording jetpack_wpa_module_toggle only when the enable or disable action proceeds. The component test now covers no toggle event for warning, cancel, manage, and lookup-failure paths, plus one event for direct or confirmed toggles.
Fixes https://linear.app/a8c/issue/ADS-1159/show-warning-when-user-disables-blaze-module-while-active-campaigns
Proposed changes
GET /wp-json/jetpack/v4/blaze/active-campaigns.Media
Related product discussion/links
Does this pull request change what data or activity we track or use?
Yes. When an admin tries to disable the Blaze module, Jetpack checks whether the connected site has active Blaze campaigns and uses that status to decide whether to show the warning. This does not add new tracking events or persist new user activity.
Testing instructions
Automated checks:
pnpm run test-gui -- _inc/client/traffic/blaze/test/component.jspnpm run lint-file -- projects/plugins/jetpack/_inc/client/traffic/blaze.jsx projects/plugins/jetpack/_inc/client/traffic/blaze/test/component.jspnpm run build-clientManual testing:
wp-admin/admin.php?page=jetpack#/traffic.