diff options
-rw-r--r-- | core/Tracker/Visit.php | 21 | ||||
-rw-r--r-- | plugins/Goals/Tracker/GoalsRequestProcessor.php | 22 |
2 files changed, 27 insertions, 16 deletions
diff --git a/core/Tracker/Visit.php b/core/Tracker/Visit.php index 7f26956fe1..0a5a2f0425 100644 --- a/core/Tracker/Visit.php +++ b/core/Tracker/Visit.php @@ -128,8 +128,6 @@ class Visit implements VisitInterface $isNewVisit = $this->isVisitNew($visitor, $action); $goalManager = GoalsRequestProcessor::$goalManager; - $isManualGoalConversion = $goalManager->isManualGoalConversion(); - $requestIsEcommerce = $goalManager->requestIsEcommerce; foreach ($this->requestProcessors as $processor) { $abort = $processor->manipulateVisitProperties($this->visitProperties, $this->request); @@ -146,7 +144,6 @@ class Visit implements VisitInterface // AND // - the last page view for this visitor was less than 30 minutes ago @see isLastActionInTheSameVisit() if (!$isNewVisit) { - $idReferrerActionUrl = $this->visitProperties->visitorInfo['visit_exit_idaction_url']; $idReferrerActionName = $this->visitProperties->visitorInfo['visit_exit_idaction_name']; @@ -161,19 +158,7 @@ class Visit implements VisitInterface $action->record($visitor, $idReferrerActionUrl, $idReferrerActionName); } } catch (VisitorNotFoundInDb $e) { - - // There is an edge case when: - // - two manual goal conversions happen in the same second - // - which result in handleExistingVisit throwing the exception - // because the UPDATE didn't affect any rows (one row was found, but not updated since no field changed) - // - the exception is caught here and will result in a new visit incorrectly - // In this case, we cancel the current conversion to be recorded: - if ($isManualGoalConversion - || $requestIsEcommerce - ) { - $this->visitProperties->setRequestMetadata('Goals', 'someGoalsConverted', false); - $this->visitProperties->setRequestMetadata('Goals', 'visitIsConverted', false); - } + $this->visitProperties->setRequestMetadata('CoreHome', 'visitorNotFoundInDb', true); } } @@ -199,6 +184,10 @@ class Visit implements VisitInterface // update the cookie with the new visit information $this->request->setThirdPartyCookie($this->visitProperties->visitorInfo['idvisitor']); + foreach ($this->requestProcessors as $processor) { + $processor->processRequest($this->visitProperties); + } + // record the goals if applicable if ($this->visitProperties->getRequestMetadata('Goals', 'someGoalsConverted')) { $goalManager->recordGoals( diff --git a/plugins/Goals/Tracker/GoalsRequestProcessor.php b/plugins/Goals/Tracker/GoalsRequestProcessor.php index 22315f7511..2bde947928 100644 --- a/plugins/Goals/Tracker/GoalsRequestProcessor.php +++ b/plugins/Goals/Tracker/GoalsRequestProcessor.php @@ -70,4 +70,26 @@ class GoalsRequestProcessor extends RequestProcessor $visitProperties->setRequestMetadata('Goals', 'visitIsConverted', $someGoalsConverted); } } + + public function processRequest(VisitProperties $visitProperties) + { + $isManualGoalConversion = self::$goalManager->isManualGoalConversion(); + $requestIsEcommerce = self::$goalManager->requestIsEcommerce; + + $visitorNotFoundInDb = $visitProperties->getRequestMetadata('CoreHome', 'visitorNotFoundInDb'); + + // There is an edge case when: + // - two manual goal conversions happen in the same second + // - which result in handleExistingVisit throwing the exception + // because the UPDATE didn't affect any rows (one row was found, but not updated since no field changed) + // - the exception is caught here and will result in a new visit incorrectly + // In this case, we cancel the current conversion to be recorded: + if ($visitorNotFoundInDb + && ($isManualGoalConversion + || $requestIsEcommerce) + ) { + $visitProperties->setRequestMetadata('Goals', 'someGoalsConverted', false); + $visitProperties->setRequestMetadata('Goals', 'visitIsConverted', false); + } + } } |