diff --git a/plugins/Live/API.php b/plugins/Live/API.php index 602e26797ed0f53d530042970fc13d9175ab6862..800ae963aa570f4dae437c73f568df2646e18278 100644 --- a/plugins/Live/API.php +++ b/plugins/Live/API.php @@ -225,9 +225,11 @@ class Piwik_Live_API // set the time spent for this action (which is the timeSpentRef of the next action) if (isset($actionDetails[$actionIdx + 1])) { - $timeSpent = $actionDetails[$actionIdx + 1]['timeSpentRef']; - $actionDetail['timeSpent'] = Piwik::getPrettyTimeFromSeconds($timeSpent); + $actionDetail['timeSpent'] = $actionDetails[$actionIdx + 1]['timeSpentRef']; + $actionDetail['timeSpentPretty'] = Piwik::getPrettyTimeFromSeconds($actionDetail['timeSpent']); + } + unset($actionDetails[$actionIdx]['timeSpentRef']); // not needed after timeSpent is added } // If the visitor converted a goal, we shall select all Goals diff --git a/plugins/Live/templates/lastVisits.tpl b/plugins/Live/templates/lastVisits.tpl index c114ebb10607325a7da78009f40f927cf4c05bd7..03991ff08fa4a48f35eff4ee7956c6f6f200a366 100644 --- a/plugins/Live/templates/lastVisits.tpl +++ b/plugins/Live/templates/lastVisits.tpl @@ -53,7 +53,7 @@ {php}$col++; if ($col>=9) { $col=0; }{/php} <a href="{$action.url|escape:'html'}" target="_blank"> {if $action.type == 'action'} - <img src="plugins/Live/templates/images/file{php} echo $col; {/php}.png" title="{if !empty($action.pageTitle)}{$action.pageTitle}{/if} - {$action.serverTimePretty|escape:'html'}{if isset($action.timeSpent)} - {'General_TimeOnPage'|translate}: {$action.timeSpent}{/if}" /> + <img src="plugins/Live/templates/images/file{php} echo $col; {/php}.png" title="{if !empty($action.pageTitle)}{$action.pageTitle}{/if} - {$action.serverTimePretty|escape:'html'}{if isset($action.timeSpentPretty)} - {'General_TimeOnPage'|translate}: {$action.timeSpentPretty}{/if}" /> {elseif $action.type == 'outlink' || $action.type == 'download'} <img class='iconPadding' src="{$action.icon}" title="{$action.url|escape:'html'} - {$action.serverTimePretty|escape:'html'}" /> {else} diff --git a/plugins/Live/templates/visitorLog.tpl b/plugins/Live/templates/visitorLog.tpl index 15288843f07d286a1c86f3884d5edacdb13b6b1b..d10bc45a375b49df3b06f33c5ccaaa80e1e0cf9d 100644 --- a/plugins/Live/templates/visitorLog.tpl +++ b/plugins/Live/templates/visitorLog.tpl @@ -167,7 +167,7 @@ {if !$javascriptVariablesToSet.filterEcommerce || $action.type == 'ecommerceOrder' || $action.type == 'ecommerceAbandonedCart'} - <li class="{if !empty($action.goalName)}goal{else}action{/if}" title="{$action.serverTimePretty|escape:'html'}{if !empty($action.url) && strlen(trim($action.url))} - {$action.url|escape:'html'}{/if} {if strlen(trim($customVariablesTooltip))} - {$customVariablesTooltip}{/if}{if isset($action.timeSpent)} - {'General_TimeOnPage'|translate}: {$action.timeSpent}{/if}"> + <li class="{if !empty($action.goalName)}goal{else}action{/if}" title="{$action.serverTimePretty|escape:'html'}{if !empty($action.url) && strlen(trim($action.url))} - {$action.url|escape:'html'}{/if} {if strlen(trim($customVariablesTooltip))} - {$customVariablesTooltip}{/if}{if isset($action.timeSpentPretty)} - {'General_TimeOnPage'|translate}: {$action.timeSpentPretty}{/if}"> {if $action.type == 'ecommerceOrder' || $action.type == 'ecommerceAbandonedCart'} {* Ecommerce Abandoned Cart / Ecommerce Order *} diff --git a/tests/integration/expected/test_OneVisitorTwoVisits_withCookieSupport__Live.getLastVisitsDetails_day.xml b/tests/integration/expected/test_OneVisitorTwoVisits_withCookieSupport__Live.getLastVisitsDetails_day.xml index fffeb83b897b622899d4e484de59736e2f9fdb4c..ff3bbeff8557138828fee141a39046d141bd365b 100644 --- a/tests/integration/expected/test_OneVisitorTwoVisits_withCookieSupport__Live.getLastVisitsDetails_day.xml +++ b/tests/integration/expected/test_OneVisitorTwoVisits_withCookieSupport__Live.getLastVisitsDetails_day.xml @@ -108,6 +108,8 @@ <pageIdAction>2</pageIdAction> <pageId>1</pageId> + <timeSpent>180</timeSpent> + <timeSpentPretty>3 min 0s</timeSpentPretty> <icon /> </row> <row> @@ -117,6 +119,8 @@ <pageIdAction>4</pageIdAction> <pageId>2</pageId> + <timeSpent>180</timeSpent> + <timeSpentPretty>3 min 0s</timeSpentPretty> <icon /> </row> <row> @@ -126,6 +130,8 @@ <pageIdAction>5</pageIdAction> <pageId>3</pageId> + <timeSpent>360</timeSpent> + <timeSpentPretty>6 min 0s</timeSpentPretty> <icon>themes/default/images/link.gif</icon> </row> <row> @@ -135,6 +141,8 @@ <pageIdAction>6</pageIdAction> <pageId>4</pageId> + <timeSpent>72</timeSpent> + <timeSpentPretty>1 min 12s</timeSpentPretty> <icon>themes/default/images/download.png</icon> </row> <row> @@ -144,6 +152,8 @@ <pageIdAction>7</pageIdAction> <pageId>5</pageId> + <timeSpent>108</timeSpent> + <timeSpentPretty>1 min 48s</timeSpentPretty> <icon>themes/default/images/link.gif</icon> </row> <row> @@ -153,6 +163,8 @@ <pageIdAction>5</pageIdAction> <pageId>6</pageId> + <timeSpent>180</timeSpent> + <timeSpentPretty>3 min 0s</timeSpentPretty> <icon>themes/default/images/link.gif</icon> </row> <row> diff --git a/tests/integration/expected/test_ecommerceOrderWithItems_LiveEcommerceStatusOrdered__Live.getLastVisitsDetails_day.xml b/tests/integration/expected/test_ecommerceOrderWithItems_LiveEcommerceStatusOrdered__Live.getLastVisitsDetails_day.xml index 8c219b8cc6711373ab27d4dd393bd9eee55ab7a5..14a51850c5a106d41bf10a29f5288b003d771b33 100644 --- a/tests/integration/expected/test_ecommerceOrderWithItems_LiveEcommerceStatusOrdered__Live.getLastVisitsDetails_day.xml +++ b/tests/integration/expected/test_ecommerceOrderWithItems_LiveEcommerceStatusOrdered__Live.getLastVisitsDetails_day.xml @@ -147,6 +147,8 @@ <customVariableValue4>PRODUCT THREE LEFT in cart</customVariableValue4> </row> </customVariables> + <timeSpent>180</timeSpent> + <timeSpentPretty>3 min 0s</timeSpentPretty> <icon /> </row> <row> @@ -170,6 +172,8 @@ <customVariableValue4>PRODUCT THREE LEFT in cart</customVariableValue4> </row> </customVariables> + <timeSpent>180</timeSpent> + <timeSpentPretty>3 min 0s</timeSpentPretty> <icon /> </row> <row> diff --git a/tests/integration/expected/test_ecommerceOrderWithItems__Live.getLastVisitsDetails_day.xml b/tests/integration/expected/test_ecommerceOrderWithItems__Live.getLastVisitsDetails_day.xml index 578e257aa9ff44253331e7a6d043eb40d4440f04..94939080c35c9b27f56817cc497b9de80901a49a 100644 --- a/tests/integration/expected/test_ecommerceOrderWithItems__Live.getLastVisitsDetails_day.xml +++ b/tests/integration/expected/test_ecommerceOrderWithItems__Live.getLastVisitsDetails_day.xml @@ -34,6 +34,8 @@ <customVariableValue4>PRODUCT THREE LEFT in cart</customVariableValue4> </row> </customVariables> + <timeSpent>180</timeSpent> + <timeSpentPretty>3 min 0s</timeSpentPretty> <icon /> </row> <row> @@ -57,6 +59,8 @@ <customVariableValue4>PRODUCT THREE LEFT in cart</customVariableValue4> </row> </customVariables> + <timeSpent>180</timeSpent> + <timeSpentPretty>3 min 0s</timeSpentPretty> <icon /> </row> <row> @@ -203,6 +207,8 @@ <customVariableValue5>Electronics & Cameras</customVariableValue5> </row> </customVariables> + <timeSpent>360</timeSpent> + <timeSpentPretty>6 min 0s</timeSpentPretty> <icon /> </row> <row> @@ -218,6 +224,8 @@ <customVariableValue5>Electronics & Cameras</customVariableValue5> </row> </customVariables> + <timeSpent>360</timeSpent> + <timeSpentPretty>6 min 0s</timeSpentPretty> <icon /> </row> <row> @@ -245,6 +253,8 @@ <customVariableValue5>Electronics & Cameras</customVariableValue5> </row> </customVariables> + <timeSpent>720</timeSpent> + <timeSpentPretty>12 min 0s</timeSpentPretty> <icon /> </row> <row> @@ -324,6 +334,8 @@ <customVariableValue4>PRODUCT THREE LEFT in cart</customVariableValue4> </row> </customVariables> + <timeSpent>180</timeSpent> + <timeSpentPretty>3 min 0s</timeSpentPretty> <icon /> </row> <row> @@ -347,6 +359,8 @@ <customVariableValue4>PRODUCT THREE LEFT in cart</customVariableValue4> </row> </customVariables> + <timeSpent>180</timeSpent> + <timeSpentPretty>3 min 0s</timeSpentPretty> <icon /> </row> <row> @@ -514,6 +528,8 @@ <customVariableValue5>Electronics & Cameras</customVariableValue5> </row> </customVariables> + <timeSpent>360</timeSpent> + <timeSpentPretty>6 min 0s</timeSpentPretty> <icon /> </row> <row> @@ -541,6 +557,8 @@ <customVariableValue5>Electronics & Cameras</customVariableValue5> </row> </customVariables> + <timeSpent>360</timeSpent> + <timeSpentPretty>6 min 0s</timeSpentPretty> <icon /> </row> <row> @@ -560,6 +578,8 @@ <customVariableValue4>PRODUCT name</customVariableValue4> </row> </customVariables> + <timeSpent>0</timeSpent> + <timeSpentPretty>0s</timeSpentPretty> <icon /> </row> <row>