diff options
author | diosmosis <benaka@piwik.pro> | 2015-08-06 14:54:34 +0300 |
---|---|---|
committer | diosmosis <benaka@piwik.pro> | 2015-08-07 17:15:43 +0300 |
commit | 2f91d3c83a834b0e451d3e58fa246ef0a87740fb (patch) | |
tree | 4c650ff22651921af10f84344557bf78106f4952 | |
parent | 0f67ba1ae63db2ccef642ef215002379c3ee8bfe (diff) |
Add public methods to VisitProperties for property access and use instead of direct access.
-rw-r--r-- | core/Tracker/GoalManager.php | 19 | ||||
-rw-r--r-- | core/Tracker/Visit.php | 57 | ||||
-rw-r--r-- | core/Tracker/Visit/VisitProperties.php | 54 | ||||
-rw-r--r-- | core/Tracker/Visitor.php | 6 | ||||
-rw-r--r-- | core/Tracker/VisitorRecognizer.php | 22 | ||||
-rw-r--r-- | plugins/Actions/Tracker/ActionsRequestProcessor.php | 6 | ||||
-rw-r--r-- | plugins/CoreHome/Tracker/VisitRequestProcessor.php | 16 | ||||
-rw-r--r-- | plugins/CoreHome/tests/Integration/Tracker/VisitRequestProcessorTest.php | 2 | ||||
-rw-r--r-- | plugins/CustomVariables/Tracker/CustomVariablesRequestProcessor.php | 2 | ||||
-rw-r--r-- | plugins/Ecommerce/Tracker/EcommerceRequestProcessor.php | 3 | ||||
-rw-r--r-- | tests/PHPUnit/Integration/Tracker/Visit2Test.php | 6 |
11 files changed, 126 insertions, 67 deletions
diff --git a/core/Tracker/GoalManager.php b/core/Tracker/GoalManager.php index 8b3c86734f..880e5c91b4 100644 --- a/core/Tracker/GoalManager.php +++ b/core/Tracker/GoalManager.php @@ -205,7 +205,7 @@ class GoalManager */ public function recordGoals(VisitProperties $visitProperties, Request $request) { - $visitorInformation = $visitProperties->visitorInfo; + $visitorInformation = $visitProperties->getProperties(); $visitCustomVariables = $visitProperties->getRequestMetadata('CustomVariables', 'visitCustomVariables'); /** @var Action $action */ @@ -315,9 +315,10 @@ class GoalManager $conversion['items'] = $itemsCount; if ($isThereExistingCartInVisit) { - $recorded = $this->getModel()->updateConversion($visitProperties->visitorInfo['idvisit'], self::IDGOAL_CART, $conversion); + $recorded = $this->getModel()->updateConversion( + $visitProperties->getProperty('idvisit'), self::IDGOAL_CART, $conversion); } else { - $recorded = $this->insertNewConversion($conversion, $visitProperties->visitorInfo, $request); + $recorded = $this->insertNewConversion($conversion, $visitProperties->getProperties(), $request); } if ($recorded) { @@ -335,7 +336,7 @@ class GoalManager * @param array $visitInformation The visit entity that we are tracking a conversion for. See what * information it contains [here](/guides/persistence-and-the-mysql-backend#visits). */ - Piwik::postEvent('Tracker.recordEcommerceGoal', array($conversion, $visitProperties->visitorInfo)); + Piwik::postEvent('Tracker.recordEcommerceGoal', array($conversion, $visitProperties->getProperties())); } /** @@ -665,12 +666,12 @@ class GoalManager // If multiple Goal conversions per visit, set a cache buster $conversion['buster'] = $convertedGoal['allow_multiple'] == 0 ? '0' - : $visitProperties->visitorInfo['visit_last_action_time']; + : $visitProperties->getProperty('visit_last_action_time'); $conversionDimensions = ConversionDimension::getAllDimensions(); $conversion = $this->triggerHookOnDimensions($request, $conversionDimensions, 'onGoalConversion', $visitor, $action, $conversion); - $this->insertNewConversion($conversion, $visitProperties->visitorInfo, $request); + $this->insertNewConversion($conversion, $visitProperties->getProperties(), $request); /** * Triggered after successfully recording a non-ecommerce conversion. @@ -791,9 +792,9 @@ class GoalManager private function getGoalFromVisitor(VisitProperties $visitProperties, Request $request, $action) { $goal = array( - 'idvisit' => $visitProperties->visitorInfo['idvisit'], - 'idvisitor' => $visitProperties->visitorInfo['idvisitor'], - 'server_time' => Date::getDatetimeFromTimestamp($visitProperties->visitorInfo['visit_last_action_time']) + 'idvisit' => $visitProperties->getProperty('idvisit'), + 'idvisitor' => $visitProperties->getProperty('idvisitor'), + 'server_time' => Date::getDatetimeFromTimestamp($visitProperties->getProperty('visit_last_action_time')), ); $visitDimensions = VisitDimension::getAllDimensions(); diff --git a/core/Tracker/Visit.php b/core/Tracker/Visit.php index 6b2883bf2b..da1ef85862 100644 --- a/core/Tracker/Visit.php +++ b/core/Tracker/Visit.php @@ -161,7 +161,7 @@ class Visit implements VisitInterface } // update the cookie with the new visit information - $this->request->setThirdPartyCookie($this->visitProperties->visitorInfo['idvisitor']); + $this->request->setThirdPartyCookie($this->visitProperties->getProperty('idvisitor')); foreach ($this->requestProcessors as $processor) { Common::printDebug("Executing " . get_class($processor) . "::recordLogs()..."); @@ -188,13 +188,13 @@ class Visit implements VisitInterface Common::printDebug("Visit is known (IP = " . IPUtils::binaryToStringIP($this->getVisitorIp()) . ")"); // TODO it should be its own dimension - $this->visitProperties->visitorInfo['time_spent_ref_action'] = $this->getTimeSpentReferrerAction(); + $this->visitProperties->setProperty('time_spent_ref_action', $this->getTimeSpentReferrerAction()); $valuesToUpdate = $this->getExistingVisitFieldsToUpdate($visitIsConverted); // update visitorInfo foreach ($valuesToUpdate as $name => $value) { - $this->visitProperties->visitorInfo[$name] = $value; + $this->visitProperties->setProperty($name, $value); } /** @@ -208,7 +208,7 @@ class Visit implements VisitInterface * @param array $visit The entire visit entity. Read [this](/guides/persistence-and-the-mysql-backend#visits) * to see what it contains. */ - Piwik::postEvent('Tracker.existingVisitInformation', array(&$valuesToUpdate, $this->visitProperties->visitorInfo)); + Piwik::postEvent('Tracker.existingVisitInformation', array(&$valuesToUpdate, $this->visitProperties->getProperties())); foreach ($this->requestProcessors as $processor) { $processor->onExistingVisit($valuesToUpdate, $this->visitProperties, $this->request); @@ -216,7 +216,7 @@ class Visit implements VisitInterface $this->updateExistingVisit($valuesToUpdate); - $this->visitProperties->visitorInfo['visit_last_action_time'] = $this->request->getCurrentTimestamp(); + $this->visitProperties->setProperty('visit_last_action_time', $this->request->getCurrentTimestamp()); } /** @@ -224,7 +224,8 @@ class Visit implements VisitInterface */ protected function getTimeSpentReferrerAction() { - $timeSpent = $this->request->getCurrentTimestamp() - $this->visitProperties->visitorInfo['visit_last_action_time']; + $timeSpent = $this->request->getCurrentTimestamp() - + $this->visitProperties->getProperty('visit_last_action_time'); if ($timeSpent < 0) { $timeSpent = 0; } @@ -270,7 +271,7 @@ class Visit implements VisitInterface * what information it contains. * @param \Piwik\Tracker\Request $request An object describing the tracking request being processed. */ - Piwik::postEvent('Tracker.newVisitorInformation', array(&$this->visitProperties->visitorInfo, $this->request)); + Piwik::postEvent('Tracker.newVisitorInformation', array($this->visitProperties->getProperties(), $this->request)); foreach ($this->requestProcessors as $processor) { $processor->onNewVisit($this->visitProperties, $this->request); @@ -278,11 +279,11 @@ class Visit implements VisitInterface $this->printVisitorInformation(); - $idVisit = $this->insertNewVisit($this->visitProperties->visitorInfo); + $idVisit = $this->insertNewVisit($this->visitProperties->getProperties()); - $this->visitProperties->visitorInfo['idvisit'] = $idVisit; - $this->visitProperties->visitorInfo['visit_first_action_time'] = $this->request->getCurrentTimestamp(); - $this->visitProperties->visitorInfo['visit_last_action_time'] = $this->request->getCurrentTimestamp(); + $this->visitProperties->setProperty('idvisit', $idVisit); + $this->visitProperties->setProperty('visit_first_action_time', $this->request->getCurrentTimestamp()); + $this->visitProperties->setProperty('visit_last_action_time', $this->request->getCurrentTimestamp()); } private function getModel() @@ -299,14 +300,15 @@ class Visit implements VisitInterface { $isKnown = $this->visitProperties->getRequestMetadata('CoreHome', 'isVisitorKnown'); if ($isKnown) { - return $this->visitProperties->visitorInfo['idvisitor']; + return $this->visitProperties->getProperty('idvisitor'); } // If the visitor had a first party ID cookie, then we use this value - if (!empty($this->visitProperties->visitorInfo['idvisitor']) - && Tracker::LENGTH_BINARY_ID == strlen($this->visitProperties->visitorInfo['idvisitor']) + $idVisitor = $this->visitProperties->getProperty('idvisitor'); + if (!empty($idVisitor) + && Tracker::LENGTH_BINARY_ID == strlen($this->visitProperties->getProperty('idvisitor')) ) { - return $this->visitProperties->visitorInfo['idvisitor']; + return $this->visitProperties->getProperty('idvisitor'); } return Common::hex2bin($this->generateUniqueVisitorId()); @@ -327,7 +329,7 @@ class Visit implements VisitInterface */ protected function getVisitorIp() { - return $this->visitProperties->visitorInfo['location_ip']; + return $this->visitProperties->getProperty('location_ip'); } /** @@ -373,7 +375,7 @@ class Visit implements VisitInterface protected function updateExistingVisit($valuesToUpdate) { $idSite = $this->request->getIdSite(); - $idVisit = (int)$this->visitProperties->visitorInfo['idvisit']; + $idVisit = (int)$this->visitProperties->getProperty('idvisit'); $wasInserted = $this->getModel()->updateVisit($idSite, $idVisit, $valuesToUpdate); @@ -386,14 +388,15 @@ class Visit implements VisitInterface Common::printDebug('Updated existing visit: ' . var_export($valuesToUpdate, true)); } else { throw new VisitorNotFoundInDb( - "The visitor with idvisitor=" . bin2hex($this->visitProperties->visitorInfo['idvisitor']) . " and idvisit=" . @$this->visitProperties->visitorInfo['idvisit'] + "The visitor with idvisitor=" . bin2hex($this->visitProperties->getProperty('idvisitor')) + . " and idvisit=" . @$this->visitProperties->getProperty('idvisit') . " wasn't found in the DB, we fallback to a new visitor"); } } private function printVisitorInformation() { - $debugVisitInfo = $this->visitProperties->visitorInfo; + $debugVisitInfo = $this->visitProperties->getProperties(); $debugVisitInfo['idvisitor'] = bin2hex($debugVisitInfo['idvisitor']); $debugVisitInfo['config_id'] = bin2hex($debugVisitInfo['config_id']); $debugVisitInfo['location_ip'] = IPUtils::binaryToStringIP($debugVisitInfo['location_ip']); @@ -406,11 +409,11 @@ class Visit implements VisitInterface $visitorIp = $this->getVisitorIp(); $configId = $this->visitProperties->getRequestMetadata('CoreHome', 'visitorId'); - $this->visitProperties->visitorInfo = array(); + $this->visitProperties->clearProperties(); - $this->visitProperties->visitorInfo['idvisitor'] = $idVisitor; - $this->visitProperties->visitorInfo['config_id'] = $configId; - $this->visitProperties->visitorInfo['location_ip'] = $visitorIp; + $this->visitProperties->setProperty('idvisitor', $idVisitor); + $this->visitProperties->setProperty('config_id', $configId); + $this->visitProperties->setProperty('location_ip', $visitorIp); } /** @@ -466,7 +469,7 @@ class Visit implements VisitInterface if ($valuesToUpdate !== null) { $valuesToUpdate[$fieldName] = $value; } else { - $this->visitProperties->visitorInfo[$fieldName] = $value; + $this->visitProperties->setProperty($fieldName, $value); } } } @@ -519,8 +522,8 @@ class Visit implements VisitInterface private function setIdVisitorForExistingVisit($valuesToUpdate) { // Might update the idvisitor when it was forced or overwritten for this visit - if (strlen($this->visitProperties->visitorInfo['idvisitor']) == Tracker::LENGTH_BINARY_ID) { - $binIdVisitor = $this->visitProperties->visitorInfo['idvisitor']; + if (strlen($this->visitProperties->getProperty('idvisitor')) == Tracker::LENGTH_BINARY_ID) { + $binIdVisitor = $this->visitProperties->getProperty('idvisitor'); $valuesToUpdate['idvisitor'] = $binIdVisitor; } @@ -529,7 +532,7 @@ class Visit implements VisitInterface if ($userId) { $userIdHash = $this->request->getUserIdHashed($userId); $binIdVisitor = Common::hex2bin($userIdHash); - $this->visitProperties->visitorInfo['idvisitor'] = $binIdVisitor; + $this->visitProperties->setProperty('idvisitor', $binIdVisitor); $valuesToUpdate['idvisitor'] = $binIdVisitor; } return $valuesToUpdate; diff --git a/core/Tracker/Visit/VisitProperties.php b/core/Tracker/Visit/VisitProperties.php index 7cc5133de7..30b3168f4c 100644 --- a/core/Tracker/Visit/VisitProperties.php +++ b/core/Tracker/Visit/VisitProperties.php @@ -10,8 +10,6 @@ namespace Piwik\Tracker\Visit; /** * Holds temporary data for tracking requests. - * - * RequestProcessors */ class VisitProperties { @@ -21,7 +19,7 @@ class VisitProperties * * @var array */ - public $visitorInfo = array(); + private $visitInfo = array(); /** * Stores plugin specific tracking request metadata. RequestProcessors can store @@ -55,4 +53,54 @@ class VisitProperties { return @$this->requestMetadata[$pluginName][$key]; } + + /** + * Returns a visit property, or `null` if none is set. + * + * @param string $name The property name. + * @return mixed + */ + public function getProperty($name) + { + return isset($this->visitInfo[$name]) ? $this->visitInfo[$name] : null; + } + + /** + * Returns all visit properties by reference. + * + * @return array + */ + public function &getProperties() + { + return $this->visitInfo; + } + + /** + * Sets a visit property. + * + * @param string $name The property name. + * @param mixed $value The property value. + */ + public function setProperty($name, $value) + { + $this->visitInfo[$name] = $value; + } + + /** + * Unsets all visit properties. + */ + public function clearProperties() + { + $this->visitInfo = array(); + } + + /** + * Sets all visit properties. + * + * @param array $properties + */ + public function setProperties($properties) + { + $this->visitInfo = $properties; + } } diff --git a/core/Tracker/Visitor.php b/core/Tracker/Visitor.php index cdd4ce7693..833e5c87ed 100644 --- a/core/Tracker/Visitor.php +++ b/core/Tracker/Visitor.php @@ -32,13 +32,13 @@ class Visitor public function setVisitorColumn($column, $value) { - $this->visitProperties->visitorInfo[$column] = $value; + $this->visitProperties->setProperty($column, $value); } public function getVisitorColumn($column) { - if (array_key_exists($column, $this->visitProperties->visitorInfo)) { - return $this->visitProperties->visitorInfo[$column]; + if (array_key_exists($column, $this->visitProperties->getProperties())) { + return $this->visitProperties->getProperty($column); } return false; diff --git a/core/Tracker/VisitorRecognizer.php b/core/Tracker/VisitorRecognizer.php index a76ad2c400..4f63017e43 100644 --- a/core/Tracker/VisitorRecognizer.php +++ b/core/Tracker/VisitorRecognizer.php @@ -85,7 +85,7 @@ class VisitorRecognizer $isVisitorIdToLookup = !empty($idVisitor); if ($isVisitorIdToLookup) { - $visitProperties->visitorInfo['idvisitor'] = $idVisitor; + $visitProperties->setProperty('idvisitor', $idVisitor); Common::printDebug("Matching visitors with: visitorId=" . bin2hex($idVisitor) . " OR configId=" . bin2hex($configId)); } else { Common::printDebug("Visitor doesn't have the piwik cookie..."); @@ -109,11 +109,11 @@ class VisitorRecognizer // These values will be used throughout the request foreach ($persistedVisitAttributes as $field) { - $visitProperties->visitorInfo[$field] = $visitRow[$field]; + $visitProperties->setProperty($field, $visitRow[$field]); } - $visitProperties->visitorInfo['visit_last_action_time'] = strtotime($visitRow['visit_last_action_time']); - $visitProperties->visitorInfo['visit_first_action_time'] = strtotime($visitRow['visit_first_action_time']); + $visitProperties->setProperty('visit_last_action_time', strtotime($visitRow['visit_last_action_time'])); + $visitProperties->setProperty('visit_first_action_time', strtotime($visitRow['visit_first_action_time'])); // Custom Variables copied from Visit in potential later conversion if (!empty($numCustomVarsToRead)) { @@ -121,22 +121,22 @@ class VisitorRecognizer if (isset($visitRow['custom_var_k' . $i]) && strlen($visitRow['custom_var_k' . $i]) ) { - $visitProperties->visitorInfo['custom_var_k' . $i] = $visitRow['custom_var_k' . $i]; + $visitProperties->setProperty('custom_var_k' . $i, $visitRow['custom_var_k' . $i]); } if (isset($visitRow['custom_var_v' . $i]) && strlen($visitRow['custom_var_v' . $i]) ) { - $visitProperties->visitorInfo['custom_var_v' . $i] = $visitRow['custom_var_v' . $i]; + $visitProperties->setProperty('custom_var_v' . $i, $visitRow['custom_var_v' . $i]); } } } - Common::printDebug("The visitor is known (idvisitor = " . bin2hex($visitProperties->visitorInfo['idvisitor']) . ", + Common::printDebug("The visitor is known (idvisitor = " . bin2hex($visitProperties->getProperty('idvisitor')) . ", config_id = " . bin2hex($configId) . ", - idvisit = {$visitProperties->visitorInfo['idvisit']}, - last action = " . date("r", $visitProperties->visitorInfo['visit_last_action_time']) . ", - first action = " . date("r", $visitProperties->visitorInfo['visit_first_action_time']) . ", - visit_goal_buyer' = " . $visitProperties->visitorInfo['visit_goal_buyer'] . ")"); + idvisit = {$visitProperties->getProperty('idvisit')}, + last action = " . date("r", $visitProperties->getProperty('visit_last_action_time')) . ", + first action = " . date("r", $visitProperties->getProperty('visit_first_action_time')) . ", + visit_goal_buyer' = " . $visitProperties->getProperty('visit_goal_buyer') . ")"); return true; } else { diff --git a/plugins/Actions/Tracker/ActionsRequestProcessor.php b/plugins/Actions/Tracker/ActionsRequestProcessor.php index cfc9bb5793..7dfb696bad 100644 --- a/plugins/Actions/Tracker/ActionsRequestProcessor.php +++ b/plugins/Actions/Tracker/ActionsRequestProcessor.php @@ -55,8 +55,10 @@ class ActionsRequestProcessor extends RequestProcessor // 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', @$visitProperties->visitorInfo['visit_exit_idaction_url']); - $visitProperties->setRequestMetadata('Actions', 'idReferrerActionName', @$visitProperties->visitorInfo['visit_exit_idaction_name']); + $visitProperties->setRequestMetadata('Actions', 'idReferrerActionUrl', + $visitProperties->getProperty('visit_exit_idaction_url')); + $visitProperties->setRequestMetadata('Actions', 'idReferrerActionName', + $visitProperties->getProperty('visit_exit_idaction_name')); } public function afterRequestProcessed(VisitProperties $visitProperties, Request $request) diff --git a/plugins/CoreHome/Tracker/VisitRequestProcessor.php b/plugins/CoreHome/Tracker/VisitRequestProcessor.php index ee7493c68d..7d963303ce 100644 --- a/plugins/CoreHome/Tracker/VisitRequestProcessor.php +++ b/plugins/CoreHome/Tracker/VisitRequestProcessor.php @@ -83,16 +83,16 @@ class VisitRequestProcessor extends RequestProcessor public function processRequestParams(VisitProperties $visitProperties, Request $request) { // the IP is needed by isExcluded() and GoalManager->recordGoals() - $visitProperties->visitorInfo['location_ip'] = $request->getIp(); + $visitProperties->setProperty('location_ip', $request->getIp()); // TODO: move VisitExcluded logic to here (or move to service class stored in DI) - $excluded = new VisitExcluded($request, $visitProperties->visitorInfo['location_ip']); + $excluded = new VisitExcluded($request, $visitProperties->getProperty('location_ip')); if ($excluded->isExcluded()) { return true; } // visitor recognition - $visitorId = $this->userSettings->getConfigId($request, $visitProperties->visitorInfo['location_ip']); + $visitorId = $this->userSettings->getConfigId($request, $visitProperties->getProperty('location_ip')); $visitProperties->setRequestMetadata('CoreHome', 'visitorId', $visitorId); $isKnown = $this->visitorRecognizer->findKnownVisitor($visitorId, $visitProperties, $request); @@ -106,6 +106,8 @@ class VisitRequestProcessor extends RequestProcessor public function afterRequestProcessed(VisitProperties $visitProperties, Request $request) { + $ip = $visitProperties->getProperty('location_ip'); + /** * Triggered after visits are tested for exclusion so plugins can modify the IP address * persisted with a visit. @@ -114,7 +116,9 @@ class VisitRequestProcessor extends RequestProcessor * * @param string &$ip The visitor's IP address. */ - $this->eventDispatcher->postEvent('Tracker.setVisitorIp', array(&$visitProperties->visitorInfo['location_ip'])); + $this->eventDispatcher->postEvent('Tracker.setVisitorIp', array(&$ip)); + + $visitProperties->setProperty('location_ip', $ip); } /** @@ -157,7 +161,7 @@ class VisitRequestProcessor extends RequestProcessor */ protected function isLastActionInTheSameVisit(VisitProperties $visitProperties, Request $request) { - $lastActionTime = $visitProperties->visitorInfo['visit_last_action_time']; + $lastActionTime = $visitProperties->getProperty('visit_last_action_time'); return isset($lastActionTime) && false !== $lastActionTime @@ -171,7 +175,7 @@ class VisitRequestProcessor extends RequestProcessor */ private function wasLastActionNotToday(VisitProperties $visitProperties, Request $request) { - $lastActionTime = $visitProperties->visitorInfo['visit_last_action_time']; + $lastActionTime = $visitProperties->getProperty('visit_last_action_time'); if (empty($lastActionTime)) { return false; diff --git a/plugins/CoreHome/tests/Integration/Tracker/VisitRequestProcessorTest.php b/plugins/CoreHome/tests/Integration/Tracker/VisitRequestProcessorTest.php index fc9e9ad423..b4507eb74c 100644 --- a/plugins/CoreHome/tests/Integration/Tracker/VisitRequestProcessorTest.php +++ b/plugins/CoreHome/tests/Integration/Tracker/VisitRequestProcessorTest.php @@ -99,7 +99,7 @@ class VisitRequestProcessorTest extends IntegrationTestCase list($visit, $request) = $this->prepareVisitWithRequest(array('idsite' => $idsite), $currentActionTime); $visitProperties = new VisitProperties(); - $visitProperties->visitorInfo = array('visit_last_action_time' => Date::factory($lastActionTimestamp)->getTimestamp()); + $visitProperties->setProperty('visit_last_action_time', Date::factory($lastActionTimestamp)->getTimestamp()); $visitProperties->setRequestMetadata('CoreHome', 'isVisitorKnown', $isVisitorKnown); return array($visit, $visitProperties, $request); diff --git a/plugins/CustomVariables/Tracker/CustomVariablesRequestProcessor.php b/plugins/CustomVariables/Tracker/CustomVariablesRequestProcessor.php index 82dc17413e..86e656929b 100644 --- a/plugins/CustomVariables/Tracker/CustomVariablesRequestProcessor.php +++ b/plugins/CustomVariables/Tracker/CustomVariablesRequestProcessor.php @@ -50,7 +50,7 @@ class CustomVariablesRequestProcessor extends RequestProcessor $visitCustomVariables = $visitProperties->getRequestMetadata('CustomVariables', 'visitCustomVariables'); if (!empty($visitCustomVariables)) { - $visitProperties->visitorInfo = array_merge($visitProperties->visitorInfo, $visitCustomVariables); + $visitProperties->setProperties(array_merge($visitProperties->getProperties(), $visitCustomVariables)); } } diff --git a/plugins/Ecommerce/Tracker/EcommerceRequestProcessor.php b/plugins/Ecommerce/Tracker/EcommerceRequestProcessor.php index fd701207d9..1bdf430032 100644 --- a/plugins/Ecommerce/Tracker/EcommerceRequestProcessor.php +++ b/plugins/Ecommerce/Tracker/EcommerceRequestProcessor.php @@ -67,7 +67,8 @@ class EcommerceRequestProcessor extends RequestProcessor { $goalsConverted = $visitProperties->getRequestMetadata('Goals', 'goalsConverted'); if (!empty($goalsConverted)) { - $isThereExistingCartInVisit = $this->goalManager->detectIsThereExistingCartInVisit($visitProperties->visitorInfo); + $isThereExistingCartInVisit = $this->goalManager->detectIsThereExistingCartInVisit( + $visitProperties->getProperties()); $visitProperties->setRequestMetadata('Goals', 'isThereExistingCartInVisit', $isThereExistingCartInVisit); } } diff --git a/tests/PHPUnit/Integration/Tracker/Visit2Test.php b/tests/PHPUnit/Integration/Tracker/Visit2Test.php index 654226aa1b..889fa74dbf 100644 --- a/tests/PHPUnit/Integration/Tracker/Visit2Test.php +++ b/tests/PHPUnit/Integration/Tracker/Visit2Test.php @@ -97,8 +97,8 @@ class FakeTrackerVisit extends Visit $this->request = $request; $this->visitProperties = $visitProperties; - $this->visitProperties->visitorInfo['location_ip'] = $request->getIp(); - $this->visitProperties->visitorInfo['idvisitor'] = 1; + $this->visitProperties->setProperty('location_ip', $request->getIp()); + $this->visitProperties->setProperty('idvisitor', 1); } public function handleExistingVisit($visitIsConverted) @@ -123,7 +123,7 @@ class FakeTrackerVisit extends Visit public function getVisitorInfo() { - return $this->visitProperties->visitorInfo; + return $this->visitProperties->getProperties(); } protected function insertNewVisit($visit) |