Skip to content

[API merging] Creating a CTA fails in RRM express setup #13634

Description

@nfmohit

Bug Description

The request to create a CTA in RRM express setup fails. The CreateCTA request body omits the CTA state, which the API requires.

Steps to reproduce

  1. Ensure Request the new RRM scopes for the express setup #13004 is merged.
  2. Turn on the rrmExpressSetup feature flag.
  3. Set up Site Kit.
  4. 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.
  5. Fill out the newsletter sign-up form and submit.
  6. 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.

QA Brief

Changelog entry

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Module: RRMReader Revenue Manager module related issuesP0High priorityTeam MIssues for Squad 2Type: BugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions