/**
* Logs the provider in the log_visit table
*/
public function enrichVisitWithProviderInfo(&$visitorInfo, \Piwik\Tracker\Request $request)
{
// if provider info has already been set, abort
if (!empty($visitorInfo['location_provider'])) {
return;
}
$privacyConfig = new PrivacyManagerConfig();
$ip = IP::N2P($privacyConfig->useAnonymizedIpForVisitEnrichment ? $visitorInfo['location_ip'] : $request->getIp());
// In case the IP was anonymized, we should not continue since the DNS reverse lookup will fail and this will slow down tracking
if (substr($ip, -2, 2) == '.0') {
Common::printDebug("IP Was anonymized so we skip the Provider DNS reverse lookup...");
return;
}
$hostname = $this->getHost($ip);
$hostnameExtension = $this->getCleanHostname($hostname);
// add the provider value in the table log_visit
$visitorInfo['location_provider'] = $hostnameExtension;
$visitorInfo['location_provider'] = substr($visitorInfo['location_provider'], 0, 100);
// improve the country using the provider extension if valid
$hostnameDomain = substr($hostnameExtension, 1 + strrpos($hostnameExtension, '.'));
if ($hostnameDomain == 'uk') {
$hostnameDomain = 'gb';
}
if (array_key_exists($hostnameDomain, Common::getCountriesList())) {
$visitorInfo['location_country'] = $hostnameDomain;
}
}