-
Notifications
You must be signed in to change notification settings - Fork 69
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
Implement JS Build (ES6) and JS Lint #261
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the work.
Unfortunately, I was hardly able to complete the test.
Found some critical issues:
- The
assets/js/src/ga-integration.js
script is not loaded to the page. And even if after fixing the loading issue, the "google_analytics_integration_product_data is not defined" errors will occur. - All the event tracking in
assets/js/src/actions.js
are not fired since the mismatched hook names. Further, even if fix the hook names, "Cannot read properties of undefined (reading 'price')" errors will occur when calling thetrackAddToCart
function. - The event tracking in WC Blocks has changed quite a lot, for example, the number of events has increased from 4 to 16. Does it need to sync the subsequent changes?
Other issues that are also worth noting:
- Some project configurations could be omitted or enhanced.
- Two scripts'
$deps
array is not set properly.
@@ -377,7 +377,7 @@ public function load_admin_assets() { | |||
return; | |||
} | |||
|
|||
wp_enqueue_script( 'wc-google-analytics-admin-enhanced-settings', plugins_url( '/assets/js/admin-ga-settings.js', dirname( __FILE__ ) ), array(), WC_GOOGLE_ANALYTICS_INTEGRATION_VERSION, true ); | |||
wp_enqueue_script( 'wc-google-analytics-admin-enhanced-settings', plugins_url( '/assets/js/build/admin-ga-settings.js', dirname( __FILE__ ) ), array(), WC_GOOGLE_ANALYTICS_INTEGRATION_VERSION, true ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is an original issue but maybe consider fixing it by the way.
The admin-ga-settings.js script depends on jQuery
so it should have 'jquery' handle in the $deps
array.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be resolved here f3e783b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Plugin::get_instance()->get_js_asset_dependencies( 'admin-ga-settings' )
returns an empty array. The 'jquery' handle is still missing.
Co-authored-by: Eason <[email protected]>
Howdy @eason9487 first of all, thanks for the amazing review as always. I patched all of your findings. Still need to test deeper to see everything is working find. But I think at least we can have another round to check most of the issues :)
Oh, I see. Maybe we can keep this one like it is (with the reduced amount) without merge and make those in a future PR if thats ok. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The event tracking in WC Blocks has changed quite a lot, for example, the number of events has increased from 4 to 16. Does it need to sync the subsequent changes?
Oh, I see. Maybe we can keep this one like it is (with the reduced amount) without merge and make those in a future PR if thats ok.
Keeping it as it's would be OK but I guess it would need a feature flag to skip the wp_enqueue_script
call by default for the actions.js file, or even remove the whole wp_enqueue_script
call for now. So that it won't lead to duplicate event tracking with WC Blocks.
@@ -377,7 +377,7 @@ public function load_admin_assets() { | |||
return; | |||
} | |||
|
|||
wp_enqueue_script( 'wc-google-analytics-admin-enhanced-settings', plugins_url( '/assets/js/admin-ga-settings.js', dirname( __FILE__ ) ), array(), WC_GOOGLE_ANALYTICS_INTEGRATION_VERSION, true ); | |||
wp_enqueue_script( 'wc-google-analytics-admin-enhanced-settings', plugins_url( '/assets/js/build/admin-ga-settings.js', dirname( __FILE__ ) ), array(), WC_GOOGLE_ANALYTICS_INTEGRATION_VERSION, true ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Plugin::get_instance()->get_js_asset_dependencies( 'admin-ga-settings' )
returns an empty array. The 'jquery' handle is still missing.
I created the feature |
Howdy @eason, I added new patches and some question in regards your comment here #261 (comment) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the further adjustment. LGTM.
Changes proposed in this Pull Request:
Closes part of #227 .
This PR implements the next major changes.
assets/js/src
and the build inassets/js/build
assets/js/src
to be included in archived zip fileChecks:
Screenshots:
Detailed test instructions:
npm i
npm run start
ga-integration.js
filega-admin-settings.js
file and they work correctly without errors.assets/js/src
and add a random console.lognpm run archive
asset/js/src
but yesasset/js/build
Additional details:
Changelog entry