-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
Story-Auto-Ads Skeleton #13239
Story-Auto-Ads Skeleton #13239
Conversation
@lannka Is there anything else you want in this initial PR? |
gulpfile.js
Outdated
@@ -135,6 +135,7 @@ declareExtension('amp-soundcloud', '0.1', {hasCss: false}); | |||
declareExtension('amp-springboard-player', '0.1', {hasCss: false}); | |||
declareExtension('amp-sticky-ad', '1.0', {hasCss: true}); | |||
declareExtension('amp-story', '0.1', {hasCss: true}); | |||
declareExtension('amp-story-auto-ads', '0.1', {hasCss: false}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we agreed not to have this as a separate binary. Can you move the code into the amp-story extension?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure, I guess we can move it later if it bloats
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
// temporary to be replaced with real page later | ||
makeMockPage() { | ||
const ampStoryAdPage = document.createElement('amp-story-page'); | ||
ampStoryAdPage.id = 'ad-page-1'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we need to make sure the id not conflict with existing element IDs on the page (provided by the publisher).
you can use our reserved prefix: i-amphtml-
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
const ampStory = this.element.parentElement; | ||
user().assert(ampStory.tagName === 'AMP-STORY', | ||
`<${TAG}> should be child of <amp-story>`); | ||
ampStory.appendChild(this.makeMockPage()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we might want to do this in layoutCallback.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
my thought was that we wanted to let the ad resources start loading ASAP but if you want layoutCallback
SGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we want to be nice to let content render first.
we are not showing ads in the first 3 page views in anyway.
// temporary to be replaced with real page later | ||
makeMockPage() { | ||
const ampStoryAdPage = document.createElement('amp-story-page'); | ||
ampStoryAdPage.id = 'i-amphtl-ad-page-1'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo amphtml.
@newmuis what do you think about this?
i-amphtml-
is reserved ID prefix by validator. we can have i-amphtml-ad-
as a prefix for all auto generated pages for ads.
this ID will be consumed by analytics.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. My question is just whether there's something more valuable than a numerical ID that publishers may want for analytics purposes, but I don't understand enough about how publishers consume/evaluate ads to be able to answer that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that's a good point.
maybe we should include the previous pageId into the ID? If the previous page has an ID of page-3
, the ad ID becomes: i-amphtml-AD-page-3
when reporting to analytics, we strip out the i-amphtml-
prefix. so publisher will see AD-page-3
, so he can infer where the ad is shown.
Of course, we will never show 2 ads next to each other, for sake of user experience, also to make sure no ID conflicts between the ads.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this idea, but I think to accomplish it we might need two pieces of identification, one to keep track of it before we know where it will be placed, and another that contains the placement data. Maybe we could use a different attr for one of these?
@@ -201,7 +201,8 @@ export class AmpStory extends AMP.BaseElement { | |||
/** @param {!AmpElement} element */ | |||
constructor(element) { | |||
super(element); | |||
|
|||
|
|||
debugger; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
debugger? :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wow that last commit was sloppy
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
@@ -41,7 +41,7 @@ export class NavigationState { | |||
* @param {!Element} storyElement | |||
* @param {function():Promise<boolean>} hasBookend | |||
*/ | |||
constructor(storyElement, hasBookend) { | |||
constructor(storyElement, hasBookend) {]de |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
woops
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
@@ -201,7 +201,8 @@ export class AmpStory extends AMP.BaseElement { | |||
/** @param {!AmpElement} element */ | |||
constructor(element) { | |||
super(element); | |||
|
|||
|
|||
debugger; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
@@ -41,7 +41,7 @@ export class NavigationState { | |||
* @param {!Element} storyElement | |||
* @param {function():Promise<boolean>} hasBookend | |||
*/ | |||
constructor(storyElement, hasBookend) { | |||
constructor(storyElement, hasBookend) {]de |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
/** @param {!AmpElement} element */ | ||
constructor(element) { | ||
super(element); | ||
this.ampStory = null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add JsDoc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
// temporary to be replaced with real page later | ||
makeMockPage() { | ||
const ampStoryAdPage = document.createElement('amp-story-page'); | ||
ampStoryAdPage.id = 'i-amphtl-ad-page-1'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: typo (missing "m": i-amphtml-ad-page-1
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
|
||
/** @override */ | ||
layoutCallback() { | ||
this.ampStory.appendChild(this.makeMockPage()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM for now. I don't think this is going to be sufficient long-term, since the amp-story won't know its children have changed. We'll need to devise a way to tell the story that it has a new page. You could either dispatch an event, or expose a function from AmpStory and call it here, like:
ampStory.getImpl().then(storyImpl => {
storyImpl.addNewPage(this.makeMockPage());
});
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In long term, maybe worth to extract a PageManager class to decouple the dependency.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
This pull request introduces 1 alert - view on lgtm.com new alerts:
Comment posted by lgtm.com |
* Component skeleton * move files into amp-story * clean up example * remove bad link * bad mock test * clean up
* Component skeleton * move files into amp-story * clean up example * remove bad link * bad mock test * clean up
* Component skeleton * move files into amp-story * clean up example * remove bad link * bad mock test * clean up
This is the start of the implementation of a new
amp-story-auto-ads
component that will handle the scheduling and display of ads in an amp-story.