diff options
-rw-r--r-- | core/Tracker/GoalManager.php | 18 | ||||
-rw-r--r-- | core/Tracker/Request.php | 33 | ||||
-rw-r--r-- | core/Tracker/RequestProcessor.php | 2 | ||||
-rw-r--r-- | core/Tracker/Visit.php | 22 | ||||
-rw-r--r-- | core/Tracker/Visit/VisitProperties.php | 33 | ||||
-rw-r--r-- | core/Tracker/Visitor.php | 4 | ||||
-rw-r--r-- | plugins/Actions/Tracker/ActionsRequestProcessor.php | 20 | ||||
-rw-r--r-- | plugins/CoreHome/Columns/VisitGoalBuyer.php | 10 | ||||
-rw-r--r-- | plugins/CoreHome/Tracker/VisitRequestProcessor.php | 8 | ||||
-rw-r--r-- | plugins/CoreHome/tests/Integration/Tracker/VisitRequestProcessorTest.php | 3 | ||||
-rw-r--r-- | plugins/CustomVariables/Tracker/CustomVariablesRequestProcessor.php | 6 | ||||
-rw-r--r-- | plugins/Ecommerce/Tracker/EcommerceRequestProcessor.php | 14 | ||||
-rw-r--r-- | plugins/Goals/Tracker/GoalsRequestProcessor.php | 28 | ||||
-rw-r--r-- | plugins/Heartbeat/Tracker/PingRequestProcessor.php | 8 |
14 files changed, 105 insertions, 104 deletions
diff --git a/core/Tracker/GoalManager.php b/core/Tracker/GoalManager.php index 880e5c91b4..3c9cd0bcf2 100644 --- a/core/Tracker/GoalManager.php +++ b/core/Tracker/GoalManager.php @@ -206,10 +206,10 @@ class GoalManager public function recordGoals(VisitProperties $visitProperties, Request $request) { $visitorInformation = $visitProperties->getProperties(); - $visitCustomVariables = $visitProperties->getRequestMetadata('CustomVariables', 'visitCustomVariables'); + $visitCustomVariables = $request->getMetadata('CustomVariables', 'visitCustomVariables'); /** @var Action $action */ - $action = $visitProperties->getRequestMetadata('Actions', 'action'); + $action = $request->getMetadata('Actions', 'action'); $goal = $this->getGoalFromVisitor($visitProperties, $request, $action); @@ -232,7 +232,7 @@ class GoalManager } // some goals are converted, so must be ecommerce Order or Cart Update - $isRequestEcommerce = $visitProperties->getRequestMetadata('Ecommerce', 'isRequestEcommerce'); + $isRequestEcommerce = $request->getMetadata('Ecommerce', 'isRequestEcommerce'); if ($isRequestEcommerce) { $this->recordEcommerceGoal($visitProperties, $request, $goal, $action); } else { @@ -268,14 +268,14 @@ class GoalManager */ protected function recordEcommerceGoal(VisitProperties $visitProperties, Request $request, $conversion, $action) { - $isThereExistingCartInVisit = $visitProperties->getRequestMetadata('Goals', 'isThereExistingCartInVisit'); + $isThereExistingCartInVisit = $request->getMetadata('Goals', 'isThereExistingCartInVisit'); if ($isThereExistingCartInVisit) { Common::printDebug("There is an existing cart for this visit"); } - $visitor = Visitor::makeFromVisitProperties($visitProperties); + $visitor = Visitor::makeFromVisitProperties($visitProperties, $request); - $isGoalAnOrder = $visitProperties->getRequestMetadata('Ecommerce', 'isGoalAnOrder'); + $isGoalAnOrder = $request->getMetadata('Ecommerce', 'isGoalAnOrder'); if ($isGoalAnOrder) { $debugMessage = 'The conversion is an Ecommerce order'; @@ -648,9 +648,9 @@ class GoalManager */ protected function recordStandardGoals(VisitProperties $visitProperties, Request $request, $goal, $action) { - $visitor = Visitor::makeFromVisitProperties($visitProperties); + $visitor = Visitor::makeFromVisitProperties($visitProperties, $request); - $convertedGoals = $visitProperties->getRequestMetadata('Goals', 'goalsConverted') ?: array(); + $convertedGoals = $request->getMetadata('Goals', 'goalsConverted') ?: array(); foreach ($convertedGoals as $convertedGoal) { $this->currentGoal = $convertedGoal; Common::printDebug("- Goal " . $convertedGoal['idgoal'] . " matched. Recording..."); @@ -799,7 +799,7 @@ class GoalManager $visitDimensions = VisitDimension::getAllDimensions(); - $visit = Visitor::makeFromVisitProperties($visitProperties); + $visit = Visitor::makeFromVisitProperties($visitProperties, $request); foreach ($visitDimensions as $dimension) { $value = $dimension->onAnyGoalConversion($request, $visit, $action); if (false !== $value) { diff --git a/core/Tracker/Request.php b/core/Tracker/Request.php index c37a9b7624..ecc027bc74 100644 --- a/core/Tracker/Request.php +++ b/core/Tracker/Request.php @@ -43,6 +43,15 @@ class Request protected $tokenAuth; + /** + * Stores plugin specific tracking request metadata. RequestProcessors can store + * whatever they want in this array, and other RequestProcessors can modify these + * values to change tracker behavior. + * + * @var string[][] + */ + private $requestMetadata = array(); + const UNKNOWN_RESOLUTION = 'unknown'; const CUSTOM_TIMESTAMP_DOES_NOT_REQUIRE_TOKENAUTH_WHEN_NEWER_THAN = 14400; // 4 hours @@ -762,4 +771,28 @@ class Request return $cip; } + + /** + * Set a request metadata value. + * + * @param string $pluginName eg, `'Actions'`, `'Goals'`, `'YourPlugin'` + * @param string $key + * @param mixed $value + */ + public function setMetadata($pluginName, $key, $value) + { + $this->requestMetadata[$pluginName][$key] = $value; + } + + /** + * Get a request metadata value. Returns `null` if none exists. + * + * @param string $pluginName eg, `'Actions'`, `'Goals'`, `'YourPlugin'` + * @param string $key + * @return mixed + */ + public function getMetadata($pluginName, $key) + { + return isset($this->requestMetadata[$pluginName][$key]) ? $this->requestMetadata[$pluginName][$key] : null; + } } diff --git a/core/Tracker/RequestProcessor.php b/core/Tracker/RequestProcessor.php index 072e9d76b5..e96ae36be6 100644 --- a/core/Tracker/RequestProcessor.php +++ b/core/Tracker/RequestProcessor.php @@ -24,7 +24,7 @@ use Piwik\Tracker\Visit\VisitProperties; * * Request metadata is shared between RequestProcessors, so RequestProcessors can tweak each others * behavior, and thus, the behavior of the Tracker. Request metadata can be set and get using the - * {@link VisitProperties::setRequestMetadata()} and {@link VisitProperties::getRequestMetadata()} + * {@link Request::setMetadata()} and {@link Request::getMetadata()} * methods. * * Each RequestProcessor lists the request metadata it computes and exposes in its class diff --git a/core/Tracker/Visit.php b/core/Tracker/Visit.php index da1ef85862..915f3cf654 100644 --- a/core/Tracker/Visit.php +++ b/core/Tracker/Visit.php @@ -119,10 +119,10 @@ class Visit implements VisitInterface } } - $isNewVisit = $this->visitProperties->getRequestMetadata('CoreHome', 'isNewVisit'); + $isNewVisit = $this->request->getMetadata('CoreHome', 'isNewVisit'); if (!$isNewVisit) { $isNewVisit = $this->triggerPredicateHookOnDimensions($this->getAllVisitDimensions(), 'shouldForceNewVisit'); - $this->visitProperties->setRequestMetadata('CoreHome', 'isNewVisit', $isNewVisit); + $this->request->setMetadata('CoreHome', 'isNewVisit', $isNewVisit); } foreach ($this->requestProcessors as $processor) { @@ -135,7 +135,7 @@ class Visit implements VisitInterface } } - $isNewVisit = $this->visitProperties->getRequestMetadata('CoreHome', 'isNewVisit'); + $isNewVisit = $this->request->getMetadata('CoreHome', 'isNewVisit'); // Known visit when: // ( - the visitor has the Piwik cookie with the idcookie ID used by Piwik to match the visitor @@ -146,9 +146,9 @@ class Visit implements VisitInterface // - the last page view for this visitor was less than 30 minutes ago @see isLastActionInTheSameVisit() if (!$isNewVisit) { try { - $this->handleExistingVisit($this->visitProperties->getRequestMetadata('Goals', 'visitIsConverted')); + $this->handleExistingVisit($this->request->getMetadata('Goals', 'visitIsConverted')); } catch (VisitorNotFoundInDb $e) { - $this->visitProperties->setRequestMetadata('CoreHome', 'visitorNotFoundInDb', true); // TODO: perhaps we should just abort here? + $this->request->setMetadata('CoreHome', 'visitorNotFoundInDb', true); // TODO: perhaps we should just abort here? } } @@ -157,7 +157,7 @@ class Visit implements VisitInterface // - the visitor doesn't have the Piwik cookie, and couldn't be matched in @see recognizeTheVisitor() // - the visitor does have the Piwik cookie but the idcookie and idvisit found in the cookie didn't match to any existing visit in the DB if ($isNewVisit) { - $this->handleNewVisit($this->visitProperties->getRequestMetadata('Goals', 'visitIsConverted')); + $this->handleNewVisit($this->request->getMetadata('Goals', 'visitIsConverted')); } // update the cookie with the new visit information @@ -298,7 +298,7 @@ class Visit implements VisitInterface */ protected function getVisitorIdcookie() { - $isKnown = $this->visitProperties->getRequestMetadata('CoreHome', 'isVisitorKnown'); + $isKnown = $this->request->getMetadata('CoreHome', 'isVisitorKnown'); if ($isKnown) { return $this->visitProperties->getProperty('idvisitor'); } @@ -407,7 +407,7 @@ class Visit implements VisitInterface { $idVisitor = $this->getVisitorIdcookie(); $visitorIp = $this->getVisitorIp(); - $configId = $this->visitProperties->getRequestMetadata('CoreHome', 'visitorId'); + $configId = $this->request->getMetadata('CoreHome', 'visitorId'); $this->visitProperties->clearProperties(); @@ -453,7 +453,7 @@ class Visit implements VisitInterface $visitor = $this->makeVisitorFacade(); /** @var Action $action */ - $action = $this->visitProperties->getRequestMetadata('Actions', 'action'); + $action = $this->request->getMetadata('Actions', 'action'); foreach ($dimensions as $dimension) { $value = $dimension->$hook($this->request, $visitor, $action); @@ -482,7 +482,7 @@ class Visit implements VisitInterface $visitor = $this->makeVisitorFacade(); /** @var Action $action */ - $action = $this->visitProperties->getRequestMetadata('Actions', 'action'); + $action = $this->request->getMetadata('Actions', 'action'); foreach ($dimensions as $dimension) { if ($dimension->$hook($this->request, $visitor, $action)) { @@ -577,6 +577,6 @@ class Visit implements VisitInterface private function makeVisitorFacade() { - return Visitor::makeFromVisitProperties($this->visitProperties); + return Visitor::makeFromVisitProperties($this->visitProperties, $this->request); } } diff --git a/core/Tracker/Visit/VisitProperties.php b/core/Tracker/Visit/VisitProperties.php index 30b3168f4c..567d9bd0f6 100644 --- a/core/Tracker/Visit/VisitProperties.php +++ b/core/Tracker/Visit/VisitProperties.php @@ -22,39 +22,6 @@ class VisitProperties private $visitInfo = array(); /** - * Stores plugin specific tracking request metadata. RequestProcessors can store - * whatever they want in this array, and other RequestProcessors can modify these - * values to change tracker behavior. - * - * @var string[][] - */ - private $requestMetadata = array(); - - /** - * Set a request metadata value. - * - * @param string $pluginName eg, `'Actions'`, `'Goals'`, `'YourPlugin'` - * @param string $key - * @param mixed $value - */ - public function setRequestMetadata($pluginName, $key, $value) - { - $this->requestMetadata[$pluginName][$key] = $value; - } - - /** - * Get a request metadata value. Returns `null` if none exists. - * - * @param string $pluginName eg, `'Actions'`, `'Goals'`, `'YourPlugin'` - * @param string $key - * @return mixed - */ - public function getRequestMetadata($pluginName, $key) - { - return @$this->requestMetadata[$pluginName][$key]; - } - - /** * Returns a visit property, or `null` if none is set. * * @param string $name The property name. diff --git a/core/Tracker/Visitor.php b/core/Tracker/Visitor.php index 833e5c87ed..92036ff974 100644 --- a/core/Tracker/Visitor.php +++ b/core/Tracker/Visitor.php @@ -24,9 +24,9 @@ class Visitor $this->setIsVisitorKnown($isVisitorKnown); } - public static function makeFromVisitProperties(VisitProperties $visitProperties) + public static function makeFromVisitProperties(VisitProperties $visitProperties, Request $request) { - $isKnown = $visitProperties->getRequestMetadata('CoreHome', 'isVisitorKnown'); + $isKnown = $request->getMetadata('CoreHome', 'isVisitorKnown'); return new Visitor($visitProperties, $isKnown); } diff --git a/plugins/Actions/Tracker/ActionsRequestProcessor.php b/plugins/Actions/Tracker/ActionsRequestProcessor.php index 7dfb696bad..0117afa452 100644 --- a/plugins/Actions/Tracker/ActionsRequestProcessor.php +++ b/plugins/Actions/Tracker/ActionsRequestProcessor.php @@ -51,20 +51,20 @@ class ActionsRequestProcessor extends RequestProcessor $action = Action::factory($request); $action->writeDebugInfo(); - $visitProperties->setRequestMetadata('Actions', 'action', $action); + $request->setMetadata('Actions', 'action', $action); // save the exit actions of the last action in this visit as the referrer actions for the action being tracked. // when the visit is updated, these columns will be changed, so we have to do this before recordLogs - $visitProperties->setRequestMetadata('Actions', 'idReferrerActionUrl', + $request->setMetadata('Actions', 'idReferrerActionUrl', $visitProperties->getProperty('visit_exit_idaction_url')); - $visitProperties->setRequestMetadata('Actions', 'idReferrerActionName', + $request->setMetadata('Actions', 'idReferrerActionName', $visitProperties->getProperty('visit_exit_idaction_name')); } public function afterRequestProcessed(VisitProperties $visitProperties, Request $request) { /** @var Action $action */ - $action = $visitProperties->getRequestMetadata('Actions', 'action'); + $action = $request->getMetadata('Actions', 'action'); if (!empty($action)) { // other plugins can unset the action if they want $action->loadIdsFromLogActionTable(); @@ -74,20 +74,20 @@ class ActionsRequestProcessor extends RequestProcessor public function recordLogs(VisitProperties $visitProperties, Request $request) { /** @var Action $action */ - $action = $visitProperties->getRequestMetadata('Actions', 'action'); + $action = $request->getMetadata('Actions', 'action'); if ($action !== null - && !$visitProperties->getRequestMetadata('CoreHome', 'visitorNotFoundInDb') + && !$request->getMetadata('CoreHome', 'visitorNotFoundInDb') ) { $idReferrerActionUrl = 0; $idReferrerActionName = 0; - if (!$visitProperties->getRequestMetadata('CoreHome', 'isNewVisit')) { - $idReferrerActionUrl = $visitProperties->getRequestMetadata('Actions', 'idReferrerActionUrl'); - $idReferrerActionName = $visitProperties->getRequestMetadata('Actions', 'idReferrerActionName'); + if (!$request->getMetadata('CoreHome', 'isNewVisit')) { + $idReferrerActionUrl = $request->getMetadata('Actions', 'idReferrerActionUrl'); + $idReferrerActionName = $request->getMetadata('Actions', 'idReferrerActionName'); } - $visitor = Visitor::makeFromVisitProperties($visitProperties); + $visitor = Visitor::makeFromVisitProperties($visitProperties, $request); $action->record($visitor, $idReferrerActionUrl, $idReferrerActionName); } } diff --git a/plugins/CoreHome/Columns/VisitGoalBuyer.php b/plugins/CoreHome/Columns/VisitGoalBuyer.php index 006c93a179..21c8b06963 100644 --- a/plugins/CoreHome/Columns/VisitGoalBuyer.php +++ b/plugins/CoreHome/Columns/VisitGoalBuyer.php @@ -56,7 +56,7 @@ class VisitGoalBuyer extends VisitDimension */ public function onNewVisit(Request $request, Visitor $visitor, $action) { - return $this->getBuyerType($visitor); + return $this->getBuyerType($request); } /** @@ -70,7 +70,7 @@ class VisitGoalBuyer extends VisitDimension $goalBuyer = $visitor->getVisitorColumn($this->columnName); // Ecommerce buyer status - $visitEcommerceStatus = $this->getBuyerType($visitor, $goalBuyer); + $visitEcommerceStatus = $this->getBuyerType($request, $goalBuyer); if ($visitEcommerceStatus != self::TYPE_BUYER_NONE // only update if the value has changed (prevents overwriting the value in case a request has @@ -106,14 +106,14 @@ class VisitGoalBuyer extends VisitDimension return self::$visitEcommerceStatus[$id]; } - private function getBuyerType(Visitor $visitor, $existingType = self::TYPE_BUYER_NONE) + private function getBuyerType(Request $request, $existingType = self::TYPE_BUYER_NONE) { - $isRequestEcommerce = $visitor->visitProperties->getRequestMetadata('Ecommerce', 'isRequestEcommerce'); + $isRequestEcommerce = $request->getMetadata('Ecommerce', 'isRequestEcommerce'); if (!$isRequestEcommerce) { return $existingType; } - $isGoalAnOrder = $visitor->visitProperties->getRequestMetadata('Ecommerce', 'isGoalAnOrder'); + $isGoalAnOrder = $request->getMetadata('Ecommerce', 'isGoalAnOrder'); if ($isGoalAnOrder) { return self::TYPE_BUYER_ORDERED; } diff --git a/plugins/CoreHome/Tracker/VisitRequestProcessor.php b/plugins/CoreHome/Tracker/VisitRequestProcessor.php index 7d963303ce..7fee641de0 100644 --- a/plugins/CoreHome/Tracker/VisitRequestProcessor.php +++ b/plugins/CoreHome/Tracker/VisitRequestProcessor.php @@ -93,13 +93,13 @@ class VisitRequestProcessor extends RequestProcessor // visitor recognition $visitorId = $this->userSettings->getConfigId($request, $visitProperties->getProperty('location_ip')); - $visitProperties->setRequestMetadata('CoreHome', 'visitorId', $visitorId); + $request->setMetadata('CoreHome', 'visitorId', $visitorId); $isKnown = $this->visitorRecognizer->findKnownVisitor($visitorId, $visitProperties, $request); - $visitProperties->setRequestMetadata('CoreHome', 'isVisitorKnown', $isKnown); + $request->setMetadata('CoreHome', 'isVisitorKnown', $isKnown); $isNewVisit = $this->isVisitNew($visitProperties, $request); - $visitProperties->setRequestMetadata('CoreHome', 'isNewVisit', $isNewVisit); + $request->setMetadata('CoreHome', 'isNewVisit', $isNewVisit); return false; } @@ -133,7 +133,7 @@ class VisitRequestProcessor extends RequestProcessor */ public function isVisitNew(VisitProperties $visitProperties, Request $request) { - $isKnown = $visitProperties->getRequestMetadata('CoreHome', 'isVisitorKnown'); + $isKnown = $request->getMetadata('CoreHome', 'isVisitorKnown'); if (!$isKnown) { return true; } diff --git a/plugins/CoreHome/tests/Integration/Tracker/VisitRequestProcessorTest.php b/plugins/CoreHome/tests/Integration/Tracker/VisitRequestProcessorTest.php index b4507eb74c..02ae4c6d99 100644 --- a/plugins/CoreHome/tests/Integration/Tracker/VisitRequestProcessorTest.php +++ b/plugins/CoreHome/tests/Integration/Tracker/VisitRequestProcessorTest.php @@ -96,11 +96,12 @@ class VisitRequestProcessorTest extends IntegrationTestCase { $idsite = API::getInstance()->addSite("name", "http://piwik.net/"); + /** @var Request $request */ list($visit, $request) = $this->prepareVisitWithRequest(array('idsite' => $idsite), $currentActionTime); $visitProperties = new VisitProperties(); $visitProperties->setProperty('visit_last_action_time', Date::factory($lastActionTimestamp)->getTimestamp()); - $visitProperties->setRequestMetadata('CoreHome', 'isVisitorKnown', $isVisitorKnown); + $request->setMetadata('CoreHome', 'isVisitorKnown', $isVisitorKnown); return array($visit, $visitProperties, $request); } diff --git a/plugins/CustomVariables/Tracker/CustomVariablesRequestProcessor.php b/plugins/CustomVariables/Tracker/CustomVariablesRequestProcessor.php index 86e656929b..44e6d59350 100644 --- a/plugins/CustomVariables/Tracker/CustomVariablesRequestProcessor.php +++ b/plugins/CustomVariables/Tracker/CustomVariablesRequestProcessor.php @@ -42,12 +42,12 @@ class CustomVariablesRequestProcessor extends RequestProcessor Common::printDebug($visitorCustomVariables); } - $visitProperties->setRequestMetadata('CustomVariables', 'visitCustomVariables', $visitorCustomVariables); + $request->setMetadata('CustomVariables', 'visitCustomVariables', $visitorCustomVariables); } public function onNewVisit(VisitProperties $visitProperties, Request $request) { - $visitCustomVariables = $visitProperties->getRequestMetadata('CustomVariables', 'visitCustomVariables'); + $visitCustomVariables = $request->getMetadata('CustomVariables', 'visitCustomVariables'); if (!empty($visitCustomVariables)) { $visitProperties->setProperties(array_merge($visitProperties->getProperties(), $visitCustomVariables)); @@ -56,7 +56,7 @@ class CustomVariablesRequestProcessor extends RequestProcessor public function onExistingVisit(&$valuesToUpdate, VisitProperties $visitProperties, Request $request) { - $visitCustomVariables = $visitProperties->getRequestMetadata('CustomVariables', 'visitCustomVariables'); + $visitCustomVariables = $request->getMetadata('CustomVariables', 'visitCustomVariables'); if (!empty($visitCustomVariables)) { $valuesToUpdate = array_merge($valuesToUpdate, $visitCustomVariables); diff --git a/plugins/Ecommerce/Tracker/EcommerceRequestProcessor.php b/plugins/Ecommerce/Tracker/EcommerceRequestProcessor.php index 1bdf430032..cc474d8df3 100644 --- a/plugins/Ecommerce/Tracker/EcommerceRequestProcessor.php +++ b/plugins/Ecommerce/Tracker/EcommerceRequestProcessor.php @@ -44,32 +44,32 @@ class EcommerceRequestProcessor extends RequestProcessor public function processRequestParams(VisitProperties $visitProperties, Request $request) { $isGoalAnOrder = $this->isRequestForAnOrder($request); - $visitProperties->setRequestMetadata('Ecommerce', 'isGoalAnOrder', $isGoalAnOrder); + $request->setMetadata('Ecommerce', 'isGoalAnOrder', $isGoalAnOrder); $isRequestEcommerce = $this->isRequestEcommerce($request); - $visitProperties->setRequestMetadata('Ecommerce', 'isRequestEcommerce', $isRequestEcommerce); + $request->setMetadata('Ecommerce', 'isRequestEcommerce', $isRequestEcommerce); if ($isRequestEcommerce) { // Mark the visit as Converted only if it is an order (not for a Cart update) $idGoal = GoalManager::IDGOAL_CART; if ($isGoalAnOrder) { $idGoal = GoalManager::IDGOAL_ORDER; - $visitProperties->setRequestMetadata('Goals', 'visitIsConverted', true); + $request->setMetadata('Goals', 'visitIsConverted', true); } - $visitProperties->setRequestMetadata('Goals', 'goalsConverted', array(array('idgoal' => $idGoal))); + $request->setMetadata('Goals', 'goalsConverted', array(array('idgoal' => $idGoal))); - $visitProperties->setRequestMetadata('Actions', 'action', null); // don't track actions when tracking ecommerce orders + $request->setMetadata('Actions', 'action', null); // don't track actions when tracking ecommerce orders } } public function afterRequestProcessed(VisitProperties $visitProperties, Request $request) { - $goalsConverted = $visitProperties->getRequestMetadata('Goals', 'goalsConverted'); + $goalsConverted = $request->getMetadata('Goals', 'goalsConverted'); if (!empty($goalsConverted)) { $isThereExistingCartInVisit = $this->goalManager->detectIsThereExistingCartInVisit( $visitProperties->getProperties()); - $visitProperties->setRequestMetadata('Goals', 'isThereExistingCartInVisit', $isThereExistingCartInVisit); + $request->setMetadata('Goals', 'isThereExistingCartInVisit', $isThereExistingCartInVisit); } } diff --git a/plugins/Goals/Tracker/GoalsRequestProcessor.php b/plugins/Goals/Tracker/GoalsRequestProcessor.php index 9d9e753921..85b4e1c809 100644 --- a/plugins/Goals/Tracker/GoalsRequestProcessor.php +++ b/plugins/Goals/Tracker/GoalsRequestProcessor.php @@ -59,12 +59,12 @@ class GoalsRequestProcessor extends RequestProcessor $goal = $this->goalManager->detectGoalId($request->getIdSite(), $request); $visitIsConverted = !empty($goal); - $visitProperties->setRequestMetadata('Goals', 'visitIsConverted', $visitIsConverted); + $request->setMetadata('Goals', 'visitIsConverted', $visitIsConverted); - $existingConvertedGoals = $visitProperties->getRequestMetadata('Goals', 'goalsConverted') ?: array(); - $visitProperties->setRequestMetadata('Goals', 'goalsConverted', array_merge($existingConvertedGoals, array($goal))); + $existingConvertedGoals = $request->getMetadata('Goals', 'goalsConverted') ?: array(); + $request->setMetadata('Goals', 'goalsConverted', array_merge($existingConvertedGoals, array($goal))); - $visitProperties->setRequestMetadata('Actions', 'action', null); // don't track actions when doing manual goal conversions + $request->setMetadata('Actions', 'action', null); // don't track actions when doing manual goal conversions // if we find a idgoal in the URL, but then the goal is not valid, this is most likely a fake request if (!$visitIsConverted) { @@ -79,10 +79,10 @@ class GoalsRequestProcessor extends RequestProcessor public function afterRequestProcessed(VisitProperties $visitProperties, Request $request) { - $goalsConverted = $visitProperties->getRequestMetadata('Goals', 'goalsConverted'); + $goalsConverted = $request->getMetadata('Goals', 'goalsConverted'); /** @var Action $action */ - $action = $visitProperties->getRequestMetadata('Actions', 'action'); + $action = $request->getMetadata('Actions', 'action'); // if the visit hasn't already been converted another way (ie, manual goal conversion or ecommerce conversion, // try to convert based on the action) @@ -91,11 +91,11 @@ class GoalsRequestProcessor extends RequestProcessor ) { $goalsConverted = $this->goalManager->detectGoalsMatchingUrl($request->getIdSite(), $action); - $existingGoalsConverted = $visitProperties->getRequestMetadata('Goals', 'goalsConverted') ?: array(); - $visitProperties->setRequestMetadata('Goals', 'goalsConverted', array_merge($existingGoalsConverted, $goalsConverted)); + $existingGoalsConverted = $request->getMetadata('Goals', 'goalsConverted') ?: array(); + $request->setMetadata('Goals', 'goalsConverted', array_merge($existingGoalsConverted, $goalsConverted)); if (!empty($goalsConverted)) { - $visitProperties->setRequestMetadata('Goals', 'visitIsConverted', true); + $request->setMetadata('Goals', 'visitIsConverted', true); } } @@ -106,15 +106,15 @@ class GoalsRequestProcessor extends RequestProcessor // - the exception is caught here and will result in a new visit incorrectly // In this case, we cancel the current conversion to be recorded: $isManualGoalConversion = $this->isManualGoalConversion($request); - $requestIsEcommerce = $visitProperties->getRequestMetadata('Goals', 'isRequestEcommerce'); - $visitorNotFoundInDb = $visitProperties->getRequestMetadata('CoreHome', 'visitorNotFoundInDb'); + $requestIsEcommerce = $request->getMetadata('Goals', 'isRequestEcommerce'); + $visitorNotFoundInDb = $request->getMetadata('CoreHome', 'visitorNotFoundInDb'); if ($visitorNotFoundInDb && ($isManualGoalConversion || $requestIsEcommerce) ) { - $visitProperties->setRequestMetadata('Goals', 'goalsConverted', array()); - $visitProperties->setRequestMetadata('Goals', 'visitIsConverted', false); + $request->setMetadata('Goals', 'goalsConverted', array()); + $request->setMetadata('Goals', 'visitIsConverted', false); } } @@ -122,7 +122,7 @@ class GoalsRequestProcessor extends RequestProcessor public function recordLogs(VisitProperties $visitProperties, Request $request) { // record the goals if there were conversions in this request (even if the visit itself was not converted) - $goalsConverted = $visitProperties->getRequestMetadata('Goals', 'goalsConverted'); + $goalsConverted = $request->getMetadata('Goals', 'goalsConverted'); if (!empty($goalsConverted)) { $this->goalManager->recordGoals($visitProperties, $request); } diff --git a/plugins/Heartbeat/Tracker/PingRequestProcessor.php b/plugins/Heartbeat/Tracker/PingRequestProcessor.php index 99c22bfc77..7f110b1d55 100644 --- a/plugins/Heartbeat/Tracker/PingRequestProcessor.php +++ b/plugins/Heartbeat/Tracker/PingRequestProcessor.php @@ -24,13 +24,13 @@ class PingRequestProcessor extends RequestProcessor 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); - $visitProperties->setRequestMetadata('Goals', 'goalsConverted', array()); - $visitProperties->setRequestMetadata('Goals', 'visitIsConverted', false); + $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 ($visitProperties->getRequestMetadata('CoreHome', 'isNewVisit')) { + if ($request->getMetadata('CoreHome', 'isNewVisit')) { Common::printDebug("-> ping=1 request: we do _not_ create a new visit."); return true; // abort request } |