Record custom element extension version numbers in AMP4ADS response.
Currently AMP4ADS documents have a JSON field that lists the set of custom element extensions in the document.
For example, if a document contains:
<script async custom-element='amp-analytics' src='https://cdn.ampproject.org/v0/amp-analytics-0.1.js'></script>
<script async custom-element='amp-list' src='https://cdn.ampproject.org/v0/amp-list-0.1.js'></script>
The AMP4ADS json will include:
"customElementExtensions" : [ "amp-analytics", "amp-list" ]
In the future, it will become important to also include the version numbers used in these extensions in some form. Currently they are (almost) all version 0.1 only.
My first suggestion is to actually capture the entire attribute values, rather than parse out the version.
"customElementExtensions" : [
{
"custom-element": "amp-analytics",
"src": "https://cdn.ampproject.org/v0/amp-analytics-0.1.js"
},
{
"custom-element": "amp-list",
"src": "https://cdn.ampproject.org/v0/amp-list-0.1.js"
},
]
This approach can also handle version labels such as amp-list-latest.js.
Sounds reasonable.
Is Cloudflare right now writing this JSON metadata as well? @dknecht
Thinking a little further, we'll probably want to emit both the old and new format for a small period of time, to avoid having to coordinate javascript and server releases simultaneously. As a result, I propose we change the name of the new field to just customElements, so:
"customElements" : [
{
"custom-element": "amp-analytics",
"src": "https://cdn.ampproject.org/v0/amp-analytics-0.1.js"
},
{
"custom-element": "amp-list",
"src": "https://cdn.ampproject.org/v0/amp-list-0.1.js"
},
]
LGTM, definitely want to keep old and new formats until we verify client change is released and working properly
cc: @ampproject/cloudflare
@Gregable should we start sending down both "customElements" and "customElementExtensions" (with entire attribute values)? Or, just the "customElements"?
Ideally you are already sending down:
"customElementExtensions" : [ "amp-analytics", "amp-list" ]
You should also now send down:
"customElements" : [
{
"custom-element": "amp-analytics",
"src": "https://cdn.ampproject.org/v0/amp-analytics-0.1.js"
},
{
"custom-element": "amp-list",
"src": "https://cdn.ampproject.org/v0/amp-list-0.1.js"
},
]
And at some point in the future, you can remove the former if you'd like.
@Gregable on Runtime side we only need extension name and version, since we always construct RTV version ourselves. So, src is unnecessary. I recommend either have amp-list:0.1 or {custo-element: 'amp-list', version: 0.1}
@Gregable What would happen to
<script async custom-template="amp-mustache" src="https://cdn.ampproject.org/v0/amp-mustache-0.1.js"></script>
Also, let's maybe do this:
"extensions" : [
{
"custom-element": "amp-analytics",
"src": "https://cdn.ampproject.org/v0/amp-analytics-0.1.js"
},
{
"custom-template": "amp-mustache",
"src": "https://cdn.ampproject.org/v0/amp-mustache-0.1.js"
},
]
OK, I will modify our implementation to match dima's suggestion:
"extensions" : [
{
"custom-element": "amp-analytics",
"src": "https://cdn.ampproject.org/v0/amp-analytics-0.1.js"
},
{
"custom-template": "amp-mustache",
"src": "https://cdn.ampproject.org/v0/amp-mustache-0.1.js"
},
]
The two differences are the s/customElements/extensions/ and the addition of the 'custom-template' key.
@Gregable We will change "customElements" to "extensions"
@oliy as well
@dvoytenko , we don't need custom-template here (currently) because we don't allow these templates in ads, so we only need to change the name from 'cusomtElements' to 'extensions'
@Gregable cool.
We've already made this change for our server-side implementation. Has the client side implementation been committed and released?
@glevitzky @lannka My guess from the status of https://github.com/ampproject/amphtml/pull/8381 is no, but perhaps I'm wrong.
Right, @glevitzky is actively working on it.
My understanding is that the client side implementation was here: https://github.com/ampproject/amphtml/pull/8381
And this has been implemented for a long time, but was never closed. Feel free to reopen if I am missing something.