Add tracking for theme activation so that we can track active block themes in WooCommerce

This commit is contained in:
Tom Cafferkey 2022-03-03 10:55:00 +00:00 committed by Jorge A. Torres
parent e767d9f220
commit 1c01cc1605
2 changed files with 39 additions and 0 deletions

View File

@ -161,6 +161,7 @@ class WC_Site_Tracking {
include_once WC_ABSPATH . 'includes/tracks/events/class-wc-coupons-tracking.php';
include_once WC_ABSPATH . 'includes/tracks/events/class-wc-order-tracking.php';
include_once WC_ABSPATH . 'includes/tracks/events/class-wc-coupon-tracking.php';
include_once WC_ABSPATH . 'includes/tracks/events/class-wc-theme-tracking.php';
$tracking_classes = array(
'WC_Extensions_Tracking',
@ -172,6 +173,7 @@ class WC_Site_Tracking {
'WC_Coupons_Tracking',
'WC_Order_Tracking',
'WC_Coupon_Tracking',
'WC_Theme_Tracking',
);
foreach ( $tracking_classes as $tracking_class ) {

View File

@ -0,0 +1,37 @@
<?php
/**
* WooCommerce Theme Tracking
*
* @package WooCommerce\Tracks
*/
defined( 'ABSPATH' ) || exit;
/**
* This class adds actions to track usage of a WooCommerce Order.
*/
class WC_Theme_Tracking {
/**
* Init tracking.
*/
public function init() {
add_action( 'switch_theme', array( $this, 'track_theme_activated' ) );
}
/**
* Send a Tracks event when a theme is activated so that we can track active block themes.
*/
public function track_theme_activated() {
if ( ! function_exists( 'wc_current_theme_is_fse_theme' ) ) {
return;
}
$properties = array(
'block_theme' => wc_current_theme_is_fse_theme(),
);
WC_Tracks::record_event( 'theme_activated', $properties );
}
}