blob: 596d0b926fe3c0c69d8775f5fc1e383b0b4ff0d4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
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, Request $request)
{
/**
* 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']));
}
}
|