<?php

declare(strict_types=1);

namespace CpCreation\VitiCore\Bridge\Symfony\Bundle\EventSubscriber;

use CpCreation\VitiCore\Bridge\Symfony\Bundle\Event\ContactMessageSentEvent;
use CpCreation\VitiCore\Bridge\Symfony\Bundle\Tracking\MetaConversionsApiTracker;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;

final readonly class MetaContactLeadSubscriber implements EventSubscriberInterface
{
    public function __construct(private MetaConversionsApiTracker $metaConversionsApiTracker)
    {
    }

    /**
     * @return array<class-string, string>
     */
    public static function getSubscribedEvents(): array
    {
        return [
            ContactMessageSentEvent::class => 'trackLead',
        ];
    }

    public function trackLead(ContactMessageSentEvent $event): void
    {
        $this->metaConversionsApiTracker->trackLead($event->data, $event->request);
    }
}
