![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/mautic.corals.io/app/bundles/EmailBundle/EventListener/ |
<?php namespace Mautic\EmailBundle\EventListener; use Mautic\EmailBundle\Entity\Stat; use Mautic\EmailBundle\Entity\StatRepository; use Mautic\LeadBundle\Event\ContactIdentificationEvent; use Mautic\LeadBundle\LeadEvents; use Symfony\Component\EventDispatcher\EventSubscriberInterface; class TrackingSubscriber implements EventSubscriberInterface { public function __construct( private StatRepository $statRepository ) { } public static function getSubscribedEvents(): array { return [ LeadEvents::ON_CLICKTHROUGH_IDENTIFICATION => ['onIdentifyContact', 0], ]; } public function onIdentifyContact(ContactIdentificationEvent $event): void { $clickthrough = $event->getClickthrough(); // Nothing left to identify by so stick to the tracked lead if (empty($clickthrough['channel']['email']) && empty($clickthrough['stat'])) { return; } /** @var Stat $stat */ $stat = $this->statRepository->findOneBy(['trackingHash' => $clickthrough['stat']]); if (!$stat) { // Stat doesn't exist so use the tracked lead return; } if ($stat->getEmail() && (int) $stat->getEmail()->getId() !== (int) $clickthrough['channel']['email']) { // ID mismatch - fishy so use tracked lead return; } if (!$contact = $stat->getLead()) { return; } $event->setIdentifiedContact($contact, 'email'); } }