-
Notifications
You must be signed in to change notification settings - Fork 497
Introduce browser client hint detection #6989
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
Conversation
it would be useful to add one property $app even anonymous browsers can be identified by ID |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it looks good
1 we need to added test for windows 11
#6928 (comment)
2 maybe worth adding to readme: if use client-hints
, you need to send the header yourself (before output html)
header('Accept-CH: Sec-CH-UA-Full-Version, Sec-CH-UA-Platform, Sec-CH-UA-Platform-Version, Sec-CH-UA-Model, Sec-CH-UA-Arc', true);
@sanchezzzhak If you have some time free, feel free to push some adjustments & tests to this branch. I'm not yet sure if I will find much time this week to go on with this.... |
@sanchezzzhak if
Examples:
|
$_SERVER['HTTP_X_UCBROWSER_UA'] |
@sanchezzzhak I wouldn't start adding detection for screen sizes or similar for now. Guess there are also client hints for such stuff. Let's focus on bringing the client hints detection for the already detected stuff on the road. We can also consider parsing other header fields later... |
@sanchezzzhak I have added improved some more code. Now also the browser should be detected with client hints if possible. |
Can you try the code exactly as it is here https://github.com/matomo-org/device-detector#usage and add It should work. |
<?php
header('Accept-CH: Sec-CH-UA-Full-Version, Sec-CH-UA-Platform, Sec-CH-UA-Platform-Version, Sec-CH-UA-Model, Sec-CH-UA-Arc', true);
use DeviceDetector\ClientHints;
use DeviceDetector\DeviceDetector;
use DeviceDetector\Parser\Device\AbstractDeviceParser;
require __DIR__ . "/../../vendor/autoload.php";
#AbstractDeviceParser::setVersionTruncation(AbstractDeviceParser::VERSION_TRUNCATION_NONE);
$userAgent = $_SERVER['HTTP_USER_AGENT'];
$clientHints = ClientHints::factory($_SERVER);
$dd = new DeviceDetector($userAgent, $clientHints);
$dd->parse();
$osInfo = $dd->getOs();
print_r($osInfo);
die(); Output: Array ( [name] => Windows [short_name] => WIN [version] => 10 [platform] => x64 [family] => Windows ) |
I'm pretty sure that's the same issue I also had when updating devicedetector.lw1.at:
|
Interesting. (And Cloudflare with Proxy) |
I assume that's FPM-related. |
i have disabled fpm, but it is still the same. |
and the headers are set, so very weird. |
example with the last commit dev-master |
It is recognized correctly, but still only gives out windows 10. object(DeviceDetector\ClientHints)#3 (8) {
--
| ["architecture":protected]=>
| string(0) ""
| ["bitness":protected]=>
| string(0) ""
| ["mobile":protected]=>
| bool(false)
| ["model":protected]=>
| string(2) """"
| ["platform":protected]=>
| string(9) ""Windows""
| ["platformVersion":protected]=>
| string(8) ""14.0.0""
| ["uaFullVersion":protected]=>
| string(14) ""99.0.4844.51""
| ["fullVersionList":protected]=>
| array(3) {
| [0]=>
| array(2) {
| ["brand"]=>
| string(12) " Not A;Brand"
| ["version"]=>
| string(2) "99"
| }
| [1]=>
| array(2) {
| ["brand"]=>
| string(8) "Chromium"
| ["version"]=>
| string(2) "99"
| }
| [2]=>
| array(2) {
| ["brand"]=>
| string(13) "Google Chrome"
| ["version"]=>
| string(2) "99"
| }
| }
| } |
|
@Nevercold Can you refresh phpsandbox page? Chrome sends the platform version on a second request. So this is the issue. |
I already have a few times. |
But also funny that it first says x64 and then x86. |
@sgiehl Can you check this when you have time? It should get the platform from bitness. |
and in general, it does not work properly either. xD |
This is a browser issue. Headers aren't sent by the browser on the first request. Probably to avoid fingerprinting or cloaking on the first attempt. |
Tricky! Private browsing or in general? |
But I have reloaded it many times, so it should be there then. |
additional quotes are present, most likely, this does not allow determine the version need fix |
true, it takes |
Fixed. #7050 Works now for me. |
Client Hints are actually designed in a way that by default only some basic data (Sec-CH-UA, Sec-CH-UA-Mobile, Sec-CH-UA-Platform) is provided in the request headers. If the server requests more details by sending a header to the client the next request will contain all information. So the first request can never detect windows 11 actually, as the platform version isn't available. |
Thanks for the explanation :) |
Hey - Thanks very much for this. Any estimate date of when will the next version be released? :) |
We are currently preparing the implementation in Matomo to see if any further changes are required here. Once that is done we will release a new major version of device detector. Guess within one or two weeks |
Description:
As discussed in some other issues it might happen in the near future that some devices or clients might freeze the useragents in favor of client hints.
This is a proposal on how we could possibly implement a client hint detection in device detector
It's not yet finished and there are still a couple of things that might need to be discussed and improved.
I did not yet had much time to think about this or implement it, so if someone has a suggestion for a better solution feel free to suggest it here.
@sanchezzzhak Any feedback on that one?