-
Notifications
You must be signed in to change notification settings - Fork 330
Closed
Labels
P0High priorityHigh priorityPHPTeam SIssues for Squad 1Issues for Squad 1Type: EnhancementImprovement of an existing featureImprovement of an existing feature
Description
Feature Description
Currently we are not unscheduling/removing Email Reporting CRON's when FF is disabled. Also it seems Email Reporting CRON's are added even before SIte Kit is setup
Do not alter or remove anything below. The following sections will be managed by moderators only.
Acceptance criteria
WhenproactiveUserEngagementfeature flag is disabled all Email Reporting CRON's are removed- When Site Kit is not set up, no Email Reporting CRON should be scheduled - Email reports should only be scheduled, at minimum, once Site Kit is set up.
- When Site Kit is reset all Email Reporting CRONs are removed
Implementation Brief
-
Perform cleanup when theproactiveUserEngagementfeature flag is disabled: during plugin bootstrap whereproactiveUserEngagementis checked (inPlugin::registerwhereFeature_Flags::enabled( 'proactiveUserEngagement' )gates Email Reporting), add a branch for the disabled path that instantiatesEmail_Reporting_Scheduler(withFrequency_Planner) and callsunschedule_all()to cleargooglesitekit_email_reporting_*cron hooks. This ensures any previously queued events are removed because the feature is no longer registered. - Gate scheduling on setup completion: inject
Authenticationinto theEmail_Reportingclass (pass it fromPlugin::registeralongside existing dependencies) and guard the scheduling logic inEmail_Reporting::register()with$this->authentication->is_setup_completed(). If setup is incomplete, short-circuit before scheduling, and proactively call$this->scheduler->unschedule_all()to clean up any existing events. - Preserve enable/disable toggle behavior: keep the existing
is_email_reporting_enabled()checks, but require both "email reporting enabled" and "setup complete" before scheduling. If either is false (flag off, toggle off, or setup incomplete), ensureunschedule_all()runs so no cron remains registered.
Test Coverage
- Extend integration tests in
tests/phpunit/integration/Core/Email_Reportingto verify:- When
proactiveUserEngagementis disabled, any pre-scheduled email reporting cron events are removed via scheduler cleanup; - When
Authentication::is_setup_completed()returns false, no new email reporting events are scheduled and existing ones are cleared.
- When
QA Brief
- Verify that before setting up the Site Kit there are no
email_reporting_*related CRONS (If previously there are some stale CRONs, remove them and reload the page, verify they are not being added)
- Setup Site Kit
- Verify that email reporting CRONs are added - as Email reporting setting is enabled by default
- Go to Settings > Admin Settings and disable Email Reporting
- Verify that Email Reporting CRONs have been removed
- Go to Settings > Admin Settings and reset Site Kit
- Verify that Email Reporting CRONs are removed
Changelog entry
- Update the uninstall script to unregister all email reporting events when the plugin is unininstalled.
Metadata
Metadata
Assignees
Labels
P0High priorityHigh priorityPHPTeam SIssues for Squad 1Issues for Squad 1Type: EnhancementImprovement of an existing featureImprovement of an existing feature