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:
authorsgiehl <stefan@piwik.org>2016-04-08 14:56:00 +0300
committerThomas Steur <thomas.steur@gmail.com>2016-08-31 16:10:58 +0300
commit0b3f3afbbb5cb3134e4b1d257afcec1642da743a (patch)
treeb3ea6a8d6597b7fed784b86e5baf91d99e1bc8e0 /plugins/DevicesDetection
parentcc49ce8ab019ae1c4ba2ccd26e0f7b0eaef4a492 (diff)
Process goal conversions for device data (type, brand, model)
Diffstat (limited to 'plugins/DevicesDetection')
-rw-r--r--plugins/DevicesDetection/API.php6
-rw-r--r--plugins/DevicesDetection/Archiver.php22
-rw-r--r--plugins/DevicesDetection/Columns/DeviceBrand.php11
-rw-r--r--plugins/DevicesDetection/Columns/DeviceModel.php11
-rw-r--r--plugins/DevicesDetection/Columns/DeviceType.php11
-rw-r--r--plugins/DevicesDetection/Reports/GetBrand.php2
-rw-r--r--plugins/DevicesDetection/Reports/GetModel.php2
-rw-r--r--plugins/DevicesDetection/Reports/GetType.php2
8 files changed, 59 insertions, 8 deletions
diff --git a/plugins/DevicesDetection/API.php b/plugins/DevicesDetection/API.php
index 69b3f80cdb..3cd5c13e80 100644
--- a/plugins/DevicesDetection/API.php
+++ b/plugins/DevicesDetection/API.php
@@ -56,7 +56,7 @@ class API extends \Piwik\Plugin\API
$mapping = DeviceParserAbstract::getAvailableDeviceTypeNames();
$dataTable->filter('AddSegmentByLabelMapping', array('deviceType', $mapping));
$dataTable->filter('ColumnCallbackAddMetadata', array('label', 'logo', __NAMESPACE__ . '\getDeviceTypeLogo'));
- $dataTable->filter('ColumnCallbackReplace', array('label', __NAMESPACE__ . '\getDeviceTypeLabel'));
+ $dataTable->filter('GroupBy', array('label', __NAMESPACE__ . '\getDeviceTypeLabel'));
return $dataTable;
}
@@ -94,7 +94,7 @@ class API extends \Piwik\Plugin\API
public function getBrand($idSite, $period, $date, $segment = false)
{
$dataTable = $this->getDataTable('DevicesDetection_brands', $idSite, $period, $date, $segment);
- $dataTable->filter('ColumnCallbackReplace', array('label', __NAMESPACE__ . '\getDeviceBrandLabel'));
+ $dataTable->filter('GroupBy', array('label', __NAMESPACE__ . '\getDeviceBrandLabel'));
$dataTable->filter('ColumnCallbackAddMetadata', array('label', 'logo', __NAMESPACE__ . '\getBrandLogo'));
$dataTable->filter('AddSegmentByLabel', array('deviceBrand'));
return $dataTable;
@@ -111,7 +111,7 @@ 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('ColumnCallbackReplace', array('label', __NAMESPACE__ . '\getModelName'));
+ $dataTable->filter('GroupBy', array('label', __NAMESPACE__ . '\getModelName'));
return $dataTable;
}
diff --git a/plugins/DevicesDetection/Archiver.php b/plugins/DevicesDetection/Archiver.php
index eac17db343..bd8019cd91 100644
--- a/plugins/DevicesDetection/Archiver.php
+++ b/plugins/DevicesDetection/Archiver.php
@@ -73,8 +73,26 @@ class Archiver extends \Piwik\Plugin\Archiver
private function aggregateByLabel($labelSQL, $recordName)
{
- $metrics = $this->getLogAggregator()->getMetricsFromVisitByDimension($labelSQL)->asDataTable();
- $report = $metrics->getSerialized($this->maximumRows, null, Metrics::INDEX_NB_VISITS);
+ $metrics = $this->getLogAggregator()->getMetricsFromVisitByDimension($labelSQL);
+
+ if (in_array($recordName, array(self::DEVICE_TYPE_RECORD_NAME, self::DEVICE_BRAND_RECORD_NAME, self::DEVICE_MODEL_RECORD_NAME))) {
+
+ $labelSQL = str_replace('log_visit.', 'log_conversion.', $labelSQL);
+
+ $query = $this->getLogAggregator()->queryConversionsByDimension(array($labelSQL));
+
+ if ($query === false) {
+ return;
+ }
+
+ while ($conversionRow = $query->fetch()) {
+
+ $metrics->sumMetricsGoals($conversionRow[$labelSQL], $conversionRow);
+ }
+ $metrics->enrichMetricsWithConversions();
+ }
+
+ $report = $metrics->asDataTable()->getSerialized($this->maximumRows, null, Metrics::INDEX_NB_VISITS);
$this->getProcessor()->insertBlobRecord($recordName, $report);
}
diff --git a/plugins/DevicesDetection/Columns/DeviceBrand.php b/plugins/DevicesDetection/Columns/DeviceBrand.php
index f21d1ed15e..f10f5e5ca0 100644
--- a/plugins/DevicesDetection/Columns/DeviceBrand.php
+++ b/plugins/DevicesDetection/Columns/DeviceBrand.php
@@ -60,4 +60,15 @@ class DeviceBrand extends Base
return $parser->getBrand();
}
+
+ /**
+ * @param Request $request
+ * @param Visitor $visitor
+ * @param Action|null $action
+ * @return mixed
+ */
+ public function onAnyGoalConversion(Request $request, Visitor $visitor, $action)
+ {
+ return $visitor->getVisitorColumn('config_device_brand');
+ }
}
diff --git a/plugins/DevicesDetection/Columns/DeviceModel.php b/plugins/DevicesDetection/Columns/DeviceModel.php
index 488eeb615e..f28693e290 100644
--- a/plugins/DevicesDetection/Columns/DeviceModel.php
+++ b/plugins/DevicesDetection/Columns/DeviceModel.php
@@ -36,4 +36,15 @@ class DeviceModel extends Base
return $parser->getModel();
}
+
+ /**
+ * @param Request $request
+ * @param Visitor $visitor
+ * @param Action|null $action
+ * @return mixed
+ */
+ public function onAnyGoalConversion(Request $request, Visitor $visitor, $action)
+ {
+ return $visitor->getVisitorColumn('config_device_model');
+ }
}
diff --git a/plugins/DevicesDetection/Columns/DeviceType.php b/plugins/DevicesDetection/Columns/DeviceType.php
index 3c7320326b..3cdf5a6ae5 100644
--- a/plugins/DevicesDetection/Columns/DeviceType.php
+++ b/plugins/DevicesDetection/Columns/DeviceType.php
@@ -61,4 +61,15 @@ class DeviceType extends Base
return $parser->getDevice();
}
+
+ /**
+ * @param Request $request
+ * @param Visitor $visitor
+ * @param Action|null $action
+ * @return mixed
+ */
+ public function onAnyGoalConversion(Request $request, Visitor $visitor, $action)
+ {
+ return $visitor->getVisitorColumn('config_device_type');
+ }
} \ No newline at end of file
diff --git a/plugins/DevicesDetection/Reports/GetBrand.php b/plugins/DevicesDetection/Reports/GetBrand.php
index 41b9fd5366..1dc3f01c58 100644
--- a/plugins/DevicesDetection/Reports/GetBrand.php
+++ b/plugins/DevicesDetection/Reports/GetBrand.php
@@ -21,7 +21,7 @@ class GetBrand extends Base
$this->name = Piwik::translate('DevicesDetection_DeviceBrand');
$this->documentation = ''; // TODO
$this->order = 4;
-
+ $this->hasGoalMetrics = true;
$this->subcategoryId = 'DevicesDetection_Devices';
}
diff --git a/plugins/DevicesDetection/Reports/GetModel.php b/plugins/DevicesDetection/Reports/GetModel.php
index 154464691c..0490549f7a 100644
--- a/plugins/DevicesDetection/Reports/GetModel.php
+++ b/plugins/DevicesDetection/Reports/GetModel.php
@@ -21,7 +21,7 @@ class GetModel extends Base
$this->name = Piwik::translate('DevicesDetection_DeviceModel');
$this->documentation = ''; // TODO
$this->order = 2;
-
+ $this->hasGoalMetrics = true;
$this->subcategoryId = 'DevicesDetection_Devices';
}
diff --git a/plugins/DevicesDetection/Reports/GetType.php b/plugins/DevicesDetection/Reports/GetType.php
index b12f19f319..71abbd871c 100644
--- a/plugins/DevicesDetection/Reports/GetType.php
+++ b/plugins/DevicesDetection/Reports/GetType.php
@@ -22,7 +22,7 @@ class GetType extends Base
$this->name = Piwik::translate('DevicesDetection_DeviceType');
$this->documentation = ''; // TODO
$this->order = 0;
-
+ $this->hasGoalMetrics = true;
$this->subcategoryId = 'DevicesDetection_Devices';
}