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
Potential bug with DevicesDetection #20139
Comments
As an example, the cache for "carbrowser604-all" is requested 30 times for one request on the example report, which contains no devices at all. All the cache requests return the same thing. |
My guess is that every day in the visitor overview, which is 30 days, makes requests for the cached items of devices. |
This is the expected behavior for Device Detector, since one php instance is launched for each visitor. in my projects, I use Device Detector like this: namespace app/helpers
class DeviceDetectorHelper
{
/**
* @param string $userAgent - user agent string
* @param array $headers - http headers
* @return DeviceDetector
*/
public static function detect(string $userAgent, array $headers = []): DeviceDetector
{
static $detector;
if ($detector === null) {
$detector = new DeviceDetector();
$detector->setCache(new Cache());
}
$clientHints = ClientHints::factory($headers);
$detector->setUserAgent($userAgent);
$detector->setClientHints($clientHints);
$detector->parse();
return $detector;
}
} I will share my experience, maybe give ideas for the future
with this approach, you lose the minimum amount of time. |
Ok, so you are not using the plugin to get the devices? |
@mikkeschiren He is using device detector for something else than Matomo. |
With DevicesDetection installed and making a request for any reports, thousands of requests are made for cached items for DevicesDetection even when it's not required. We are using Redis for cache. Could be that this a general "thing", not just for DevicesDetection. And could also be expected behaviour, that I don't know.
Expected Behavior
Cached items should only be asked for when needed.
Current Behavior
Requests are done for cached items not needed.
Steps to Reproduce (for Bugs)
Your Environment
The text was updated successfully, but these errors were encountered: