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:
authorThomas Steur <thomas.steur@gmail.com>2015-11-30 03:47:21 +0300
committerThomas Steur <thomas.steur@gmail.com>2015-12-01 06:19:52 +0300
commitea9ac058ff5da7ffe8354529e13e927ddcaf3f27 (patch)
tree50bc2d87e6c7e7fdbccb0458528d2512fb78ff94 /plugins
parent5ce9ba9744ef93c193b21cfcafe39c719b592fd9 (diff)
New segment: ActionType
Diffstat (limited to 'plugins')
-rw-r--r--plugins/Actions/ArchivingHelper.php2
-rw-r--r--plugins/Actions/Columns/ActionType.php70
-rw-r--r--plugins/Actions/lang/en.json3
-rw-r--r--plugins/Events/Actions/ActionEvent.php14
-rw-r--r--plugins/Live/Visitor.php2
-rw-r--r--plugins/SegmentEditor/SegmentSelectorControl.php13
6 files changed, 87 insertions, 17 deletions
diff --git a/plugins/Actions/ArchivingHelper.php b/plugins/Actions/ArchivingHelper.php
index b5735225b8..192a3089ba 100644
--- a/plugins/Actions/ArchivingHelper.php
+++ b/plugins/Actions/ArchivingHelper.php
@@ -53,7 +53,7 @@ class ArchivingHelper
unset($row[PiwikMetrics::INDEX_SITE_SEARCH_HAS_NO_RESULT]);
}
- if ($row['type'] == Action::TYPE_CONTENT) {
+ if (in_array($row['type'], array(Action::TYPE_CONTENT, Action::TYPE_EVENT))) {
continue;
}
diff --git a/plugins/Actions/Columns/ActionType.php b/plugins/Actions/Columns/ActionType.php
new file mode 100644
index 0000000000..3d6e9b599a
--- /dev/null
+++ b/plugins/Actions/Columns/ActionType.php
@@ -0,0 +1,70 @@
+<?php
+/**
+ * Piwik - free/libre analytics platform
+ *
+ * @link http://piwik.org
+ * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
+ *
+ */
+namespace Piwik\Plugins\Actions\Columns;
+
+use Piwik\Piwik;
+use Piwik\Plugin\Dimension\ActionDimension;
+use Piwik\Plugins\Actions\Segment;
+use Piwik\Tracker\Action;
+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 http://developer.piwik.org/api-reference/Piwik/Columns\Dimension} for more information.
+ */
+class ActionType extends ActionDimension
+{
+ private $types = array(
+ Action::TYPE_PAGE_URL => 'pageviews',
+ Action::TYPE_CONTENT => 'contents',
+ Action::TYPE_SITE_SEARCH => 'sitesearches',
+ Action::TYPE_EVENT => 'events',
+ Action::TYPE_OUTLINK => 'outlinks',
+ Action::TYPE_DOWNLOAD => 'downloads'
+ );
+
+ /**
+ * The name of the dimension which will be visible for instance in the UI of a related report and in the mobile app.
+ * @return string
+ */
+ public function getName()
+ {
+ return Piwik::translate('Actions_ActionType');
+ }
+
+ protected function configureSegments()
+ {
+ $types = $this->types;
+
+ $segment = new Segment();
+ $segment->setSegment('actionType');
+ $segment->setName('Actions_ActionType');
+ $segment->setSqlSegment('log_action.type');
+ $segment->setType(Segment::TYPE_METRIC);
+ $segment->setAcceptedValues(sprintf('A type of action, such as: %s', implode(', ', $types)));
+ $segment->setSqlFilter(function ($type) use ($types) {
+ if (array_key_exists($type, $types)) {
+ return $type;
+ }
+
+ $index = array_search(strtolower(trim(urldecode($type))), $types);
+
+ if ($index === false) {
+ throw new Exception("actionType must be one of: " . implode(', ', $types));
+ }
+
+ return $index;
+ });
+ $segment->setSuggestedValuesCallback(function ($idSite, $maxSuggestionsToReturn) use ($types) {
+ return array_slice(array_values($types), 0, $maxSuggestionsToReturn);
+ });
+ $this->addSegment($segment);
+ }
+} \ No newline at end of file
diff --git a/plugins/Actions/lang/en.json b/plugins/Actions/lang/en.json
index b4853e18f5..f176db870d 100644
--- a/plugins/Actions/lang/en.json
+++ b/plugins/Actions/lang/en.json
@@ -61,6 +61,7 @@
"WidgetPageUrlsFollowingSearch": "Pages Following a Site Search",
"WidgetSearchCategories": "Search Categories",
"WidgetSearchKeywords": "Site Search Keywords",
- "WidgetSearchNoResultKeywords": "Search Keywords with No Results"
+ "WidgetSearchNoResultKeywords": "Search Keywords with No Results",
+ "ActionType": "Action Type"
}
} \ No newline at end of file
diff --git a/plugins/Events/Actions/ActionEvent.php b/plugins/Events/Actions/ActionEvent.php
index 9921c8d39b..5106ec6092 100644
--- a/plugins/Events/Actions/ActionEvent.php
+++ b/plugins/Events/Actions/ActionEvent.php
@@ -60,9 +60,17 @@ class ActionEvent extends Action
protected function getActionsToLookup()
{
- return array(
- 'idaction_url' => $this->getUrlAndType()
- );
+ $actionUrl = false;
+
+ $url = $this->getActionUrl();
+
+ if (!empty($url)) {
+ // normalize urls by stripping protocol and www
+ $url = Tracker\PageUrl::normalizeUrl($url);
+ $actionUrl = array($url['url'], $this->getActionType(), $url['prefixId']);
+ }
+
+ return array('idaction_url' => $actionUrl);
}
// Do not track this Event URL as Entry/Exit Page URL (leave the existing entry/exit)
diff --git a/plugins/Live/Visitor.php b/plugins/Live/Visitor.php
index 6d679a8a05..2d3b0c54f3 100644
--- a/plugins/Live/Visitor.php
+++ b/plugins/Live/Visitor.php
@@ -286,7 +286,7 @@ class Visitor implements VisitorInterface
unset($actionDetails[$actionIdx]);
continue;
- } elseif ($actionDetail['type'] == Action::TYPE_EVENT_CATEGORY) {
+ } elseif ($actionDetail['type'] == Action::TYPE_EVENT) {
// Handle Event
if (strlen($actionDetail['pageTitle']) > 0) {
$actionDetail['eventName'] = $actionDetail['pageTitle'];
diff --git a/plugins/SegmentEditor/SegmentSelectorControl.php b/plugins/SegmentEditor/SegmentSelectorControl.php
index b01018dbcf..72be071e5e 100644
--- a/plugins/SegmentEditor/SegmentSelectorControl.php
+++ b/plugins/SegmentEditor/SegmentSelectorControl.php
@@ -46,9 +46,10 @@ class SegmentSelectorControl extends UIControl
$segments = APIMetadata::getInstance()->getSegmentsMetadata($this->idSite);
+ $visitTitle = Piwik::translate('General_Visit');
$segmentsByCategory = array();
foreach ($segments as $segment) {
- if ($segment['category'] == Piwik::translate('General_Visit')
+ if ($segment['category'] == $visitTitle
&& ($segment['type'] == 'metric' && $segment['segment'] != 'visitIp')
) {
$metricsLabel = Piwik::translate('General_Metrics');
@@ -57,7 +58,6 @@ class SegmentSelectorControl extends UIControl
}
$segmentsByCategory[$segment['category']][] = $segment;
}
- uksort($segmentsByCategory, array($this, 'sortSegmentCategories'));
$this->createRealTimeSegmentsIsEnabled = Config::getInstance()->General['enable_create_realtime_segments'];
$this->segmentsByCategory = $segmentsByCategory;
@@ -100,15 +100,6 @@ class SegmentSelectorControl extends UIControl
return (bool) $savedSegment['auto_archive'];
}
- public function sortSegmentCategories($a, $b)
- {
- // Custom Variables last
- if ($a == Piwik::translate('CustomVariables_CustomVariables')) {
- return 1;
- }
- return 0;
- }
-
private function getTranslations()
{
$translationKeys = array(