From 08636ce02210dad14a48b8efa05d6b28aebaae05 Mon Sep 17 00:00:00 2001 From: Alexander Kellner Date: Sun, 18 Feb 2024 16:48:43 +0100 Subject: [PATCH] [FEATURE] Second draft --- Classes/Controller/FrontendController.php | 11 ++-- .../Domain/Tracker/IndividualVisitTracker.php | 57 +++++++++++++++++++ ext_localconf.php | 7 ++- 3 files changed, 70 insertions(+), 5 deletions(-) create mode 100644 Classes/Domain/Tracker/IndividualVisitTracker.php diff --git a/Classes/Controller/FrontendController.php b/Classes/Controller/FrontendController.php index 097e5e16..5c050edc 100644 --- a/Classes/Controller/FrontendController.php +++ b/Classes/Controller/FrontendController.php @@ -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; @@ -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))); diff --git a/Classes/Domain/Tracker/IndividualVisitTracker.php b/Classes/Domain/Tracker/IndividualVisitTracker.php new file mode 100644 index 00000000..832566e3 --- /dev/null +++ b/Classes/Domain/Tracker/IndividualVisitTracker.php @@ -0,0 +1,57 @@ +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(); + } +} diff --git a/ext_localconf.php b/ext_localconf.php index a3722e9a..d83162bf 100644 --- a/ext_localconf.php +++ b/ext_localconf.php @@ -100,7 +100,12 @@ function () { ], ], 'frontend' => [ - 'isTriggered' => 'Class', + 'triggered' => [ + 'class' => \In2code\Lux\Domain\Service\IndividualAnalyseView\Backend\Activator\IsExtensionActiveActivator::class, + 'configuration' => [ + 'foo' => 'bar', + ], + ], ], ], 'search' => [