Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Added support Sec-CH-UA-Form-Factors header for ClientHints #7807

Merged
merged 11 commits into from
Sep 10, 2024

Conversation

sanchezzzhak
Copy link
Collaborator

@sanchezzzhak sanchezzzhak commented Sep 3, 2024

@sanchezzzhak
Copy link
Collaborator Author

maybe we should add examples to the documentation for client-hints?

For example, through JS, we can get them like this:

function getHints() {
    return new Promise((resolve, reject) => {
      if (!navigator.userAgentData) {
        return resolve({})
      }
      let requestHints = [
        'brands',
        'mobile',
        'platform',
        'platformVersion',
        'architecture',
        'bitness',
        'wow64',
        'model',
        'formFactors',
        'uaFullVersion',
        'fullVersionList'];

      navigator.userAgentData.getHighEntropyValues(requestHints).then((result) => {
        resolve(JSON.parse(JSON.stringify(result)))
      }).catch(() => {
        resolve({});
      });
    })
  }
getHints().then(data =>console.log(data)) 

@sgiehl
Copy link
Member

sgiehl commented Sep 3, 2024

@sanchezzzhak Based on the definition formFactors is a sf-list. So it can contain multiple comma separated values. In theory something like "Tablet","EInk" would be a valid value. So we would actually need to handle that as array and not as string. Or did I misinterpret the definition 🤔

@liviuconcioiu
Copy link
Collaborator

liviuconcioiu commented Sep 4, 2024

For reference, Android tablets are reporting as Desktop, but detection works. 🎉

tablets

@sanchezzzhak
Copy link
Collaborator Author

@sgiehl yes there should be an array.


I think the form factor based on the user agent string, since there is no prefix (Table|Mobile|VR|TV|XR) is set by default to Desktop

sanchezzzhak and others added 2 commits September 9, 2024 10:10
Co-authored-by: Liviu-Mihail Concioiu <liviu.concioiu@gmail.com>
Copy link
Member

@sgiehl sgiehl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me now.

@sanchezzzhak sanchezzzhak enabled auto-merge (squash) September 10, 2024 08:10
@sanchezzzhak sanchezzzhak merged commit c0311e1 into matomo-org:master Sep 10, 2024
15 checks passed
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants