@hpvd opened this Issue on January 21st 2016

Total time of a visit
shown for a visit e.g. in visitor log
is not always the sum of times of all page visits

an example is shown in attachments

if this total time of a visit is not only shown but also used to calculate other things like avarage duration of a visit, it may have a big imapct

2016-01-21_11h48_02

2016-01-21_11h49_23

2016-01-21_11h49_04

2016-01-21_11h48_52

2016-01-21_11h48_39

2016-01-21_11h48_16

@tsteur commented on January 21st 2016 Member

What's shown on hover for the 4. action (the search)? I checked some as well on dem.piwik.org but it was always ok

@hpvd commented on January 21st 2016

sorry for don 't showing it. I had in the calculation during testing: it's only 11s
2016-01-21_20h25_30

@hpvd commented on January 21st 2016

in the meantime this visit becomes some longer (only last page)
but still doesn't fit together..

(you can find it searching for "banca")

2016-01-21_20h30_51

@tsteur commented on January 21st 2016 Member

I can reproduce it on demo.piwik.org for Piwik forums. Thx!

image

aggregating each action individually only makes like 1hour 15minutes but it shows as 2hours 33min. The 2hours 33 min are probably actually right but some actions might not be updated. The second last action has only 10 seconds so I presume a date was never set there.

@tsteur commented on January 21st 2016 Member

The problem is the time spent for the first action should be like an "1hour 15min" or so but is only 10 seconds. By looking very quickly through the code I already found one bug here: https://github.com/piwik/piwik/blob/2.16.0-b6/core/Tracker/Visit.php#L249-L253 . We have a visit standard length of 30 minutes. If time on action spent is > 30 min (which is possible with heart beat feature) we save max 30 minutes for an action instead of the actual "1hour 15min".

However, as there is 10 seconds set, there must be another bug on top.

Buggy seems also the code just a few lines on top. We probably return max 15 seconds here if we sent ping requests every 15 seconds: https://github.com/piwik/piwik/blob/2.16.0-b6/core/Tracker/Visit.php#L244-L248 Heart beat sends constantly ping requests updating visit_last_action_time. So when the next request is happening the visit_last_action_time will be probably max 15 seconds. In race conditions the time spent value could be even negative causing 10 seconds to be written as in this case.

From what I can tell it seems quite buggy. Thx for the report!

@hpvd commented on January 27th 2016

maybe this one https://github.com/piwik/piwik/issues/9646
is the result of working on this topic...

This Issue was closed on January 22nd 2016
Powered by GitHub Issue Mirror