Skip to content
Extraits de code Groupes Projets
Valider d989c794 rédigé par Benaka Moorthi's avatar Benaka Moorthi
Parcourir les fichiers

Refs #3089, tweaks to getVisitorProfile API output. Includes change that...

Refs #3089, tweaks to getVisitorProfile API output. Includes change that allows xml renderers to use special keys when rendering arrays.
parent d6f94510
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -183,6 +183,12 @@ class Xml extends Renderer ...@@ -183,6 +183,12 @@ class Xml extends Renderer
$prefix = "<row key=\"$key\">"; $prefix = "<row key=\"$key\">";
$suffix = "</row>"; $suffix = "</row>";
$emptyNode = "<row key=\"$key\"/>"; $emptyNode = "<row key=\"$key\"/>";
} else if (strpos($key, '=') !== false) {
list($keyAttributeName, $key) = explode('=', $key, 2);
$prefix = "<row $keyAttributeName=\"$key\">";
$suffix = "</row>";
$emptyNode = "<row $keyAttributeName=\"$key\">";
} else { } else {
$prefix = "<$key>"; $prefix = "<$key>";
$suffix = "</$key>"; $suffix = "</$key>";
...@@ -368,6 +374,7 @@ class Xml extends Renderer ...@@ -368,6 +374,7 @@ class Xml extends Renderer
continue; continue;
} }
// Handing case idgoal=7, creating a new array for that one // Handing case idgoal=7, creating a new array for that one
$rowAttribute = ''; $rowAttribute = '';
if (($equalFound = strstr($rowId, '=')) !== false) { if (($equalFound = strstr($rowId, '=')) !== false) {
......
...@@ -196,7 +196,7 @@ class API ...@@ -196,7 +196,7 @@ class API
$result = array(); $result = array();
$result['totalVisits'] = 0; $result['totalVisits'] = 0;
$result['totalVisitDuration'] = 0; $result['totalVisitDuration'] = 0;
$result['totalActionCount'] = 0; $result['totalActions'] = 0;
$result['totalGoalConversions'] = 0; $result['totalGoalConversions'] = 0;
$result['totalConversionsByGoal'] = array(); $result['totalConversionsByGoal'] = array();
...@@ -217,24 +217,25 @@ class API ...@@ -217,24 +217,25 @@ class API
++$result['totalVisits']; ++$result['totalVisits'];
$result['totalVisitDuration'] += $visit->getColumn('visitDuration'); $result['totalVisitDuration'] += $visit->getColumn('visitDuration');
$result['totalActionCount'] += $visit->getColumn('actions'); $result['totalActions'] += $visit->getColumn('actions');
$result['totalGoalConversions'] += $visit->getColumn('goalConversions'); $result['totalGoalConversions'] += $visit->getColumn('goalConversions');
// individual goal conversions are stored in action details // individual goal conversions are stored in action details
foreach ($visit->getColumn('actionDetails') as $action) { foreach ($visit->getColumn('actionDetails') as $action) {
if ($action['type'] == 'goal') { // handle goal conversion if ($action['type'] == 'goal') { // handle goal conversion
$idGoal = $action['goalId']; $idGoal = $action['goalId'];
$idGoalKey = 'idgoal=' . $idGoal;
if (!isset($result['totalConversionsByGoal'][$idGoal])) { if (!isset($result['totalConversionsByGoal'][$idGoalKey])) {
$result['totalConversionsByGoal'][$idGoal] = 0; $result['totalConversionsByGoal'][$idGoalKey] = 0;
} }
++$result['totalConversionsByGoal'][$idGoal]; ++$result['totalConversionsByGoal'][$idGoalKey];
if (!empty($action['revenue'])) { if (!empty($action['revenue'])) {
if (!isset($result['totalRevenueByGoal'][$idGoal])) { if (!isset($result['totalRevenueByGoal'][$idGoalKey])) {
$result['totalRevenueByGoal'][$idGoal] = 0; $result['totalRevenueByGoal'][$idGoalKey] = 0;
} }
$result['totalRevenueByGoal'][$idGoal] += $action['revenue']; $result['totalRevenueByGoal'][$idGoalKey] += $action['revenue'];
} }
} else if ($action['type'] == Piwik::LABEL_ID_GOAL_IS_ECOMMERCE_ORDER // handle ecommerce order } else if ($action['type'] == Piwik::LABEL_ID_GOAL_IS_ECOMMERCE_ORDER // handle ecommerce order
&& $isEcommerceEnabled && $isEcommerceEnabled
...@@ -310,7 +311,7 @@ class API ...@@ -310,7 +311,7 @@ class API
// looking at the popup. // looking at the popup.
$latestVisitTime = reset($rows)->getColumn('lastActionDateTime'); $latestVisitTime = reset($rows)->getColumn('lastActionDateTime');
$result['nextVisitorId'] = $this->getAdjacentVisitorId($idSite, $visitorId, $latestVisitTime, $segment, $getNext = true); $result['nextVisitorId'] = $this->getAdjacentVisitorId($idSite, $visitorId, $latestVisitTime, $segment, $getNext = true);
$result['prevVisitorId'] = $this->getAdjacentVisitorId($idSite, $visitorId, $latestVisitTime, $segment, $getNext = false); $result['previousVisitorId'] = $this->getAdjacentVisitorId($idSite, $visitorId, $latestVisitTime, $segment, $getNext = false);
Piwik_PostEvent(Live::GET_EXTRA_VISITOR_DETAILS_EVENT, array(&$result)); Piwik_PostEvent(Live::GET_EXTRA_VISITOR_DETAILS_EVENT, array(&$result));
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
<div class="visitor-profile" <div class="visitor-profile"
data-visitor-id="{{ visitorData.lastVisits.getFirstRow().getColumn('visitorId') }}" data-visitor-id="{{ visitorData.lastVisits.getFirstRow().getColumn('visitorId') }}"
data-next-visitor="{{ visitorData.nextVisitorId }}" data-next-visitor="{{ visitorData.nextVisitorId }}"
data-prev-visitor="{{ visitorData.prevVisitorId }}" data-prev-visitor="{{ visitorData.previousVisitorId }}"
tabindex="0"> tabindex="0">
<a href class="visitor-profile-close"></a> <a href class="visitor-profile-close"></a>
<div class="visitor-profile-info"> <div class="visitor-profile-info">
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
</div> </div>
<div> <div>
<div class="visitor-profile-header"> <div class="visitor-profile-header">
{% if visitorData.prevVisitorId is not empty %}<a class="visitor-profile-prev-visitor" href="#" title="{{ 'Live_PreviousVisitor'|translate }}">&larr;</a>{% endif %} {% if visitorData.previousVisitorId is not empty %}<a class="visitor-profile-prev-visitor" href="#" title="{{ 'Live_PreviousVisitor'|translate }}">&larr;</a>{% endif %}
<h1>{{ 'Live_VisitorProfile'|translate }} <img class="loadingPiwik" style="display:none;" src="plugins/Zeitgeist/images/loading-blue.gif"/></h1> <h1>{{ 'Live_VisitorProfile'|translate }} <img class="loadingPiwik" style="display:none;" src="plugins/Zeitgeist/images/loading-blue.gif"/></h1>
{% if visitorData.nextVisitorId is not empty %}<a class="visitor-profile-next-visitor" href="#" title="{{ 'Live_NextVisitor'|translate }}">&rarr;</a>{% endif %} {% if visitorData.nextVisitorId is not empty %}<a class="visitor-profile-next-visitor" href="#" title="{{ 'Live_NextVisitor'|translate }}">&rarr;</a>{% endif %}
</div> </div>
...@@ -31,10 +31,11 @@ ...@@ -31,10 +31,11 @@
<div class="visitor-profile-summary"> <div class="visitor-profile-summary">
<h1>{{ 'General_Summary'|translate }}</h1> <h1>{{ 'General_Summary'|translate }}</h1>
<div> <div>
<p>{{ 'Live_VisitSummary'|translate('<strong>', visitorData.totalVisitDurationPretty, '</strong>', '<strong>', visitorData.totalActionCount, visitorData.totalVisits, '</strong>')|raw }}</p> <p>{{ 'Live_VisitSummary'|translate('<strong>', visitorData.totalVisitDurationPretty, '</strong>', '<strong>', visitorData.totalActions, visitorData.totalVisits, '</strong>')|raw }}</p>
<p><strong>{{ 'Live_ConvertedNGoals'|translate(visitorData.totalGoalConversions) }}</strong> <p><strong>{{ 'Live_ConvertedNGoals'|translate(visitorData.totalGoalConversions) }}</strong>
{%- if visitorData.totalGoalConversions %} ( {%- if visitorData.totalGoalConversions %} (
{%- for idGoal, totalConversions in visitorData.totalConversionsByGoal -%} {%- for idGoal, totalConversions in visitorData.totalConversionsByGoal -%}
{%- set idGoal = idGoal[7:] -%}
{%- if not loop.first %}, {% endif -%}{{- totalConversions }} <span class="visitor-profile-goal-name">{{ goals[idGoal]['name'] -}}</span> {%- if not loop.first %}, {% endif -%}{{- totalConversions }} <span class="visitor-profile-goal-name">{{ goals[idGoal]['name'] -}}</span>
{%- endfor -%} {%- endfor -%}
){% endif %}.</p> ){% endif %}.</p>
......
...@@ -2,10 +2,10 @@ ...@@ -2,10 +2,10 @@
<result> <result>
<totalVisits>2</totalVisits> <totalVisits>2</totalVisits>
<totalVisitDuration>361</totalVisitDuration> <totalVisitDuration>361</totalVisitDuration>
<totalActionCount>2</totalActionCount> <totalActions>2</totalActions>
<totalGoalConversions>1</totalGoalConversions> <totalGoalConversions>1</totalGoalConversions>
<totalConversionsByGoal> <totalConversionsByGoal>
<row key="1">1</row> <row idgoal="1">1</row>
</totalConversionsByGoal> </totalConversionsByGoal>
<continents> <continents>
<row> <row>
...@@ -138,7 +138,7 @@ ...@@ -138,7 +138,7 @@
<serverDateTimePrettyFirstAction>4 Sep 2013 16:55:17</serverDateTimePrettyFirstAction>
</row> </row>
<row> <row>
<idSite>1</idSite> <idSite>1</idSite>
...@@ -252,9 +252,9 @@ ...@@ -252,9 +252,9 @@
<serverDateTimePrettyFirstAction>4 Sep 2013 15:55:17</serverDateTimePrettyFirstAction>
</row> </row>
</lastVisits> </lastVisits>
<previousVisitorId>61e8cc2d51fea26d</previousVisitorId>
</result> </result>
\ No newline at end of file
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter