Skip to content

Conversation

bramanudom
Copy link
Contributor

#20083

Publishers should be able to specify what page should follow a given page element. This has already existed/ been correctly implemented in the form of i-amphtml-advance-to. Removing just the i-amphtml should be sufficient for making this usable by publishers.

@newmuis
Copy link
Contributor

newmuis commented Jan 2, 2019

We likely also want this behind an experiment, so we can control when it goes live 😄 We can use one experiment to guard everything, if that's easier

@newmuis
Copy link
Contributor

newmuis commented Jan 2, 2019

Adding @calebcordry since this affects ads code

@gmajoulet
Copy link
Contributor

gmajoulet commented Jan 2, 2019

Do we want to:

(1) merge this whenever we want to launch the feature?
(2) add all these small changes behind the same branching experiment, so we can launch it all at once?

@calebcordry
Copy link
Member

@bramanudom this should be fine, but would you mind testing manually to be sure? You can use the doubleclick.html example. Please add this attribute before and after the pages where the ad will be inserted (should be after seventh page) and make sure the ad still shows up. Thanks.

@bramanudom
Copy link
Contributor Author

@gmajoulet I think adding these small changes to the same branching experiment would be good. Not sure if it would make a big difference, but it would be great to be able to test/ see how the changes work together. If that sounds good, I'll add in the experiment statements

@calebcordry We talked online but I did a manual test:

  • adding jumps some pages before the ad
  • right before the ad
  • and once again for later ads

and it all seems to be working as expected.

I will be adding a unit test for amp-story tests in this PR as well as validation that this works for branching purposes.


if (isExperimentOn(this.win, 'amp-story-branching')) {
Attributes[ADVANCE_TO] = 'advance-to';
}
Copy link
Contributor

@gmajoulet gmajoulet Jan 4, 2019

Choose a reason for hiding this comment

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

Can we define another attribute (ie: Attributes.BRANCHING_ADVANCE_TO, or PUBLIC_ADVANCE_TO, ...) instead, that we'd use here and for the other occurrences? It's pretty risky to change the values of an enum :(

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Got it! Done.

.element.setAttribute('advance-to', 'page-3');

story.activePage_.element.dispatchEvent(
new MouseEvent('click', {clientX: 200}));
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: indent

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.


/** @enum {string} */
const Attributes = {
let Attributes = {
Copy link
Member

Choose a reason for hiding this comment

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

nit: Can't we leave this as const since it is an obj?

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.

const nextPageEl = nextPage.element;
const nextPageId = nextPageEl.id;
pageToBeInsertedEl.setAttribute(Attributes.ADVANCE_TO, nextPageId);
pageToBeInsertedEl.setAttribute(Attributes.advanceAttr, nextPageId);
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we also change the one in the next_ method for this PR to work?

Copy link
Contributor Author

@bramanudom bramanudom Jan 7, 2019

Choose a reason for hiding this comment

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

Thank you for catching this! I never caught it in testing because this check addresses the case where the last page has the private attribute.

I'm assuming that the check for the private attribute was originally added in the case where an ad should follow the last page. I made the change/added the check, but I'm also not sure what the use case for allowing the last page of a story to have a public advance-to attribute would be. It seems like it would more likely than not create an infinite cycle since a story wouldn't be able to 'end'.

Copy link
Member

Choose a reason for hiding this comment

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

I am a bit confused here. This is the method that amp-story-auto-ads calls when it wants to add a new page to the story. So if we have a story like page1 -> page2 we can change it to page1 -> ad -> page2. All this logic is just trying to copy any pointers from page1 to the ad so that the flow is the same.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry for the confusion, I definitely could've been more clear. Gabriel brought up changing the code in next_ that uses ADVANCE_TO as well, and my response was for the logic in the that method and not in insertPage.

Copy link
Member

Choose a reason for hiding this comment

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

I see, I think that the the idea there was just future proofing knowing that this eventually may be used for non linear stories, but @gmajoulet is right, as it is written now it won't respect the experiment.

Copy link
Member

Choose a reason for hiding this comment

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

(the ad can't be the last page of a story anyway)

if (!pageAfterAd) {
return AD_STATE.PENDING;
}

@bramanudom
Copy link
Contributor Author

I think this is ready for merging! @gmajoulet

@gmajoulet gmajoulet merged commit 62a92e4 into ampproject:master Jan 9, 2019
noranazmy pushed a commit to noranazmy/amphtml that referenced this pull request Mar 22, 2019
* make advance-to a public attribute

* added a tests, and put the changes behind an experiment check

* addressed code review changes

* added public advance-to check in next

* add TODOs for cleaning up the experiment

* Revert "add TODOs for cleaning up the experiment"

This reverts commit 088a0c5.

* fixed merge conflicts

* fixed lint issues

* fixed typo
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.

5 participants