Skip to content

Blaze: warn before disabling active campaigns#49522

Open
chriskmnds wants to merge 6 commits into
trunkfrom
add/ads-1159-blaze-disable-warning
Open

Blaze: warn before disabling active campaigns#49522
chriskmnds wants to merge 6 commits into
trunkfrom
add/ads-1159-blaze-disable-warning

Conversation

@chriskmnds

@chriskmnds chriskmnds commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Fixes https://linear.app/a8c/issue/ADS-1159/show-warning-when-user-disables-blaze-module-while-active-campaigns

Proposed changes

  • Add a Blaze package helper that checks whether the connected site has active Blaze campaigns.
  • Expose the campaign status through GET /wp-json/jetpack/v4/blaze/active-campaigns.
  • Add a Jetpack API client helper for the new endpoint.
  • Show a confirmation modal before disabling the Blaze module when active campaigns are present or when the campaign status check is unavailable.
  • Keep the modal centered and content-sized on desktop and mobile viewports.
  • Add PHP and JS test coverage plus changelog entries for the affected projects.

Media

Screenshot 2026-06-10 at 1 58 43 PM

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.js
  • pnpm run lint-file -- projects/plugins/jetpack/_inc/client/traffic/blaze.jsx projects/plugins/jetpack/_inc/client/traffic/blaze/test/component.js
  • pnpm run build-client

Manual testing:

  • Build or sync this branch to any connected Jetpack test site where Blaze can initialize, such as a temporary test site (JN) or sandbox.
  • In WP Admin, confirm the Blaze module is enabled and the Traffic settings card is visible.
  • To test the active-campaign warning without using a real campaign, run this WP-CLI fixture on the test site:
wp eval '$site_id = \Automattic\Jetpack\Connection\Manager::get_site_id(); if ( is_wp_error( $site_id ) ) { var_dump( $site_id ); return; } $mods = (array) get_option( "jetpack_active_modules", array() ); if ( ! in_array( "blaze", $mods, true ) ) { $mods[] = "blaze"; update_option( "jetpack_active_modules", array_values( $mods ) ); } set_transient( "jetpack_blaze_active_campaigns_status_" . $site_id, array( "has_active_campaigns" => true, "status" => "active" ), HOUR_IN_SECONDS ); var_export( array( "site_id" => $site_id, "blaze_active" => in_array( "blaze", (array) get_option( "jetpack_active_modules", array() ), true ), "fixture" => get_transient( "jetpack_blaze_active_campaigns_status_" . $site_id ) ) );'
  • Go to Jetpack > Settings > Traffic, or open wp-admin/admin.php?page=jetpack#/traffic.
  • Toggle Blaze off.
  • Confirm the warning modal appears with the title "Active Blaze campaigns are still running".
  • Confirm the modal explains that disabling the setting only hides the Blaze interface, and that campaigns continue to serve ads and charge until stopped in campaign management.
  • Click "Keep Blaze enabled" and confirm the modal closes and Blaze stays enabled.
  • Toggle Blaze off again, then click "Manage campaigns". Confirm the campaign management destination opens and Blaze stays enabled.
  • Toggle Blaze off again, then click "Disable anyway". Confirm the modal closes and the Blaze module is disabled.
  • Re-enable Blaze before continuing if needed.
  • To test the no-active-campaign path, run this WP-CLI fixture:
wp eval '$site_id = \Automattic\Jetpack\Connection\Manager::get_site_id(); if ( is_wp_error( $site_id ) ) { var_dump( $site_id ); return; } $mods = (array) get_option( "jetpack_active_modules", array() ); if ( ! in_array( "blaze", $mods, true ) ) { $mods[] = "blaze"; update_option( "jetpack_active_modules", array_values( $mods ) ); } set_transient( "jetpack_blaze_active_campaigns_status_" . $site_id, array( "has_active_campaigns" => false, "status" => "none" ), HOUR_IN_SECONDS ); var_export( array( "site_id" => $site_id, "blaze_active" => in_array( "blaze", (array) get_option( "jetpack_active_modules", array() ), true ), "fixture" => get_transient( "jetpack_blaze_active_campaigns_status_" . $site_id ) ) );'
  • Go back to Jetpack > Settings > Traffic and toggle Blaze off.
  • Confirm Blaze disables without showing the warning modal.
  • Repeat the active-campaign warning test at a narrow mobile viewport, for example under 600px wide. Confirm the modal stays centered, uses content height, and does not fill the whole page.

@chriskmnds chriskmnds added the [Status] Needs Privacy Updates Our support docs will need to be updated to take this change into account label Jun 10, 2026
@github-actions

github-actions Bot commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.

  • To test on WoA, go to the Plugins menu on a WoA dev site. Click on the "Upload" button and follow the upgrade flow to be able to upload, install, and activate the Jetpack Beta plugin. Once the plugin is active, go to Jetpack > Jetpack Beta, select your plugin (Jetpack or WordPress.com Site Helper), and enable the add/ads-1159-blaze-disable-warning branch.
  • To test on Simple, run the following command on your sandbox:
bin/jetpack-downloader test jetpack add/ads-1159-blaze-disable-warning
bin/jetpack-downloader test jetpack-mu-wpcom-plugin add/ads-1159-blaze-disable-warning

Interested in more tips and information?

  • In your local development environment, use the jetpack rsync command to sync your changes to a WoA dev blog.
  • Read more about our development workflow here: PCYsg-eg0-p2
  • Figure out when your changes will be shipped to customers here: PCYsg-eg5-p2

@github-actions github-actions Bot added [JS Package] API [Package] Blaze [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Status] In Progress [Tests] Includes Tests Admin Page React-powered dashboard under the Jetpack menu RNA labels Jun 10, 2026
@github-actions

github-actions Bot commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Thank you for your PR!

When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:

  • ✅ Include a description of your PR changes.
  • ✅ Add a "[Status]" label (In Progress, Needs Review, ...).
  • ✅ Add testing instructions.
  • ✅ Specify whether this PR includes any changes to data or privacy.
  • ✅ Add changelog entries to affected projects

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:

  1. Ensure all required checks appearing at the bottom of this PR are passing.
  2. Make sure to test your changes on all platforms that it applies to. You're responsible for the quality of the code you ship.
  3. You can use GitHub's Reviewers functionality to request a review.
  4. When it's reviewed and merged, you will be pinged in Slack to deploy the changes to WordPress.com simple once the build is done.

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:

  • WordPress.com Simple releases happen as soon as you deploy your changes after merging this PR (PCYsg-Jjm-p2).
  • WoA releases happen weekly.
  • Releases to self-hosted sites happen monthly:
    • Scheduled release: July 7, 2026
    • Code freeze: July 6, 2026

If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack.

@chriskmnds chriskmnds self-assigned this Jun 10, 2026
@jp-launch-control

jp-launch-control Bot commented Jun 10, 2026

Copy link
Copy Markdown

Code Coverage Summary

Coverage changed in 8 files. Only the first 5 are listed here.

File Coverage Δ% Δ Uncovered
projects/packages/blaze/src/class-blaze.php 141/224 (62.95%) 8.00% 1 ❤️‍🩹
projects/js-packages/api/index.jsx 26/154 (16.88%) 0.54% 0 💚
projects/plugins/jetpack/_inc/client/components/module-toggle/index.jsx 18/27 (66.67%) 5.13% -1 💚
projects/plugins/jetpack/_inc/client/components/settings-group/index.jsx 16/17 (94.12%) 5.88% -1 💚
projects/plugins/jetpack/_inc/client/state/connection/reducer.js 53/79 (67.09%) 1.27% -1 💚

Full summary · PHP report · JS report

@chriskmnds chriskmnds marked this pull request as ready for review June 12, 2026 10:46
@chriskmnds chriskmnds requested a review from Copilot June 12, 2026 10:46

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread projects/packages/blaze/tests/php/REST_Controller_Test.php Outdated
Comment on lines +212 to +217
<Button
variant="secondary"
href={ getBlazeDashboardUrl() }
onClick={ trackDashboardClick }
{ ...getBlazeDashboardLinkProps() }
>

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@chriskmnds chriskmnds force-pushed the add/ads-1159-blaze-disable-warning branch from ba333e5 to 7f1561a Compare June 12, 2026 11:22
@chriskmnds chriskmnds requested a review from Copilot June 12, 2026 11:46

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.

Comment on lines 160 to 170
<ModuleToggle
slug="blaze"
activated={ blazeActive }
disabled={ unavailableInOfflineMode || ! hasConnectedOwner || isSavingAnyOption( 'blaze' ) }
toggleModule={ toggleModuleNow }
disabled={
unavailableInOfflineMode ||
! hasConnectedOwner ||
isSavingAnyOption( 'blaze' ) ||
checkingActiveCampaigns
}
toggleModule={ handleToggleModule }
>

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@github-actions github-actions Bot added the Docs label Jun 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Admin Page React-powered dashboard under the Jetpack menu Docs [JS Package] API [Package] Blaze [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ RNA [Status] In Progress [Status] Needs Privacy Updates Our support docs will need to be updated to take this change into account [Tests] Includes Tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants