Skip to content

heartbeat/pingreq. does not update log_visit.visit_last_action_time #15179

@toredash

Description

@toredash

I believe there is an issue with how ping requests are processed.

According to the source visit_last_action_time holds the visit´s end time:

/**
 * This dimension holds the best guess for a visit's end time. It is set the last action
 * time for each visit. `ping=1` requests can be sent to update the dimension value so
 * it can be a more accurate guess of the time the visitor spent on the site.
 *
 * Note: though it is named 'visit last action time' it actually refers to the visit's last action's
 * end time.
 */

https://github.com/matomo-org/matomo/blob/6b4cd1676d524641167ba32776a999e3e37a6a2a/plugins/CoreHome/Columns/VisitLastActionMinute.php

Looking at how the PingRequestProcessor (https://github.com/matomo-org/matomo/blob/3.x-dev/plugins/Heartbeat/Tracker/PingRequestProcessor.php) handles hearbeats, it seems it does not update log_visit.visit_last_action_time, it only updates log_visit.visit_total_time.

log_visit.visit_last_action_time is only updated if an action is sent. I think the issue is that PingRequestProcessor sends an empty Actions:
https://github.com/matomo-org/matomo/blob/2.16.0-b6/plugins/Heartbeat/Tracker/PingRequestProcessor.php#L24-L29

When viewing a users visits, the "x actions in " is correct, as it uses log_visit.visit_first_action_time + log_visit. visit_total_time.

Example of this:
image

For us, this becomes an issue an issue when using CustomReports and Server Time - Hour/Minute (End Of Visit), as it using log_visit.visit_last_action_time (https://github.com/matomo-org/matomo/blob/3.x-dev/plugins/CoreHome/Columns/VisitLastActionMinute.php#L32) to determine the visis end time. This occurs since ping requests does not update log_visit.visit_last_action_time. With the current code, it is not possible to determine when a visit ended for SPA apps, since it seems only an action can that trigger an update of log_visit.visit_last_action_time.

I'm not sure if this is a bug in the PingRequestProcessor, or an issue with how VisitLastActionMinute is expected to compute the visits end time.

Issues i think are relevant:
#9626 #9748

Metadata

Metadata

Assignees

No one assigned

    Labels

    c: Website matomo.orgFor issues related to our matomo.org website.not-in-changelogFor issues or pull requests that should not be included in our release changelog on matomo.org.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions