WICG / ua-client-hints

Wouldn't it be nice if `User-Agent` was a (set of) client hints?
https://wicg.github.io/ua-client-hints/
Other
590 stars 77 forks source link

Make Sec-CH-UA-Form-Factor a list, add meanings #343

Closed djmitche closed 1 year ago

djmitche commented 1 year ago

This


Preview | Diff

djmitche commented 1 year ago

@miketaylr I'd be interested in your opinions here, and would appreciate it if you can draw the attention of other interested stakeholders.

miketaylr commented 1 year ago

Will try to get this reviewed before EOW! (was OOO 😎 🙇 )

nielsbasjes commented 1 year ago

Just to introduce myself: I'm an IT Architect at a really large online retailer. I have been doing large data processing for ~25 years and I have been doing large scale webanalytics for about 18 years now.

I have written several opensource libraries to support these kinds of usecases and I have contributed to (just about) all Apache Software Foundation "Big Data" projects. In light of the definitions of these ClientHints; this project of mine is most relevant to mention: Yauaa https://yauaa.basjes.nl/ (https://github.com/nielsbasjes/yauaa). This library tries to parse and analyse the useragent and clienthints to make this available to (usually) analytics systems.

Looking at the usecases of the output of Yauaa at the place where I work I see some things that would really benefit from having good values in the Sec-CH-UA-Form-Factor header.

Disclaimer: I have NOT discussed any of this below with any of my colleagues; This is all on me.

Essentially the key question is about what kinds of devices should the website work on and which variant of the website should we send to the visitor that just arrived.

Looking at the Client Hints the Sec-Ch-Ua-Mobile is the only one that can be used for this purpose and it is really vague. It only indicates if it is a Phone or not. It does not indicate if the touch interface is needed because a Tablet (with a touch screen) returns a false here. So in my library I try to improve it by (for example) also look at the tag that is put before Safari and the Operating system tags. So Safari on Mac OS is Desktop. Safari on iOS is Tablet. Mobile Safari on iOS is Phone. I consider this to be quite messy.

As I mentioned here there is great diversity you could include in a header like this. But having too much detail would make it a fingerprinting feature.

So just let me propose how I would approach this and hear what you think.

I need a clear indicator for:

I'm in doubt if "How mobile" the device is (like wall mounted, handheld, vehicle mounted) would add any value to this.

Note that some of these dimensions are not independent: So a watch, phone and tablet are almost always touch screens for example.

I did some more digging about what VR, AR and MR really mean and on this (Dutch, sorry) site they explained with some images https://cadcompany.nl/blog/vr-ar-en-mr-verschillen/

My summary:

Now all of this does NOT mean you are using a headset. To give an example the kids app created for my work is a clear example of MR that is intended to work on phones and tablets as demonstrated in this video https://youtu.be/fZZCAs4G9Zg?t=36

So when the key question is "which content should we show" the key question becomes: Can the device mix the real world and the virtual world?

My initial proposal for this header where I'm trying to stay at useful detail without going into fingerprinting detail:

ScreenType indicator: s="ScreenType"

With allowed values:

Interaction indicator: i="InteractionType"

With allowed values:

Discussion: Perhaps "Game" and "Remote" should be merged to "Joystick"?

Attention indicator: a="AttentionType"

With allowed values:

Examples:

Watch: s="Watch";i="Touch";a="High" Phone: s="Phone";i="Touch";a="High" Tablet: s="Tablet";i="Touch";a="High" Amazon Echo: s="Tablet";i="Touch";a="Medium" PS5: s="TV";i="Game";a="High" Nintendo Switch: s="Phone";i="Game";a="High" Tesla: s="Tablet";i="Touch";a="Low" Google TV: s="TV";i="Remote";a="Medium" Apple Vision Pro: s="XR";i="Gesture";a="High" PS4 VR Headset: s="VR";i="Gesture";a="High" PS5 VR Headset: s="XR";i="Gesture";a="High"

I would set the standard to require all 3 always and given the intended usecase What website version should I show the visitor I would like to see this as one of the low entropy headers that is sent on the first request.

nielsbasjes commented 1 year ago

Additional thought: In some cases you can have multiple screens and multiple interaction types. A phone with a watch attached: s="Phone|Watch" ? A laptop with a touch screen: i="Touch|Keyboard" ?

nielsbasjes commented 1 year ago

Additional: eInk screens should be clear. No colors, no animations, ...

miketaylr commented 1 year ago

I have written several opensource libraries to support these kinds of usecases and I have contributed to (just about) all Apache Software Foundation "Big Data" projects.

@nielsbasjes really appreciate your input!

nielsbasjes commented 1 year ago

@miketaylr

Why don't we start with XR, and if someone claims to have a different use case for VR (or MR)... we can consider adding it.

My current view of this header is that is an indication on the kind of content the device/agent the user has can handle. Based on that my point about keeping the VR in addition to the XR is the question if the device/agent the user has can or cannot mix the provided content with the outside world (i.e. it has the sensors/cameras/compute power/... to support this).

nielsbasjes commented 1 year ago

The goal for this header (the way I see it) is that it tells the website what the device/agent the user has can handle.

This is also what my (bit too long) response earlier was about:

Do you guys have a similar goal/mindset for this header or do you have something completely different in mind?

djmitche commented 1 year ago

@nielsbasjes that's great input -- thank you! I appreciate that you've broken things into a lower-level ontology, and that feels like the right way to go here: a few well-defined bits of data that a site can use to make its own decisions about what kind of content to serve, in a manner likely to continue to work in the future when new forms of user-agents are introduced.

That said, it's quite different from what I've proposed in this PR. Would you mind creating an issue to continue discussion, perhaps copy/pasting some of the text you've written above? I'll work to pull in some more feedback, and as that develops decide whether to merge or abandon this PR, and whether to create a PR implementing something closer to your suggestions.

djmitche commented 1 year ago

OK, I've updated this based on the conversation in #344:

Please let me know what you think.

arichiv commented 1 year ago

This adds non-normative meanings for the suggested values. Consider this a very early draft:

  • Let's talk about the definitions of the form factors and what should or should not be included.
  • Let's talk about where I've used overly-normative language.
  • Let's talk about when a multiple-valued list might make sense.

Preview | Diff

If this is close to being committed can you update the PR description?

nielsbasjes commented 1 year ago

This looks very good to me.

Given that a new value is valid if "that users interact with in a meaningfully different way" then I propose 2 additions because to me they are "meaningfully different": 1) "eInk": terribly slow screen (no animations) and very limited color (if any, usually only greyscale) capabilities. 2) "Watch": so small you really have to design for it and multitouch does not make sense because you cannot even fit 2 fingers on such a screen.

Also I think it would be a good idea to explicitly define approximate screen sizes in the documentation (similar to what I have done here https://yauaa.basjes.nl/expect/fieldvalues/#deviceclass )

My personal opinion is that the term "Mobile" is vague; I would use "Phone". This is not important if the documentation on this is made a bit clearer by adding something like the screensize.

Proposal:

djmitche commented 1 year ago

Thanks! I had chosen "Mobile" to try to indicate that Mobile: ?1 would correspond to this value, but you're right that the term is vague and shouldn't be perpetuated. Choosing a different name allows implementers to decide how Sec-CH-UA-Mobile and Sec-CH-UA-Form-Factor should be related. I suspect that "Phone" is a bit US-centric, but probably the best choice after "Mobile".

I'll add Watch and EInk as options, and include screen size descriptions. I'll also clarify that values should be given as written (including capitalization) to avoid providing additional fingerprinting entropy.

nielsbasjes commented 1 year ago

I'm Dutch and here the terms "Telefoon" and "Mobieltje" are used by many people interchangeable. The online shop I work for shows them as Smartphone to the customers. So calling it "Phone" is not a US term from where I'm standing.

miketaylr commented 1 year ago

Still LGTM :)

djmitche commented 1 year ago

I've had some positive private reactions, and nothing suggesting a change, so I'm going to merge this as-is.

nielsbasjes commented 1 year ago

I'll add Watch and EInk as options, and include screen size descriptions. I'll also clarify that values should be given as written (including capitalization) to avoid providing additional fingerprinting entropy.

Seems like this was missing from the actual commit? @djmitche

lukewarlow commented 1 year ago

Should https://wicg.github.io/ua-client-hints/#dom-uadatavalues-formfactor be a sequence<DOMString> now?

djmitche commented 1 year ago

Both good points. I'll make a new PR.