You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Go through the RRM express setup at yoursite.com/wp-admin/admin.php?page=googlesitekit-dashboard&slug=reader-revenue-manager&reAuth=true&expressSetup=true&cta=newsletter-signup until the setup-cta step.
Fill out the newsletter sign-up form and submit.
Observe the error encountered.
Do not alter or remove anything below. The following sections will be managed by moderators only.
Acceptance criteria
Creating a CTA in the Reader Revenue Manager express setup flow no longer fails due to the reason mentioned in the issue description.
Implementation Brief
In includes/Modules/Reader_Revenue_Manager/Datapoints/Create_CTA.php:
Require data.state and validate it against Cta::STATE_ACTIVE and Cta::STATE_DRAFT, throwing Missing_Required_Param_Exception and Invalid_Param_Exception respectively, alongside the existing parameter validation.
Set the validated state on the Cta object.
In assets/js/modules/reader-revenue-manager/datastore/cta-types/types.ts:
Add a CTA_STATES map with ACTIVE and DRAFT members and a CallToActionState type derived from it, and use that type for CallToActionBase's state property in place of string.
In assets/js/modules/reader-revenue-manager/datastore/cta-types/index.ts:
Re-export the above, add an optional state to CreateCTAData, and add an isCTAState() guard alongside the existing isCTAType().
In assets/js/modules/reader-revenue-manager/datastore/ctas.ts:
Validate data.state within validateCreateCTAParams(). It remains optional, but is rejected when it is not a supported state.
Default data.state to ACTIVE in the createCTA action before the fetch is dispatched, so that existing callers need no change.
Test Coverage
Add JS tests covering isCTAState(), the ACTIVE default, an explicit DRAFT state passing through, and the rejection of an unsupported state.
Add PHP tests covering a missing state, an invalid state, and an explicit DRAFT state passing through.
Update existing tests to account for the state property in the request body.
Bug Description
The request to create a CTA in RRM express setup fails. The
CreateCTArequest body omits the CTAstate, which the API requires.Steps to reproduce
rrmExpressSetupfeature flag.yoursite.com/wp-admin/admin.php?page=googlesitekit-dashboard&slug=reader-revenue-manager&reAuth=true&expressSetup=true&cta=newsletter-signupuntil thesetup-ctastep.Do not alter or remove anything below. The following sections will be managed by moderators only.
Acceptance criteria
Implementation Brief
includes/Modules/Reader_Revenue_Manager/Datapoints/Create_CTA.php:data.stateand validate it againstCta::STATE_ACTIVEandCta::STATE_DRAFT, throwingMissing_Required_Param_ExceptionandInvalid_Param_Exceptionrespectively, alongside the existing parameter validation.Ctaobject.assets/js/modules/reader-revenue-manager/datastore/cta-types/types.ts:CTA_STATESmap withACTIVEandDRAFTmembers and aCallToActionStatetype derived from it, and use that type forCallToActionBase'sstateproperty in place ofstring.assets/js/modules/reader-revenue-manager/datastore/cta-types/index.ts:statetoCreateCTAData, and add anisCTAState()guard alongside the existingisCTAType().assets/js/modules/reader-revenue-manager/datastore/ctas.ts:data.statewithinvalidateCreateCTAParams(). It remains optional, but is rejected when it is not a supported state.data.statetoACTIVEin thecreateCTAaction before the fetch is dispatched, so that existing callers need no change.Test Coverage
isCTAState(), theACTIVEdefault, an explicitDRAFTstate passing through, and the rejection of an unsupported state.DRAFTstate passing through.stateproperty in the request body.QA Brief
Changelog entry