Tracks: Status page events
This commit is contained in:
parent
d69f014807
commit
2d244a8047
|
@ -108,6 +108,7 @@ class WC_Site_Tracking {
|
|||
include_once WC_ABSPATH . 'includes/tracks/events/class-wc-products-tracking.php';
|
||||
include_once WC_ABSPATH . 'includes/tracks/events/class-wc-orders-tracking.php';
|
||||
include_once WC_ABSPATH . 'includes/tracks/events/class-wc-settings-tracking.php';
|
||||
include_once WC_ABSPATH . 'includes/tracks/events/class-wc-status-tracking.php';
|
||||
|
||||
$tracking_classes = array(
|
||||
'WC_Admin_Setup_Wizard_Tracking',
|
||||
|
@ -116,6 +117,7 @@ class WC_Site_Tracking {
|
|||
'WC_Products_Tracking',
|
||||
'WC_Orders_Tracking',
|
||||
'WC_Settings_Tracking',
|
||||
'WC_Status_Tracking',
|
||||
);
|
||||
|
||||
foreach ( $tracking_classes as $tracking_class ) {
|
||||
|
|
|
@ -0,0 +1,48 @@
|
|||
<?php
|
||||
/**
|
||||
* WooCommerce Status Tracking
|
||||
*
|
||||
* @package WooCommerce\Tracks
|
||||
*/
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
* This class adds actions to track usage of WooCommerce Orders.
|
||||
*/
|
||||
class WC_Status_Tracking {
|
||||
/**
|
||||
* Init tracking.
|
||||
*/
|
||||
public function init() {
|
||||
add_action( 'admin_init', array( $this, 'track_status_view' ), 10 );
|
||||
}
|
||||
|
||||
/**
|
||||
* Add Tracks events to the status page.
|
||||
*/
|
||||
public function track_status_view() {
|
||||
if ( isset( $_GET['page'] ) && 'wc-status' === sanitize_text_field( wp_unslash( $_GET['page'] ) ) ) {
|
||||
|
||||
$tab = isset( $_GET['tab'] ) ? sanitize_text_field( wp_unslash( $_GET['tab'] ) ) : 'status';
|
||||
|
||||
WC_Tracks::record_event(
|
||||
'status_view',
|
||||
array(
|
||||
'tab' => $tab,
|
||||
'tool_used' => isset( $_GET['action'] ) ? sanitize_text_field( wp_unslash( $_GET['action'] ) ) : null,
|
||||
)
|
||||
);
|
||||
|
||||
if ( 'status' === $tab ) {
|
||||
wc_enqueue_js(
|
||||
"
|
||||
$( 'a.debug-report' ).click( function() {
|
||||
window.wcTracks.recordEvent( 'status_view_reports' );
|
||||
} );
|
||||
"
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue