1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
|
<?php
/**
* Matomo - free/libre analytics platform
*
* @link https://matomo.org
* @license https://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
namespace Piwik\Plugins\Actions\Columns;
use Piwik\Columns\DimensionMetricFactory;
use Piwik\Columns\MetricsList;
use Piwik\Development;
use Piwik\Piwik;
use Piwik\Plugin\Dimension\ActionDimension;
use Exception;
/**
* This example dimension only defines a name and does not track any data. It's supposed to be only used in reports.
*
* See {@link https://developer.matomo.org/api-reference/Piwik/Columns\Dimension} for more information.
*/
class ActionType extends ActionDimension
{
protected $columnName = 'type';
protected $dbTableName = 'log_action';
protected $segmentName = 'actionType';
protected $type = self::TYPE_ENUM;
protected $nameSingular = 'Actions_ActionType';
protected $namePlural = 'Actions_ActionTypes';
protected $category = 'General_Actions';
public function getAcceptValues()
{
return Piwik::translate('Actions_ActionTypeSegmentHelp', 'pageviews, contents, sitesearches, events, outlinks, downloads');
}
public function getEnumColumnValues()
{
$availableTypes = [];
/**
* Triggered to determine the available action types
*
* Plugin can use this event to add their own action types, so they are available in segmentation
* The array maps internal ids to readable action type names used in visitor details
*
* **Example**
*
* public function addActionTypes(&$availableTypes)
* {
* $availableTypes[] = array(
* 'id' => 76,
* 'name' => 'media_play'
* );
* }
*
* @param array $availableTypes
*/
Piwik::postEvent('Actions.addActionTypes', [&$availableTypes]);
$types = [];
foreach ($availableTypes as $type) {
if (empty($type['id']) || empty($type['name'])) {
throw new Exception("Invalid action added with event `Actions.addActionTypes`: " . var_export($type, true));
}
if (Development::isEnabled() && array_key_exists($type['id'], $types)) {
throw new Exception(sprintf("Action '%s' with id %s couldn't be added, as '%s' was already added for this id", $type['name'], $type['id'], $types[$type['id']]));
}
$types[$type['id']] = $type['name'];
}
return $types;
}
public function configureMetrics(MetricsList $metricsList, DimensionMetricFactory $dimensionMetricFactory)
{
// do not generate any metric for this
}
}
|