-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Bugfix/target filtering api fix #1220
Conversation
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.
function getWinningBidTargeting
also needs to be updated to accept param.
src/targeting.js
Outdated
window.googletag.pubads().getSlots().forEach(slot => { | ||
pbTargetingKeys.forEach(function(key) { | ||
// reset only registered adunits | ||
adUnitCodes.find(function(unit) { | ||
adUnits.find(function(unit) { |
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 should probably be .forEach
as find is just being used here to loop through the adUnits
src/targeting.js
Outdated
const adUnitCodes = adUnitCode && adUnitCode.length ? [adUnitCode] : $$PREBID_GLOBAL$$._adUnitCodes; | ||
let adUnitCodes = $$PREBID_GLOBAL$$._adUnitCodes; | ||
if (typeof adUnitCodes === 'string') { | ||
adUnitCode = [adUnitCode]; |
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.
should this be adUnitCodes = [adUnitCode]
?
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.
yep good catch
Thanks for the quick turnaround looking into this |
src/prebid.js
Outdated
@@ -260,21 +260,21 @@ $$PREBID_GLOBAL$$.getBidResponsesForAdUnitCode = function (adUnitCode) { | |||
* Set query string targeting on all GPT ad units. | |||
* @alias module:$$PREBID_GLOBAL$$.setTargetingForGPTAsync | |||
*/ | |||
$$PREBID_GLOBAL$$.setTargetingForGPTAsync = function (adUnits) { | |||
$$PREBID_GLOBAL$$.setTargetingForGPTAsync = function (adUnitsCodeArr) { |
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.
Do you think we should start JSDoc-ing params whenever the types cause confusion?
Renaming it here does help... but in other cases (like getAllTargeting
, where the arg might be a string or array) that's not always possible.
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.
yeah we should. I'll update 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.
Currently we have adUnits
and _adUnitCodes
with the latter being a "filter" of ad units to use in current operation. A subset of ad units gets persisted to _adUnitCodes
. This change adds a second "filter" of sorts just when setting targeting, so if the intent is to set targeting on the same subset of ad units for which bids were requested we should use the existing filter _adUnitCodes
. If a subset of the subset, as we have here, then the filter will not be persisted such that a subsequent call to setTargeting...
will operate on the "full subset" of _adUnitCodes, not the last used subset of codes passed to setTargeting...
Is this the intention?
src/prebid.js
Outdated
* @alias module:$$PREBID_GLOBAL$$.setTargetingForGPTAsync | ||
*/ | ||
$$PREBID_GLOBAL$$.setTargetingForGPTAsync = function (adUnits) { | ||
$$PREBID_GLOBAL$$.setTargetingForGPTAsync = function (adUnitsCodeArr) { |
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.
can adUnitCodes
be standard param name, here in place of adUnitsCodeArr
?
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.
Yeah I thought about it. It does make sense
src/targeting.js
Outdated
else if (utils.isArray(adUnitCode)) { | ||
return adUnitCode; | ||
} | ||
return $$PREBID_GLOBAL$$._adUnitCodes; |
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.
It should not be possible to get to this point and still have pbjs._adUnitCodes
filter undefined but might want to test for that or otherwise assure the return value here, if undefined, is handled.
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.
good call. I'll address.
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. I think some of the variables names are still kind of wonky, but I think most of this will be resolved when we adopt types, so it can wait for later :)
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, thanks!
….23.0 to aolgithub-master * commit '136fc37637749a764070c35c03e7e87a5c157947': (33 commits) Added changelog entry. Implemented passing key values feature. Update code to ESlint rules. Prebid 0.24.1 Release tests: drop ie9 browserstack test Audience Network: separate size from format (prebid#1218) Bugfix/target filtering api fix (prebid#1220) Map sponsor request param to endpoint param (prebid#1219) Increment pre version Probed 0.24.0 Release Beachfront adapter - add ad unit size (prebid#1183) Thoughtleadr adapter - fix postMessage (prebid#1207) When prebid server issues a no-bid response, call addBidResponse for every adUnit requested (prebid#1204) Improvement/timeout xhr (prebid#1172) Add native support (prebid#1072) Improvement/alias queue (prebid#1156) Updated documentaion (prebid#1160) Improvement/prebid iframes amp pages (prebid#1119) Fixes prebid#1114 possible xss issue (prebid#1186) Allowed setTargetingForGPTAsync() to target specific ad unit codes. (prebid#1158) ...
* fix bug and unit tests * Fix space * PR review fix * Address review comments. Fix 1 more bug :) * Add back alias * Make sure we reset targeting properly based on input type. * update per review * defensive coding
* fix bug and unit tests * Fix space * PR review fix * Address review comments. Fix 1 more bug :) * Add back alias * Make sure we reset targeting properly based on input type. * update per review * defensive coding
Type of change
Description of change
Resolves #1217
Other information
@prebid/core for review