public function onNewVisit(Request $request, Visitor $visitor, $action)
{
$value = $this->getUrlOverrideValueIfAllowed('country', $request);
if ($value !== false) {
return $value;
}
$userInfo = $this->getUserInfo($request, $visitor);
$country = $this->getLocationDetail($userInfo, LocationProvider::COUNTRY_CODE_KEY);
if (!empty($country) && $country != Visit::UNKNOWN_CODE) {
return strtolower($country);
}
$country = $this->getCountryUsingProviderExtensionIfValid($userInfo['ip']);
if (!empty($country)) {
return $country;
}
return Visit::UNKNOWN_CODE;
}