Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

total time of visit is not the sum of times of page visits #9610

Closed
hpvd opened this issue Jan 21, 2016 · 6 comments
Closed

total time of visit is not the sum of times of page visits #9610

hpvd opened this issue Jan 21, 2016 · 6 comments
Assignees
Labels
Bug For errors / faults / flaws / inconsistencies etc.
Milestone

Comments

@hpvd
Copy link

hpvd commented Jan 21, 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

@hpvd hpvd changed the title total time of visit is not the sum of times of page visits HUGE: total time of visit is not the sum of times of page visits Jan 21, 2016
@tsteur
Copy link
Member

tsteur commented Jan 21, 2016

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
Copy link
Author

hpvd commented Jan 21, 2016

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

@hpvd
Copy link
Author

hpvd commented Jan 21, 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

@hpvd hpvd changed the title HUGE: total time of visit is not the sum of times of page visits total time of visit is not the sum of times of page visits Jan 21, 2016
@tsteur
Copy link
Member

tsteur commented Jan 21, 2016

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
Copy link
Member

tsteur commented Jan 21, 2016

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!

@tsteur tsteur added the Bug For errors / faults / flaws / inconsistencies etc. label Jan 21, 2016
@tsteur tsteur added this to the 2.16.0 milestone Jan 22, 2016
@tsteur tsteur self-assigned this Jan 22, 2016
tsteur added a commit that referenced this issue Jan 22, 2016
@hpvd
Copy link
Author

hpvd commented Jan 27, 2016

maybe this one #9646
is the result of working on this topic...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug For errors / faults / flaws / inconsistencies etc.
Projects
None yet
Development

No branches or pull requests

2 participants