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

Change Story Ad Insertion #18959

Merged
merged 7 commits into from Oct 26, 2018
Merged

Change Story Ad Insertion #18959

merged 7 commits into from Oct 26, 2018

Conversation

calebcordry
Copy link
Member

FR was to have the first ad show after 7 pages, and then after every 8 thereafter.

Tweaked the page counting a bit so that the defined consts more accurately reflect the page of insertion.

}

// Set to -1 because there is still one page to be viewed before ad.
this.uniquePagesCount_ = -1;
Copy link
Member Author

Choose a reason for hiding this comment

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

This felt a bit strange, I could be convinced to move this -1 to L601.

Copy link
Contributor

Choose a reason for hiding this comment

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

indeed, still don't quite understand why it was initialized as 1 and reset as -1

Copy link
Member Author

Choose a reason for hiding this comment

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

We can only count at navigation (click to next page) time. So on the first page we have seen one page even though 0 pages have been navigated to.

We then reset the counter when an ad is inserted. It is inserted one page away, so we see one more page before the ad. Then we still want to wait 8 pages after.

Do you think it would be better to set it always to zero, and have the offset at the check time?

}

return false;
}

/**
* start the process over
* @private
*/
startNextPage_() {
Copy link
Contributor

Choose a reason for hiding this comment

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

naming: startNextAdPage_

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

/** @const */
const MIN_INTERVAL = 4;
/** @const {number} */
const FIRST_AD_MIN = 7;
Copy link
Contributor

Choose a reason for hiding this comment

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

does this mean the 8th page can be an ad?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes. 7 pages then ad.

const FIRST_AD_MIN = 7;

/** @const {number} */
const MIN_INTERVAL = 8;
Copy link
Contributor

Choose a reason for hiding this comment

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

does this mean the 9th page be an ad? or 8th?

Copy link
Member Author

Choose a reason for hiding this comment

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

Ninth page should be ad (really its after the 15th then after 23 etc.)

this.uniquePagesCount_ = 0;
/**
* Set to one here because we count on navigation event, and we do have
* an event before first page.
Copy link
Contributor

Choose a reason for hiding this comment

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

i don't fully understand this. could you rephrase?

Copy link
Member Author

Choose a reason for hiding this comment

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

I tried to explain above. Let me know if you think there is a better way to rephrase.

Copy link
Member Author

Choose a reason for hiding this comment

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

Rewrote this. LMK if you think it should still be improved.

* @return {boolean}
* @private
*/
enoughPagesShown_() {
Copy link
Contributor

Choose a reason for hiding this comment

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

enoughContentPagesViewed_()

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

@@ -182,6 +189,9 @@ export class AmpStoryAutoAds extends AMP.BaseElement {
/** @private {number|null} */
this.idOfAdShowing_ = null;

/** @private {boolean} */
this.firstAdShown_ = false;
Copy link
Contributor

Choose a reason for hiding this comment

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

let's be consistent about terminology here, i think this mean viewed?

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

}

// Set to -1 because there is still one page to be viewed before ad.
this.uniquePagesCount_ = -1;
Copy link
Contributor

Choose a reason for hiding this comment

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

indeed, still don't quite understand why it was initialized as 1 and reset as -1

@calebcordry
Copy link
Member Author

A couple extra things after initial review:

Moved the logic so that we start next ad loading after view. This eliminates the -1 confusion.

Set pages before first ad, and interval thereafter to be the same. I think we should keep the extra logic in case we want to special case the first ad in the future.

* @return {boolean}
* @private
*/
enoughContentPagesShown_() {
Copy link
Contributor

Choose a reason for hiding this comment

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

enoughContentPagesViewed

Copy link
Member Author

Choose a reason for hiding this comment

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

done.

@calebcordry calebcordry merged commit cb21e8b into ampproject:master Oct 26, 2018
@calebcordry calebcordry deleted the stamp-ad-algo branch October 26, 2018 05:17
Enriqe pushed a commit to Enriqe/amphtml that referenced this pull request Nov 28, 2018
* tweak insertion

* renaming

* start next after view

* change interval

* closure

* test

* rename
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.

None yet

3 participants