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@piwik.org>2017-09-15 00:54:01 +0300
committerMatthieu Aubry <mattab@users.noreply.github.com>2017-09-15 00:54:01 +0300
commit40f886baf0e3ce5bbe4a066b333a7cc24eb93163 (patch)
tree93418e061ccf95d86383504d4c778b305aee8792 /plugins/Actions
parent595da1313efd43a0a60c1797364da42511d46de6 (diff)
Makes visitor log/profile independent from Events plugin (#12047)
* makes profile query independent from events plugin * move more stuff to event plugin * update test files
Diffstat (limited to 'plugins/Actions')
-rw-r--r--plugins/Actions/VisitorDetails.php59
1 files changed, 23 insertions, 36 deletions
diff --git a/plugins/Actions/VisitorDetails.php b/plugins/Actions/VisitorDetails.php
index 7292bd87f5..becb6cdaf7 100644
--- a/plugins/Actions/VisitorDetails.php
+++ b/plugins/Actions/VisitorDetails.php
@@ -22,8 +22,6 @@ use Piwik\View;
class VisitorDetails extends VisitorDetailsAbstract
{
- const EVENT_VALUE_PRECISION = 3;
-
public function extendVisitorDetails(&$visitor)
{
$visitor['searches'] = $this->details['visit_total_searches'];
@@ -50,19 +48,11 @@ class VisitorDetails extends VisitorDetailsAbstract
$formatter = new Formatter();
- $actionTypesToHandle = array(
- Action::TYPE_PAGE_URL,
- Action::TYPE_SITE_SEARCH,
- Action::TYPE_EVENT,
- Action::TYPE_OUTLINK,
- Action::TYPE_DOWNLOAD
- );
-
// Enrich with time spent per action
$nextActionId = 0;
foreach ($actionDetails as $idx => &$action) {
- if ($idx < $nextActionId || !in_array($action['type'], $actionTypesToHandle)) {
+ if ($idx < $nextActionId || !$this->shouldHandleAction($action)) {
continue; // skip to next action having timeSpentRef
}
@@ -71,7 +61,7 @@ class VisitorDetails extends VisitorDetailsAbstract
$nextAction = null;
while (isset($actionDetails[$nextActionId]) &&
- (!in_array($actionDetails[$nextActionId]['type'], $actionTypesToHandle) ||
+ (!$this->shouldHandleAction($actionDetails[$nextActionId]) ||
!array_key_exists('timeSpentRef', $actionDetails[$nextActionId]))) {
$nextActionId++;
}
@@ -107,40 +97,37 @@ class VisitorDetails extends VisitorDetailsAbstract
$actions = $actionDetails;
}
+ private function shouldHandleAction($action) {
+ $actionTypesToHandle = array(
+ Action::TYPE_PAGE_URL,
+ Action::TYPE_SITE_SEARCH,
+ Action::TYPE_EVENT,
+ Action::TYPE_OUTLINK,
+ Action::TYPE_DOWNLOAD
+ );
+
+ return in_array($action['type'], $actionTypesToHandle) || !empty($action['eventType']);
+ }
+
public function extendActionDetails(&$action, $nextAction, $visitorDetails)
{
$formatter = new Formatter();
- if ($action['type'] == Action::TYPE_EVENT) {
- // Handle Event
- if (strlen($action['pageTitle']) > 0) {
- $action['eventName'] = $action['pageTitle'];
- }
-
+ if ($action['type'] == Action::TYPE_SITE_SEARCH) {
+ // Handle Site Search
+ $action['siteSearchKeyword'] = $action['pageTitle'];
unset($action['pageTitle']);
-
- } else {
- if ($action['type'] == Action::TYPE_SITE_SEARCH) {
- // Handle Site Search
- $action['siteSearchKeyword'] = $action['pageTitle'];
- unset($action['pageTitle']);
- }
}
- // Event value / Generation time
- if ($action['type'] == Action::TYPE_EVENT) {
- if (strlen($action['custom_float']) > 0) {
- $action['eventValue'] = round($action['custom_float'], self::EVENT_VALUE_PRECISION);
- }
- } elseif (isset($action['custom_float']) && $action['custom_float'] > 0) {
+ // Generation time
+ if ($this->shouldHandleAction($action) && empty($action['eventType']) && isset($action['custom_float']) && $action['custom_float'] > 0) {
$action['generationTimeMilliseconds'] = $action['custom_float'];
$action['generationTime'] = $formatter->getPrettyTimeFromSeconds($action['custom_float'] / 1000, true);
+ unset($action['custom_float']);
}
- unset($action['custom_float']);
- if ($action['type'] != Action::TYPE_EVENT) {
- unset($action['eventCategory']);
- unset($action['eventAction']);
+ if (array_key_exists('custom_float', $action) && is_null($action['custom_float'])) {
+ unset($action['custom_float']);
}
if (array_key_exists('interaction_position', $action)) {
@@ -214,7 +201,7 @@ class VisitorDetails extends VisitorDetailsAbstract
$sql = "
SELECT
log_link_visit_action.idvisit,
- COALESCE(log_action_event_category.type, log_action.type, log_action_title.type) AS type,
+ COALESCE(log_action.type, log_action_title.type) AS type,
log_action.name AS url,
log_action.url_prefix,
log_action_title.name AS pageTitle,