Piwik\Plugins\CoreHome\Columns\VisitTotalTime::onConvertedVisit PHP Method

onConvertedVisit() public method

public onConvertedVisit ( Request $request, Piwik\Tracker\Visitor $visitor, Action | null $action ) : integer
$request Piwik\Tracker\Request
$visitor Piwik\Tracker\Visitor
$action Piwik\Tracker\Action | null
return integer
    public function onConvertedVisit(Request $request, Visitor $visitor, $action)
    {
        if (!$visitor->isVisitorKnown()) {
            return false;
        }
        $totalTime = $visitor->getVisitorColumn('visit_total_time');
        // If a pageview and goal conversion in the same second, with previously a goal conversion recorded
        // the request would not "update" the row since all values are the same as previous
        // therefore the request below throws exception, instead we make sure the UPDATE will affect the row
        $totalTime = $totalTime + $request->getParam('idgoal');
        // +2 to offset idgoal=-1 and idgoal=0
        $totalTime = $totalTime + 2;
        return $this->cleanupVisitTotalTime($totalTime);
    }