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-importer-tracking.php
85 lines
| 1 | <?php |
| 2 | /** |
| 3 | * WooCommerce Import Tracking |
| 4 | * |
| 5 | * @package WooCommerce\Tracks |
| 6 | */ |
| 7 | |
| 8 | defined( 'ABSPATH' ) || exit; |
| 9 | |
| 10 | /** |
| 11 | * This class adds actions to track usage of WooCommerce Imports. |
| 12 | */ |
| 13 | class WC_Importer_Tracking { |
| 14 | /** |
| 15 | * Init tracking. |
| 16 | */ |
| 17 | public function init() { |
| 18 | add_action( 'product_page_product_importer', array( $this, 'track_product_importer' ) ); |
| 19 | } |
| 20 | |
| 21 | /** |
| 22 | * Route product importer action to the right callback. |
| 23 | * |
| 24 | * @return void |
| 25 | */ |
| 26 | public function track_product_importer() { |
| 27 | // phpcs:disable WordPress.Security.NonceVerification.Recommended |
| 28 | if ( ! isset( $_REQUEST['step'] ) ) { |
| 29 | return; |
| 30 | } |
| 31 | |
| 32 | if ( 'import' === $_REQUEST['step'] ) { |
| 33 | return $this->track_product_importer_start(); |
| 34 | } |
| 35 | |
| 36 | if ( 'done' === $_REQUEST['step'] ) { |
| 37 | return $this->track_product_importer_complete(); |
| 38 | } |
| 39 | // phpcs:enable |
| 40 | } |
| 41 | |
| 42 | /** |
| 43 | * Send a Tracks event when the product importer is started. |
| 44 | * |
| 45 | * @return void |
| 46 | */ |
| 47 | public function track_product_importer_start() { |
| 48 | // phpcs:disable WordPress.Security.NonceVerification.Recommended |
| 49 | if ( ! isset( $_REQUEST['file'] ) || ! isset( $_REQUEST['_wpnonce'] ) ) { |
| 50 | return; |
| 51 | } |
| 52 | |
| 53 | $properties = array( |
| 54 | 'update_existing' => isset( $_REQUEST['update_existing'] ) ? (bool) $_REQUEST['update_existing'] : false, |
| 55 | 'delimiter' => empty( $_REQUEST['delimiter'] ) ? ',' : wc_clean( wp_unslash( $_REQUEST['delimiter'] ) ), |
| 56 | ); |
| 57 | // phpcs:enable |
| 58 | |
| 59 | WC_Tracks::record_event( 'product_import_start', $properties ); |
| 60 | } |
| 61 | |
| 62 | /** |
| 63 | * Send a Tracks event when the product importer has finished. |
| 64 | * |
| 65 | * @return void |
| 66 | */ |
| 67 | public function track_product_importer_complete() { |
| 68 | // phpcs:disable WordPress.Security.NonceVerification.Recommended |
| 69 | if ( ! isset( $_REQUEST['nonce'] ) ) { |
| 70 | return; |
| 71 | } |
| 72 | |
| 73 | $properties = array( |
| 74 | 'imported' => isset( $_GET['products-imported'] ) ? absint( $_GET['products-imported'] ) : 0, |
| 75 | 'imported_variations' => isset( $_GET['products-imported-variations'] ) ? absint( $_GET['products-imported-variations'] ) : 0, |
| 76 | 'updated' => isset( $_GET['products-updated'] ) ? absint( $_GET['products-updated'] ) : 0, |
| 77 | 'failed' => isset( $_GET['products-failed'] ) ? absint( $_GET['products-failed'] ) : 0, |
| 78 | 'skipped' => isset( $_GET['products-skipped'] ) ? absint( $_GET['products-skipped'] ) : 0, |
| 79 | ); |
| 80 | // phpcs:enable |
| 81 | |
| 82 | WC_Tracks::record_event( 'product_import_complete', $properties ); |
| 83 | } |
| 84 | } |
| 85 |