amphtml icon indicating copy to clipboard operation
amphtml copied to clipboard

Record custom element extension version numbers in AMP4ADS response.

Open Gregable opened this issue 9 years ago • 18 comments

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.

Gregable avatar Jan 26 '17 18:01 Gregable

Sounds reasonable.

Is Cloudflare right now writing this JSON metadata as well? @dknecht

lannka avatar Jan 26 '17 18:01 lannka

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"
   },
]

Gregable avatar Jan 26 '17 19:01 Gregable

LGTM, definitely want to keep old and new formats until we verify client change is released and working properly

keithwrightbos avatar Jan 26 '17 19:01 keithwrightbos

cc: @ampproject/cloudflare

dknecht avatar Jan 26 '17 19:01 dknecht

@Gregable should we start sending down both "customElements" and "customElementExtensions" (with entire attribute values)? Or, just the "customElements"?

irtefa avatar Jan 26 '17 20:01 irtefa

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 avatar Jan 26 '17 23:01 Gregable

@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}

dvoytenko avatar Feb 06 '17 19:02 dvoytenko

@Gregable What would happen to

<script async custom-template="amp-mustache" src="https://cdn.ampproject.org/v0/amp-mustache-0.1.js"></script>

dvoytenko avatar Feb 09 '17 19:02 dvoytenko

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"
   },
]

dvoytenko avatar Feb 09 '17 19:02 dvoytenko

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 avatar Feb 09 '17 21:02 Gregable

@Gregable We will change "customElements" to "extensions"

irtefa avatar Feb 09 '17 21:02 irtefa

@oliy as well

Gregable avatar Feb 09 '17 21:02 Gregable

@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 avatar Feb 09 '17 23:02 Gregable

@Gregable cool.

dvoytenko avatar Feb 11 '17 01:02 dvoytenko

We've already made this change for our server-side implementation. Has the client side implementation been committed and released?

oliy avatar Mar 28 '17 16:03 oliy

@glevitzky @lannka My guess from the status of https://github.com/ampproject/amphtml/pull/8381 is no, but perhaps I'm wrong.

Gregable avatar Mar 30 '17 17:03 Gregable

Right, @glevitzky is actively working on it.

lannka avatar Mar 30 '17 17:03 lannka

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.

Gregable avatar Jul 29 '19 20:07 Gregable