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

Create New Ads Module Datastore Partial for Plugin Detection Selectors #10170

Open
26 tasks
10upsimon opened this issue Feb 5, 2025 · 2 comments
Open
26 tasks
Assignees
Labels
javascript Pull requests that update Javascript code Module: Ads Google Ads module related issues Team S Issues for Squad 1 Type: Enhancement Improvement of an existing feature

Comments

@10upsimon
Copy link
Collaborator

10upsimon commented Feb 5, 2025

Feature Description

With the integration of plugin detection logic and surfacing said data in the Ads module inline/base data (see #10169), an extension of the existing Ads module moduleData.js datastore partial is required, with the addition of specific selectors that return responses based on the shape of said newly added plugins Ads module base/inline data. This update should also include the plugins object in the initial state.

In addition to this, a new datastore partial (say woocommerce.js) should also be created to hold specific selectors relative to whether the modal should be shown or not, and to retrieve the WooCommerce redirect URI based on the current scenario (which will use selectors form the extension to moduleData,.js). This datastore partial will not maintain any state, and will merely make use of the selectors from the above datastore extension, as well as navigation selectors from the CORE_SITE store, such as getAdminURL().

The following selectors (and their accompanying logic patterns) should be added to the existing moduleData.js partial:

  • isWooCommerceInstalled()
    • A boolean value depicting whether WooCommerce is installed or not.
  • isWooCommerceActive()
    • A boolean value depicting whether WooCommerce is active or not.
  • isGoogleForWooCommerceInstalled()
    • A boolean value depicting whether Google for WooCommerce plugin is installed or not.
  • isGoogleForWooCommerceActive()
    • A boolean value depicting whether Google for WooCommerce is active or not.
  • hasGoogleForWooCommerceAdsAccount()
    • A boolean value depicting whether an existing Ads account is linked via Google for WooCommerce.

The following selectors (and their accompanying logic patterns) should be added to the new woocommerce.js partial:

  • shouldShowWooCommerceRedirectModal()
    • A boolean value depicting whether the WooCommerce redirect modal should be triggered, useful for triggering the modal from various CTA's such as the Ads module setup CTA banner and Connect more services areas.
  • getGoogleForWooCommerceRedirectURI()
    • A string URI value (or undefined) of where to send the user to. This selector should use the getAdminURL() selector from the CORE_SITE datastore.

For more information, see the Datastore Setup sub heading of the design document.


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

Acceptance criteria

  • Following selector should be added to fetch new Ads inline module data from _googlesitekitModulesData (added in Add Plugin Detection Logic to Ads Module Backend Infrastructure #10169) and combine the returned values:
    • Selector which returns a boolean value for whether WooCommerce is installed or not.
    • Selector which returns a boolean value for whether WooCommerce is active or not.
    • Selector which returns a boolean value for whether Google for WooCommerce is installed or not.
    • Selector which returns a boolean value for whether Google for WooCommerce is active or not.
    • Selector which returns a boolean value for whether an Ads account is detected as linked to Google for WooCommerce.
    • Selector which should return a boolean state based on whether WooCommerce is installed and no existing Google for WooCommerce ads account is detected.
    • Selector which should return the applicable URI based on the WooCommerce scenarios, as defined in the design doc.
  • See actions and selectors section in the design doc
  • Rename assets/js/modules/ads/datastore/moduleData.js datastore file to use kebab case - assets/js/modules/ads/datastore/module-data.js

Implementation Brief

EDIT: Since we will need this data before Ads module is active/connected, we moved the selectors to the core site datastore

  • Within the existing moduleData.js datastore partial at assets/js/modules/ads/datastore/moduleData.js:
  • In assets/js/googlesitekit/datastore/site/info.js
    • Rename the file to module-data.js and update it's references in other files where used
    • [ ] Update the initialState const to include the woocommerce and google-listings-and-ads objects from base data, default to undefined
    • Update RECEIVE_MODULE_DATA in the reducer to extract and pass new objects (woocommerce and google-listings-and-ads)
    • Add getWooCommercePluginStatus and getGoogleForWooCommercePluginStatus selectors, similar to how other selectors are added, invoke getSiteInfoProperty function and pass woocommerce and google-listings-and-ads respectively as arguments
  • Create a new datastore partial at assets/js/modules/ads/datastore/woocommerce.js assets/js/googlesitekit/datastore/site/plugin-status.js. Add following selectors:
    • isWooCommerceActive, which returns the boolean value of the active property obtained from getWooCommercePluginStatus selector
    • isGoogleForWooCommercePresent which returns boolean value from installed property of getGoogleForWooCommercePluginStatus selector value
    • isGoogleForWooCommerceActive, which checks boolean value of active property returned from same selector as above
    • isGoogleForWooCommerceAdsAccountLinked, which checks boolean value of adsConnected property from same selector as previously used
    • shouldShowWooCommerceRedirectModal
      • Calls the isWooCommerceActive, isGoogleForWooCommerceActive and isGoogleForWooCommerceAdsAccountLinked selectors and stores the results against applicable constants.
      • Returns true in the following conditions:
        • The result of isWooCommerceActive is true but the result of isGoogleForWooCommerceActive is false
        • The results of isWooCommerceActive is true and the result of isGoogleForWooCommerceActive is true, but the result of isGoogleForWooCommerceAdsAccountLinked is false
        • Returns false otherwise
    • getGoogleForWooCommerceRedirectURI
      • Gets the admin URL via select(CORE_SITE).getAdminURL() and references said value
      • Returns a string URI identifier based on the following conditions:
        • The result of isWooCommerceActive is true but the result of isGoogleForWooCommerceActive is false:
          • Returns ${ adminURL }/plugin-install.php?s=google-listings-and-ads&tab=search&type=term
        • The results of isWooCommerceActive is true and the result of isGoogleForWooCommerceActive is true, but the result of isGoogleForWooCommerceAdsAccountLinked is false:
          • Returns ${ adminURL }/admin.php?page=wc-admin&path=%2Fgoogle%2Fdashboard
        • The results of isWooCommerceActive is true, the result of isGoogleForWooCommerceActive is also true, and the result of isGoogleForWooCommerceAdsAccountLinked is true:
          • Returns ${ adminURL }/admin.php?page=wc-admin&path=%2Fgoogle%2Fdashboard

Test Coverage

  • Update the test suite at assets/js/modules/ads/datastore/moduleData.test.js assets/js/googlesitekit/datastore/site/info.test.js and add tests cases for the newly added selectors, updating the mocked base data assigned to the baseData const.
  • Create a new test suite at assets/js/modules/ads/datastore/woocommerce.test.js assets/js/googlesitekit/datastore/site/plugin-status.test.js that tests the new selectors.

QA Brief

Changelog entry

@10upsimon 10upsimon added javascript Pull requests that update Javascript code Module: Ads Google Ads module related issues Team S Issues for Squad 1 Type: Enhancement Improvement of an existing feature labels Feb 5, 2025
@10upsimon 10upsimon self-assigned this Feb 5, 2025
@10upsimon 10upsimon changed the title Create New Ads Module Datastore Partial for Plugin Detection Selectors (WC Redirect) Create New Ads Module Datastore Partial for Plugin Detection Selectors Feb 5, 2025
@10upsimon 10upsimon assigned zutigrm and unassigned 10upsimon Feb 7, 2025
@zutigrm
Copy link
Collaborator

zutigrm commented Feb 7, 2025

Thanks @10upsimon , I updated the AC to make it more simple, and avoid more detailed parts that would be falling under IB territory.

AC ✅

@zutigrm zutigrm removed their assignment Feb 7, 2025
@10upsimon 10upsimon assigned 10upsimon and zutigrm and unassigned 10upsimon Feb 7, 2025
@zutigrm
Copy link
Collaborator

zutigrm commented Feb 7, 2025

Thanks @10upsimon I simplified the inline data selectors a bit and aligned AC further so it is not explicit as where new woo selectors should be added

IB ✅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
javascript Pull requests that update Javascript code Module: Ads Google Ads module related issues Team S Issues for Squad 1 Type: Enhancement Improvement of an existing feature
Projects
None yet
Development

No branches or pull requests

2 participants