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

Add missing tracking data for the migration process #2765

Merged
merged 3 commits into from
Jul 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 16 additions & 26 deletions woocommerce-services.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
);
}
}
}

Expand Down Expand Up @@ -921,7 +936,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();
Expand Down Expand Up @@ -1531,30 +1545,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(
'<style>
.plugins tr[data-slug="woocommerce-services"] td, .plugins tr[data-slug="woocommerce-services"] th { box-shadow: none; }
</style>
<tr class="plugin-update-tr active update">
<td colspan="4" class="plugin-update colspanchange">
<div class="notice inline notice-warning" style="border:0; border-left: 5px solid #4AB866; padding: 12px; background-color: #EFF9F1;">
<p>%s</p>
</div>
</td>
</tr>',
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.<br />For support, please <a href="https://woocommerce.com/my-account/create-a-ticket/">contact our Happiness Engineers</a>.', 'woocommerce-services' ) )
);
}
}

/**
* Registers the React UI bundle
*/
Expand Down
Loading