@ColinDude2020 opened this Issue on August 13th 2020

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?

@tsteur commented on August 13th 2020 Member

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 >= '...'
@ColinDude2020 commented on August 14th 2020

I'll get back at you asap!

@ColinDude2020 commented on August 14th 2020

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
);
@ColinDude2020 commented on August 15th 2020

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)
@ColinDude2020 commented on August 16th 2020

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!

@tsteur commented on August 16th 2020 Member

Awesome thanks for letting us know @ColinDude2020

This Issue was closed on August 16th 2020
Powered by GitHub Issue Mirror