google / google/site-kit-wp

Simplify RRM JS CTA type registration

Open
#13,428 0 comments 0 reactions 1 assignee Claimed by @hussain-t View on GitHub
Module: RRM P2 Team M Type: Enhancement
Dominant language
JavaScript
Stars
1.4k
Forks
383
Avg merge
4d 12h
Merged PRs (30d)
80

Description

## Feature Description

Adding a Reader Revenue Manager CTA type on the datastore currently means touching four compile-enforced maps in `assets/js/modules/reader-revenue-manager/datastore/cta-types/`:

- `CTA_TYPES`
- `CallToActionConfigByType`
- `CallToActionByType`
- `CTA_TYPE_HANDLERS`

That was an intentional choice for [#13006](https://github.com/google/site-kit-wp/issues/13006) / [#13208](https://github.com/google/site-kit-wp/pull/13208): missing one of those spots is a `tsc` error on that line. PHP already registers handlers in one list and keys them off `get_type()`.

With a second CTA type, keeping four maps in sync is more costly. This ticket simplifies that to a small number of/one registration point without changing create/list behavior.

See relevant discussions:
1. https://github.com/google/site-kit-wp/pull/13208#discussion_r3810194883
2. https://github.com/google/site-kit-wp/pull/13208#issuecomment-5344974178
3. https://github.com/google/site-kit-wp/pull/13208#pullrequestreview-5000780779

---------------

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

## Acceptance criteria

*

## Implementation Brief

* [ ]

### Test Coverage

*

## QA Brief

*

## Changelog entry

*

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.