@tsteur opened this Issue on October 24th 2019 Member

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 https://github.com/matomo-org/matomo/issues/8225

@diosmosis commented on November 4th 2019 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 commented on November 4th 2019 Member

@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 commented on November 4th 2019 Member

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

@tsteur commented on November 4th 2019 Member

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 https://github.com/matomo-org/matomo/issues/9504 which then led to https://github.com/matomo-org/matomo/pull/9542 where we were only tracking when the tab had focus. Eventually we implemented https://github.com/matomo-org/matomo/pull/9617

@diosmosis commented on November 4th 2019 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!

This Issue was closed on November 5th 2019
Powered by GitHub Issue Mirror