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

Adpod module #3511

Merged
merged 24 commits into from
Feb 27, 2019
Merged

Adpod module #3511

merged 24 commits into from
Feb 27, 2019

Conversation

jsnellbaker
Copy link
Collaborator

Type of change

  • Feature
  • Does this change affect user-facing APIs or examples documented on http://prebid.org?

Description of change

This PR adds adpod module to prebid. It creates several hooked functions that are used to handle/evaluate adpod bids/adunits.

In terms of usage, this module would be ideally activated through another module (eg freeWheelAdserverVideo (see #3489)) by calling the initAdpodHooks() function somewhere in the file directly. Through this approach, the module would not need to be directly specified in the build process; it would automatically be pulled in when the ...AdserverVideo module is included.

Other information

Docs PR here

@mkendall07
Copy link
Member

This pull request introduces 2 alerts when merging c661a7a into 29dd87c - view on LGTM.com

new alerts:

  • 2 for Invocation of non-function

Comment posted by LGTM.com

@mkendall07
Copy link
Member

This pull request introduces 2 alerts when merging 9c7d7e0 into 90afc1a - view on LGTM.com

new alerts:

  • 2 for Invocation of non-function

Comment posted by LGTM.com

@mkendall07
Copy link
Member

This pull request introduces 2 alerts when merging 1a6cd39 into 90afc1a - view on LGTM.com

new alerts:

  • 2 for Invocation of non-function

Comment posted by LGTM.com

@mkendall07
Copy link
Member

This pull request introduces 2 alerts when merging 2b7158f into 90afc1a - view on LGTM.com

new alerts:

  • 2 for Invocation of non-function

Comment posted by LGTM.com

@mkendall07
Copy link
Member

This pull request introduces 2 alerts when merging 44eb4ec into 90afc1a - view on LGTM.com

new alerts:

  • 2 for Invocation of non-function

Comment posted by LGTM.com

@mkendall07
Copy link
Member

This pull request introduces 2 alerts when merging 7380f08 into fbe766e - view on LGTM.com

new alerts:

  • 2 for Invocation of non-function

Comment posted by LGTM.com

@mkendall07
Copy link
Member

This pull request introduces 2 alerts when merging db14fc6 into 16ae069 - view on LGTM.com

new alerts:

  • 2 for Invocation of non-function

Comment posted by LGTM.com

@mkendall07
Copy link
Member

This pull request introduces 2 alerts when merging 69bc093 into 16ae069 - view on LGTM.com

new alerts:

  • 2 for Invocation of non-function

Comment posted by LGTM.com

@mkendall07
Copy link
Member

This pull request introduces 2 alerts when merging 9860a56 into c2ef82b - view on LGTM.com

new alerts:

  • 2 for Invocation of non-function

Comment posted by LGTM.com

Copy link
Collaborator

@jaiminpanchal27 jaiminpanchal27 left a comment

Choose a reason for hiding this comment

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

Overall LGTM.
Few minor things

modules/adpod.js Outdated
*/
export function initAdpodHooks() {
function setupHookFnOnce(hookId, hookFn, priority = 15) {
let result = hooks[hookId].getHooks({hook: hookFn});
Copy link
Collaborator

Choose a reason for hiding this comment

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

What if some other module has added hook on checkAdUnitSetup and it is added first. Will these hooks be added since your are comparing the length to 0 ?

Copy link
Collaborator Author

@jsnellbaker jsnellbaker Feb 6, 2019

Choose a reason for hiding this comment

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

So they would be added to the hooks['checkAdUnitSetup'] object, but they wouldn't show when I execute the getHooks() call because I'm effectively filtering that get to only look for the function that's inside this module.

I tested this out locally and even when I name the hook function the same (ie checkAdUnitSetupHook) - the hooked function won't return with this type of call because the function signature is different.

modules/adpod.js Outdated
*/
export function checkAdUnitSetupHook(fn, adUnits) {
let goodAdUnits = adUnits.filter(adUnit => {
let mediaTypes = adUnit.mediaTypes;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggestion: utils.deepAccess can be used here. deepAccess(adUnit, 'mediaTypes.video.context')

modules/adpod.js Outdated
* @param {Object} bidderRequest copy of bid's associated bidderRequest object
*/
export function callPrebidCacheHook(fn, auctionInstance, bidResponse, afterBidAdded, bidderRequest) {
let videoConfig = bidderRequest.mediaTypes && bidderRequest.mediaTypes.video;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggestion: utils.deepAccess can be used here. deepAccess(bidderRequest, 'mediaTypes.video.context')

modules/adpod.js Outdated
// note to reviewers - was doing this to ensure the variable wouldn't be malformed by the additional incoming bids
// while the current list is being processed by PBC and the store callback
// ...but is this copy really needed?
let bidListCopy = bidList.slice();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can be removed. No need to copy

modules/adpod.js Outdated
} else {
for (let i = 0; i < cacheIds.length; i++) {
// when uuid in response is empty string then the key already existed, so this bid wasn't cached
// TODO? - should we throw warning here? should we call the afterBidAdded() anyway to decrement the internal bid counter?
Copy link
Collaborator

Choose a reason for hiding this comment

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

We should call afterBidAdded to decrement the counter because there can be a case where auction is not timedout and one of the bid is back with empty uuid. In this case we would like to close the auction and not wait for timer to expire

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

To confirm on this point - should we throw any type of message that the bid wasn't cached b/c it had a duplicate key? Or just let it go silently?

Copy link
Collaborator

Choose a reason for hiding this comment

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

yep logMessage is good

modules/adpod.js Outdated
for (let i = 0; i < cacheIds.length; i++) {
// when uuid in response is empty string then the key already existed, so this bid wasn't cached
// TODO? - should we throw warning here? should we call the afterBidAdded() anyway to decrement the internal bid counter?
// TODO? - verify the cacheKey is one of the expected values (eg in case PBC returns generic UUID)?
Copy link
Collaborator

Choose a reason for hiding this comment

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

We can ignore this check

@jsnellbaker
Copy link
Collaborator Author

@jaiminpanchal27 I have made several updates in lieu of your feedback; please take another look when you have the chance.

Copy link
Contributor

@idettman idettman left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@mkendall07 mkendall07 left a comment

Choose a reason for hiding this comment

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

LGTM. One requested change on the bid duration rounding behavior

import find from 'core-js/library/fn/array/find';
const from = require('core-js/library/fn/array/from');

export const TARGETING_KEY_PB_CAT_DUR = 'hb_pb_cat_dur';
Copy link
Member

Choose a reason for hiding this comment

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

kind of late but are we happy with this name? :)

export const TARGETING_KEY_PB_CAT_DUR = 'hb_pb_cat_dur';
export const TARGETING_KEY_CACHE_ID = 'hb_cache_id'

let queueTimeDelay = 50;
Copy link
Member

Choose a reason for hiding this comment

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

any experimentation with different default values here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I did test using different values (went to 500) and with the timers I setup at different points in this module - it was executing the call to Prebid Cache at the set time value when there was a sufficient gap in bids.

modules/adpod.js Outdated
// create parent level object based on auction ID (in case there are concurrent auctions running) to store objects for that auction
if (!registry[bid.auctionId]) {
registry[bid.auctionId] = {};
registry[bid.auctionId].bidStorage = new Set();
Copy link
Member

Choose a reason for hiding this comment

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

nice use of a new data type!

modules/adpod.js Outdated
* - only bids that exactly match those listed values are accepted (don't round at all).
* - populate the `bid.video.durationBucket` field with the matching duration value
* when adUnit.mediaTypes.video.requireExactDuration is false
* - round the duration to the next highest specified duration value based on adunit (eg if range was [5, 15, 30] -> 3s is rounded to 5s; 16s is rounded to 30s)
Copy link
Member

Choose a reason for hiding this comment

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

we wanted to add a 2 second buffer here. That is if a bid is 16s it should be rounded down to the the nearest bucket (15s in this case) because it is within 2s of a bucket.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'll make an update here to incorporate this logic. Should this buffer apply to the highest range? ie if the ranges were [15, 30, 45, 60] and the bid was 61 - we would round it down to 60 and accept it?

Copy link
Member

Choose a reason for hiding this comment

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

yeah I think we can apply it to the highest value as well.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I updated the logic to account for this buffer; please take another look when you have the chance.

@jaiminpanchal27 jaiminpanchal27 merged commit e96d58e into master Feb 27, 2019
@jsnellbaker jsnellbaker deleted the adpod_module branch March 18, 2019 13:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants