<?php

declare(strict_types=1);

namespace App\Framework\LiveComponents\Attributes;

use Attribute;

/**
 * Track State History Attribute
 *
 * Marks a LiveComponent to track state changes in component_state_history table.
 * Use this for components where debugging, analytics, or audit trails are needed.
 *
 * Example:
 *   #[LiveComponent(name: 'order-form')]
 *   #[TrackStateHistory]
 *   final readonly class OrderFormComponent
 *   {
 *       // State changes will be tracked in history
 *   }
 *
 * Performance Impact:
 * - One additional INSERT per state change
 * - Minimal overhead (~1-2ms per change)
 * - Consider cleanup strategy for old history entries
 */
#[Attribute(Attribute::TARGET_CLASS)]
final readonly class TrackStateHistory
{
    public function __construct(
        public bool $trackIpAddress = true,
        public bool $trackUserAgent = true,
        public bool $trackChangedProperties = true,
        public ?int $maxHistoryEntries = null,  // Auto-cleanup after N entries
    ) {}
}
