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

Bugfix/target filtering api fix #1220

Merged
merged 8 commits into from
May 25, 2017
Merged

Conversation

mkendall07
Copy link
Member

Type of change

  • Bugfix

Description of change

Resolves #1217

Other information

@prebid/core for review

Copy link
Collaborator

@snapwich snapwich left a 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) {
Copy link
Collaborator

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];
Copy link
Collaborator

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]?

Copy link
Member Author

Choose a reason for hiding this comment

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

yep good catch

@snapwich
Copy link
Collaborator

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) {
Copy link
Contributor

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.

Copy link
Member Author

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

Copy link
Collaborator

@protonate protonate left a 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) {
Copy link
Collaborator

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?

Copy link
Member Author

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;
Copy link
Collaborator

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.

Copy link
Member Author

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.

Copy link
Collaborator

@snapwich snapwich left a 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 :)

Copy link
Collaborator

@protonate protonate left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@protonate protonate merged commit a4d5160 into master May 25, 2017
@protonate protonate deleted the bugfix/target_filtering_api_fix branch May 25, 2017 01:43
vzhukovsky added a commit to aol/Prebid.js that referenced this pull request Jul 17, 2017
….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)
  ...
jbAdyoulike pushed a commit to jbAdyoulike/Prebid.js that referenced this pull request Sep 21, 2017
* 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
dluxemburg pushed a commit to Genius/Prebid.js that referenced this pull request Jul 17, 2018
* 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Targeting filtering API is broken and mismatched
4 participants