class-wc-admin-setup-wizard-tracking.php
5 years ago
class-wc-coupon-tracking.php
6 years ago
class-wc-coupons-tracking.php
7 months ago
class-wc-extensions-tracking.php
1 year ago
class-wc-importer-tracking.php
3 years ago
class-wc-order-tracking.php
6 years ago
class-wc-orders-tracking.php
1 year ago
class-wc-product-collection-block-tracking.php
7 months ago
class-wc-products-tracking.php
1 month ago
class-wc-settings-tracking.php
11 months ago
class-wc-status-tracking.php
7 months ago
class-wc-theme-tracking.php
1 year ago
class-wc-status-tracking.php
61 lines
| 1 | <?php |
| 2 | /** |
| 3 | * WooCommerce Status Tracking |
| 4 | * |
| 5 | * @package WooCommerce\Tracks |
| 6 | */ |
| 7 | |
| 8 | defined( 'ABSPATH' ) || exit; |
| 9 | |
| 10 | /** |
| 11 | * This class adds actions to track usage of WooCommerce Orders. |
| 12 | */ |
| 13 | class WC_Status_Tracking { |
| 14 | /** |
| 15 | * Init tracking. |
| 16 | */ |
| 17 | public function init() { |
| 18 | add_action( 'admin_init', array( $this, 'track_status_view' ), 10 ); |
| 19 | } |
| 20 | |
| 21 | /** |
| 22 | * Add Tracks events to the status page. |
| 23 | */ |
| 24 | public function track_status_view() { |
| 25 | if ( isset( $_GET['page'] ) && 'wc-status' === sanitize_text_field( wp_unslash( $_GET['page'] ) ) ) { |
| 26 | |
| 27 | $tab = isset( $_GET['tab'] ) ? sanitize_text_field( wp_unslash( $_GET['tab'] ) ) : 'status'; |
| 28 | |
| 29 | WC_Tracks::record_event( |
| 30 | 'status_view', |
| 31 | array( |
| 32 | 'tab' => $tab, |
| 33 | 'tool_used' => isset( $_GET['action'] ) ? sanitize_text_field( wp_unslash( $_GET['action'] ) ) : null, |
| 34 | ) |
| 35 | ); |
| 36 | |
| 37 | if ( 'status' === $tab ) { |
| 38 | $handle = 'wc-tracks-status-view'; |
| 39 | wp_register_script( $handle, '', array(), WC_VERSION, array( 'in_footer' => true ) ); |
| 40 | wp_enqueue_script( $handle ); |
| 41 | wp_add_inline_script( |
| 42 | $handle, |
| 43 | " |
| 44 | (function() { |
| 45 | 'use strict'; |
| 46 | const debugReportLink = document.querySelector( 'a.debug-report' ); |
| 47 | if ( debugReportLink ) { |
| 48 | debugReportLink.addEventListener( 'click', function() { |
| 49 | if ( window.wcTracks && window.wcTracks.recordEvent ) { |
| 50 | window.wcTracks.recordEvent( 'status_view_reports' ); |
| 51 | } |
| 52 | } ); |
| 53 | } |
| 54 | })(); |
| 55 | " |
| 56 | ); |
| 57 | } |
| 58 | } |
| 59 | } |
| 60 | } |
| 61 |