| @@ -14,14 +14,18 @@ | ||
| 14 | 14 | if (!defined('WPINC')) { |
| 15 | 15 | die; |
| 16 | 16 | } |
| 17 | 17 | |
| 18 | -// Class files are autoloaded by Composer. Procedural/side-effect files stay explicit. | |
| 19 | -require_once plugin_dir_path(__FILE__) . 'sentry-wordpress-integration.php'; | |
| 20 | -require_once plugin_dir_path(__FILE__) . 'wordpress-error-handler.php'; | |
| 21 | -require_once plugin_dir_path(__FILE__) . 'sentry-helper.php'; | |
| 18 | +require_once plugin_dir_path(__FILE__) . 'privacy.php'; | |
| 22 | 19 | |
| 20 | +// Side-effectful telemetry files must not load after either opt-out path. | |
| 21 | +if (!metasync_telemetry_is_disabled()) { | |
| 22 | + require_once plugin_dir_path(__FILE__) . 'sentry-wordpress-integration.php'; | |
| 23 | + require_once plugin_dir_path(__FILE__) . 'wordpress-error-handler.php'; | |
| 24 | + require_once plugin_dir_path(__FILE__) . 'sentry-helper.php'; | |
| 25 | +} | |
| 23 | 26 | |
| 27 | + | |
| 24 | 28 | /** |
| 25 | 29 | * Initialize telemetry system |
| 26 | 30 | */ |
| 27 | 31 | function init_metasync_telemetry() { |
| @@ -65,9 +69,9 @@ | ||
| 65 | 69 | return; // Skip if memory was already determined to be unsafe |
| 66 | 70 | } |
| 67 | 71 | |
| 68 | 72 | // Check if telemetry is explicitly disabled |
| 69 | - if (defined('METASYNC_DISABLE_TELEMETRY') && constant('METASYNC_DISABLE_TELEMETRY')) { | |
| 73 | + if (metasync_telemetry_is_disabled()) { | |
| 70 | 74 | return; |
| 71 | 75 | } |
| 72 | 76 | |
| 73 | 77 | try { |
| @@ -136,9 +140,9 @@ | ||
| 136 | 140 | } |
| 137 | 141 | } |
| 138 | 142 | |
| 139 | 143 | // Only initialize telemetry if not explicitly disabled |
| 140 | -if (!defined('METASYNC_DISABLE_TELEMETRY') || !constant('METASYNC_DISABLE_TELEMETRY')) { | |
| 144 | +if (!metasync_telemetry_is_disabled()) { | |
| 141 | 145 | // Add hook - memory check is now handled inside the function for efficiency |
| 142 | 146 | add_action('plugins_loaded', 'init_metasync_telemetry', 5); |
| 143 | 147 | } |
| 144 | 148 | |
| @@ -147,8 +151,12 @@ | ||
| 147 | 151 | * |
| 148 | 152 | * @return Metasync_Telemetry_Manager|null Null when the class cannot be loaded. |
| 149 | 153 | */ |
| 150 | 154 | function metasync_telemetry() { |
| 155 | + if (metasync_telemetry_is_disabled()) { | |
| 156 | + return null; | |
| 157 | + } | |
| 158 | + | |
| 151 | 159 | if (!class_exists('Metasync_Telemetry_Manager')) { |
| 152 | 160 | $manager_file = plugin_dir_path(__FILE__) . 'class-telemetry-manager.php'; |
| 153 | 161 | if (is_readable($manager_file)) { |
| 154 | 162 | require_once $manager_file; |