PluginProbe ʕ •ᴥ•ʔ
Matomo Analytics – Powerful, Privacy-First Insights for WordPress / 5.13.0
Matomo Analytics – Powerful, Privacy-First Insights for WordPress v5.13.0
5.13.0 5.12.1 5.12.0 5.11.1 5.11.0 5.10.2 5.10.1 trunk 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.1.0 1.1.1 1.1.2 1.1.3 1.2.0 1.3.0 1.3.1 1.3.2 4.0.0 4.0.1 4.0.2 4.0.3 4.0.4 4.1.0 4.1.1 4.1.2 4.1.3 4.10.0 4.11.0 4.12.0 4.13.0 4.13.2 4.13.3 4.13.4 4.13.5 4.14.0 4.14.1 4.14.2 4.15.0 4.15.1 4.15.2 4.15.3 4.2.0 4.3.0 4.3.1 4.4.1 4.4.2 4.5.0 4.6.0 5.0.1 5.0.2 5.0.3 5.0.4 5.0.5 5.0.6 5.0.7 5.0.8 5.1.0 5.1.1 5.1.2 5.1.3 5.1.4 5.1.5 5.1.6 5.1.7 5.10.0 5.2.0 5.2.1 5.2.2 5.3.0 5.3.1 5.3.2 5.3.3 5.6.0 5.6.1 5.7.0 5.7.1 5.8.0 5.8.1 5.8.2
matomo / app / core / Tracker / Handler.php
matomo / app / core / Tracker Last commit date
Config 6 months ago Db 5 days ago Handler 2 years ago Visit 1 month ago Action.php 1 month ago ActionPageview.php 2 years ago BotRequest.php 5 months ago BotRequestProcessor.php 3 months ago Cache.php 1 month ago Db.php 1 month ago Failures.php 8 months ago FingerprintSalt.php 1 month ago GoalManager.php 5 days ago Handler.php 2 years ago IgnoreCookie.php 1 year ago LogTable.php 1 month ago Model.php 1 month ago PageUrl.php 1 month ago Request.php 1 month ago RequestHandlerTrait.php 6 months ago RequestProcessor.php 3 months ago RequestSet.php 8 months ago Response.php 5 months ago ScheduledTasksRunner.php 1 year ago Settings.php 1 month ago TableLogAction.php 1 month ago TrackerCodeGenerator.php 1 month ago TrackerConfig.php 3 months ago Visit.php 1 month ago VisitExcluded.php 1 month ago VisitInterface.php 5 months ago Visitor.php 3 months ago VisitorNotFoundInDb.php 3 months ago VisitorRecognizer.php 1 month ago
Handler.php
100 lines
1 <?php
2
3 /**
4 * Matomo - free/libre analytics platform
5 *
6 * @link https://matomo.org
7 * @license https://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
8 */
9 namespace Piwik\Tracker;
10
11 use Piwik\Container\StaticContainer;
12 use Piwik\Exception\InvalidRequestParameterException;
13 use Piwik\Exception\UnexpectedWebsiteFoundException;
14 use Piwik\Tracker;
15 use Exception;
16 use Piwik\Log\LoggerInterface;
17 class Handler
18 {
19 /**
20 * @var Response
21 */
22 private $response;
23 /**
24 * @var ScheduledTasksRunner
25 */
26 private $tasksRunner;
27 /**
28 * @var LoggerInterface
29 */
30 private $logger;
31 public function __construct()
32 {
33 $this->setResponse(new \Piwik\Tracker\Response());
34 $this->logger = StaticContainer::get(LoggerInterface::class);
35 }
36 public function setResponse($response)
37 {
38 $this->response = $response;
39 }
40 public function init(Tracker $tracker, \Piwik\Tracker\RequestSet $requestSet)
41 {
42 $this->response->init($tracker);
43 }
44 public function process(Tracker $tracker, \Piwik\Tracker\RequestSet $requestSet)
45 {
46 foreach ($requestSet->getRequests() as $request) {
47 $tracker->trackRequest($request);
48 }
49 }
50 public function onStartTrackRequests(Tracker $tracker, \Piwik\Tracker\RequestSet $requestSet)
51 {
52 }
53 public function onAllRequestsTracked(Tracker $tracker, \Piwik\Tracker\RequestSet $requestSet)
54 {
55 $tasks = $this->getScheduledTasksRunner();
56 if ($tasks->shouldRun($tracker)) {
57 $tasks->runScheduledTasks();
58 }
59 }
60 private function getScheduledTasksRunner()
61 {
62 if (is_null($this->tasksRunner)) {
63 $this->tasksRunner = new \Piwik\Tracker\ScheduledTasksRunner();
64 }
65 return $this->tasksRunner;
66 }
67 /**
68 * @internal
69 */
70 public function setScheduledTasksRunner(\Piwik\Tracker\ScheduledTasksRunner $runner)
71 {
72 $this->tasksRunner = $runner;
73 }
74 public function onException(Tracker $tracker, \Piwik\Tracker\RequestSet $requestSet, Exception $e)
75 {
76 $statusCode = 500;
77 if ($e instanceof UnexpectedWebsiteFoundException) {
78 $statusCode = 400;
79 } elseif ($e instanceof InvalidRequestParameterException) {
80 $statusCode = 400;
81 }
82 // if an internal server error, log as a real error, otherwise it's just malformed input
83 if ($statusCode == 500) {
84 $this->logger->error('Exception: {exception}', ['exception' => $e]);
85 } else {
86 $this->logger->debug('Exception: {exception}', ['exception' => $e]);
87 }
88 $this->response->outputException($tracker, $e, $statusCode);
89 }
90 public function finish(Tracker $tracker, \Piwik\Tracker\RequestSet $requestSet)
91 {
92 $this->response->outputResponse($tracker);
93 return $this->response->getOutput();
94 }
95 public function getResponse()
96 {
97 return $this->response;
98 }
99 }
100