diff options
author | Stefan Giehl <stefan@piwik.org> | 2018-01-07 02:41:29 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-01-07 02:41:29 +0300 |
commit | 390edc755a4ae1f5e88542189a8e19d5c5155dfd (patch) | |
tree | 9c36de1402bcb89207c5fbcacc9972deb4fce78b /plugins | |
parent | 48864a124789b665a649e6e5bd75692048fcba76 (diff) |
Adds segment for device model (#12298)
* Adds segment for device model
and segmented visitor log link to device model report
* update tests
* submodule update
Diffstat (limited to 'plugins')
m--------- | plugins/CustomDimensions | 0 | ||||
-rw-r--r-- | plugins/DevicesDetection/API.php | 20 | ||||
-rw-r--r-- | plugins/DevicesDetection/Columns/DeviceModel.php | 2 | ||||
-rw-r--r-- | plugins/DevicesDetection/tests/System/expected/test___DevicesDetection.getModel_day.xml | 7 |
4 files changed, 29 insertions, 0 deletions
diff --git a/plugins/CustomDimensions b/plugins/CustomDimensions -Subproject 0106441a5d4873aaacc08d2143551669d956348 +Subproject 097b3454fdf99554a5ba1bca102c0a2de728e90 diff --git a/plugins/DevicesDetection/API.php b/plugins/DevicesDetection/API.php index 3cd5c13e80..667affa57b 100644 --- a/plugins/DevicesDetection/API.php +++ b/plugins/DevicesDetection/API.php @@ -111,6 +111,26 @@ class API extends \Piwik\Plugin\API public function getModel($idSite, $period, $date, $segment = false) { $dataTable = $this->getDataTable('DevicesDetection_models', $idSite, $period, $date, $segment); + + $dataTable->filter(function (DataTable $table) { + foreach ($table->getRowsWithoutSummaryRow() as $row) { + + $label = $row->getColumn('label'); + + if (strpos($label, ';') !== false) { + list($brand, $model) = explode(';', $label, 2); + $brand = getDeviceBrandLabel($brand); + } else { + $brand = null; + $model = $label; + } + + $segment = sprintf('deviceBrand==%s;deviceModel==%s', urlencode($brand), urlencode($model)); + + $row->setMetadata('segment', $segment); + } + }); + $dataTable->filter('GroupBy', array('label', __NAMESPACE__ . '\getModelName')); return $dataTable; } diff --git a/plugins/DevicesDetection/Columns/DeviceModel.php b/plugins/DevicesDetection/Columns/DeviceModel.php index 4ac962f0e1..932334e3ed 100644 --- a/plugins/DevicesDetection/Columns/DeviceModel.php +++ b/plugins/DevicesDetection/Columns/DeviceModel.php @@ -19,6 +19,8 @@ class DeviceModel extends Base protected $type = self::TYPE_TEXT; protected $nameSingular = 'DevicesDetection_DeviceModel'; protected $namePlural = 'DevicesDetection_DeviceModels'; + protected $segmentName = 'deviceModel'; + protected $acceptValues = 'iPad, Nexus 5, Galaxy S5, Fire TV, etc.'; /** * @param Request $request diff --git a/plugins/DevicesDetection/tests/System/expected/test___DevicesDetection.getModel_day.xml b/plugins/DevicesDetection/tests/System/expected/test___DevicesDetection.getModel_day.xml index 3ed4a7857a..da6473c98b 100644 --- a/plugins/DevicesDetection/tests/System/expected/test___DevicesDetection.getModel_day.xml +++ b/plugins/DevicesDetection/tests/System/expected/test___DevicesDetection.getModel_day.xml @@ -18,6 +18,7 @@ </goals> <nb_conversions>3</nb_conversions> <revenue>62.26</revenue> + <segment>deviceBrand==Unknown;deviceModel==</segment> </row> <row> <label>Apple - iPad</label> @@ -37,6 +38,7 @@ </goals> <nb_conversions>1</nb_conversions> <revenue>42.26</revenue> + <segment>deviceBrand==Apple;deviceModel==iPad</segment> </row> <row> <label>Apple - iPhone 5S</label> @@ -56,6 +58,7 @@ </goals> <nb_conversions>1</nb_conversions> <revenue>10</revenue> + <segment>deviceBrand==Apple;deviceModel==iPhone+5S</segment> </row> <row> <label>HTC - Butterfly</label> @@ -75,6 +78,7 @@ </goals> <nb_conversions>1</nb_conversions> <revenue>42.26</revenue> + <segment>deviceBrand==HTC;deviceModel==Butterfly</segment> </row> <row> <label>Philips - Blu-ray Player (BDP5600)</label> @@ -86,6 +90,7 @@ <sum_visit_length>0</sum_visit_length> <bounce_count>1</bounce_count> <nb_visits_converted>0</nb_visits_converted> + <segment>deviceBrand==Philips;deviceModel==Blu-ray+Player+%28BDP5600%29</segment> </row> <row> <label>Samsung - GALAXY Tab 3 8.0" WiFi</label> @@ -97,6 +102,7 @@ <sum_visit_length>0</sum_visit_length> <bounce_count>1</bounce_count> <nb_visits_converted>0</nb_visits_converted> + <segment>deviceBrand==Samsung;deviceModel==GALAXY+Tab+3+8.0%22+WiFi</segment> </row> <row> <label>ViewSonic - ViewPad 7e</label> @@ -116,5 +122,6 @@ </goals> <nb_conversions>1</nb_conversions> <revenue>10</revenue> + <segment>deviceBrand==ViewSonic;deviceModel==ViewPad+7e</segment> </row> </result>
\ No newline at end of file |