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

[Enhancement]: Allow dropdown options recording for WooCommerce Settings #38035

Merged
merged 3 commits into from May 8, 2023

Conversation

octaedro
Copy link
Contributor

@octaedro octaedro commented Apr 28, 2023

Submission Review Guidelines:

Changes proposed in this Pull Request:

Record events for dropdown menus under WooCommerce Settings.

Closes #37989.

How to test the changes in this Pull Request:

Using the WooCommerce Testing Instructions Guide, include your detailed testing instructions:

  1. Go to WooCommerce > Settings.
  2. Choose a dropdown menu and change it (e.g.: General > Selling location(s) ).
  3. Press Save changes.
  4. Go to WooCommerce > Status > Logs (URL /wp-admin/admin.php?page=wc-status&tab=logs) and select the file that starts with tracks-[date]-[hash].
  5. Look for the event wcadmin_settings_change and verify the option has been recorded. In the case of the example I mentioned, the settings name is woocommerce_allowed_countries.
  6. Please note that some files are not recording Tracks events yet. This fix targets recording dropdowns for settings that are already being saved.

@github-actions github-actions bot added the plugin: woocommerce Issues related to the WooCommerce Core plugin. label Apr 28, 2023
@github-actions
Copy link
Contributor

github-actions bot commented Apr 28, 2023

Test Results Summary

Commit SHA: db314f1

Test 🧪Passed ✅Failed 🚨Broken 🚧Skipped ⏭️Unknown ❔Total 📊Duration ⏱️
API Tests26700202690m 53s
E2E Tests1870010019715m 19s

To view the full API test report, click here.
To view the full E2E test report, click here.
To view all test reports, visit the WooCommerce Test Reports Dashboard.

@octaedro octaedro changed the title Dev/37989 allow dropdown recording for wc settings Modify 'WC_Settings_Tracking' to allow dropdown options recording for WooCommerce Settings Apr 28, 2023
@octaedro octaedro changed the title Modify 'WC_Settings_Tracking' to allow dropdown options recording for WooCommerce Settings [Enhancement]: 'WC_Settings_Tracking' - Allow dropdown options recording for WooCommerce Settings Apr 28, 2023
@octaedro octaedro changed the title [Enhancement]: 'WC_Settings_Tracking' - Allow dropdown options recording for WooCommerce Settings [Enhancement]: Allow dropdown options recording for WooCommerce Settings Apr 28, 2023
@octaedro octaedro self-assigned this Apr 28, 2023
@octaedro octaedro marked this pull request as ready for review April 28, 2023 15:43
@octaedro octaedro requested a review from a team April 28, 2023 15:44
@github-actions
Copy link
Contributor

Hi , @woocommerce/mothra-enhancements

Apart from reviewing the code changes, please make sure to review the testing instructions as well.

You can follow this guide to find out what good testing instructions should look like:
https://github.com/woocommerce/woocommerce/wiki/Writing-high-quality-testing-instructions

Copy link
Contributor

@mattsherman mattsherman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work on this, @octaedro ! Left a few comments just expressing some concern over potential issues if the option names were not valid Tracks event property names (or, if they conflicted), but we can handle that in a future issue (I'll backlog later).

@@ -120,6 +141,12 @@ public function send_settings_change_event() {
}
}

if ( ! empty( $this->modified_options ) ) {
foreach ( $this->modified_options as $option_name => $selected_option ) {
$properties[ $option_name ] = $selected_option ?? '';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a little concerned that we aren't checking if the $option_name conflicts with any built-in/other Tracks event property names. But, we are already not doing this for $toggled_options $state above, and I suppose our options are all going to start with woocommerce_ or wc_, so we are probably okay for now. Something to keep in mind in the future for tracking... we should ideally namespace/prefix these sort of things when we log them to avoid possible collisions.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also a little concerned that we don't do anything to make sure $option_name is a valid Tracks event property name (ensuring use of _ and not -, etc.).

I'll open up a separate issue for us to make this a bit more robust, since this isn't an immediate concern.

Copy link
Contributor

@mattsherman mattsherman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work on this, @octaedro ! Left a few comments just expressing some concern over potential issues if the option names were not valid Tracks event property names (or, if they conflicted), but we can handle that in a future issue (I'll backlog later).

@octaedro octaedro merged commit 7f87c7d into trunk May 8, 2023
16 of 18 checks passed
@octaedro octaedro deleted the dev/37989_allow_dropdown_recording_for_wc_settings branch May 8, 2023 15:04
@github-actions github-actions bot added this to the 7.8.0 milestone May 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
plugin: woocommerce Issues related to the WooCommerce Core plugin.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Enhancement]: Modify 'WC_Settings_Tracking' to allow dropdown options recording for WooCommerce Settings
2 participants