Skip to content
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

ClientHints plan upgrade #7274

Open
sanchezzzhak opened this issue Oct 21, 2022 · 4 comments
Open

ClientHints plan upgrade #7274

sanchezzzhak opened this issue Oct 21, 2022 · 4 comments

Comments

@sanchezzzhak
Copy link
Collaborator

https://www.chromium.org/updates/ua-reduction/#proposed-rollout-plan

according to this information, the user-agent will be depersonalized at maximum for browsers: Chromium, Opera, YandexBrowser, Brave etc

we will need to adjust all regular expressions and abandon the pattern
BrandName ([^;)]+)(?: Build|[;)]) or set like this BrandName ([^;)]+)(?: Build|[;)]|$)

more details https://51degrees.com/blog/countdown-to-gday-phase-5-reduced-desktop-ua

@zhouhui
Copy link

zhouhui commented Nov 23, 2022

Hi @sanchezzzhak, I have a question about reduced user-agent: Is it possible to detect device-type( mobile, tablet, desktop, etc.) in reduced user agent only without client-hints? Thanks!

@sanchezzzhak
Copy link
Collaborator Author

Hi, yes it will still be possible

@zhouhui
Copy link

zhouhui commented Nov 23, 2022

Hi, yes it will still be possible

Thanks for your quick reply. From the file 'mobiles.yml', I see some devices types are detected in model regex, for an example:

Microsoft:
  regex: 'KIN\.(One|Two)|RM-(?:1010|1031|106[57]|107[23467]|1089|109[02]|1096|1099|1109|111[348]|1127|1141|115[24]|994)|Microsoft; Lumia|Lumia (?:1530|1320|950|850|650|640|550|535|435)|Corporation/Surface|Surface Duo|Surface 3'
  device: 'smartphone'
  models:
    - regex: 'Surface Duo 2'
      device: 'tablet'
      model: 'Surface Duo 2'

And from the google ua-reduction doc, the part of Model would be reduced in user agent, so I guess, for the target devices of 'Surface Duo 2', the device-type would be detected as 'smartphone' instead of the accurate result 'tablet' with only reduced ua (without client-hints). Am I correct? If so, do we have other ways to get the accurate device-type? Thanks a lot.

@sanchezzzhak
Copy link
Collaborator Author

the type of device, when the brand and model of the device are unknown, is determined by several factors

if (null === $this->device && 'Android' === $osFamily
&& $this->matchUserAgent('Chrome/[\.0-9]*')
) {
if ($this->matchUserAgent('(?:Mobile|eliboM) Safari/')) {
$this->device = AbstractDeviceParser::DEVICE_TYPE_SMARTPHONE;
} elseif ($this->matchUserAgent('(?!Mobile )Safari/')) {
$this->device = AbstractDeviceParser::DEVICE_TYPE_TABLET;
}
}

and further down the list.

If we know the device model, we are guaranteed to return the device type.
When we don't know the model of the device, it's all speculation.

Some tablet devices may return mobile types in the useragent string, this will be inaccurate here, but there are very few such devices. (this is due to the fact that the tablet has a SIM module, and the processor is used from a mobile device, processors for phones and tablets are most often different)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants
@zhouhui @sanchezzzhak and others