1
0
قرینه از https://github.com/matomo-org/matomo.git synced 2025-08-22 06:57:53 +00:00
Files
matomo/plugins/Heartbeat/Tracker/PingRequestProcessor.php
Michal Kleiner 9a3ef94df6 [Coding Style] Enable rule PSR12.Files.FileHeader + unify file headers (#22132)
* [Coding Style] Enable rule PSR12.Files.FileHeader

* Apply CS

* Replace Piwik with Matomo in file headers

* Unify file headers (position, no. of lines, https links)

* Rebuild dist files

* Apply CS

* Fix system test that relies on line numbers in a file that had the file header updated

---------

Co-authored-by: Stefan Giehl <stefan@matomo.org>
2024-04-20 20:50:47 +02:00

49 خطوط
1.5 KiB
PHP

<?php
/**
* Matomo - free/libre analytics platform
*
* @link https://matomo.org
* @license https://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
namespace Piwik\Plugins\Heartbeat\Tracker;
use Piwik\Common;
use Piwik\Tracker\Request;
use Piwik\Tracker\RequestProcessor;
use Piwik\Tracker\Visit\VisitProperties;
/**
* Handles ping tracker requests.
*
* Defines no request metadata.
*/
class PingRequestProcessor extends RequestProcessor
{
public function afterRequestProcessed(VisitProperties $visitProperties, Request $request)
{
if ($this->isPingRequest($request)) {
// on a ping request that is received before the standard visit length, we just update the visit time w/o adding a new action
Common::printDebug("-> ping=1 request: we do not track a new action nor a new visit nor any goal.");
$request->setMetadata('Actions', 'action', null);
$request->setMetadata('Goals', 'goalsConverted', array());
$request->setMetadata('Goals', 'visitIsConverted', false);
// When a ping request is received more than 30 min after the last request/ping,
// we choose not to create a new visit.
if ($request->getMetadata('CoreHome', 'isNewVisit')) {
Common::printDebug("-> ping=1 request: we do _not_ create a new visit.");
return true; // abort request
}
}
return false;
}
private function isPingRequest(Request $request)
{
return $request->getParam('ping') == 1;
}
}