/**
* Records in the DB the association between the visit and this action.
*
* @param int $idReferrerActionUrl is the ID of the last action done by the current visit.
* @param $idReferrerActionName
* @param Visitor $visitor
*/
public function record(Visitor $visitor, $idReferrerActionUrl, $idReferrerActionName)
{
$this->loadIdsFromLogActionTable();
$visitAction = array('idvisit' => $visitor->getVisitorColumn('idvisit'), 'idsite' => $this->request->getIdSite(), 'idvisitor' => $visitor->getVisitorColumn('idvisitor'), 'idaction_url' => $this->getIdActionUrl(), 'idaction_url_ref' => $idReferrerActionUrl, 'idaction_name_ref' => $idReferrerActionName);
/** @var ActionDimension[] $dimensions */
$dimensions = ActionDimension::getAllDimensions();
foreach ($dimensions as $dimension) {
$value = $dimension->onNewAction($this->request, $visitor, $this);
if ($value !== false) {
if (is_float($value)) {
$value = Common::forceDotAsSeparatorForDecimalPoint($value);
}
$visitAction[$dimension->getColumnName()] = $value;
}
}
// idaction_name is NULLable. we only set it when applicable
if ($this->isActionHasActionName()) {
$visitAction['idaction_name'] = (int) $this->getIdActionName();
}
foreach ($this->actionIdsCached as $field => $idAction) {
$visitAction[$field] = $idAction === false ? 0 : $idAction;
}
$customValue = $this->getCustomFloatValue();
if (!empty($customValue)) {
$visitAction[self::DB_COLUMN_CUSTOM_FLOAT] = Common::forceDotAsSeparatorForDecimalPoint($customValue);
}
$visitAction = array_merge($visitAction, $this->customFields);
$this->idLinkVisitAction = $this->getModel()->createAction($visitAction);
$visitAction['idlink_va'] = $this->idLinkVisitAction;
Common::printDebug("Inserted new action:");
$visitActionDebug = $visitAction;
$visitActionDebug['idvisitor'] = bin2hex($visitActionDebug['idvisitor']);
Common::printDebug($visitActionDebug);
}