Skip to content

Commit

Permalink
Update conversion event providers to load correctly from the manifest…
Browse files Browse the repository at this point in the history
… without manually getting filename.
  • Loading branch information
benbowler committed Jul 4, 2024
1 parent 0fda663 commit fe19720
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 51 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

namespace Google\Site_Kit\Core\Conversion_Tracking\Conversion_Event_Providers;

use Google\Site_Kit\Core\Assets\Manifest;
use Google\Site_Kit\Core\Assets\Script;
use Google\Site_Kit\Core\Conversion_Tracking\Conversion_Events_Provider;

Expand Down Expand Up @@ -55,11 +54,10 @@ public function get_event_names() {
* @return Script Script instance.
*/
public function register_script() {
list( $filename ) = Manifest::get( self::CONVERSION_EVENT_PROVIDER_SLUG );
$script = new Script(
'gsk-cep-' . self::CONVERSION_EVENT_PROVIDER_SLUG,
$script = new Script(
'googlesitekit-events-provider-' . self::CONVERSION_EVENT_PROVIDER_SLUG,
array(
'src' => $this->context->url( 'dist/assets/js/' . $filename ),
'src' => $this->context->url( 'dist/assets/js/contact-form-7.js' ),
'execution' => 'defer',
)
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

namespace Google\Site_Kit\Core\Conversion_Tracking\Conversion_Event_Providers;

use Google\Site_Kit\Core\Assets\Manifest;
use Google\Site_Kit\Core\Assets\Script;
use Google\Site_Kit\Core\Conversion_Tracking\Conversion_Events_Provider;

Expand Down Expand Up @@ -55,11 +54,10 @@ public function get_event_names() {
* @return Script Script instance.
*/
public function register_script() {
list( $filename ) = Manifest::get( self::CONVERSION_EVENT_PROVIDER_SLUG );
$script = new Script(
'gsk-cep-' . self::CONVERSION_EVENT_PROVIDER_SLUG,
$script = new Script(
'googlesitekit-events-provider-' . self::CONVERSION_EVENT_PROVIDER_SLUG,
array(
'src' => $this->context->url( 'dist/assets/js/' . $filename ),
'src' => $this->context->url( 'dist/assets/js/easy-digital-downloads.js' ),
'execution' => 'defer',
'dependencies' => array( 'edd-ajax' ),
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

namespace Google\Site_Kit\Core\Conversion_Tracking\Conversion_Event_Providers;

use Google\Site_Kit\Core\Assets\Manifest;
use Google\Site_Kit\Core\Assets\Script;
use Google\Site_Kit\Core\Conversion_Tracking\Conversion_Events_Provider;

Expand Down Expand Up @@ -55,11 +54,10 @@ public function get_event_names() {
* @return Script Script instance.
*/
public function register_script() {
list( $filename ) = Manifest::get( self::CONVERSION_EVENT_PROVIDER_SLUG );
$script = new Script(
'gsk-cep-' . self::CONVERSION_EVENT_PROVIDER_SLUG,
$script = new Script(
'googlesitekit-events-provider-' . self::CONVERSION_EVENT_PROVIDER_SLUG,
array(
'src' => $this->context->url( 'dist/assets/js/' . $filename ),
'src' => $this->context->url( 'dist/assets/js/mailchimp.js' ),
'execution' => 'defer',
'dependencies' => array( 'mc4wp-forms-api' ),
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

namespace Google\Site_Kit\Core\Conversion_Tracking\Conversion_Event_Providers;

use Google\Site_Kit\Core\Assets\Manifest;
use Google\Site_Kit\Core\Assets\Script;
use Google\Site_Kit\Core\Conversion_Tracking\Conversion_Events_Provider;

Expand Down Expand Up @@ -55,11 +54,10 @@ public function get_event_names() {
* @return Script Script instance.
*/
public function register_script() {
list( $filename ) = Manifest::get( self::CONVERSION_EVENT_PROVIDER_SLUG );
$script = new Script(
'gsk-cep-' . self::CONVERSION_EVENT_PROVIDER_SLUG,
$script = new Script(
'googlesitekit-events-provider-' . self::CONVERSION_EVENT_PROVIDER_SLUG,
array(
'src' => $this->context->url( 'dist/assets/js/' . $filename ),
'src' => $this->context->url( 'dist/assets/js/ninja-forms.js' ),
'execution' => 'defer',
'dependencies' => array( 'nf-front-end-deps' ),
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

namespace Google\Site_Kit\Core\Conversion_Tracking\Conversion_Event_Providers;

use Google\Site_Kit\Core\Assets\Manifest;
use Google\Site_Kit\Core\Assets\Script;
use Google\Site_Kit\Core\Conversion_Tracking\Conversion_Events_Provider;

Expand Down Expand Up @@ -55,11 +54,10 @@ public function get_event_names() {
* @return Script Script instance.
*/
public function register_script() {
list( $filename ) = Manifest::get( self::CONVERSION_EVENT_PROVIDER_SLUG );
$script = new Script(
'gsk-cep-' . self::CONVERSION_EVENT_PROVIDER_SLUG,
$script = new Script(
'googlesitekit-events-provider-' . self::CONVERSION_EVENT_PROVIDER_SLUG,
array(
'src' => $this->context->url( 'dist/assets/js/' . $filename ),
'src' => $this->context->url( 'dist/assets/js/optin-monster.js' ),
'execution' => 'defer',
)
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

namespace Google\Site_Kit\Core\Conversion_Tracking\Conversion_Event_Providers;

use Google\Site_Kit\Core\Assets\Manifest;
use Google\Site_Kit\Core\Assets\Script;
use Google\Site_Kit\Core\Conversion_Tracking\Conversion_Events_Provider;

Expand Down Expand Up @@ -55,11 +54,10 @@ public function get_event_names() {
* @return Script Script instance.
*/
public function register_script() {
list( $filename ) = Manifest::get( self::CONVERSION_EVENT_PROVIDER_SLUG );
$script = new Script(
'gsk-cep-' . self::CONVERSION_EVENT_PROVIDER_SLUG,
$script = new Script(
'googlesitekit-events-provider-' . self::CONVERSION_EVENT_PROVIDER_SLUG,
array(
'src' => $this->context->url( 'dist/assets/js/' . $filename ),
'src' => $this->context->url( 'dist/assets/js/popup-maker.js' ),
'dependencies' => array( 'popup-maker-site' ),
'execution' => 'defer',
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

namespace Google\Site_Kit\Core\Conversion_Tracking\Conversion_Event_Providers;

use Google\Site_Kit\Core\Assets\Manifest;
use Google\Site_Kit\Core\Assets\Script;
use Google\Site_Kit\Core\Conversion_Tracking\Conversion_Events_Provider;

Expand Down Expand Up @@ -55,11 +54,10 @@ public function get_event_names() {
* @return Script Script instance.
*/
public function register_script() {
list( $filename ) = Manifest::get( self::CONVERSION_EVENT_PROVIDER_SLUG );
$script = new Script(
'gsk-cep-' . self::CONVERSION_EVENT_PROVIDER_SLUG,
$script = new Script(
'googlesitekit-events-provider-' . self::CONVERSION_EVENT_PROVIDER_SLUG,
array(
'src' => $this->context->url( 'dist/assets/js/' . $filename ),
'src' => $this->context->url( 'dist/assets/js/wpforms.js' ),
'execution' => 'defer',
)
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

namespace Google\Site_Kit\Core\Conversion_Tracking\Conversion_Event_Providers;

use Google\Site_Kit\Core\Assets\Manifest;
use Google\Site_Kit\Core\Assets\Script;
use Google\Site_Kit\Core\Conversion_Tracking\Conversion_Events_Provider;
use Google\Site_Kit\Core\Util\BC_Functions;
Expand Down Expand Up @@ -56,11 +55,10 @@ public function get_event_names() {
* @return Script Script instance.
*/
public function register_script() {
list( $filename ) = Manifest::get( self::CONVERSION_EVENT_PROVIDER_SLUG );
$script = new Script(
'gsk-cep-' . self::CONVERSION_EVENT_PROVIDER_SLUG,
$script = new Script(
'googlesitekit-events-provider-' . self::CONVERSION_EVENT_PROVIDER_SLUG,
array(
'src' => $this->context->url( 'dist/assets/js/' . $filename ),
'src' => $this->context->url( 'dist/assets/js/woocommerce.js' ),
'execution' => 'defer',
'dependencies' => array( 'woocommerce' ),
)
Expand Down
27 changes: 16 additions & 11 deletions webpack/conversionEventProviders.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,22 +35,27 @@ const {

module.exports = ( mode ) => ( {
entry: {
'contact-form-7': './assets/js/event-providers/contact-form-7.js',
'easy-digital-downloads':
'googlesitekit-events-provider-contact-form-7':
'./assets/js/event-providers/contact-form-7.js',
'googlesitekit-events-provider-easy-digital-downloads':
'./assets/js/event-providers/easy-digital-downloads.js',
mailchimp: './assets/js/event-providers/mailchimp.js',
'ninja-forms': './assets/js/event-providers/ninja-forms.js',
'optin-monster': './assets/js/event-providers/optin-monster.js',
'popup-maker': './assets/js/event-providers/popup-maker.js',
woocommerce: './assets/js/event-providers/woocommerce.js',
wpforms: './assets/js/event-providers/wpforms.js',
'googlesitekit-events-provider-mailchimp':
'./assets/js/event-providers/mailchimp.js',
'googlesitekit-events-provider-ninja-forms':
'./assets/js/event-providers/ninja-forms.js',
'googlesitekit-events-provider-optin-monster':
'./assets/js/event-providers/optin-monster.js',
'googlesitekit-events-provider-popup-maker':
'./assets/js/event-providers/popup-maker.js',
'googlesitekit-events-provider-woocommerce':
'./assets/js/event-providers/woocommerce.js',
'googlesitekit-events-provider-wpforms':
'./assets/js/event-providers/wpforms.js',
},
externals,
output: {
filename:
mode === 'production'
? 'googlesitekit-events-provider-[name]-[contenthash].js'
: 'googlesitekit-events-provider-[name].js',
mode === 'production' ? '[name]-[contenthash].js' : '[name].js',
path: rootDir + '/dist/assets/js',
publicPath: '',
},
Expand Down

0 comments on commit fe19720

Please sign in to comment.