Skip to content

Commit

Permalink
[FEATURE] Second draft
Browse files Browse the repository at this point in the history
  • Loading branch information
einpraegsam committed Feb 18, 2024
1 parent be2842e commit 08636ce
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 5 deletions.
11 changes: 7 additions & 4 deletions Classes/Controller/FrontendController.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use In2code\Lux\Domain\Tracker\CompanyTracker;
use In2code\Lux\Domain\Tracker\DownloadTracker;
use In2code\Lux\Domain\Tracker\FrontenduserAuthenticationTracker;
use In2code\Lux\Domain\Tracker\IndividualVisitTracker;
use In2code\Lux\Domain\Tracker\LinkClickTracker;
use In2code\Lux\Domain\Tracker\LuxletterlinkAttributeTracker;
use In2code\Lux\Domain\Tracker\NewsTracker;
Expand Down Expand Up @@ -108,10 +109,12 @@ public function pageRequestAction(string $identificator, array $arguments): Resp
$companyTracker->track($visitor);
$pageTracker = GeneralUtility::makeInstance(PageTracker::class);
$pagevisit = $pageTracker->track($visitor, $arguments);
$newsTracker = GeneralUtility::makeInstance(NewsTracker::class);
$newsTracker->track($visitor, $arguments, $pagevisit);
$searchTracker = GeneralUtility::makeInstance(SearchTracker::class);
$searchTracker->track($visitor, $arguments);
$individualVisitTracker = GeneralUtility::makeInstance(IndividualVisitTracker::class);
$individualVisitTracker->track($visitor, $arguments, $pagevisit);
// $newsTracker = GeneralUtility::makeInstance(NewsTracker::class);
// $newsTracker->track($visitor, $arguments, $pagevisit);
// $searchTracker = GeneralUtility::makeInstance(SearchTracker::class);
// $searchTracker->track($visitor, $arguments);
return $this->jsonResponse(json_encode($this->afterAction($visitor)));
} catch (Throwable $exception) {
return $this->jsonResponse(json_encode($this->getError($exception)));
Expand Down
57 changes: 57 additions & 0 deletions Classes/Domain/Tracker/IndividualVisitTracker.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?php

declare(strict_types=1);
namespace In2code\Lux\Domain\Tracker;

use In2code\Lux\Domain\Model\News;
use In2code\Lux\Domain\Model\Newsvisit;
use In2code\Lux\Domain\Model\Pagevisit;
use In2code\Lux\Domain\Model\Visitor;
use In2code\Lux\Domain\Repository\NewsRepository;
use In2code\Lux\Domain\Repository\VisitorRepository;
use In2code\Lux\Events\NewsTrackerEvent;
use In2code\Lux\Utility\ObjectUtility;
use Psr\EventDispatcher\EventDispatcherInterface;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Configuration\Exception\InvalidConfigurationTypeException;
use TYPO3\CMS\Extbase\Persistence\Exception\IllegalObjectTypeException;
use TYPO3\CMS\Extbase\Persistence\Exception\UnknownObjectException;

class IndividualVisitTracker
{
protected VisitorRepository $visitorRepository;
private EventDispatcherInterface $eventDispatcher;

public function __construct(VisitorRepository $visitorRepository, EventDispatcherInterface $eventDispatcher)
{
$this->visitorRepository = $visitorRepository;
$this->eventDispatcher = $eventDispatcher;
}

/**
* @param Visitor $visitor
* @param array $arguments
* @param Pagevisit|null $pagevisit
* @return void
* @throws IllegalObjectTypeException
* @throws InvalidConfigurationTypeException
* @throws UnknownObjectException
*/
public function track(Visitor $visitor, array $arguments, Pagevisit $pagevisit = null): void
{
if ($this->isTrackingActivated($visitor, $arguments)) {
die(__CLASS__ . ':' . __LINE__);
}
}

/**
* @param Visitor $visitor
* @param array $arguments
* @return bool
* @throws InvalidConfigurationTypeException
*/
protected function isTrackingActivated(Visitor $visitor, array $arguments): bool
{
return $visitor->isNotBlacklisted() && $this->isTrackingActivatedInSettings();
}
}
7 changes: 6 additions & 1 deletion ext_localconf.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,12 @@ function () {
],
],
'frontend' => [
'isTriggered' => 'Class',
'triggered' => [
'class' => \In2code\Lux\Domain\Service\IndividualAnalyseView\Backend\Activator\IsExtensionActiveActivator::class,
'configuration' => [
'foo' => 'bar',
],
],
],
],
'search' => [
Expand Down

0 comments on commit 08636ce

Please sign in to comment.