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-08 06:20:16 +0300
committerdiosmosis <benaka@piwik.pro>2015-08-06 17:37:57 +0300
commit34d4ab4177e14c53f0fc42509efe6bd397114ed1 (patch)
treeb412cefd11bf7c241af64c2f8cd67358d2a28446 /plugins/Goals/Tracker/GoalsRequestProcessor.php
parentdffadbc7e3a36f8981411d74d9fd7c447c56dd1a (diff)
Move manual goal conversion logic from Visit::handle() to a new RequestProcessor stored in the Goals plugin.
Diffstat (limited to 'plugins/Goals/Tracker/GoalsRequestProcessor.php')
-rw-r--r--plugins/Goals/Tracker/GoalsRequestProcessor.php44
1 files changed, 44 insertions, 0 deletions
diff --git a/plugins/Goals/Tracker/GoalsRequestProcessor.php b/plugins/Goals/Tracker/GoalsRequestProcessor.php
new file mode 100644
index 0000000000..ac475e5733
--- /dev/null
+++ b/plugins/Goals/Tracker/GoalsRequestProcessor.php
@@ -0,0 +1,44 @@
+<?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\Goals\Tracker;
+
+use Piwik\Common;
+use Piwik\Tracker\GoalManager;
+use Piwik\Tracker\Request;
+use Piwik\Tracker\RequestProcessor;
+use Piwik\Tracker\Visit\VisitProperties;
+
+/**
+ * TODO
+ *
+ * TODO: document request metadata here
+ */
+class GoalsRequestProcessor extends RequestProcessor
+{
+ public function processRequestParams(VisitProperties $visitProperties, Request $request)
+ {
+ $goalManager = new GoalManager($request); // TODO: GoalManager should be stateless and stored in DI.
+
+ if ($goalManager->isManualGoalConversion()) {
+ // this request is from the JS call to piwikTracker.trackGoal()
+ $someGoalsConverted = $goalManager->detectGoalId($request->getIdSite());
+
+ $visitProperties->setRequestMetadata('Goals', 'someGoalsConverted', $someGoalsConverted);
+ $visitProperties->setRequestMetadata('Goals', 'visitIsConverted', $someGoalsConverted);
+
+ // if we find a idgoal in the URL, but then the goal is not valid, this is most likely a fake request
+ if (!$someGoalsConverted) {
+ Common::printDebug('Invalid goal tracking request for goal id = ' . $goalManager->idGoal);
+ return true;
+ }
+ }
+
+ return false;
+ }
+} \ No newline at end of file