| @@ -20,18 +20,14 @@ | ||
| 20 | 20 | * Hooked to admin_init for proper WordPress lifecycle integration |
| 21 | 21 | * Only loads after WordPress, plugins, and themes are fully loaded |
| 22 | 22 | */ |
| 23 | 23 | function metasync_init_analytics() { |
| 24 | - // Initialize the consent-gated PostHog dispatcher in every request context | |
| 25 | - // so REST, MCP, cron, and admin events share one central gate. | |
| 26 | - Metasync_PostHog::get_instance(); | |
| 27 | - | |
| 28 | - // GA4's browser integration remains limited to MetaSync admin screens. | |
| 24 | + // Only initialize in admin area (excludes AJAX and REST API requests) | |
| 29 | 25 | if (is_admin() && !wp_doing_ajax() && !defined('REST_REQUEST')) { |
| 30 | 26 | Metasync_GA4::get_instance(); |
| 31 | 27 | } |
| 32 | 28 | } |
| 33 | -add_action('init', 'metasync_init_analytics', 1); | |
| 29 | +add_action('admin_init', 'metasync_init_analytics', 10); | |
| 34 | 30 | |
| 35 | 31 | /** |
| 36 | 32 | * Initialize API Backoff System |
| 37 | 33 | * Hooked to init for proper WordPress lifecycle integration |
| @@ -65,23 +61,8 @@ | ||
| 65 | 61 | Metasync_Review_Notice::get_instance(); |
| 66 | 62 | } |
| 67 | 63 | } |
| 68 | 64 | add_action('init', 'metasync_init_review_notice'); |
| 69 | - | |
| 70 | -/** | |
| 71 | - * Initialize Analytics Consent Notice | |
| 72 | - * Asks existing installs to opt in to usage analytics; re-shows every | |
| 73 | - * 10 days while consent stays off. | |
| 74 | - */ | |
| 75 | -function metasync_init_analytics_consent_notice() { | |
| 76 | - if (metasync_is_non_metasync_admin_ajax()) { | |
| 77 | - return; | |
| 78 | - } | |
| 79 | - if (is_admin()) { | |
| 80 | - Metasync_Analytics_Consent_Notice::get_instance(); | |
| 81 | - } | |
| 82 | -} | |
| 83 | -add_action('init', 'metasync_init_analytics_consent_notice'); | |
| 84 | 65 | |
| 85 | 66 | /** |
| 86 | 67 | * Initialize Host Blocking Check |
| 87 | 68 | * Owns the shared GET/POST reachability probe, its post-activation + weekly crons, |