Mautic Community Forums

Lead events filter not work

2017_01_16_17h56_53.png


Typing something in the search box won't filter events correctly.

Typing something in the search box won’t filter events correctly.

I added these few lines…

[code]
case ‘page.hit’:
if(!empty($filters))
{
$this->addSearchTextIdentifiedEntry($event, $type, $name);
}

				break;[/code]

[code]/**
* @param EventsLeadTimelineEvent $event
* @param $eventTypeKey
* @param $eventTypeName
*/
protected function addSearchTextIdentifiedEntry(EventsLeadTimelineEvent $event, $eventTypeKey, $eventTypeName)
{
$lead = $event->getLead();
$hits = $this->em->getRepository(‘MauticPageBundle:Hit’)->getHitsByLead($lead->getId(), $event->getQueryOptions());

    // Add to counter
    $event->addToCounter($eventTypeKey, $hits);

    if (!$event->isEngagementCount()) {
        // Add the logs to the event array
        foreach ($hits['results'] as $hit) {
            $icon = 'fa-link';
            
            $event->addEvent(
                    [
                        'event'      => $eventTypeKey,
                        'eventType'  => $eventTypeName,
                        'eventLabel' => $hit['url_title'],
                        'timestamp'  => $hit['date_hit'],
                        'icon'       => $icon,
                        'extra'      => [
                            'hits' => $hit,
                        ],
                        'contentTemplate' => 'MauticLeadBundle:SubscribedEventsTimeline:pagehitadded.html.php',
                    ]
                );
        }
    } else {
        // Purposively not including this in engagements graph as the engagement is counted by the page hit
    }
}[/code]

please tell me if it is a good approach or not. I’ll tear my hair when an upgrade will take place…