amphtml icon indicating copy to clipboard operation
amphtml copied to clipboard

[amp-analytics] Low Entropy UACH macro

Open micajuine-ho opened this issue 5 years ago • 2 comments

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).

micajuine-ho avatar Apr 05 '21 13:04 micajuine-ho

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

fredsh2k avatar Oct 28 '21 07:10 fredsh2k

Yes, looks like an open issue that we forgot to resolve.

If you have issues using UACH, let us know!

kristoferbaxter avatar Oct 28 '21 12:10 kristoferbaxter