Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordiosmosis <benaka@piwik.pro>2015-07-07 04:53:42 +0300
committerdiosmosis <benaka@piwik.pro>2015-08-06 17:37:57 +0300
commit7d8ae6adf53851fea1714bdc174390bcaac498e3 (patch)
tree535e03873a1627dc792241b1c8f3df9ab091ab25 /plugins/CoreHome/Tracker
parent08f113d9c4edae6182bfd458e63016f49a7dd024 (diff)
Add initial RequestProcessor base + DI entry + use in Visit::handle(). Moving some core visit handling logic to a new RequestProcessor in CoreHome plugin.
Diffstat (limited to 'plugins/CoreHome/Tracker')
-rw-r--r--plugins/CoreHome/Tracker/VisitRequestProcessor.php58
1 files changed, 58 insertions, 0 deletions
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 @@
+<?php
+/**
+ * Piwik - free/libre analytics platform
+ *
+ * @link http://piwik.org
+ * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
+ */
+
+namespace Piwik\Plugins\CoreHome\Tracker;
+
+use Piwik\EventDispatcher;
+use Piwik\Tracker\Request;
+use Piwik\Tracker\RequestProcessor;
+use Piwik\Tracker\Visit\VisitProperties;
+use Piwik\Tracker\VisitExcluded;
+
+/**
+ * Encapsulates core tracking logic related to visits.
+ */
+class VisitRequestProcessor extends RequestProcessor
+{
+ /**
+ * @var EventDispatcher
+ */
+ private $eventDispatcher;
+
+ public function __construct(EventDispatcher $eventDispatcher)
+ {
+ $this->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']));
+ }
+}