Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add SDK integration doc for inabox. #23272

Merged
merged 5 commits into from
Jul 12, 2019
Merged

Conversation

lannka
Copy link
Contributor

@lannka lannka commented Jul 10, 2019

/cc @zombifier (can't add you to reviewer for some reason).

@lannka lannka requested a review from jeffkaufman July 10, 2019 23:47
# SDK integration for AMPHTML ad
One goal of AMPHTML ad is for advertisers to create once and use every where.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"everywhere"

This term describes the situation that an AMPHTML ad is being served
on an non-AMP page inside an iframe embed or in a WebView for native
mobile apps. This is very different from how AMPHTML ad gets rendered
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"how an AMPHTML ad"

on an non-AMP page inside an iframe embed or in a WebView for native
mobile apps. This is very different from how AMPHTML ad gets rendered
on an AMP page, as in which case, more sources sharing between the
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

incomplete?


###### friendly iframe
An iframe on the host page that has the same origin, so that it has
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"An iframe with the same origin as the host page"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

full access to the host page content.

###### foreign iframe
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cross-domain ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done


In the 2nd step, if the ad is generated by a 3rd party, it's a good
idea to run it through an AMP validator to make sure it is valid AMP.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In cases where the ad network is relying on AMPHTML being trustworthy, running the ad through the validator is more than a good idea!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

`https://cdn.ampproject.org/rtv/{version}/amp4ads-host-v0.js`
1. Before host script is loaded, ads tag is still responsible to queue
up all coming AMP messages into a global array.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

coming -> arriving

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

corresponding host script:
`https://cdn.ampproject.org/rtv/{version}/amp4ads-host-v0.js`
1. Before host script is loaded, ads tag is still responsible to queue
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to queue -> for queuing

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

join us to serve and render AMPHTML ad in various environment, for
example regular web & native mobile apps.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mention server-side rendering somewhere?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hesitated to do so... given it's not really standardized at this moment. It makes quite lot assumption with AMP runtime. There is an on-going effort to open-source some SSR for regular AMP doc. But I don't think it's that ready yet, as nothing about amp4ads is covered.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's worth mentioning that this is in progress, and that if you're looking at serving inabox you should get in touch with the project. Without SSR performance is pretty bad.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added a section for Server side rendering

Copy link
Contributor Author

@lannka lannka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

comments addressed

full access to the host page content.

###### foreign iframe
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done


###### friendly iframe
An iframe on the host page that has the same origin, so that it has
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done


In the 2nd step, if the ad is generated by a 3rd party, it's a good
idea to run it through an AMP validator to make sure it is valid AMP.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

`https://cdn.ampproject.org/rtv/{version}/amp4ads-host-v0.js`
1. Before host script is loaded, ads tag is still responsible to queue
up all coming AMP messages into a global array.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

corresponding host script:
`https://cdn.ampproject.org/rtv/{version}/amp4ads-host-v0.js`
1. Before host script is loaded, ads tag is still responsible to queue
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

communicate to the host page via postMessage API.

## Web SDK (ads tag) integration
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how about JS SDK?

join us to serve and render AMPHTML ad in various environment, for
example regular web & native mobile apps.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hesitated to do so... given it's not really standardized at this moment. It makes quite lot assumption with AMP runtime. There is an on-going effort to open-source some SSR for regular AMP doc. But I don't think it's that ready yet, as nothing about amp4ads is covered.

join us to serve and render AMPHTML ad in various environment, for
example regular web & native mobile apps.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's worth mentioning that this is in progress, and that if you're looking at serving inabox you should get in touch with the project. Without SSR performance is pretty bad.

1. Add [Content-Security-Policy](https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP)
rules to the ad response to 1) only load JS files from trusted AMP
CDN; 2) disallow iframe embed.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you look on a page with GPT you can see Google is currently using:

<meta http-equiv="Content-Security-Policy" content="script-src https://cdn.ampproject.org/;object-src 'none';child-src blob:;frame-src 'none'">

Why not recommend that here? If you're not careful, for example, you can break amp-bind by not allowing workers to be loaded from blobs.

See #21681 where I proposed AMP recommend this CSP.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

CDN; 2) disallow iframe embed.
1. Validate the AMPHTML ad using an AMP validator. There is an open
source JS implementation for the validator. But for performance reason
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reasons

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

###### Security assurance
In case that the AMPHTML ad is generated by a 3rd party, to ensure it's
secure to put it in a friendly iframe, the following 2 enforcements
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"enforcements" -> "restrictions" or "protections"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

host script is to be loaded in that case to fulfill the requirements.

Main work flow:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

workflow

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@lannka lannka merged commit 480db01 into ampproject:master Jul 12, 2019
rindo pushed a commit to logly/amphtml that referenced this pull request Jul 24, 2019
* Add SDK integration doc for inabox.

* Update

* address comments

* Fix presumit check

* Updates
thekorn pushed a commit to edelight/amphtml that referenced this pull request Sep 11, 2019
* Add SDK integration doc for inabox.

* Update

* address comments

* Fix presumit check

* Updates
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants