Skip to content

Add Update CTA datapoint. - #14267

Open
JakePT wants to merge 6 commits into
developfrom
enhancement/13738-update-cta
Open

JakePT wants to merge 6 commits into
developfrom
enhancement/13738-update-cta

Conversation

@JakePT

@JakePT JakePT commented Nov 25, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Related issue(s):

Relevant technical choices

PR Author Checklist

  • My code is tested and passes existing unit tests.
  • My code has an appropriate set of unit tests which all pass.
  • My code is backward-compatible with WordPress 5.2 and PHP 7.4.
  • My code follows the WordPress coding standards.
  • My code has proper inline documentation.
  • I have added a QA Brief on the issue linked above.
  • I have signed the Contributor License Agreement (see https://cla.developers.google.com/).

Do not alter or remove anything below. The following sections will be managed by moderators only.

Code Reviewer Checklist

  • Run the code.
  • Ensure the acceptance criteria are satisfied.
  • Reassess the implementation with the IB.
  • Ensure no unrelated changes are included.
  • Ensure CI checks pass.
  • Check Storybook where applicable.
  • Ensure there is a QA Brief.
  • Ensure there are no unexpected significant changes to file sizes.

Merge Reviewer Checklist

  • Ensure the PR has the correct target branch.
  • Double-check that the PR is okay to be merged.
  • Ensure the corresponding issue has a ZenHub release assigned.
  • Add a changelog message to the issue.

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request implements the capability to update Call to Action (CTA) configurations within the Reader Revenue Manager module. It introduces the "updateCTA" datastore action, the "POST:cta" REST API datapoint ("Update_CTA"), and a unified "CTA_Type_Handlers" registry to handle type-specific configurations. The review feedback correctly identifies a critical issue where the new "ctasByID" state is expected by unit tests to be populated during "receiveGetPublicationCTAs", but the reducer has not been updated to do so, which will lead to test failures.

type CreateCTARequest = PublicationParams & CreateCTAParams;
interface CTAsState {
ctas: Record< string, CTA[] | undefined >;
ctasByID: Record< string, Record< string, CTA | null > >;

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.

high

The ctasByID state property is added to CTAsState and initialized in baseInitialState, but it is only populated in the fetchUpdateCTAStore reducer. However, the unit test should store the updated CTA by its ID, whether or not it was loaded in ctas.test.ts (lines 556-582) expects receiveGetPublicationCTAs to populate ctasByID with the loaded CTAs.

Since the fetchGetPublicationCTAsStore reducer does not populate ctasByID, this test will fail because getState().ctasByID[ params.publicationID ] will be undefined after calling receiveGetPublicationCTAs.

To resolve this, we should update the fetchGetPublicationCTAsStore reducer to populate ctasByID when CTAs are received, or ensure that the test is aligned with the actual implementation if the population is expected to be introduced in another PR (e.g., #13737).

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I'd originally copied the full implementation of ctasByID from #13737 but trimmed it back to just what was needed for this issue but it left some tests behind. I've cleaned that up so there shouldn't be any remaining tests dependent on #13737.

@JakePT
JakePT marked this pull request as ready for review November 25, 2026 14:44
@github-actions

github-actions Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

🤖 This comment is automatically updated by CI workflows. Each section is managed independently.

📚 Storybook for a5a57c3:

📦 Build files for a5a57c3:

🖼️ VRT report for a5a57c3:

🎭 Playwright reports for a5a57c3:

@github-actions

Copy link
Copy Markdown

Size Change: 0 B

Total Size: 3.58 MB

ℹ️ View Unchanged
Filename Size Change
dist/assets/blocks/reader-revenue-manager/block-editor-plugin/editor-styles.css 124 B 0 B
dist/assets/blocks/reader-revenue-manager/block-editor-plugin/editor-styles.js 0 B 0 B 🆕
dist/assets/blocks/reader-revenue-manager/block-editor-plugin/index.js 47.1 kB 0 B
dist/assets/blocks/reader-revenue-manager/common/editor-styles.css 307 B 0 B
dist/assets/blocks/reader-revenue-manager/common/editor-styles.js 0 B 0 B 🆕
dist/assets/blocks/reader-revenue-manager/contribute-with-google/index.js 7.25 kB 0 B
dist/assets/blocks/reader-revenue-manager/contribute-with-google/non-site-kit-user.js 6.46 kB 0 B
dist/assets/blocks/reader-revenue-manager/subscribe-with-google/index.js 7.26 kB 0 B
dist/assets/blocks/reader-revenue-manager/subscribe-with-google/non-site-kit-user.js 6.46 kB 0 B
dist/assets/blocks/sign-in-with-google/editor-styles.css 84 B 0 B
dist/assets/blocks/sign-in-with-google/editor-styles.js 0 B 0 B 🆕
dist/assets/blocks/sign-in-with-google/index.js 18.5 kB 0 B
dist/assets/css/googlesitekit-admin-css-********************.min.css 79.2 kB 0 B
dist/assets/css/googlesitekit-adminbar-css-********************.min.css 12.7 kB 0 B
dist/assets/css/googlesitekit-authorize-application-css-********************.min.css 851 B 0 B
dist/assets/css/googlesitekit-wp-dashboard-css-********************.min.css 9.09 kB 0 B
dist/assets/js/492-********************.js 970 B 0 B
dist/assets/js/959-********************.js 3 kB 0 B
dist/assets/js/1020-********************.js 1.03 kB 0 B
dist/assets/js/1212-********************.js 2.26 kB 0 B
dist/assets/js/1315-********************.js 3.08 kB 0 B
dist/assets/js/3022-********************.js 2.41 kB 0 B
dist/assets/js/3741-********************.js 3.84 kB 0 B
dist/assets/js/6174-********************.js 4.04 kB 0 B
dist/assets/js/7603-********************.js 61.5 kB 0 B
dist/assets/js/7792-********************.js 110 kB 0 B
dist/assets/js/9397-********************.js 477 kB 0 B
dist/assets/js/analytics-advanced-tracking-********************.js 428 B 0 B
dist/assets/js/googlesitekit-activation-********************.js 31.9 kB 0 B
dist/assets/js/googlesitekit-ad-blocking-recovery-********************.js 72.9 kB 0 B
dist/assets/js/googlesitekit-admin-pointers-********************.js 6.88 kB 0 B
dist/assets/js/googlesitekit-adminbar-********************.js 38.8 kB 0 B
dist/assets/js/googlesitekit-api-********************.js 9.93 kB 0 B
dist/assets/js/googlesitekit-block-tracking-********************.js 6.88 kB 0 B
dist/assets/js/googlesitekit-components-********************.js 7.02 kB 0 B
dist/assets/js/googlesitekit-consent-mode-********************.js 25.5 kB 0 B
dist/assets/js/googlesitekit-data-********************.js 1.84 kB 0 B
dist/assets/js/googlesitekit-datastore-forms-********************.js 8.6 kB 0 B
dist/assets/js/googlesitekit-datastore-location-********************.js 1.6 kB 0 B
dist/assets/js/googlesitekit-datastore-pdf-********************.js 1.23 kB 0 B
dist/assets/js/googlesitekit-datastore-site-********************.js 21.7 kB 0 B
dist/assets/js/googlesitekit-datastore-ui-********************.js 8.76 kB 0 B
dist/assets/js/googlesitekit-datastore-user-********************.js 27 kB 0 B
dist/assets/js/googlesitekit-entity-dashboard-********************.js 99.2 kB 0 B
dist/assets/js/googlesitekit-events-provider-contact-form-7-********************.js 1.27 kB 0 B
dist/assets/js/googlesitekit-events-provider-content-events-********************.js 3.16 kB 0 B
dist/assets/js/googlesitekit-events-provider-easy-digital-downloads-********************.js 651 B 0 B
dist/assets/js/googlesitekit-events-provider-mailchimp-********************.js 1.24 kB 0 B
dist/assets/js/googlesitekit-events-provider-ninja-forms-********************.js 1.26 kB 0 B
dist/assets/js/googlesitekit-events-provider-optin-monster-********************.js 1.28 kB 0 B
dist/assets/js/googlesitekit-events-provider-popup-maker-********************.js 1.35 kB 0 B
dist/assets/js/googlesitekit-events-provider-woocommerce-********************.js 895 B 0 B
dist/assets/js/googlesitekit-events-provider-wpforms-********************.js 1.3 kB 0 B
dist/assets/js/googlesitekit-feature-discovery-********************.js 40.2 kB 0 B
dist/assets/js/googlesitekit-features-********************.js 92.9 kB 0 B
dist/assets/js/googlesitekit-features-badge-********************.js 835 B 0 B
dist/assets/js/googlesitekit-i18n-********************.js 4.43 kB 0 B
dist/assets/js/googlesitekit-intents-********************.js 9.33 kB 0 B
dist/assets/js/googlesitekit-key-metrics-setup-********************.js 67.9 kB 0 B
dist/assets/js/googlesitekit-main-dashboard-********************.js 230 kB 0 B
dist/assets/js/googlesitekit-metric-selection-********************.js 70 kB 0 B
dist/assets/js/googlesitekit-modules-********************.js 30.9 kB 0 B
dist/assets/js/googlesitekit-modules-ads-********************.js 62.6 kB 0 B
dist/assets/js/googlesitekit-modules-adsense-********************.js 158 kB 0 B
dist/assets/js/googlesitekit-modules-analytics-4-********************.js 321 kB 0 B
dist/assets/js/googlesitekit-modules-pagespeed-insights-********************.js 32.6 kB 0 B
dist/assets/js/googlesitekit-modules-reader-revenue-manager-********************.js 155 kB +217 B (+0.14%)
dist/assets/js/googlesitekit-modules-search-console-********************.js 79.7 kB 0 B
dist/assets/js/googlesitekit-modules-sign-in-with-google-********************.js 41 kB 0 B
dist/assets/js/googlesitekit-modules-tagmanager-********************.js 35 kB 0 B
dist/assets/js/googlesitekit-notifications-********************.js 97.6 kB 0 B
dist/assets/js/googlesitekit-polyfills-********************.js 227 B 0 B
dist/assets/js/googlesitekit-settings-********************.js 91.4 kB 0 B
dist/assets/js/googlesitekit-splash-********************.js 75.6 kB 0 B
dist/assets/js/googlesitekit-user-input-********************.js 63.8 kB 0 B
dist/assets/js/googlesitekit-vendor-********************.js 315 kB 0 B
dist/assets/js/googlesitekit-vendor-lazy-pdf-********************.js 24.6 kB 0 B
dist/assets/js/googlesitekit-widgets-********************.js 187 kB 0 B
dist/assets/js/googlesitekit-wp-dashboard-********************.js 47.7 kB 0 B
dist/assets/js/runtime-********************.js 1.98 kB 0 B
dist/assets/js/sign-in-with-google-********************.js 1.35 kB 0 B

compressed-size-action

@ankitrox ankitrox left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thank you @JakePT
Changes are looking good to me, but can you resolve the merge conflicts with the base branch please?

Once resolved this is good to go to MR.

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add the POST:cta datapoint and updateCTA() action for Reader Revenue Manager

2 participants