Feature Description
Starting in #10165 it was proposed to refactor several methods that hook into the googlesitekit_inline_modules_data filter, so they are consolidated into a single method get_inline_data that will return all data in the single method.
For consistency, we should do this in all modules, and preferably enforce this as with an interface. We can create Module_With_Inline_data interface that will force adding get_inline_data method, and new trait Module_With_Inline_Data_Trait that will include register_inline_data method, which will hook into the googlesitekit_inline_modules_data filter and invoke get_inline_data method.
We can then refactor all modules to use this new interface and trait, and it should be used in all new modules that are created in the future.
Do not alter or remove anything below. The following sections will be managed by moderators only.
Acceptance criteria
- New interface
Module_With_Inline_Data is introduced to enforce the presence of a unified method on any module that provides inline data.
- New trait
Module_With_Inline_Data_Trait is introduced to include a registration method - which will hook into the googlesitekit_inline_modules_data and use the interface enforced method as a callback
- Existing modules with inline data should be refactored to use the interface and trait for consistency.
Implementation Brief
Test Coverage
- Update tests for updated modules to adapt the new method name usage
QA Brief (QA:ENG)
- Set up Site Kit with Analytics and Ads enabled.
- Go to the Site Kit page.
- Type
_googlesitekitModulesData in the console.
- The object should have an
ads key, whose value is an object containing:
supportedConversionEvents: an array of supported conversion events.
- As a sanity check, install WooCommerce. This array should contain WooCommerce-related events (
add-to-cart, purchase).
- The object should have an
analytics-4 key, whose value is an object containing:
customDimensionsDataAvailable
resourceAvailabilityDates
tagIDMismatch
newEvents
lostEvents
newBadgeEvents
- Without setting up Sign In With Google, the object should not have
sign-in-with-google.
- After setting up Sign In With Google, the object should have the
sign-in-with-google key, whose value is an object containing:
isWooCommerceActive
isWooCommerceRegistrationEnabled
Changelog entry
Feature Description
Starting in #10165 it was proposed to refactor several methods that hook into the
googlesitekit_inline_modules_datafilter, so they are consolidated into a single methodget_inline_datathat will return all data in the single method.For consistency, we should do this in all modules, and preferably enforce this as with an interface. We can create
Module_With_Inline_datainterface that will force addingget_inline_datamethod, and new traitModule_With_Inline_Data_Traitthat will includeregister_inline_datamethod, which will hook into thegooglesitekit_inline_modules_datafilter and invokeget_inline_datamethod.We can then refactor all modules to use this new interface and trait, and it should be used in all new modules that are created in the future.
Do not alter or remove anything below. The following sections will be managed by moderators only.
Acceptance criteria
Module_With_Inline_Datais introduced to enforce the presence of a unified method on any module that provides inline data.Module_With_Inline_Data_Traitis introduced to include a registration method - which will hook into thegooglesitekit_inline_modules_dataand use the interface enforced method as a callbackImplementation Brief
includes/Core/Modules/Module_With_Inline_Data.phpget_inline_datamethod which should return an arrayincludes/Core/Modules/Module_With_Inline_Data_Trait.phpregister_inline_datamethod which hooks into thegooglesitekit_inline_modules_dataand usesget_inline_dataas a callbackincludes/Modules/Analytics_4.phpincludes/Modules/Ads.phpincludes/Modules/Sign_In_With_Google.phpModule_With_Inline_Datainterface and useModule_With_Inline_Data_Traittraitgooglesitekit_inline_modules_datahook to use new methodget_inline_dataregistermethod, invokeregister_inline_dataTest Coverage
QA Brief (QA:ENG)
_googlesitekitModulesDatain the console.adskey, whose value is an object containing:supportedConversionEvents: an array of supported conversion events.add-to-cart,purchase).analytics-4key, whose value is an object containing:customDimensionsDataAvailableresourceAvailabilityDatestagIDMismatchnewEventslostEventsnewBadgeEventssign-in-with-google.sign-in-with-googlekey, whose value is an object containing:isWooCommerceActiveisWooCommerceRegistrationEnabledChangelog entry