matomo
matomo copied to clipboard
[Bug] Heartbeat may not work in combination with tracker plugins
What happened?
The heartbeat feature for the tracker checks various events to update the visit duration. With a default configuration (15 second heartbeat interval), if the page goes out of focus (e.g. tab switched) after it was watched for more than 15 seconds, a ping request is sent to the server to update the visit duration:
The page will get a grey background and have "blurred" in the top right corner once focus is lost. In this example everything is working as expected and the visit duration was updated.
Some tracker plugins sent their own requests to the server, and can have unexpected effects. The heartbeat will only be sent if there has been no other tracker request during the configured interval.
If a plugin does not update the last action time itself, this can more or less break the heartbeat feature:
Tracker plugin sends a request. The blur event on the page does not send a ping because the plugin request was sent too recently.
In some cases the heartbeat can be skipped only partially:
Ping request got sent after enough inactivity of the plugin. Having a shorter heartbeat timeout could achieve partial heartbeat success with interleaved requests (plugin, heartbeat, plugin, heartbeat, ...), though only a workaround without guarantees.
What should happen?
The behaviour of the heartbeat should either be not affected by plugins, or be documented as "potentially dependent" on what the plugins are doing.
How can this be reproduced?
Videos were taken with an active Heatmap recording.
Matomo version
5.x
PHP version
No response
Server operating system
No response
What browsers are you seeing the problem on?
Firefox, Chrome
Computer operating system
No response
Relevant log output
No response
Validations
- [X] Read our Contributing Guidelines.
- [X] Follow our Security Policy.
- [X] Check that there isn't already an issue that reports the same bug to avoid creating duplicates.
- [X] The provided steps to reproduce is a minimal reproducible of the Bug.