From d99cdbff0ce5ef5eef771be6988a668d643dd6e0 Mon Sep 17 00:00:00 2001 From: Fernando Espinosa Date: Fri, 12 Jul 2024 06:22:19 +0200 Subject: [PATCH] Add missing tracking data for the migration process (#2765) * Update tracking data when the migration is completed * Move plugin entry deactivated message to WooCommerce Shipping * Add missing imports for tracks in a static method --- woocommerce-services.php | 41 ++++++++++++++++------------------------ 1 file changed, 16 insertions(+), 25 deletions(-) diff --git a/woocommerce-services.php b/woocommerce-services.php index c1a5b661f..5c08c8745 100644 --- a/woocommerce-services.php +++ b/woocommerce-services.php @@ -263,11 +263,26 @@ 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' ); 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 ) { + $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, + 'updated' => $result, + ) + ); + } } } @@ -1560,30 +1575,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 */