From 27cc53695f62f60d8dfb6aec68b39637c406d9f5 Mon Sep 17 00:00:00 2001
From: diosmosis <benaka@piwik.pro>
Date: Fri, 10 Jul 2015 21:31:20 -0700
Subject: [PATCH] Tweaking PingRequestProcessor, filling out missing docs and
 removing TODO from VisitTest.php.

---
 core/Tracker/Settings.php                     |  3 ++-
 core/Tracker/VisitorRecognizer.php            | 26 +++++--------------
 .../Tracker/PingRequestProcessor.php          | 10 +------
 .../PHPUnit/Integration/Tracker/VisitTest.php |  2 --
 4 files changed, 10 insertions(+), 31 deletions(-)

diff --git a/core/Tracker/Settings.php b/core/Tracker/Settings.php
index f58c01d6ba..36aeb91716 100644
--- a/core/Tracker/Settings.php
+++ b/core/Tracker/Settings.php
@@ -18,7 +18,8 @@ class Settings // TODO: merge w/ visitor recognizer or make it it's own service.
     const OS_BOT = 'BOT';
 
     /**
-     * TODO
+     * If `true`, the config ID for a visitor will be the same no matter what site is being tracked.
+     * If `false, the config ID will be different.
      *
      * @var bool
      */
diff --git a/core/Tracker/VisitorRecognizer.php b/core/Tracker/VisitorRecognizer.php
index 962e92a3ec..a76ad2c400 100644
--- a/core/Tracker/VisitorRecognizer.php
+++ b/core/Tracker/VisitorRecognizer.php
@@ -15,55 +15,52 @@ use Piwik\Plugins\CustomVariables\CustomVariables;
 use Piwik\Tracker\Visit\VisitProperties;
 
 /**
- * TODO
+ * Tracker service that finds the last known visit for the visitor being tracked.
  */
 class VisitorRecognizer
 {
     /**
-     * TODO
+     * Local variable cache for the getVisitFieldsPersist() method.
      *
      * @var array
      */
     private $visitFieldsToSelect;
 
     /**
-     * TODO
+     * See http://piwik.org/faq/how-to/faq_175/.
      *
      * @var bool
      */
     private $trustCookiesOnly;
 
     /**
-     * TODO
+     * Length of a visit in seconds.
      *
      * @var int
      */
     private $visitStandardLength;
 
     /**
-     * TODO
+     * Number of seconds that have to pass after an action before a new action from the same visitor is
+     * considered a new visit. Defaults to $visitStandardLength.
      *
      * @var int
      */
     private $lookBackNSecondsCustom;
 
     /**
-     * TODO
+     * Forces all requests to result in new visits. For debugging only.
      *
      * @var int
      */
     private $trackerAlwaysNewVisitor;
 
     /**
-     * TODO
-     *
      * @var Model
      */
     private $model;
 
     /**
-     * TODO
-     *
      * @var EventDispatcher
      */
     private $eventDispatcher;
@@ -80,15 +77,6 @@ class VisitorRecognizer
         $this->eventDispatcher = $eventDispatcher;
     }
 
-    /**
-     * This methods tries to see if the visitor has visited the website before.
-     *
-     * We have to split the visitor into one of the category
-     * - Known visitor
-     * - New visitor
-     *
-     * TODO: move docs to class docs
-     */
     public function findKnownVisitor($configId, VisitProperties $visitProperties, Request $request)
     {
         $idSite    = $request->getIdSite();
diff --git a/plugins/Heartbeat/Tracker/PingRequestProcessor.php b/plugins/Heartbeat/Tracker/PingRequestProcessor.php
index 20144aa6f9..80e9759df8 100644
--- a/plugins/Heartbeat/Tracker/PingRequestProcessor.php
+++ b/plugins/Heartbeat/Tracker/PingRequestProcessor.php
@@ -19,22 +19,14 @@ use Piwik\Tracker\Visit\VisitProperties;
  */
 class PingRequestProcessor extends RequestProcessor
 {
-    public function processRequestParams(VisitProperties $visitProperties, Request $request)
+    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.");
-
             $visitProperties->setRequestMetadata('Actions', 'action', null);
-        }
-    }
-
-    public function afterRequestProcessed(VisitProperties $visitProperties, Request $request)
-    {
-        if ($this->isPingRequest($request)) {
             $visitProperties->setRequestMetadata('Goals', 'someGoalsConverted', false);
             $visitProperties->setRequestMetadata('Goals', 'visitIsConverted', false);
-            // TODO: double check: can this be merged w/ setting action to null?
 
             // When a ping request is received more than 30 min after the last request/ping,
             // we choose not to create a new visit.
diff --git a/tests/PHPUnit/Integration/Tracker/VisitTest.php b/tests/PHPUnit/Integration/Tracker/VisitTest.php
index b89800e705..a9ff54f44c 100644
--- a/tests/PHPUnit/Integration/Tracker/VisitTest.php
+++ b/tests/PHPUnit/Integration/Tracker/VisitTest.php
@@ -23,8 +23,6 @@ use Piwik\Tests\Framework\TestCase\IntegrationTestCase;
 
 /**
  * @group Core
- *
- * TODO: move isVisitNew tests to CoreHome plugin
  */
 class VisitTest extends IntegrationTestCase
 {
-- 
GitLab