From 7b9b2fff6b94892361cb0f219c1a8a0e03711393 Mon Sep 17 00:00:00 2001 From: Fernando Espinosa Date: Thu, 11 Jul 2024 11:21:34 +0200 Subject: [PATCH 1/3] Update tracking data when the migration is completed --- woocommerce-services.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/woocommerce-services.php b/woocommerce-services.php index a59b7f3d5..f6d337059 100644 --- a/woocommerce-services.php +++ b/woocommerce-services.php @@ -267,7 +267,17 @@ public static function plugin_deactivation() { $migration_state = get_option( 'wcshipping_migration_state' ); if ( ! $migration_state || intval( $migration_state ) !== WC_Connect_WCST_To_WCShipping_Migration_State_Enum::COMPLETED ) { - update_option( 'wcshipping_migration_state', WC_Connect_WCST_To_WCShipping_Migration_State_Enum::COMPLETED ); + $result = update_option( 'wcshipping_migration_state', WC_Connect_WCST_To_WCShipping_Migration_State_Enum::COMPLETED ); + + if ( $result ) { + $this->tracks->record_user_event( + 'migration_flag_state_update', + array( + 'migration_state' => $migration_state, + 'updated' => $result, + ) + ); + } } } From b29ee7c03c30e92420a258e2bc2fe98443b33564 Mon Sep 17 00:00:00 2001 From: Fernando Espinosa Date: Thu, 11 Jul 2024 11:22:15 +0200 Subject: [PATCH 2/3] Move plugin entry deactivated message to WooCommerce Shipping --- woocommerce-services.php | 25 ------------------------- 1 file changed, 25 deletions(-) diff --git a/woocommerce-services.php b/woocommerce-services.php index f6d337059..80e012030 100644 --- a/woocommerce-services.php +++ b/woocommerce-services.php @@ -931,7 +931,6 @@ public function attach_hooks() { add_action( 'woocommerce_checkout_order_processed', array( $this, 'track_completed_order' ), 10, 3 ); add_action( 'admin_print_footer_scripts', array( $this, 'add_sift_js_tracker' ) ); add_action( 'current_screen', array( $this, 'edit_orders_page_actions' ) ); - add_action( 'after_plugin_row_woocommerce-services/woocommerce-services.php', array( $this, 'add_custom_message_to_plugin_list' ), 10, 2 ); $tracks = $this->get_tracks(); $tracks->init(); @@ -1541,30 +1540,6 @@ public function edit_orders_page_actions() { } } - /** - * Add a "deactivated" message to the plugin list table for WooCommerce Shipping & Tax - * - * @param string $plugin_file - * @param array $plugin_data - */ - public function add_custom_message_to_plugin_list() { - if ( false ) { - printf( - ' - - -
-

%s

-
- - ', - wp_kses_post( __( 'WooCommerce Shipping & Tax has been deactivated. Your data and settings have been carried over to the dedicated WooCommerce Shipping and WooCommerce Tax extensions.
For support, please contact our Happiness Engineers.', 'woocommerce-services' ) ) - ); - } - } - /** * Registers the React UI bundle */ From 2c42ed4706ea47083d55d29f0da29afcdf3e75b6 Mon Sep 17 00:00:00 2001 From: Fernando Espinosa Date: Thu, 11 Jul 2024 16:08:25 +0200 Subject: [PATCH 3/3] Add missing imports for tracks in a static method --- woocommerce-services.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/woocommerce-services.php b/woocommerce-services.php index 80e012030..1e84e2d2c 100644 --- a/woocommerce-services.php +++ b/woocommerce-services.php @@ -263,6 +263,8 @@ public static function plugin_deactivation() { * When we deactivate the plugin after wcshipping_migration_state has started, * that means the migration is done. We can mark it as completed before we deactivate the plugin. */ + require_once __DIR__ . '/classes/class-wc-connect-logger.php'; + require_once __DIR__ . '/classes/class-wc-connect-tracks.php'; require_once __DIR__ . '/classes/class-wc-connect-wcst-to-wcshipping-migration-state-enum.php'; $migration_state = get_option( 'wcshipping_migration_state' ); @@ -270,7 +272,10 @@ public static function plugin_deactivation() { $result = update_option( 'wcshipping_migration_state', WC_Connect_WCST_To_WCShipping_Migration_State_Enum::COMPLETED ); if ( $result ) { - $this->tracks->record_user_event( + $core_logger = new WC_Logger(); + $logger = new WC_Connect_Logger( $core_logger ); + $tracks = new WC_Connect_Tracks( $logger, __FILE__ ); + $tracks->record_user_event( 'migration_flag_state_update', array( 'migration_state' => $migration_state,