Skip to content
Extraits de code Groupes Projets
Valider 7a98becb rédigé par sgiehl's avatar sgiehl
Parcourir les fichiers

use DeviceDetector instead of old UserAgentParser

parent cde0263a
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -14,7 +14,7 @@ use Piwik\Config; ...@@ -14,7 +14,7 @@ use Piwik\Config;
use Piwik\IP; use Piwik\IP;
use Piwik\Piwik; use Piwik\Piwik;
use Piwik\Tracker; use Piwik\Tracker;
use UserAgentParser; use DeviceDetector;
/** /**
* Class used to handle a Visit. * Class used to handle a Visit.
...@@ -592,20 +592,22 @@ class Visit implements VisitInterface ...@@ -592,20 +592,22 @@ class Visit implements VisitInterface
if (is_array($this->userSettingsInformation)) { if (is_array($this->userSettingsInformation)) {
return $this->userSettingsInformation; return $this->userSettingsInformation;
} }
require_once PIWIK_INCLUDE_PATH . '/libs/UserAgentParser/UserAgentParser.php';
list($plugin_Flash, $plugin_Java, $plugin_Director, $plugin_Quicktime, $plugin_RealPlayer, $plugin_PDF, list($plugin_Flash, $plugin_Java, $plugin_Director, $plugin_Quicktime, $plugin_RealPlayer, $plugin_PDF,
$plugin_WindowsMedia, $plugin_Gears, $plugin_Silverlight, $plugin_Cookie) = $this->request->getPlugins(); $plugin_WindowsMedia, $plugin_Gears, $plugin_Silverlight, $plugin_Cookie) = $this->request->getPlugins();
$resolution = $this->request->getParam('res'); $resolution = $this->request->getParam('res');
$userAgent = $this->request->getUserAgent(); $userAgent = $this->request->getUserAgent();
$aBrowserInfo = UserAgentParser::getBrowser($userAgent);
$browserName = ($aBrowserInfo !== false && $aBrowserInfo['id'] !== false) ? $aBrowserInfo['id'] : 'UNK'; $deviceDetector = new DeviceDetector($userAgent);
$deviceDetector->parse();
$aBrowserInfo = $deviceDetector->getBrowser();
$browserName = ($aBrowserInfo !== false && $aBrowserInfo['short_name'] !== false) ? $aBrowserInfo['short_name'] : 'UNK';
$browserVersion = ($aBrowserInfo !== false && $aBrowserInfo['version'] !== false) ? $aBrowserInfo['version'] : ''; $browserVersion = ($aBrowserInfo !== false && $aBrowserInfo['version'] !== false) ? $aBrowserInfo['version'] : '';
$os = UserAgentParser::getOperatingSystem($userAgent); $os = $deviceDetector->getOS();
$os = $os === false ? 'UNK' : $os['id']; $os = empty($os['short_name']) ? 'UNK' : $os['short_name'];
$browserLang = substr($this->request->getBrowserLanguage(), 0, 20); // limit the length of this string to match db $browserLang = substr($this->request->getBrowserLanguage(), 0, 20); // limit the length of this string to match db
$configurationHash = $this->getConfigHash( $configurationHash = $this->getConfigHash(
......
...@@ -65,7 +65,7 @@ class API extends \Piwik\Plugin\API ...@@ -65,7 +65,7 @@ class API extends \Piwik\Plugin\API
/** /**
* Gets a DataTable displaying number of visits by operating system family. The operating * Gets a DataTable displaying number of visits by operating system family. The operating
* system families are listed in /libs/UserAgentParser/UserAgentParser.php. * system families are listed in vendor piwik/device-detector.
*/ */
public function getOSFamily($idSite, $period, $date, $segment = false) public function getOSFamily($idSite, $period, $date, $segment = false)
{ {
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter