Add tracks event for WCPay install via addons page

This adds a tracks event for WooCommerce Payments installs via the
wc-addons page.
This commit is contained in:
Rasmy Nguyen 2021-02-08 17:29:44 +09:00
parent 68dd901b65
commit 4ad1465fe3
2 changed files with 14 additions and 1 deletions

View File

@ -704,7 +704,9 @@ class WC_Admin_Addons {
'repo-slug' => 'woocommerce-payments', 'repo-slug' => 'woocommerce-payments',
); );
WC_Install::background_installer( $services_plugin_id, $wcpay_plugin ); WC_Install::background_installer( $wcpay_plugin_id, $wcpay_plugin );
do_action( 'wc_addons_woocommerce_payments_installed' );
wp_safe_redirect( remove_query_arg( array( 'install-addon', '_wpnonce' ) ) ); wp_safe_redirect( remove_query_arg( array( 'install-addon', '_wpnonce' ) ) );
exit; exit;

View File

@ -21,6 +21,7 @@ class WC_Extensions_Tracking {
add_action( 'woocommerce_helper_connected', array( $this, 'track_helper_connection_complete' ) ); add_action( 'woocommerce_helper_connected', array( $this, 'track_helper_connection_complete' ) );
add_action( 'woocommerce_helper_disconnected', array( $this, 'track_helper_disconnected' ) ); add_action( 'woocommerce_helper_disconnected', array( $this, 'track_helper_disconnected' ) );
add_action( 'woocommerce_helper_subscriptions_refresh', array( $this, 'track_helper_subscriptions_refresh' ) ); add_action( 'woocommerce_helper_subscriptions_refresh', array( $this, 'track_helper_subscriptions_refresh' ) );
add_action( 'wc_addons_woocommerce_payments_installed', array( $this, 'track_woocommerce_payments_install' ) );
} }
/** /**
@ -76,4 +77,14 @@ class WC_Extensions_Tracking {
public function track_helper_subscriptions_refresh() { public function track_helper_subscriptions_refresh() {
WC_Tracks::record_event( 'extensions_subscriptions_update' ); WC_Tracks::record_event( 'extensions_subscriptions_update' );
} }
/**
* Send a Tracks event when WooCommerce Payments is installed from the Extensions page.
*/
public function track_woocommerce_payments_install() {
$properties = array( 'context' => 'extensions' );
WC_Tracks::record_event( 'woocommerce_payments_install', $properties );
}
} }