Currently, when the heart beat timer is enabled, we ping every 15s the Matomo server. If you have 1000 visitors on your page that makes 66req/s. It also sends a request every time you focus the window after you were on another tab.
This PR implements pretty much the opposite behaviour:
This means instead of possibly sending heaps of requests every few seconds we typically would maybe send one or two ping requests per pageview. Most of the times it be one (on page unload) or even none (when user was only a few seconds on a page).
Behaviour is otherwise the same, it's just more efficient by not sending as many requests. Instead we only send requests when needed. Which is either when the user is leaving the window, or closes the window.