public static function getFirstIpFromList($csv, $excludedIps = null)
    {
        $p = strrpos($csv, ',');
        if ($p !== false) {
            $elements = explode(',', $csv);
            foreach ($elements as $ipString) {
                $element = trim(Common::sanitizeInputValue($ipString));
                if(empty($element)) {
                    continue;
                }
                $ip = \Piwik\Network\IP::fromStringIP(IPUtils::sanitizeIp($element));
                if (empty($excludedIps) || (!in_array($element, $excludedIps) && !$ip->isInRanges($excludedIps))) {
                    return $element;
                }
            }

            return '';
        }
        return trim(Common::sanitizeInputValue($csv));
    }