Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Giehl <stefan@matomo.org>2019-04-10 22:59:31 +0300
committerdiosmosis <diosmosis@users.noreply.github.com>2019-04-10 22:59:31 +0300
commitbeff637e0ec74154b81ca18de50f7c9d30092e8e (patch)
tree39a82c6864c6289e8cbe3dd67e38d672d5e0821c /plugins/DevicesDetection
parentff1c579f1faa003e461db2534f2606bd4ac4ddaa (diff)
Readable segment values for browser, os and country segments (#13929)
* Use readable segment value for browser and os segments instead of short codes * readds original segments using short codes * Adds additional segment country name to segment by (english) country name * compare browser and os names case sensitive for segments * use correct segments for reports * update tests
Diffstat (limited to 'plugins/DevicesDetection')
-rw-r--r--plugins/DevicesDetection/API.php2
-rw-r--r--plugins/DevicesDetection/Columns/BrowserName.php40
-rw-r--r--plugins/DevicesDetection/Columns/Os.php40
-rw-r--r--plugins/DevicesDetection/lang/en.json2
4 files changed, 79 insertions, 5 deletions
diff --git a/plugins/DevicesDetection/API.php b/plugins/DevicesDetection/API.php
index 667affa57b..8e4625f75a 100644
--- a/plugins/DevicesDetection/API.php
+++ b/plugins/DevicesDetection/API.php
@@ -255,7 +255,7 @@ class API extends \Piwik\Plugin\API
public function getBrowsers($idSite, $period, $date, $segment = false)
{
$dataTable = $this->getDataTable('DevicesDetection_browsers', $idSite, $period, $date, $segment);
- $dataTable->filter('AddSegmentValue');
+ $dataTable->filter('AddSegmentByLabel', ['browserCode']);
// handle legacy archives
if ($dataTable instanceof DataTable\Map || !$dataTable->getRowsCount()) {
diff --git a/plugins/DevicesDetection/Columns/BrowserName.php b/plugins/DevicesDetection/Columns/BrowserName.php
index 0fe0d724d5..0c94371316 100644
--- a/plugins/DevicesDetection/Columns/BrowserName.php
+++ b/plugins/DevicesDetection/Columns/BrowserName.php
@@ -8,7 +8,10 @@
*/
namespace Piwik\Plugins\DevicesDetection\Columns;
+use DeviceDetector\Parser\Client\Browser;
+use Piwik\Common;
use Piwik\Metrics\Formatter;
+use Piwik\Plugin\Segment;
use Piwik\Tracker\Request;
use Piwik\Tracker\Visitor;
use Piwik\Tracker\Action;
@@ -17,12 +20,45 @@ class BrowserName extends Base
{
protected $columnName = 'config_browser_name';
protected $columnType = 'VARCHAR(10) NULL';
- protected $segmentName = 'browserCode';
+ protected $segmentName = 'browserName';
protected $nameSingular = 'DevicesDetection_ColumnBrowser';
protected $namePlural = 'DevicesDetection_Browsers';
- protected $acceptValues = 'FF, IE, CH, SF, OP, etc.';
+ protected $acceptValues = 'FireFox, Internet Explorer, Chrome, Safari, Opera etc.';
protected $type = self::TYPE_TEXT;
+ public function __construct()
+ {
+ $this->sqlFilterValue = function ($val) {
+ $browsers = Browser::getAvailableBrowsers();
+ array_map(function($val) {
+ return Common::mb_strtolower($val);
+ }, $browsers);
+ $result = array_search(Common::mb_strtolower($val), $browsers);
+
+ if ($result === false) {
+ $result = 'UNK';
+ }
+
+ return $result;
+ };
+ $this->suggestedValuesCallback = function ($idSite, $maxValuesToReturn) {
+ return array_values(Browser::getAvailableBrowsers() + ['Unknown']);
+ };
+ }
+
+ protected function configureSegments()
+ {
+ parent::configureSegments();
+
+ $segment = new Segment();
+ $segment->setSegment('browserCode');
+ $segment->setName('DevicesDetection_BrowserCode');
+ $segment->setAcceptedValues('FF, IE, CH, SF, OP etc.');
+ $this->suggestedValuesCallback = null;
+ $this->sqlFilterValue = null;
+ $this->addSegment($segment);
+ }
+
public function formatValue($value, $idSite, Formatter $formatter)
{
return \Piwik\Plugins\DevicesDetection\getBrowserName($value);
diff --git a/plugins/DevicesDetection/Columns/Os.php b/plugins/DevicesDetection/Columns/Os.php
index 455b971486..e3003b46fa 100644
--- a/plugins/DevicesDetection/Columns/Os.php
+++ b/plugins/DevicesDetection/Columns/Os.php
@@ -8,8 +8,11 @@
*/
namespace Piwik\Plugins\DevicesDetection\Columns;
+use DeviceDetector\Parser\OperatingSystem;
+use Piwik\Common;
use Piwik\Metrics\Formatter;
use Piwik\Piwik;
+use Piwik\Plugin\Segment;
use Piwik\Tracker\Request;
use Piwik\Tracker\Settings;
use Piwik\Tracker\Visitor;
@@ -19,12 +22,45 @@ class Os extends Base
{
protected $columnName = 'config_os';
protected $columnType = 'CHAR(3) NULL';
- protected $segmentName = 'operatingSystemCode';
+ protected $segmentName = 'operatingSystemName';
protected $nameSingular = 'DevicesDetection_ColumnOperatingSystem';
protected $namePlural = 'DevicesDetection_OperatingSystems';
- protected $acceptValues = 'WIN, MAC, LIN, AND, IPD, etc.';
+ protected $acceptValues = 'Windows, Linux, Mac, Android, iOS etc.';
protected $type = self::TYPE_TEXT;
+ public function __construct()
+ {
+ $this->sqlFilterValue = function ($val) {
+ $oss = OperatingSystem::getAvailableOperatingSystems();
+ array_map(function($val) {
+ return Common::mb_strtolower($val);
+ }, $oss);
+ $result = array_search(Common::mb_strtolower($val), $oss);
+
+ if ($result === false) {
+ $result = 'UNK';
+ }
+
+ return $result;
+ };
+ $this->suggestedValuesCallback = function ($idSite, $maxValuesToReturn) {
+ return array_values(OperatingSystem::getAvailableOperatingSystems() + ['Unknown']);
+ };
+ }
+
+ protected function configureSegments()
+ {
+ parent::configureSegments();
+
+ $segment = new Segment();
+ $segment->setSegment('operatingSystemCode');
+ $segment->setName('DevicesDetection_OperatingSystemCode');
+ $segment->setAcceptedValues('WIN, LIN, MAX, AND, IOS etc.');
+ $this->suggestedValuesCallback = null;
+ $this->sqlFilterValue = null;
+ $this->addSegment($segment);
+ }
+
public function formatValue($value, $idSite, Formatter $formatter)
{
return \Piwik\Plugins\DevicesDetection\getOSFamilyFullName($value);
diff --git a/plugins/DevicesDetection/lang/en.json b/plugins/DevicesDetection/lang/en.json
index 732deb200b..33789201e6 100644
--- a/plugins/DevicesDetection/lang/en.json
+++ b/plugins/DevicesDetection/lang/en.json
@@ -11,6 +11,7 @@
"CarBrowser": "Car browser",
"Software": "Software",
"ColumnBrowser": "Browser",
+ "BrowserCode": "Browser code",
"ColumnOperatingSystem": "Operating system",
"ColumnOperatingSystemVersion": "Operating system version",
"Console": "Console",
@@ -30,6 +31,7 @@
"FeaturePhone": "Feature phone",
"OperatingSystemFamilies": "Operating System families",
"OperatingSystemFamily": "Operating system family",
+ "OperatingSystemCode": "Operating system code",
"OperatingSystems": "Operating systems",
"OperatingSystemVersions": "Operating System versions",
"PluginDescription": "Provides extended information about user devices, such as Brand (manufacturer), Model (device version), device type (tv, consoles, smart phones, desktop, etc) and more.",