Skip to content

Commit

Permalink
CAPT-74: Pass ext section of each bid for prebid slot ID and GPID (#8509
Browse files Browse the repository at this point in the history
)

Co-authored-by: Timothy M. Ace <tace@imds.tv>
  • Loading branch information
ecammit and ecammit authored Jun 1, 2022
1 parent 08622d3 commit 72732f8
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 2 deletions.
13 changes: 11 additions & 2 deletions modules/synacormediaBidAdapter.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

import {deepSetValue, getAdUnitSizes, isFn, isPlainObject, logWarn} from '../src/utils.js';
import {deepAccess, deepSetValue, getAdUnitSizes, isFn, isPlainObject, logWarn} from '../src/utils.js';
import {registerBidder} from '../src/adapters/bidderFactory.js';
import {BANNER, VIDEO} from '../src/mediaTypes.js';
import {includes} from '../src/polyfill.js';
Expand Down Expand Up @@ -79,7 +79,16 @@ export const spec = {
imps = this.buildVideoImpressions(adSizes, bid, tagIdOrPlacementId, pos, videoOrBannerKey);
}
if (imps.length > 0) {
imps.forEach(i => openRtbBidRequest.imp.push(i));
imps.forEach(i => {
// Deeply add ext section to all imp[] for GPID, prebid slot id, and anything else down the line
const extSection = deepAccess(bid, 'ortb2Imp.ext');
if (extSection) {
deepSetValue(i, 'ext', extSection);
}

// Add imp[] to request object
openRtbBidRequest.imp.push(i);
});
}
});

Expand Down
74 changes: 74 additions & 0 deletions test/spec/modules/synacormediaBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1362,4 +1362,78 @@ describe('synacormediaBidAdapter ', function () {
expect(videoRequest.data.imp[0].bidfloor).to.equal(priceModuleFloor);
});
});

describe('Bid Requests with gpid or anything in bid.ext should use if available', function () {
let validVideoBidRequest = {
bidder: 'synacormedia',
params: {
seatId: 'prebid',
placementId: 'demo1',
pos: 1,
video: {}
},
renderer: {
url: '../syncOutstreamPlayer.js'
},
ortb2Imp: {
ext: {
gpid: '/1111/homepage-video',
data: {
pbadslot: '/1111/homepage-video'
}
}
},
mediaTypes: {
video: {
playerSize: [[300, 250]],
context: 'outstream'
}
},
adUnitCode: 'div-1',
transactionId: '0869f34e-090b-4b20-84ee-46ff41405a39',
sizes: [[300, 250]],
bidId: '22b3a2268d9f0e',
bidderRequestId: '1d195910597e13',
auctionId: '3375d336-2aea-4ee7-804c-6d26b621ad20',
src: 'client',
bidRequestsCount: 1,
bidderRequestsCount: 1,
bidderWinsCount: 0
};

let validBannerBidRequest = {
bidId: '9876abcd',
sizes: [[300, 250]],
params: {
seatId: 'prebid',
placementId: '1234',
},
ortb2Imp: {
ext: {
gpid: '/1111/homepage-banner',
data: {
pbadslot: '/1111/homepage-banner'
}
}
}
};

let bidderRequest = {
refererInfo: {
referer: 'http://localhost:9999/'
},
bidderCode: 'synacormedia',
auctionId: 'f8a75621-d672-4cbb-9275-3db7d74fb110'
};

it('should return valid gpid and pbadslot', function () {
let videoRequest = spec.buildRequests([validVideoBidRequest], bidderRequest);
let bannerRequest = spec.buildRequests([validBannerBidRequest], bidderRequest);

expect(videoRequest.data.imp[0].ext.gpid).to.equal('/1111/homepage-video');
expect(videoRequest.data.imp[0].ext.data.pbadslot).to.equal('/1111/homepage-video');
expect(bannerRequest.data.imp[0].ext.gpid).to.equal('/1111/homepage-banner');
expect(bannerRequest.data.imp[0].ext.data.pbadslot).to.equal('/1111/homepage-banner');
});
});
});

0 comments on commit 72732f8

Please sign in to comment.