Open aaemnnosttv opened 1 week ago
@10upsimon I actually had a similar issue on my Consent Mode refactor issue #8384 today, this is how I fixed it.
IB ✅
@tofumatt @10upsimon @benbowler
- change the logic within the
register_script()
method to instead use theManifest::get()
method, passingself::CONVERSION_EVENT_PROVIDER_SLUG
as the parameter, to obtain the filename
This would work but isn't necessary as Script
already handles the application of the file in the Manifest
automatically. Ultimately, this is the root cause for the issue as you'll notice no assets touch the Manifest
directly yet they all load the right URLs for the build. We simply need to update the event provider scripts to follow the same approach as every other asset rather than treating these as a special case unnecessarily.
Thanks @aaemnnosttv I've simplified this and handed back to you.
- For each of the event providers within the
includes/Core/Conversion_Tracking/Conversion_Event_Providers
folder, change the logic within theregister_script()
method to instead pass just theself::CONVERSION_EVENT_PROVIDER_SLUG
constso as to handle correctManifest
behavior when surfacing the asset URL- Remove the prepended
'gsk-cep-'
string from the handle passed toScript()
, this will ensure correct handling of the Manifest entry in theScript
class.
@10upsimon while this will have the intended outcome as far as loading the script is concerned, it's changing the handle to be generic. E.g. gsk-cep-mailchimp
will become mailchimp
, which as a (global) WP script handle, is not something SK should be using but this might not be obvious due to the abstraction of our Script
; it does not add any kind of namespacing, etc to the given handle. With that said, we should update both the handle and the entry name (key) to reference the same value (according to the AC) since the entry name is what the resulting manifest is keyed by.
Since the entry name also defines the default resulting filename, there's no need to add the prefix to the output
if it's included in the entry name.
IB ✅
WooCommerce
and WPForms
plugin.googlesitekit-events-provider-contact-form-7-$HASH.js
JS files
WPFORMS
Woocommerce
Bug Description
The event provider JS loaded on the front end for its respective supported plugin integration for enhanced conversion tracking does not load when using a production build of Site Kit. It does work on development builds, but not intentionally.
Steps to reproduce
Do not alter or remove anything below. The following sections will be managed by moderators only.
Acceptance criteria
googlesitekit-events-provider-
prefix for consistencyImplementation Brief
webpack/conversionEventProviders.config.js
:entry
object with'googlesitekit-events-provider-'
, i.e'googlesitekit-events-provider-contact-form-7': './assets/js/event-providers/contact-form-7.js',
includes/Core/Conversion_Tracking/Conversion_Event_Providers
folder, undertake the following changes:'gsk-cep-'
string from the handle passed toScript()
with the string value prepended to filenames in the webpack config,'googlesitekit-events-provider-'
. This will ensure correct resolving of the script src by theScript
class, regardless of production or development modes.src
entry of theScript()
args unchanged.Test Coverage
QA Brief
.js
files now load correctly by viewing page source and searching forgooglesitekit-events-provider-contact-form-7-$HASH.js
Changelog entry