Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add URL params when initiating an RRM publication creation #10166

Closed
12 tasks done
nfmohit opened this issue Feb 4, 2025 · 6 comments
Closed
12 tasks done

Add URL params when initiating an RRM publication creation #10166

nfmohit opened this issue Feb 4, 2025 · 6 comments
Labels
Good First Issue Good first issue for new engineers Module: RRM Reader Revenue Manager module related issues P0 High priority Team M Issues for Squad 2 Type: Enhancement Improvement of an existing feature

Comments

@nfmohit
Copy link
Collaborator

nfmohit commented Feb 4, 2025

Feature Description

When navigating the user to the Publisher Center to create a new Reader Revenue Manager publication, in addition to the existing utm_source=sitekit parameter, three new parameters should be included, as follows:

Name Usage Example
prefill_canonical_domain The canonical domain of the referred site(as opposed to referrer). The url should be passed through encodeURIComponent. www.example.com, https://www.google.com, abc.xyz
prefill_lang The site’s primary language in BCP47. en-US, fr-CA, pt-BR
app_redirect The app we want to redirect the user to when navigating to the site. For Site Kit we always expect this to be “rrm”. rrm

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

Acceptance criteria

  • When the rrmModuleV2 feature flag is enabled:
    • In the Reader Revenue Manager setup screen, when the user clicks on the "Create publication" button, or the "Create new publication" link, the link that the user is navigated to should have the URL parameters added as specified in the feature description. See further details below:
      • prefill_canonical_domain: This should equal to the site's reference URL.
      • prefill_lang: This should be obtained from WordPress, e.g. by using the get_locale WordPress function, but replacing the underscore (e.g. en_US) with a dash (e.g. en-US).
      • app_redirect: This should equal to rrm.

Implementation Brief

  • In includes/Core/Assets/Assets.php:
    • Update the get_inline_base_data() method to include a siteLocale item in the $inline_data array. Its value should be obtained using the $this->context->get_locale() method.
  • In assets/js/googlesitekit/datastore/site/info.js:
    • Update the getSiteInfo() selector (including its relevant resolver and reducer) to output siteLocale from global._googlesitekitBaseData.
    • Create a new selector named getSiteLocale(), that obtains siteLocale using the getSiteInfo() selector and replaces the underscore, if exists (e.g. en_US), with a dash (e.g. en-US). See getLocale for reference.
  • In assets/js/modules/reader-revenue-manager/datastore/service.js:
    • Create a new selector, say getCreatePublicationLinkURL(). It should return the service URL using the getServiceURL selector, including the query parameters specified in the ACs, as follows:
      • prefill_canonical_domain: Its value should be the site's reference URL, obtainable using the CORE_SITE getReferenceSiteURL() selector.
      • prefill_lang: Its value should be the site's locale obtained using the CORE_SITE getSiteLocale() selector.
      • app_redirect: Its value should be rrm.
  • In assets/js/modules/reader-revenue-manager/components/common/PublicationCreate.js and assets/js/modules/reader-revenue-manager/components/setup/SetupForm.js:
    • Update serviceURL if the rrmModuleV2 feature flag is enabled to use the new getCreatePublicationLinkURL() selector instead of getServiceURL.

Test Coverage

  • In assets/js/googlesitekit/datastore/site/info.test.js:
    • Update test coverage to verify that the new locale information is included in the getSiteInfo() selector.
    • Add test coverage for the new getSiteLocale() selector.
  • In assets/js/modules/reader-revenue-manager/datastore/service.test.js:
    • Update test coverage to include tests for the getCreatePublicationLinkURL selector.
  • In assets/js/modules/reader-revenue-manager/components/common/PublicationCreate.test.js:
    • Verify the change in the URL if the rrmModule feature flag is enabled.

QA Brief

  • Setup SiteKit with an https URL and enable the rrmModule feature flag.
  • Begin the setup flow for RRM from the plugin settings, going through the Google auth process.
  • Check the URL for the "Create Publication" button, it should contain the following query attributes in the URL:
    • prefill_canonical_domain: Its value should be the site's URL.
    • prefill_lang: Its value should be the site's locale.
    • app_redirect: Its value should be rrm.

Changelog entry

  • Update URL for RRM publication creation to streamline configuration.
@nfmohit nfmohit self-assigned this Feb 4, 2025
@nfmohit nfmohit added P0 High priority Type: Enhancement Improvement of an existing feature Team M Issues for Squad 2 Module: RRM Reader Revenue Manager module related issues labels Feb 4, 2025
@nfmohit nfmohit changed the title Add URL params when initiating an RRM publication creation Add URL params when initiating a RRM publication creation Feb 4, 2025
@ivonac4 ivonac4 added the Next Up Issues to prioritize for definition label Feb 6, 2025
@nfmohit nfmohit changed the title Add URL params when initiating a RRM publication creation Add URL params when initiating an RRM publication creation Feb 7, 2025
@nfmohit nfmohit removed their assignment Feb 7, 2025
@techanvil techanvil self-assigned this Feb 7, 2025
@techanvil
Copy link
Collaborator

Hey @nfmohit, thanks for drafting this IB. A couple of points:

  • In includes/Core/Assets/Assets.php:
    • Update the get_inline_base_data method to include a locale item in the $inline_data array. Its value should be obtained using the $this->context->get_locale() method.
  • In assets/js/googlesitekit/datastore/site/info.js:
    • Update the getSiteInfo selector (including its relevant resolver and reducer) to output locale from global._googlesitekitBaseData.

This addition shouldn't be needed, as we're already passing locale via _googlesitekitLegacyData and have the getLocale() utility function to access it:

/~https://github.com/google/site-kit-wp/blob/77be4ab2b67492e433d185c7e574585f3243cab9/assets/js/util/i18n.js#L478-L501

  • prefill_canonical_domain: Its value should be the site's reference URL, passed through encodeURIComponent.

It shouldn't be necessary to call encodeURIComponent() ourselves here, as this is already taken care of by addQueryArgs(), via buildQueryString().

@techanvil techanvil assigned nfmohit and unassigned techanvil Feb 7, 2025
@nfmohit
Copy link
Collaborator Author

nfmohit commented Feb 7, 2025

Thank you for the kind IBR feedback, @techanvil !

    • In includes/Core/Assets/Assets.php:

      • Update the get_inline_base_data method to include a locale item in the $inline_data array. Its value should be obtained using the $this->context->get_locale() method.* [ ] In assets/js/googlesitekit/datastore/site/info.js:

      • Update the getSiteInfo selector (including its relevant resolver and reducer) to output locale from global._googlesitekitBaseData.

This addition shouldn't be needed, as we're already passing locale via _googlesitekitLegacyData and have the getLocale() utility function to access it:

77be4ab/assets/js/util/i18n.js#L478-L501

Thank you. I did notice that, but it appears that the locale included in _googlesitekitLegacyData is the user locale instead of the global one. See here. Don't you think we should use the site locale instead?

That is a good point, removed, thank you!

@nfmohit nfmohit assigned techanvil and unassigned nfmohit Feb 7, 2025
@techanvil
Copy link
Collaborator

techanvil commented Feb 7, 2025

Thanks @nfmohit!

      • [ ]
        [ ] In includes/Core/Assets/Assets.php:

        • [ ]
          [ ] Update the get_inline_base_data method to include a locale item in the $inline_data array. Its value should be obtained using the $this->context->get_locale() method.* [ ] In assets/js/googlesitekit/datastore/site/info.js:* [ ]
          [ ] Update the getSiteInfo selector (including its relevant resolver and reducer) to output locale from global._googlesitekitBaseData.

This addition shouldn't be needed, as we're already passing locale via _googlesitekitLegacyData and have the getLocale() utility function to access it:
77be4ab/assets/js/util/i18n.js#L478-L501

Thank you. I did notice that, but it appears that the locale included in _googlesitekitLegacyData is the user locale instead of the global one. See here. Don't you think we should use the site locale instead?

That's a good point, yes, using the site locale does make sense here.

I'd suggest a couple of tweaks, then:

  • Let's call the property siteLocale to help differentiate it from the user locale.
  • We'll want to add a getSiteLocale() selector for convenience.
  • It's worth a link to the existing getLocale() function as we might want to extract/reuse its substitution logic.

@techanvil techanvil assigned nfmohit and unassigned techanvil Feb 7, 2025
@nfmohit nfmohit added the Good First Issue Good first issue for new engineers label Feb 8, 2025
@nfmohit nfmohit assigned techanvil and unassigned nfmohit Feb 8, 2025
@nfmohit
Copy link
Collaborator Author

nfmohit commented Feb 8, 2025

Updated the IB accordingly, thank you @techanvil!

Just a note that I've increased the estimate by a notch as we've specced a new selector and have included the GFI label in this one. Thanks!

@techanvil
Copy link
Collaborator

That's great, thanks @nfmohit. The IB LGTM!

IB ✅

@techanvil techanvil removed their assignment Feb 10, 2025
@ivonac4 ivonac4 removed the Next Up Issues to prioritize for definition label Feb 11, 2025
@ankitrox ankitrox assigned ankitrox and unassigned ankitrox Feb 12, 2025
@benbowler benbowler self-assigned this Feb 13, 2025
@benbowler benbowler removed their assignment Feb 14, 2025
@wpdarren wpdarren self-assigned this Feb 18, 2025
@wpdarren
Copy link
Collaborator

QA Update: ✅

Verified:

  • The "Create Publication" button contains the following query attributes in the URL:
    • prefill_canonical_domain: Its value is the site's URL.
    • prefill_lang: Its value is the site's locale.
    • app_redirect: Its value is rrm.
  1. To test this I changed the sites local to a few different locations/languages and the corrrect prefill_lang appeared.
  2. I also changed the URL in the tester plugin alongside the actual site domain and the correct URL appeared.
  3. When I clicked on the Create publication CTA, a new window opened to the publisher opened and the URL as detailed below appears in the browser.

Examples:

https://accounts.google.com/accountchooser?continue=https%3A%2F%2Fpublishercenter.google.com%3Fprefill_canonical_domain%3Dhttps%253A%252F%252Foi.ie%252F%26prefill_lang%3Dde-DE%26app_redirect%3Drrm%26utm_source%3Dsitekit

https://accounts.google.com/accountchooser?continue=https%3A%2F%2Fpublishercenter.google.com%3Fprefill_canonical_domain%3Dhttps%253A%252F%252Foi.ie%252F%26prefill_lang%3Den-US%26app_redirect%3Drrm%26utm_source%3Dsitekit

Image

@wpdarren wpdarren removed their assignment Feb 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Good First Issue Good first issue for new engineers Module: RRM Reader Revenue Manager module related issues P0 High priority Team M Issues for Squad 2 Type: Enhancement Improvement of an existing feature
Projects
None yet
Development

No branches or pull requests

8 participants