← All changes
|
jetpack_vendor/automattic/jetpack-premium-analytics/src/class-woocommerce-analytics-tracker.php
+42
-0
16.2-beta
→
16.3
View file →
| @@ -1,0 +1,42 @@ | ||
| 1 | +<?php | |
| 2 | +/** | |
| 3 | + * Wires up the WooCommerce Analytics front-end tracker for Premium Analytics. | |
| 4 | + * | |
| 5 | + * @package automattic/jetpack-premium-analytics | |
| 6 | + */ | |
| 7 | + | |
| 8 | +namespace Automattic\Jetpack\PremiumAnalytics; | |
| 9 | + | |
| 10 | +use Automattic\Woocommerce_Analytics; | |
| 11 | + | |
| 12 | +/** | |
| 13 | + * Turns on the modern (ClickHouse + proxy) pipeline and triggers the vendored | |
| 14 | + * WooCommerce Analytics tracker, which self-gates on WooCommerce + connection | |
| 15 | + * and is idempotent. | |
| 16 | + */ | |
| 17 | +class WooCommerce_Analytics_Tracker { | |
| 18 | + | |
| 19 | + /** | |
| 20 | + * Register the tracker bootstrap. | |
| 21 | + */ | |
| 22 | + public static function configure() { | |
| 23 | + add_action( 'after_setup_theme', array( __CLASS__, 'bootstrap' ) ); | |
| 24 | + } | |
| 25 | + | |
| 26 | + /** | |
| 27 | + * Enable the modern pipeline and trigger the tracker. | |
| 28 | + * | |
| 29 | + * On `after_setup_theme` the filters are in place before the package reads | |
| 30 | + * them while localizing `window.wcAnalytics` at `wp_footer`. | |
| 31 | + */ | |
| 32 | + public static function bootstrap() { | |
| 33 | + add_filter( 'woocommerce_analytics_clickhouse_enabled', '__return_true' ); | |
| 34 | + add_filter( 'woocommerce_analytics_experimental_proxy_tracking_enabled', '__return_true' ); | |
| 35 | + | |
| 36 | + // Guarded because the package ships with the Jetpack plugin or as a | |
| 37 | + // composer dependency, not with premium-analytics' own source. | |
| 38 | + if ( class_exists( Woocommerce_Analytics::class ) ) { | |
| 39 | + Woocommerce_Analytics::init(); | |
| 40 | + } | |
| 41 | + } | |
| 42 | +} | |