From 7d8ae6adf53851fea1714bdc174390bcaac498e3 Mon Sep 17 00:00:00 2001 From: diosmosis Date: Mon, 6 Jul 2015 18:53:42 -0700 Subject: Add initial RequestProcessor base + DI entry + use in Visit::handle(). Moving some core visit handling logic to a new RequestProcessor in CoreHome plugin. --- plugins/CoreHome/Tracker/VisitRequestProcessor.php | 58 ++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 plugins/CoreHome/Tracker/VisitRequestProcessor.php (limited to 'plugins/CoreHome/Tracker') diff --git a/plugins/CoreHome/Tracker/VisitRequestProcessor.php b/plugins/CoreHome/Tracker/VisitRequestProcessor.php new file mode 100644 index 0000000000..513b78b54a --- /dev/null +++ b/plugins/CoreHome/Tracker/VisitRequestProcessor.php @@ -0,0 +1,58 @@ +eventDispatcher = $eventDispatcher; + } + + public function processRequestParams(VisitProperties $visitProperties, Request $request) + { + // the IP is needed by isExcluded() and GoalManager->recordGoals() + $visitProperties->visitorInfo['location_ip'] = $request->getIp(); + + // TODO: move VisitExcluded logic to here (or break into other request processors) + $excluded = new VisitExcluded($request, $visitProperties->visitorInfo['location_ip']); + if ($excluded->isExcluded()) { + return true; + } + + return false; + } + + public function manipulateVisitProperties(VisitProperties $visitProperties) + { + /** + * Triggered after visits are tested for exclusion so plugins can modify the IP address + * persisted with a visit. + * + * This event is primarily used by the **PrivacyManager** plugin to anonymize IP addresses. + * + * @param string &$ip The visitor's IP address. + */ + $this->eventDispatcher->postEvent('Tracker.setVisitorIp', array(&$visitProperties->visitorInfo['location_ip'])); + } +} -- cgit v1.2.3