<?php

defined('ABSPATH') || exit;

class BundlePress_Event_Tracker
{
    public static function init()
    {
        add_action('bundlepress_track_event', [__CLASS__, 'track_event'], 10, 2);
    }

    public static function track_install()
    {
        self::track_event('install', [
            'site_url' => get_site_url(),
            'php_version' => PHP_VERSION,
            'wp_version' => get_bloginfo('version'),
            'plugin_version' => BUNDLEPRESS_VERSION,
        ]);
    }

    public static function track_deactivation()
    {
        self::track_event('deactivation', [
            'site_url' => get_site_url(),
        ]);
    }

    public static function track_event($event_name, $data = [])
    {
        // Tracking logic
        $settings = BundlePress_Settings_API::get_feature_settings();
        if (isset($settings['usage_tracking']) && $settings['usage_tracking']) {
            BundlePress_Remote_API::post('events/' . $event_name, $data);
        }
    }
}
