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

More efficient heart beat timer #15049

Closed
tsteur opened this issue Oct 24, 2019 · 5 comments · Fixed by #15058
Closed

More efficient heart beat timer #15049

tsteur opened this issue Oct 24, 2019 · 5 comments · Fixed by #15058
Assignees
Labels
c: Performance For when we could improve the performance / speed of Matomo. Major Indicates the severity or impact or benefit of an issue is much higher than normal but not critical.
Milestone

Comments

@tsteur
Copy link
Member

tsteur commented Oct 24, 2019

Currently the heart beat timer is pinging the site every 15s if enabled.

Since we're now using sendBeacon and can quite ensure a request will make it through onPageUnload, we don't really need to ping every 15 seconds. I reckon it's fine to only ping

  • onWindowBlur
  • every 15 minutes (since a visit is usually active for say 30 minutes anyway)
  • stop pinging after maybe 1 hour? or earlier? I think heart beat is not keeping the visit alive anyway so we should stop after 30 minutes from page view start by default (or whatever is configured as visit length).
  • When tab / window closes (if the window was not focussed before (a blur happened) we would maybe only send the ping event if the window had focus after a blur for at least 10 seconds... and only if the tab is being closed within the visit length of eg 30 minutes)

This will significantly reduce the footprint of this feature and would possibly allow us to enable this feature by default in #8225

@tsteur tsteur added Major Indicates the severity or impact or benefit of an issue is much higher than normal but not critical. c: Performance For when we could improve the performance / speed of Matomo. labels Oct 24, 2019
@tsteur tsteur added this to the 4.0.0 milestone Oct 24, 2019
@tsteur tsteur modified the milestones: 4.0.0, 3.13.0 Oct 24, 2019
@diosmosis
Copy link
Member

I think heart beat is not keeping the visit alive anyway so we should stop after 30 minutes from page view start by default (or whatever is configured as visit length).

Should the heartbeat ping keep the visit alive? I thought it was just by there being a new action in log_link_visit_action. I wonder if this is a bug.

@tsteur
Copy link
Member Author

tsteur commented Nov 4, 2019

@diosmosis in the beginning it was supposed to keep the visit alive but we changed this behaviour shortly after as it was leading to wrong visit length metrics etc. I reckon that's why we now can do a more efficient version.

@diosmosis
Copy link
Member

Out of curiosity, do you remember why it led to incorrect visit lengths?

@tsteur
Copy link
Member Author

tsteur commented Nov 4, 2019

Sometimes it kept visits alive for many hours. Like for people who have a tab open for hours etc and some visits ended up having 10 hours and more.

There was eg #9504 which then led to #9542 where we were only tracking when the tab had focus. Eventually we implemented #9617

@diosmosis
Copy link
Member

I see, so an ideal fix would take into account if the user actually interacts w/ the page (ie, if 30 mins since last click/scroll/etc. stop). It's out of scope of course for the PR, but thanks for helping me understand!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c: Performance For when we could improve the performance / speed of Matomo. Major Indicates the severity or impact or benefit of an issue is much higher than normal but not critical.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants