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 #15058
Conversation
|
||
tracker.disableHeartBeatTimer(); // flatline | ||
|
||
return Q.delay(1000); // for the ping request to get sent | ||
return Q.delay(1000); // for a ping request to get sent if there was one |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we add a test here for when the time goes past setVisitStandardLength()
? For example, we set setVisitStandardLength()
to 4 or something, then wait 5 seconds and make sure a ping isn't sent.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point 👍 Added that test and also resolved the merge conflicts.
* More efficient heart beat timer * add changelog * make sure the event is added for each tracker * add test * fix test
Hi,
Maybe you can ping on hashchange event or even better: provide a method to force ping. This would be helpful for matomo integrations in different frameworks or if we have own (custom)events that we are listening to. |
@ZupZ3r0 AFAIK this should still work because all it does is update the overall visit time but not anything else. |
@ZupZ3r0 btw there is also a tracker method named |
@tsteur apperently it doesn't work out of the box, because the heartbeat sends only the first ping on pageload but never again (or only if you leave the active tab). This doesn't really break something, but results in a visit time of 1s for every action/event. |
@ZupZ3r0 be great to let me know if using |
I have been testing for a few days now with sending a ping ( |
fix #15049
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.