<?php

if ( ! defined('ABSPATH') ) { exit; }

class VASP_Analytics {
    private string $plugin_name = 'valserv-analytics-for-sentinelpro';
    private string $version = '1.0.0';
    private VASP_Analytics_Loader $loader;

    public function __construct() {
        $this->load_dependencies();
        $this->define_admin_hooks();
        $this->define_public_hooks();
    }

    private function load_dependencies(): void {
        require_once plugin_dir_path(__FILE__) . 'class-vasp-analytics-loader.php';
        require_once plugin_dir_path(__FILE__) . '../admin/class-vasp-analytics-admin.php';
        require_once plugin_dir_path(__FILE__) . '../public/class-vasp-analytics-public.php';
        require_once plugin_dir_path(__FILE__) . '../admin/post-metrics-column.php';
        $this->loader = new VASP_Analytics_Loader();
    }

    private function define_admin_hooks(): void {
        $admin = new VASP_Analytics_Admin();
        $metrics = VASP_Post_Metrics_Column::instance();
        // Admin and metrics classes are self-hooking in their constructors
    }

    private function define_public_hooks(): void {
        $plugin_public = new VASP_Analytics_Public($this->plugin_name, $this->version);

        // ✅ Fixed: now uses the correct variable
        $this->loader->add_action('wp_head', $plugin_public, 'inject_tracking_script');
    }

    public function run(): void {
        $this->loader->run();
    }
}
