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
heartbeat/pingreq. does not update log_visit.visit_last_action_time #15179
Comments
This is correct and expected behaviour. You can see a bit more info here: #15049 (comment) We'll need to update the docs that it does not extend the visit. You'd need some custom plugin in this case to get this behaviour. |
@tsteur do you have suggestions on workaround for this usecase ? Initial thought is to introduce Adding a regular
In reality, this value is already present since Happy to create an PR if any of the initial thoughts seems like a good idea. |
I suppose you want to extend all visits? You could do this in a custom plugin without changing the ping value. All you would need to do is put a file like this in namespace ...
class MyRequestProcessor{
public function onExistingVisit(&$valuesToUpdate, VisitProperties $visitProperties, Request $request)
{
$valuesToUpdate['visit_last_action_time'] = $request->getCurrentTimestamp()
}
} Haven't tested it but something like this should work. |
Actually @toredash not sure if we have any public documentation that heart beat extends the visit? it looks like we can actually close the issue. |
@tsteur For what I've seen regarding docs, it is for me difficult to say if the docs are explicit enough to answer that question. https://matomo.org/faq/how-to/faq_21824/
I'm not sure if the current implementation does this the way I interpret the docs. From the screenshot in my first post, the ping updates the "Time spent on page" for the last action, not the page itself. Our applications are primarily single-page-applications, and in rare-cases we might have no actions sent from the client, so we are unable have an accurate report with CustomReports which informs us when the visit ended. This information is used to graph the number of concurrent users active on our service by the minute. We are able to determine when they came (visit_first_action_time), how long they stayed (visit_total_time), but matomo/plugins/CoreHome/Columns/VisitLastActionMinute.php Lines 18 to 25 in 48d3770
If anything should be changed, it should be the definition of All the information is present in
I looked at the Segment docs (https://developer.matomo.org/api-reference/Piwik/Plugin/Segment#setsqlsegment) to see if there is a way create a new segment, but I think that performance would suffer it it needs to calculate a value based on two other values. |
Yes, that is correct, I'll try the code you suggested, thanks!
|
I reckon that makes sense 👍 Any thoughts @mattab ? |
Sounds like a good fix to rename the dimension + fix the code comment @tsteur @toredash
@toredash I reckon performance of using 2 fields VS 1 field shouldn't be an issue? if you can try this and add a new segment, that would be great... so we can cover all use cases including yours 👍 |
Our use case is that we want to graph the number of unique visitors on a granularity of per minute. That is not possible with how Matomo works now, as the segment only considers when the first and last actions was done, not anything in between. When using Custom Reports, we have two reports, one with "Server Time - Start of Visit (Hour)" and "Server Time - Start of Visit (Minute)". The other report contains "Server Time - End of Visit (Hour)" and "Server Time - End of Visit (Minute)". This does not give us the correct data, example: User A join at UNIX time: 1000, and is active to time 2000. visit_first_action_time = 1000, visit_last_action_time = 2000. User B join at UNIX time: 1500, and is active to time 2500. visit_first_action_time = 1500, visit_last_action_time = 2500. User A would then be considered to start the visit at hour 00 and minute 16. User A would then be considered to end the visit at hour 00 and minute 33. When the use the
But that is not what we get, we get:
This stems from the fact that the segment only uses the I know we could solve this with a recursive CTE in SQL, but it seems we are pushing matomo in a direction that is not meant for. Or, we are doing something wrong with CustomReports. Here are the Start and End reports we are using: @mattab We have an ongoing e-mail discussion with you about this in email, if you believe this should be possible in Matomo, should we continue the discussion there ? |
Be good to follow up in the email discussion. @toredash So in this issue it's only about renaming the segment/dimension. |
Yes, that is correct. |
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: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 updateslog_visit.visit_total_time
.log_visit.visit_last_action_time
is only updated if an action is sent. I think the issue is thatPingRequestProcessor
sends an emptyActions
: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:
For us, this becomes an issue an issue when using CustomReports and
Server Time - Hour/Minute (End Of Visit)
, as it usinglog_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 updatelog_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 oflog_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
The text was updated successfully, but these errors were encountered: