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
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
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.
@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.
Out of curiosity, do you remember why it led to incorrect visit lengths?
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
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!