From 4dda86e025215fa830e275c6b1f11546c61fe619 Mon Sep 17 00:00:00 2001 From: Matt Lane Date: Wed, 23 Jan 2019 09:50:02 -0800 Subject: [PATCH 01/24] Add new context type --- src/utils.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils.js b/src/utils.js index 2abad759e7a..fa43b80b44c 100644 --- a/src/utils.js +++ b/src/utils.js @@ -986,7 +986,7 @@ export function getDefinedParams(object, params) { */ export function isValidMediaTypes(mediaTypes) { const SUPPORTED_MEDIA_TYPES = ['banner', 'native', 'video']; - const SUPPORTED_STREAM_TYPES = ['instream', 'outstream']; + const SUPPORTED_STREAM_TYPES = ['instream', 'outstream', 'adpod']; const types = Object.keys(mediaTypes); From 564fdd1698895368e7c432408a45f93fae7e8d18 Mon Sep 17 00:00:00 2001 From: Matt Lane Date: Wed, 23 Jan 2019 09:51:52 -0800 Subject: [PATCH 02/24] Write request duplication test --- test/spec/modules/appnexusBidAdapter_spec.js | 26 ++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/test/spec/modules/appnexusBidAdapter_spec.js b/test/spec/modules/appnexusBidAdapter_spec.js index b94e574713c..150883c8330 100644 --- a/test/spec/modules/appnexusBidAdapter_spec.js +++ b/test/spec/modules/appnexusBidAdapter_spec.js @@ -171,6 +171,32 @@ describe('AppNexusAdapter', function () { }); }); + it('should duplicate adpod placements and set correct maxduration', function() { + let bidRequest = Object.assign({}, + bidRequests[0], + { + params: { placementId: '14542875' } + }, + { + mediaTypes: { + video: { + context: 'adpod', + playerSize: [640, 480], + adPodDuration: 300, + durationRange: [15, 30], + } + } + } + ); + + const request = spec.buildRequests([bidRequest]); + const payload = JSON.parse(request.data); + + expect(payload.tags.length).to.equal(20); + expect(payload.tags[0]).to.deep.equal(payload.tags[1]); + expect(payload.tags[0].video.maxduration).to.equal(30); + }); + it('should attach native params to the request', function () { let bidRequest = Object.assign({}, bidRequests[0], From 7643efbdcaf790da71701ad3b0bf48a9acb2b0ce Mon Sep 17 00:00:00 2001 From: Matt Lane Date: Thu, 24 Jan 2019 16:04:39 -0800 Subject: [PATCH 03/24] Duplicate adpod placement for request --- modules/appnexusBidAdapter.js | 22 ++++++++++++++++++++++ src/utils.js | 27 +++++++++++++++++++++++++++ 2 files changed, 49 insertions(+) diff --git a/modules/appnexusBidAdapter.js b/modules/appnexusBidAdapter.js index d330c09aa10..1bb10fec807 100644 --- a/modules/appnexusBidAdapter.js +++ b/modules/appnexusBidAdapter.js @@ -119,6 +119,7 @@ export const spec = { version: '$prebid.version$' } }; + if (member > 0) { payload.member_id = member; } @@ -130,6 +131,14 @@ export const spec = { payload.app = appIdObj; } + const adPodBid = find(bidRequests, hasAdPod); + if (adPodBid) { + const numberOfPlacements = utils.getAdPodPlacementNumber(adPodBid.mediaTypes.video); + const maxDuration = utils.getAdPodMaxDuration(adPodBid.mediaTypes.video); + payload.tags = utils.fill(...tags, numberOfPlacements); + payload.tags.map(tag => setMaxDuration(tag, maxDuration)); + } + if (debugObjParams.enabled) { payload.debug = debugObjParams; utils.logInfo('AppNexus Debug Auction Settings:\n\n' + JSON.stringify(debugObjParams, null, 4)); @@ -519,6 +528,19 @@ function hasDebug(bid) { return !!bid.debug } +function hasAdPod(bid) { + return ( + bid.mediaTypes && + bid.mediaTypes.video && + bid.mediaTypes.video.context === 'adpod' + ); +} + +function setMaxDuration(tag, duration) { + if (utils.isEmpty(tag.video)) { tag.video = {}; } + tag.video.maxduration = duration; +} + function getRtbBid(tag) { return tag && tag.ads && tag.ads.length && find(tag.ads, ad => ad.rtb); } diff --git a/src/utils.js b/src/utils.js index fa43b80b44c..bac2d0081b2 100644 --- a/src/utils.js +++ b/src/utils.js @@ -1190,3 +1190,30 @@ export function convertTypes(types, params) { export function isArrayOfNums(val, size) { return (isArray(val)) && ((size) ? val.length === size : true) && (val.every(v => isInteger(v))); } + +/** + * Creates an array of n length and fills each item with the given value + */ +export function fill(value, length) { + let newArray = []; + + for (let i = 0; i < length; i++) { + newArray.push(value); + } + + return newArray; +} + +/** + * + */ +export function getAdPodPlacementNumber(videoParams) { + return videoParams.adPodDuration / Math.min(...videoParams.durationRange); +} + +/** + * + */ +export function getAdPodMaxDuration(videoParams) { + return Math.max(...videoParams.durationRange); +} From 93ee04ec4369efc3e21ce002a221d093aa7da83a Mon Sep 17 00:00:00 2001 From: Matt Lane Date: Fri, 25 Jan 2019 14:29:54 -0800 Subject: [PATCH 04/24] Write requireExactDuration duplication test --- test/spec/modules/appnexusBidAdapter_spec.js | 31 ++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/test/spec/modules/appnexusBidAdapter_spec.js b/test/spec/modules/appnexusBidAdapter_spec.js index 150883c8330..472ab60c99d 100644 --- a/test/spec/modules/appnexusBidAdapter_spec.js +++ b/test/spec/modules/appnexusBidAdapter_spec.js @@ -197,6 +197,37 @@ describe('AppNexusAdapter', function () { expect(payload.tags[0].video.maxduration).to.equal(30); }); + it('should duplicate adpod placements when requireExactDuration is set', function() { + let bidRequest = Object.assign({}, + bidRequests[0], + { + params: { placementId: '14542875' } + }, + { + mediaTypes: { + video: { + context: 'adpod', + playerSize: [640, 480], + adPodDuration: 300, + durationRange: [15, 30], + requireExactDuration: true, + } + } + } + ); + + const request = spec.buildRequests([bidRequest]); + const payload = JSON.parse(request.data); + + expect(payload.tags.length).to.equal(20); + + const tagsWith15 = payload.tags.filter(tag => tag.video.maxduration === 15); + const tagsWith30 = payload.tags.filter(tag => tag.video.maxduration === 30); + + expect(tagsWith15.length).to.equal(10); + expect(tagsWith30.length).to.equal(10); + }); + it('should attach native params to the request', function () { let bidRequest = Object.assign({}, bidRequests[0], From 7c3fe3386ba32cf5a81611d3932f025b34d5451a Mon Sep 17 00:00:00 2001 From: Matt Lane Date: Fri, 25 Jan 2019 15:03:13 -0800 Subject: [PATCH 05/24] Duplicate adpod placement when requireExactDuration is set --- modules/appnexusBidAdapter.js | 44 ++++++++++++++++++++++++++++++----- src/utils.js | 17 +++++--------- 2 files changed, 44 insertions(+), 17 deletions(-) diff --git a/modules/appnexusBidAdapter.js b/modules/appnexusBidAdapter.js index 1bb10fec807..333f011dd6e 100644 --- a/modules/appnexusBidAdapter.js +++ b/modules/appnexusBidAdapter.js @@ -133,10 +133,7 @@ export const spec = { const adPodBid = find(bidRequests, hasAdPod); if (adPodBid) { - const numberOfPlacements = utils.getAdPodPlacementNumber(adPodBid.mediaTypes.video); - const maxDuration = utils.getAdPodMaxDuration(adPodBid.mediaTypes.video); - payload.tags = utils.fill(...tags, numberOfPlacements); - payload.tags.map(tag => setMaxDuration(tag, maxDuration)); + payload.tags = createAdPodRequest(tags, adPodBid); } if (debugObjParams.enabled) { @@ -536,9 +533,44 @@ function hasAdPod(bid) { ); } -function setMaxDuration(tag, duration) { +function createAdPodRequest(tags, adPodBid) { + const { durationRange, requireExactDuration } = adPodBid.mediaTypes.video; + const numberOfPlacements = getAdPodPlacementNumber(adPodBid.mediaTypes.video); + const maxDuration = utils.getMaxValueFromArray(durationRange); + + let request = utils.fill(...tags, numberOfPlacements); + + if (requireExactDuration) { + const divider = numberOfPlacements / durationRange.length; + + for (let i = 1; i <= durationRange.length; i++) { + const end = i * divider; + + request.slice(end - divider, end).map(tag => { + setVideoProperty(tag, 'minduration', durationRange[i - 1]); + setVideoProperty(tag, 'maxduration', durationRange[i - 1]); + }); + } + } else { + request.map(tag => setVideoProperty(tag, 'maxduration', maxDuration)); + } + + return request; +} + +function getAdPodPlacementNumber(videoParams, requireExactDuration) { + const { adPodDuration, durationRange } = videoParams; + const minAllowedDuration = utils.getMinValueFromArray(durationRange); + const numberOfPlacements = adPodDuration / minAllowedDuration; + + return requireExactDuration + ? Math.max(numberOfPlacements, adPodDuration.length) + : numberOfPlacements; +} + +function setVideoProperty(tag, key, value) { if (utils.isEmpty(tag.video)) { tag.video = {}; } - tag.video.maxduration = duration; + tag.video[key] = value; } function getRtbBid(tag) { diff --git a/src/utils.js b/src/utils.js index bac2d0081b2..c2e5f99b12c 100644 --- a/src/utils.js +++ b/src/utils.js @@ -1198,22 +1198,17 @@ export function fill(value, length) { let newArray = []; for (let i = 0; i < length; i++) { - newArray.push(value); + let valueToPush = isPlainObject(value) ? deepClone(value) : value; + newArray.push(valueToPush); } return newArray; } -/** - * - */ -export function getAdPodPlacementNumber(videoParams) { - return videoParams.adPodDuration / Math.min(...videoParams.durationRange); +export function getMinValueFromArray(array) { + return Math.min(...array); } -/** - * - */ -export function getAdPodMaxDuration(videoParams) { - return Math.max(...videoParams.durationRange); +export function getMaxValueFromArray(array) { + return Math.max(...array); } From b803679a05a55e61677615c4528c1678c8ace028 Mon Sep 17 00:00:00 2001 From: Matt Lane Date: Fri, 25 Jan 2019 15:36:27 -0800 Subject: [PATCH 06/24] Add brandCategoryExclusion config to request --- modules/appnexusBidAdapter.js | 5 +++++ test/spec/modules/appnexusBidAdapter_spec.js | 16 ++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/modules/appnexusBidAdapter.js b/modules/appnexusBidAdapter.js index 333f011dd6e..7824dac80f9 100644 --- a/modules/appnexusBidAdapter.js +++ b/modules/appnexusBidAdapter.js @@ -1,5 +1,6 @@ import { Renderer } from '../src/Renderer'; import * as utils from '../src/utils'; +import { config } from '../src/config'; import { registerBidder } from '../src/adapters/bidderFactory'; import { BANNER, NATIVE, VIDEO } from '../src/mediaTypes'; import find from 'core-js/library/fn/array/find'; @@ -136,6 +137,10 @@ export const spec = { payload.tags = createAdPodRequest(tags, adPodBid); } + if (config.getConfig('adpod.brandCategoryExclusion')) { + payload.brand_cat_uniqueness = true; + } + if (debugObjParams.enabled) { payload.debug = debugObjParams; utils.logInfo('AppNexus Debug Auction Settings:\n\n' + JSON.stringify(debugObjParams, null, 4)); diff --git a/test/spec/modules/appnexusBidAdapter_spec.js b/test/spec/modules/appnexusBidAdapter_spec.js index 472ab60c99d..e96e9be71b8 100644 --- a/test/spec/modules/appnexusBidAdapter_spec.js +++ b/test/spec/modules/appnexusBidAdapter_spec.js @@ -2,6 +2,7 @@ import { expect } from 'chai'; import { spec } from 'modules/appnexusBidAdapter'; import { newBidder } from 'src/adapters/bidderFactory'; import { deepClone } from 'src/utils'; +import { config } from 'src/config'; const ENDPOINT = '//ib.adnxs.com/ut/v3/prebid'; @@ -228,6 +229,21 @@ describe('AppNexusAdapter', function () { expect(tagsWith30.length).to.equal(10); }); + it('adds brand_category_exclusion to request when set', function() { + let bidRequest = Object.assign({}, bidRequests[0]); + sinon + .stub(config, 'getConfig') + .withArgs('adpod.brandCategoryExclusion') + .returns(true); + + const request = spec.buildRequests([bidRequest]); + const payload = JSON.parse(request.data); + + expect(payload.brand_cat_uniqueness).to.equal(true); + + config.getConfig.restore(); + }); + it('should attach native params to the request', function () { let bidRequest = Object.assign({}, bidRequests[0], From 305c4dda4e3215d6a5f31d6158c1e4cc6b00da40 Mon Sep 17 00:00:00 2001 From: Matt Lane Date: Fri, 25 Jan 2019 16:16:35 -0800 Subject: [PATCH 07/24] Add adpod fields to bid response object --- modules/appnexusBidAdapter.js | 16 +++++++++ test/spec/modules/appnexusBidAdapter_spec.js | 37 ++++++++++++++++++++ 2 files changed, 53 insertions(+) diff --git a/modules/appnexusBidAdapter.js b/modules/appnexusBidAdapter.js index 7824dac80f9..d224700b09a 100644 --- a/modules/appnexusBidAdapter.js +++ b/modules/appnexusBidAdapter.js @@ -327,6 +327,22 @@ function newBid(serverBid, rtbBid, bidderRequest) { vastImpUrl: rtbBid.notify_url, ttl: 3600 }); + + const videoContext = utils.deepAccess( + bidderRequest.bids[0], + 'mediaTypes.video.context' + ); + if (videoContext === 'adpod') { + bid.meta = { + primaryCatId: rtbBid.brand_category_id + }; + + bid.video = { + context: 'adpod', + durationSeconds: rtbBid.rtb.video.duration_ms / 1000, + }; + } + // This supports Outstream Video if (rtbBid.renderer_url) { const rendererOptions = utils.deepAccess( diff --git a/test/spec/modules/appnexusBidAdapter_spec.js b/test/spec/modules/appnexusBidAdapter_spec.js index e96e9be71b8..095e13cfc54 100644 --- a/test/spec/modules/appnexusBidAdapter_spec.js +++ b/test/spec/modules/appnexusBidAdapter_spec.js @@ -617,6 +617,43 @@ describe('AppNexusAdapter', function () { expect(result[0]).to.have.property('mediaType', 'video'); }); + it('handles adpod responses', function () { + let response = { + 'tags': [{ + 'uuid': '84ab500420319d', + 'ads': [{ + 'ad_type': 'video', + 'brand_category_id': 10, + 'cpm': 0.500000, + 'notify_url': 'imptracker.com', + 'rtb': { + 'video': { + 'content': '', + 'duration_ms': 30000, + } + } + }] + }] + }; + + let bidderRequest = { + bids: [{ + bidId: '84ab500420319d', + adUnitCode: 'code', + mediaTypes: { + video: { + context: 'adpod' + } + } + }] + }; + + let result = spec.interpretResponse({ body: response }, {bidderRequest}); + expect(result[0].meta.primaryCatId).to.equal(10); + expect(result[0].video.context).to.equal('adpod'); + expect(result[0].video.durationSeconds).to.equal(30); + }); + it('handles native responses', function () { let response1 = deepClone(response); response1.tags[0].ads[0].ad_type = 'native'; From 7136d47b64f7f3ac5a4555eddf20a6c59901511f Mon Sep 17 00:00:00 2001 From: Matt Lane Date: Tue, 29 Jan 2019 14:56:51 -0800 Subject: [PATCH 08/24] Split large requests into batches --- modules/appnexusBidAdapter.js | 55 ++++++++++++---- src/utils.js | 20 ++++++ test/spec/modules/appnexusBidAdapter_spec.js | 68 ++++++++++++++++---- 3 files changed, 119 insertions(+), 24 deletions(-) diff --git a/modules/appnexusBidAdapter.js b/modules/appnexusBidAdapter.js index d224700b09a..0e2e4bb310c 100644 --- a/modules/appnexusBidAdapter.js +++ b/modules/appnexusBidAdapter.js @@ -33,6 +33,7 @@ const NATIVE_MAPPING = { displayUrl: 'displayurl' }; const SOURCE = 'pbjs'; +const MAX_IMPS_PER_REQUEST = 15; export const spec = { code: BIDDER_CODE, @@ -132,11 +133,6 @@ export const spec = { payload.app = appIdObj; } - const adPodBid = find(bidRequests, hasAdPod); - if (adPodBid) { - payload.tags = createAdPodRequest(tags, adPodBid); - } - if (config.getConfig('adpod.brandCategoryExclusion')) { payload.brand_cat_uniqueness = true; } @@ -164,13 +160,15 @@ export const spec = { payload.referrer_detection = refererinfo; } - const payloadString = JSON.stringify(payload); - return { - method: 'POST', - url: URL, - data: payloadString, - bidderRequest - }; + const adPodBid = find(bidRequests, hasAdPod); + if (adPodBid) { + const adPodTags = createAdPodRequest(tags, adPodBid); + const nonAdPodTags = payload.tags.filter(tag => tag.uuid !== adPodBid.bidId); + payload.tags = [...nonAdPodTags, ...adPodTags]; + } + + const request = formatRequest(payload, bidderRequest); + return request; }, /** @@ -268,6 +266,35 @@ function deleteValues(keyPairObj) { } } +function formatRequest(payload, bidderRequest) { + let request = []; + + if (payload.tags.length > MAX_IMPS_PER_REQUEST) { + const clonedPayload = utils.deepClone(payload); + + utils.chunk(payload.tags, MAX_IMPS_PER_REQUEST).forEach(tags => { + clonedPayload.tags = tags; + const payloadString = JSON.stringify(clonedPayload); + request.push({ + method: 'POST', + url: URL, + data: payloadString, + bidderRequest + }); + }); + } else { + const payloadString = JSON.stringify(payload); + request = { + method: 'POST', + url: URL, + data: payloadString, + bidderRequest + }; + } + + return request; +} + function newRenderer(adUnitCode, rtbBid, rendererOptions = {}) { const renderer = Renderer.install({ id: rtbBid.renderer_id, @@ -328,6 +355,7 @@ function newBid(serverBid, rtbBid, bidderRequest) { ttl: 3600 }); + // TODO: check bidRequest variable instead of [0] const videoContext = utils.deepAccess( bidderRequest.bids[0], 'mediaTypes.video.context' @@ -559,7 +587,8 @@ function createAdPodRequest(tags, adPodBid) { const numberOfPlacements = getAdPodPlacementNumber(adPodBid.mediaTypes.video); const maxDuration = utils.getMaxValueFromArray(durationRange); - let request = utils.fill(...tags, numberOfPlacements); + const tagToDuplicate = tags.filter(tag => tag.uuid === adPodBid.bidId); + let request = utils.fill(...tagToDuplicate, numberOfPlacements); if (requireExactDuration) { const divider = numberOfPlacements / durationRange.length; diff --git a/src/utils.js b/src/utils.js index c2e5f99b12c..b749b43dfd3 100644 --- a/src/utils.js +++ b/src/utils.js @@ -1205,6 +1205,26 @@ export function fill(value, length) { return newArray; } +/** + * http://npm.im/chunk + * Returns an array with *size* chunks from given array + * + * Example: + * ['a', 'b', 'c', 'd', 'e'] chunked by 2 => + * [['a', 'b'], ['c', 'd'], ['e']] + */ +export function chunk(array, size) { + let newArray = []; + + for (let i = 0; i < Math.ceil(array.length / size); i++) { + let start = i * size; + let end = start + size; + newArray.push(array.slice(start, end)); + } + + return newArray; +} + export function getMinValueFromArray(array) { return Math.min(...array); } diff --git a/test/spec/modules/appnexusBidAdapter_spec.js b/test/spec/modules/appnexusBidAdapter_spec.js index 095e13cfc54..55864aa45f0 100644 --- a/test/spec/modules/appnexusBidAdapter_spec.js +++ b/test/spec/modules/appnexusBidAdapter_spec.js @@ -172,7 +172,7 @@ describe('AppNexusAdapter', function () { }); }); - it('should duplicate adpod placements and set correct maxduration', function() { + it('should duplicate adpod placements into batches and set correct maxduration', function() { let bidRequest = Object.assign({}, bidRequests[0], { @@ -191,11 +191,18 @@ describe('AppNexusAdapter', function () { ); const request = spec.buildRequests([bidRequest]); - const payload = JSON.parse(request.data); + const payload1 = JSON.parse(request[0].data); + const payload2 = JSON.parse(request[1].data); + + // 300 / 15 = 20 total + expect(payload1.tags.length).to.equal(15); + expect(payload2.tags.length).to.equal(5); + + expect(payload1.tags[0]).to.deep.equal(payload1.tags[1]); + expect(payload1.tags[0].video.maxduration).to.equal(30); - expect(payload.tags.length).to.equal(20); - expect(payload.tags[0]).to.deep.equal(payload.tags[1]); - expect(payload.tags[0].video.maxduration).to.equal(30); + expect(payload2.tags[0]).to.deep.equal(payload1.tags[1]); + expect(payload2.tags[0].video.maxduration).to.equal(30); }); it('should duplicate adpod placements when requireExactDuration is set', function() { @@ -217,16 +224,55 @@ describe('AppNexusAdapter', function () { } ); + // 20 total placements with 15 max impressions = 2 requests const request = spec.buildRequests([bidRequest]); - const payload = JSON.parse(request.data); + expect(request.length).to.equal(2); + + // 20 spread over 2 requests = 15 in first request, 5 in second + const payload1 = JSON.parse(request[0].data); + const payload2 = JSON.parse(request[1].data); + expect(payload1.tags.length).to.equal(15); + expect(payload2.tags.length).to.equal(5); + + // 10 placements should have max/min at 15 + // 10 placemenst should have max/min at 30 + const payload1tagsWith15 = payload1.tags.filter(tag => tag.video.maxduration === 15); + const payload1tagsWith30 = payload1.tags.filter(tag => tag.video.maxduration === 30); + expect(payload1tagsWith15.length).to.equal(10); + expect(payload1tagsWith30.length).to.equal(5); + + // 5 placemenst with min/max at 30 were in the first request + // so 5 remaining should be in the second + const payload2tagsWith30 = payload2.tags.filter(tag => tag.video.maxduration === 30); + expect(payload2tagsWith30.length).to.equal(5); + }); - expect(payload.tags.length).to.equal(20); + it('should break adpod request into batches', function() { + let bidRequest = Object.assign({}, + bidRequests[0], + { + params: { placementId: '14542875' } + }, + { + mediaTypes: { + video: { + context: 'adpod', + playerSize: [640, 480], + adPodDuration: 225, + durationRange: [5], + } + } + } + ); - const tagsWith15 = payload.tags.filter(tag => tag.video.maxduration === 15); - const tagsWith30 = payload.tags.filter(tag => tag.video.maxduration === 30); + const request = spec.buildRequests([bidRequest]); + const payload1 = JSON.parse(request[0].data); + const payload2 = JSON.parse(request[1].data); + const payload3 = JSON.parse(request[2].data); - expect(tagsWith15.length).to.equal(10); - expect(tagsWith30.length).to.equal(10); + expect(payload1.tags.length).to.equal(15); + expect(payload2.tags.length).to.equal(15); + expect(payload3.tags.length).to.equal(15); }); it('adds brand_category_exclusion to request when set', function() { From ffb89bea863c29c128d05a9c96e6c7c47090efce Mon Sep 17 00:00:00 2001 From: Matt Lane Date: Wed, 30 Jan 2019 15:58:12 -0800 Subject: [PATCH 09/24] Get context from correct object --- modules/appnexusBidAdapter.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/modules/appnexusBidAdapter.js b/modules/appnexusBidAdapter.js index 0e2e4bb310c..9cbb2aaf8a4 100644 --- a/modules/appnexusBidAdapter.js +++ b/modules/appnexusBidAdapter.js @@ -355,11 +355,7 @@ function newBid(serverBid, rtbBid, bidderRequest) { ttl: 3600 }); - // TODO: check bidRequest variable instead of [0] - const videoContext = utils.deepAccess( - bidderRequest.bids[0], - 'mediaTypes.video.context' - ); + const videoContext = utils.deepAccess(bidRequest, 'mediaTypes.video.context'); if (videoContext === 'adpod') { bid.meta = { primaryCatId: rtbBid.brand_category_id From e8dfb44d7a43ec32a0f6a365553bf454d920ffbc Mon Sep 17 00:00:00 2001 From: Matt Lane Date: Thu, 31 Jan 2019 11:20:01 -0800 Subject: [PATCH 10/24] Use util function to get request subsets --- modules/appnexusBidAdapter.js | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/modules/appnexusBidAdapter.js b/modules/appnexusBidAdapter.js index 9cbb2aaf8a4..114d0bd2167 100644 --- a/modules/appnexusBidAdapter.js +++ b/modules/appnexusBidAdapter.js @@ -578,8 +578,14 @@ function hasAdPod(bid) { ); } +/** + * Expand an adpod placement into a set of request objects according to the + * total adpod duration and the range of duration seconds. Sets minduration/ + * maxduration video property according to requireExactDuration configuration + */ function createAdPodRequest(tags, adPodBid) { const { durationRange, requireExactDuration } = adPodBid.mediaTypes.video; + const numberOfPlacements = getAdPodPlacementNumber(adPodBid.mediaTypes.video); const maxDuration = utils.getMaxValueFromArray(durationRange); @@ -588,16 +594,17 @@ function createAdPodRequest(tags, adPodBid) { if (requireExactDuration) { const divider = numberOfPlacements / durationRange.length; + const chunked = utils.chunk(request, divider); - for (let i = 1; i <= durationRange.length; i++) { - const end = i * divider; - - request.slice(end - divider, end).map(tag => { - setVideoProperty(tag, 'minduration', durationRange[i - 1]); - setVideoProperty(tag, 'maxduration', durationRange[i - 1]); + // each configured duration is set as min/maxduration for a subset of requests + durationRange.forEach((duration, index) => { + chunked[index].map(tag => { + setVideoProperty(tag, 'minduration', duration); + setVideoProperty(tag, 'maxduration', duration); }); - } + }); } else { + // all maxdurations should be the same request.map(tag => setVideoProperty(tag, 'maxduration', maxDuration)); } From bd1eb8b6bdd5f4fe198aa971a35336a0800dc476 Mon Sep 17 00:00:00 2001 From: Matt Lane Date: Mon, 4 Feb 2019 14:54:21 -0800 Subject: [PATCH 11/24] Use correct mediaType.video configuration names --- modules/appnexusBidAdapter.js | 16 ++++++++-------- test/spec/modules/appnexusBidAdapter_spec.js | 12 ++++++------ 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/modules/appnexusBidAdapter.js b/modules/appnexusBidAdapter.js index 114d0bd2167..9ec85f0c780 100644 --- a/modules/appnexusBidAdapter.js +++ b/modules/appnexusBidAdapter.js @@ -584,20 +584,20 @@ function hasAdPod(bid) { * maxduration video property according to requireExactDuration configuration */ function createAdPodRequest(tags, adPodBid) { - const { durationRange, requireExactDuration } = adPodBid.mediaTypes.video; + const { durationRangeSec, requireExactDuration } = adPodBid.mediaTypes.video; const numberOfPlacements = getAdPodPlacementNumber(adPodBid.mediaTypes.video); - const maxDuration = utils.getMaxValueFromArray(durationRange); + const maxDuration = utils.getMaxValueFromArray(durationRangeSec); const tagToDuplicate = tags.filter(tag => tag.uuid === adPodBid.bidId); let request = utils.fill(...tagToDuplicate, numberOfPlacements); if (requireExactDuration) { - const divider = numberOfPlacements / durationRange.length; + const divider = numberOfPlacements / durationRangeSec.length; const chunked = utils.chunk(request, divider); // each configured duration is set as min/maxduration for a subset of requests - durationRange.forEach((duration, index) => { + durationRangeSec.forEach((duration, index) => { chunked[index].map(tag => { setVideoProperty(tag, 'minduration', duration); setVideoProperty(tag, 'maxduration', duration); @@ -612,12 +612,12 @@ function createAdPodRequest(tags, adPodBid) { } function getAdPodPlacementNumber(videoParams, requireExactDuration) { - const { adPodDuration, durationRange } = videoParams; - const minAllowedDuration = utils.getMinValueFromArray(durationRange); - const numberOfPlacements = adPodDuration / minAllowedDuration; + const { adPodDurationSec, durationRangeSec } = videoParams; + const minAllowedDuration = utils.getMinValueFromArray(durationRangeSec); + const numberOfPlacements = adPodDurationSec / minAllowedDuration; return requireExactDuration - ? Math.max(numberOfPlacements, adPodDuration.length) + ? Math.max(numberOfPlacements, durationRangeSec.length) : numberOfPlacements; } diff --git a/test/spec/modules/appnexusBidAdapter_spec.js b/test/spec/modules/appnexusBidAdapter_spec.js index 55864aa45f0..0417499c78c 100644 --- a/test/spec/modules/appnexusBidAdapter_spec.js +++ b/test/spec/modules/appnexusBidAdapter_spec.js @@ -183,8 +183,8 @@ describe('AppNexusAdapter', function () { video: { context: 'adpod', playerSize: [640, 480], - adPodDuration: 300, - durationRange: [15, 30], + adPodDurationSec: 300, + durationRangeSec: [15, 30], } } } @@ -216,8 +216,8 @@ describe('AppNexusAdapter', function () { video: { context: 'adpod', playerSize: [640, 480], - adPodDuration: 300, - durationRange: [15, 30], + adPodDurationSec: 300, + durationRangeSec: [15, 30], requireExactDuration: true, } } @@ -258,8 +258,8 @@ describe('AppNexusAdapter', function () { video: { context: 'adpod', playerSize: [640, 480], - adPodDuration: 225, - durationRange: [5], + adPodDurationSec: 225, + durationRangeSec: [5], } } } From 04005672b30cd1d99e4e403cbaf9fa264c8fde67 Mon Sep 17 00:00:00 2001 From: Matt Lane Date: Mon, 4 Feb 2019 14:58:02 -0800 Subject: [PATCH 12/24] Rename category prop to iabSubCatId --- modules/appnexusBidAdapter.js | 2 +- test/spec/modules/appnexusBidAdapter_spec.js | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/modules/appnexusBidAdapter.js b/modules/appnexusBidAdapter.js index 9ec85f0c780..bc4febd325b 100644 --- a/modules/appnexusBidAdapter.js +++ b/modules/appnexusBidAdapter.js @@ -358,7 +358,7 @@ function newBid(serverBid, rtbBid, bidderRequest) { const videoContext = utils.deepAccess(bidRequest, 'mediaTypes.video.context'); if (videoContext === 'adpod') { bid.meta = { - primaryCatId: rtbBid.brand_category_id + iabSubCatId: null // translate rtbBid.brand_category_id to iab when translation module ready }; bid.video = { diff --git a/test/spec/modules/appnexusBidAdapter_spec.js b/test/spec/modules/appnexusBidAdapter_spec.js index 0417499c78c..54a5d878797 100644 --- a/test/spec/modules/appnexusBidAdapter_spec.js +++ b/test/spec/modules/appnexusBidAdapter_spec.js @@ -695,7 +695,6 @@ describe('AppNexusAdapter', function () { }; let result = spec.interpretResponse({ body: response }, {bidderRequest}); - expect(result[0].meta.primaryCatId).to.equal(10); expect(result[0].video.context).to.equal('adpod'); expect(result[0].video.durationSeconds).to.equal(30); }); From 07c58d5be935c8918af757c00df8015276aa6947 Mon Sep 17 00:00:00 2001 From: Matt Lane Date: Tue, 5 Feb 2019 15:52:29 -0800 Subject: [PATCH 13/24] Comment sub function usage --- modules/appnexusBidAdapter.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/appnexusBidAdapter.js b/modules/appnexusBidAdapter.js index bc4febd325b..6c4b941017c 100644 --- a/modules/appnexusBidAdapter.js +++ b/modules/appnexusBidAdapter.js @@ -358,7 +358,7 @@ function newBid(serverBid, rtbBid, bidderRequest) { const videoContext = utils.deepAccess(bidRequest, 'mediaTypes.video.context'); if (videoContext === 'adpod') { bid.meta = { - iabSubCatId: null // translate rtbBid.brand_category_id to iab when translation module ready + iabSubCatId: null // utils.getIabSubCategory('key', rtbBid.brand_category_id) after translation module/mapping file merged }; bid.video = { From 4c21d197e7aee78b1a4017c4e7f88a0180b78fc6 Mon Sep 17 00:00:00 2001 From: Matt Lane Date: Wed, 6 Feb 2019 10:34:15 -0800 Subject: [PATCH 14/24] Round down placements when config uneven --- modules/appnexusBidAdapter.js | 2 +- test/spec/modules/appnexusBidAdapter_spec.js | 23 ++++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/modules/appnexusBidAdapter.js b/modules/appnexusBidAdapter.js index 6c4b941017c..3a4f10b979d 100644 --- a/modules/appnexusBidAdapter.js +++ b/modules/appnexusBidAdapter.js @@ -614,7 +614,7 @@ function createAdPodRequest(tags, adPodBid) { function getAdPodPlacementNumber(videoParams, requireExactDuration) { const { adPodDurationSec, durationRangeSec } = videoParams; const minAllowedDuration = utils.getMinValueFromArray(durationRangeSec); - const numberOfPlacements = adPodDurationSec / minAllowedDuration; + const numberOfPlacements = Math.floor(adPodDurationSec / minAllowedDuration); return requireExactDuration ? Math.max(numberOfPlacements, durationRangeSec.length) diff --git a/test/spec/modules/appnexusBidAdapter_spec.js b/test/spec/modules/appnexusBidAdapter_spec.js index 54a5d878797..577fcc4ba35 100644 --- a/test/spec/modules/appnexusBidAdapter_spec.js +++ b/test/spec/modules/appnexusBidAdapter_spec.js @@ -205,6 +205,29 @@ describe('AppNexusAdapter', function () { expect(payload2.tags[0].video.maxduration).to.equal(30); }); + it('should round down adpod placements when numbers are uneven', function() { + let bidRequest = Object.assign({}, + bidRequests[0], + { + params: { placementId: '14542875' } + }, + { + mediaTypes: { + video: { + context: 'adpod', + playerSize: [640, 480], + adPodDurationSec: 123, + durationRangeSec: [45], + } + } + } + ); + + const request = spec.buildRequests([bidRequest]); + const payload = JSON.parse(request.data); + expect(payload.tags.length).to.equal(2); + }); + it('should duplicate adpod placements when requireExactDuration is set', function() { let bidRequest = Object.assign({}, bidRequests[0], From c8ac854f498f1deb077cf8d36f65902b11be79cc Mon Sep 17 00:00:00 2001 From: Matt Lane Date: Wed, 6 Feb 2019 11:40:36 -0800 Subject: [PATCH 15/24] Set max/min duration across tags when config numbers are uneven --- modules/appnexusBidAdapter.js | 6 ++-- test/spec/modules/appnexusBidAdapter_spec.js | 31 ++++++++++++++++++++ 2 files changed, 34 insertions(+), 3 deletions(-) diff --git a/modules/appnexusBidAdapter.js b/modules/appnexusBidAdapter.js index 3a4f10b979d..da24d88ba8f 100644 --- a/modules/appnexusBidAdapter.js +++ b/modules/appnexusBidAdapter.js @@ -593,7 +593,7 @@ function createAdPodRequest(tags, adPodBid) { let request = utils.fill(...tagToDuplicate, numberOfPlacements); if (requireExactDuration) { - const divider = numberOfPlacements / durationRangeSec.length; + const divider = Math.ceil(numberOfPlacements / durationRangeSec.length); const chunked = utils.chunk(request, divider); // each configured duration is set as min/maxduration for a subset of requests @@ -611,8 +611,8 @@ function createAdPodRequest(tags, adPodBid) { return request; } -function getAdPodPlacementNumber(videoParams, requireExactDuration) { - const { adPodDurationSec, durationRangeSec } = videoParams; +function getAdPodPlacementNumber(videoParams) { + const { adPodDurationSec, durationRangeSec, requireExactDuration } = videoParams; const minAllowedDuration = utils.getMinValueFromArray(durationRangeSec); const numberOfPlacements = Math.floor(adPodDurationSec / minAllowedDuration); diff --git a/test/spec/modules/appnexusBidAdapter_spec.js b/test/spec/modules/appnexusBidAdapter_spec.js index 577fcc4ba35..c1f25526673 100644 --- a/test/spec/modules/appnexusBidAdapter_spec.js +++ b/test/spec/modules/appnexusBidAdapter_spec.js @@ -270,6 +270,37 @@ describe('AppNexusAdapter', function () { expect(payload2tagsWith30.length).to.equal(5); }); + it('should set durations for placements when requireExactDuration is set and numbers are uneven', function() { + let bidRequest = Object.assign({}, + bidRequests[0], + { + params: { placementId: '14542875' } + }, + { + mediaTypes: { + video: { + context: 'adpod', + playerSize: [640, 480], + adPodDurationSec: 105, + durationRangeSec: [15, 30, 60], + requireExactDuration: true, + } + } + } + ); + + const request = spec.buildRequests([bidRequest]); + const payload = JSON.parse(request.data); + expect(payload.tags.length).to.equal(7); + + const tagsWith15 = payload.tags.filter(tag => tag.video.maxduration === 15); + const tagsWith30 = payload.tags.filter(tag => tag.video.maxduration === 30); + const tagsWith60 = payload.tags.filter(tag => tag.video.maxduration === 60); + expect(tagsWith15.length).to.equal(3); + expect(tagsWith30.length).to.equal(3); + expect(tagsWith60.length).to.equal(1); + }); + it('should break adpod request into batches', function() { let bidRequest = Object.assign({}, bidRequests[0], From 03aa09f6f78a42a881ebef708befefc13d0d5d07 Mon Sep 17 00:00:00 2001 From: Matt Lane Date: Wed, 6 Feb 2019 14:14:26 -0800 Subject: [PATCH 16/24] Account for multiple adpod adUnits --- modules/appnexusBidAdapter.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/modules/appnexusBidAdapter.js b/modules/appnexusBidAdapter.js index da24d88ba8f..7ab1d2d4827 100644 --- a/modules/appnexusBidAdapter.js +++ b/modules/appnexusBidAdapter.js @@ -160,11 +160,14 @@ export const spec = { payload.referrer_detection = refererinfo; } - const adPodBid = find(bidRequests, hasAdPod); - if (adPodBid) { - const adPodTags = createAdPodRequest(tags, adPodBid); - const nonAdPodTags = payload.tags.filter(tag => tag.uuid !== adPodBid.bidId); - payload.tags = [...nonAdPodTags, ...adPodTags]; + const hasAdPodBid = find(bidRequests, hasAdPod); + if (hasAdPodBid) { + bidRequests.filter(hasAdPod).forEach(adPodBid => { + const adPodTags = createAdPodRequest(tags, adPodBid); + // don't need the original adpod placement because it's in adPodTags + const nonPodTags = payload.tags.filter(tag => tag.uuid !== adPodBid.bidId); + payload.tags = [...nonPodTags, ...adPodTags]; + }); } const request = formatRequest(payload, bidderRequest); From 5e5c511197369ba5e0b3e9cd294308193d1fef70 Mon Sep 17 00:00:00 2001 From: Matt Lane Date: Wed, 6 Feb 2019 14:16:11 -0800 Subject: [PATCH 17/24] Round durationSeconds up if remainder --- modules/appnexusBidAdapter.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/appnexusBidAdapter.js b/modules/appnexusBidAdapter.js index 7ab1d2d4827..8bf3e427cb5 100644 --- a/modules/appnexusBidAdapter.js +++ b/modules/appnexusBidAdapter.js @@ -366,7 +366,7 @@ function newBid(serverBid, rtbBid, bidderRequest) { bid.video = { context: 'adpod', - durationSeconds: rtbBid.rtb.video.duration_ms / 1000, + durationSeconds: Math.ceil(rtbBid.rtb.video.duration_ms / 1000), }; } From 71071c08fb892f95ad6e0cde55a7939032dfeb95 Mon Sep 17 00:00:00 2001 From: Matt Lane Date: Wed, 6 Feb 2019 14:18:30 -0800 Subject: [PATCH 18/24] Use adpod constant --- modules/appnexusBidAdapter.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/appnexusBidAdapter.js b/modules/appnexusBidAdapter.js index 8bf3e427cb5..9dac3209da3 100644 --- a/modules/appnexusBidAdapter.js +++ b/modules/appnexusBidAdapter.js @@ -2,7 +2,7 @@ import { Renderer } from '../src/Renderer'; import * as utils from '../src/utils'; import { config } from '../src/config'; import { registerBidder } from '../src/adapters/bidderFactory'; -import { BANNER, NATIVE, VIDEO } from '../src/mediaTypes'; +import { BANNER, NATIVE, VIDEO, ADPOD } from '../src/mediaTypes'; import find from 'core-js/library/fn/array/find'; import includes from 'core-js/library/fn/array/includes'; @@ -359,13 +359,13 @@ function newBid(serverBid, rtbBid, bidderRequest) { }); const videoContext = utils.deepAccess(bidRequest, 'mediaTypes.video.context'); - if (videoContext === 'adpod') { + if (videoContext === ADPOD) { bid.meta = { iabSubCatId: null // utils.getIabSubCategory('key', rtbBid.brand_category_id) after translation module/mapping file merged }; bid.video = { - context: 'adpod', + context: ADPOD, durationSeconds: Math.ceil(rtbBid.rtb.video.duration_ms / 1000), }; } @@ -577,7 +577,7 @@ function hasAdPod(bid) { return ( bid.mediaTypes && bid.mediaTypes.video && - bid.mediaTypes.video.context === 'adpod' + bid.mediaTypes.video.context === ADPOD ); } From dbc475c4253050db9aa4d15dcdc3f6ee6ca972cd Mon Sep 17 00:00:00 2001 From: Matt Lane Date: Wed, 6 Feb 2019 14:33:16 -0800 Subject: [PATCH 19/24] Update subCat usage comment --- modules/appnexusBidAdapter.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/modules/appnexusBidAdapter.js b/modules/appnexusBidAdapter.js index 9dac3209da3..d546daaaa78 100644 --- a/modules/appnexusBidAdapter.js +++ b/modules/appnexusBidAdapter.js @@ -361,7 +361,10 @@ function newBid(serverBid, rtbBid, bidderRequest) { const videoContext = utils.deepAccess(bidRequest, 'mediaTypes.video.context'); if (videoContext === ADPOD) { bid.meta = { - iabSubCatId: null // utils.getIabSubCategory('key', rtbBid.brand_category_id) after translation module/mapping file merged + // after translation module/mapping file merged, set iabSubCatId + // let key = `${spec.code}_${mappingFileInfo.uniqueKey}` + // utils.getIabSubCategory(key, rtbBid.brand_category_id) + iabSubCatId: null }; bid.video = { From be536fb94e6c7fcefe354d7ae785cd38b95727ad Mon Sep 17 00:00:00 2001 From: Matt Lane Date: Mon, 11 Feb 2019 11:14:30 -0800 Subject: [PATCH 20/24] Update subCat usage comment --- modules/appnexusBidAdapter.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/modules/appnexusBidAdapter.js b/modules/appnexusBidAdapter.js index d546daaaa78..13fddd16d4f 100644 --- a/modules/appnexusBidAdapter.js +++ b/modules/appnexusBidAdapter.js @@ -360,11 +360,10 @@ function newBid(serverBid, rtbBid, bidderRequest) { const videoContext = utils.deepAccess(bidRequest, 'mediaTypes.video.context'); if (videoContext === ADPOD) { + // TODO: uncomment and add to bid.meta after util function merged + // const iabSubCatId = getIabSubCategory(bidRequest.bidder, rtbBid.brand_category_id); bid.meta = { - // after translation module/mapping file merged, set iabSubCatId - // let key = `${spec.code}_${mappingFileInfo.uniqueKey}` - // utils.getIabSubCategory(key, rtbBid.brand_category_id) - iabSubCatId: null + iabSubCatId: null, }; bid.video = { From 635b02bb41858659e72f61177e425245552c112d Mon Sep 17 00:00:00 2001 From: Matt Lane Date: Mon, 11 Feb 2019 11:16:18 -0800 Subject: [PATCH 21/24] Change ceil to floor --- modules/appnexusBidAdapter.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/appnexusBidAdapter.js b/modules/appnexusBidAdapter.js index 13fddd16d4f..3d740bf2d3b 100644 --- a/modules/appnexusBidAdapter.js +++ b/modules/appnexusBidAdapter.js @@ -368,7 +368,7 @@ function newBid(serverBid, rtbBid, bidderRequest) { bid.video = { context: ADPOD, - durationSeconds: Math.ceil(rtbBid.rtb.video.duration_ms / 1000), + durationSeconds: Math.floor(rtbBid.rtb.video.duration_ms / 1000), }; } From 905bf8acccfd1c055dde2f582ea6a4700a39b217 Mon Sep 17 00:00:00 2001 From: Jaimin Panchal Date: Tue, 12 Feb 2019 22:57:57 -0500 Subject: [PATCH 22/24] fix unit test --- test/spec/modules/appnexusBidAdapter_spec.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/test/spec/modules/appnexusBidAdapter_spec.js b/test/spec/modules/appnexusBidAdapter_spec.js index c1f25526673..749243be98f 100644 --- a/test/spec/modules/appnexusBidAdapter_spec.js +++ b/test/spec/modules/appnexusBidAdapter_spec.js @@ -1,6 +1,8 @@ import { expect } from 'chai'; import { spec } from 'modules/appnexusBidAdapter'; import { newBidder } from 'src/adapters/bidderFactory'; +// TODO remove comment on merge +// import * as bidderFactory from 'src/adapters/bidderFactory'; import { deepClone } from 'src/utils'; import { config } from 'src/config'; @@ -598,6 +600,16 @@ describe('AppNexusAdapter', function () { }) describe('interpretResponse', function () { + // TODO remove comments on merge + // let bfStub; + // before(function() { + // bfStub = sinon.stub(bidderFactory, 'getIabSubCategory'); + // }); + + // after(function() { + // bfStub.restore(); + // }); + let response = { 'version': '3.0.0', 'tags': [ @@ -747,6 +759,8 @@ describe('AppNexusAdapter', function () { } }] }; + // TODO remove on merge + // bfStub.returns('1'); let result = spec.interpretResponse({ body: response }, {bidderRequest}); expect(result[0].video.context).to.equal('adpod'); From 17a517636d22bd2914d5d7cf16c3822cc3fb7c0d Mon Sep 17 00:00:00 2001 From: Jaimin Panchal Date: Tue, 19 Feb 2019 15:28:19 -0500 Subject: [PATCH 23/24] correct flag name --- modules/appnexusBidAdapter.js | 2 +- test/spec/modules/appnexusBidAdapter_spec.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/appnexusBidAdapter.js b/modules/appnexusBidAdapter.js index 3d740bf2d3b..9ba310edbe0 100644 --- a/modules/appnexusBidAdapter.js +++ b/modules/appnexusBidAdapter.js @@ -134,7 +134,7 @@ export const spec = { } if (config.getConfig('adpod.brandCategoryExclusion')) { - payload.brand_cat_uniqueness = true; + payload.brand_category_uniqueness = true; } if (debugObjParams.enabled) { diff --git a/test/spec/modules/appnexusBidAdapter_spec.js b/test/spec/modules/appnexusBidAdapter_spec.js index 749243be98f..9a9f1d01b61 100644 --- a/test/spec/modules/appnexusBidAdapter_spec.js +++ b/test/spec/modules/appnexusBidAdapter_spec.js @@ -341,7 +341,7 @@ describe('AppNexusAdapter', function () { const request = spec.buildRequests([bidRequest]); const payload = JSON.parse(request.data); - expect(payload.brand_cat_uniqueness).to.equal(true); + expect(payload.brand_category_uniqueness).to.equal(true); config.getConfig.restore(); }); From 0635c0f84f87433f2f71119d94bb5724132b81e6 Mon Sep 17 00:00:00 2001 From: Jaimin Panchal Date: Tue, 26 Feb 2019 15:27:55 -0500 Subject: [PATCH 24/24] uncomment todos --- modules/appnexusBidAdapter.js | 7 +++---- test/spec/modules/appnexusBidAdapter_spec.js | 21 +++++++++----------- 2 files changed, 12 insertions(+), 16 deletions(-) diff --git a/modules/appnexusBidAdapter.js b/modules/appnexusBidAdapter.js index 9ba310edbe0..e56e7b23964 100644 --- a/modules/appnexusBidAdapter.js +++ b/modules/appnexusBidAdapter.js @@ -1,7 +1,7 @@ import { Renderer } from '../src/Renderer'; import * as utils from '../src/utils'; import { config } from '../src/config'; -import { registerBidder } from '../src/adapters/bidderFactory'; +import { registerBidder, getIabSubCategory } from '../src/adapters/bidderFactory'; import { BANNER, NATIVE, VIDEO, ADPOD } from '../src/mediaTypes'; import find from 'core-js/library/fn/array/find'; import includes from 'core-js/library/fn/array/includes'; @@ -360,10 +360,9 @@ function newBid(serverBid, rtbBid, bidderRequest) { const videoContext = utils.deepAccess(bidRequest, 'mediaTypes.video.context'); if (videoContext === ADPOD) { - // TODO: uncomment and add to bid.meta after util function merged - // const iabSubCatId = getIabSubCategory(bidRequest.bidder, rtbBid.brand_category_id); + const iabSubCatId = getIabSubCategory(bidRequest.bidder, rtbBid.brand_category_id); bid.meta = { - iabSubCatId: null, + iabSubCatId }; bid.video = { diff --git a/test/spec/modules/appnexusBidAdapter_spec.js b/test/spec/modules/appnexusBidAdapter_spec.js index 9a9f1d01b61..d2094217c70 100644 --- a/test/spec/modules/appnexusBidAdapter_spec.js +++ b/test/spec/modules/appnexusBidAdapter_spec.js @@ -1,8 +1,7 @@ import { expect } from 'chai'; import { spec } from 'modules/appnexusBidAdapter'; import { newBidder } from 'src/adapters/bidderFactory'; -// TODO remove comment on merge -// import * as bidderFactory from 'src/adapters/bidderFactory'; +import * as bidderFactory from 'src/adapters/bidderFactory'; import { deepClone } from 'src/utils'; import { config } from 'src/config'; @@ -600,15 +599,14 @@ describe('AppNexusAdapter', function () { }) describe('interpretResponse', function () { - // TODO remove comments on merge - // let bfStub; - // before(function() { - // bfStub = sinon.stub(bidderFactory, 'getIabSubCategory'); - // }); + let bfStub; + before(function() { + bfStub = sinon.stub(bidderFactory, 'getIabSubCategory'); + }); - // after(function() { - // bfStub.restore(); - // }); + after(function() { + bfStub.restore(); + }); let response = { 'version': '3.0.0', @@ -759,8 +757,7 @@ describe('AppNexusAdapter', function () { } }] }; - // TODO remove on merge - // bfStub.returns('1'); + bfStub.returns('1'); let result = spec.interpretResponse({ body: response }, {bidderRequest}); expect(result[0].video.context).to.equal('adpod');