[amp-analytics] Low Entropy UACH macro
https://web.dev/user-agent-client-hints/
Since the low entropy version (navigator.userAgentData) is synchronous, we can create a macro to allow devs access this information and send it via analytics request.
If required, we could also add it to our platform variables to be supported by all extensions that could potential require it (i.e. pixel, consent, etc), and it should not add much in terms of size to v0.
Perhaps something like USER_AGENT_CLIENT_HINTS(_param_), where acceptable values of param are mobile and brands.
USER_AGENT_CLIENT_HINTS(mobile) => boolean
USER_AGENT_CLIENT_HINTS(brands) => array of brand objects that is stringified
If UACH is not supported by the browser, the macro will return null.
In the future, we could support the async high entropy version.
USER_AGENT_CLIENT_HINTS_HIGH_ENTROPY(_param_)
However, we would have to address the problem of this API budgeting based on domain (i.e. viewer would face problems).
isn't this already implemented? check this out https://github.com/ampproject/amphtml/blob/main/docs/spec/amp-var-substitutions.md#user-agent-client-hint
Yes, looks like an open issue that we forgot to resolve.
If you have issues using UACH, let us know!