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
API bug? - Twice the amount of visitors in method Live.getCounters just after midnight #16293
Comments
Thanks for creating the issue @ColinDude2020 . Looking in the code at the database query things look all good. Does the same happen for visits and actions? Note: the query is : SELECT
COUNT(DISTINCT log_visit.idvisitor)
FROM
matomo_log_visit AS log_visit
WHERE
log_visit.idsite in (2) AND log_visit.visit_last_action_time >= '...' |
I'll get back at you asap! |
Okay, I captured a few json files, pasted here: https://pastebin.com/pQbxBChN "actions" seems not to be affected. but both "visitors" and "visits" are. I use the Symfony framework to register the visitors (using the server-side api with curl) like this. These are my post params. Maybe that could be a lead? $postData = array(
"token_auth" => '1234',
"cip" => $ip,
"rec" => 1,
"idsite" => 2,
"action_name" => $actionName,
"url " => urlencode($url),
"apiv" => 1,
"_id" => $session->get('unique_userid'),
"urlref" => $_SERVER["HTTP_REFERER"] ?? null
); |
I just realized that it's probably caused by the _id mapping. Something funny happens with the PHP function uniqid() around midnight. $session = $request->getSession();
if (!$session->get('unique_userid'))
{
$session->set('unique_userid', uniqid());
} I don't have registered users, so I cannot use something like a username or e-mail address for the _id mapping. Should I try changing it to md5($ipAddress) ? Okay for testing purposes I have just changed it to: "_id" => substr(md5($ip),0,16) |
So that fixes it for me. No bug on Mamoto's side. Somehow the session within Symfony resets at exactly 00:00 mid night. I'm keeping the change, works fine for me. 👍 Thanks! |
Awesome thanks for letting us know @ColinDude2020 |
I’m calling this URL every 5 minutes: https://$baseurl/?module=API&token_auth=$token&method=Live.getCounters&idSite=2&lastMinutes=10&format=json
Somehow, the “visitors” measure is always twice as high as it should be when the URL is called between 00:00 AM and 00:10 AM. This always happened, so I can reproduce it at that timeframe.
I’m using Matomo 3.14.0 on Ubuntu 18.04, on-premise.
Any thoughts?
The text was updated successfully, but these errors were encountered: