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

AdagioBidAdapter: update preparation for Rtd module and Prebid.js 9 #11580

Merged
merged 1 commit into from
May 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions modules/adagioBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -667,13 +667,14 @@ function autoFillParams(bid) {
bid.params.site = adgGlobalConf.siteId.split(':')[1];
}

// Edge case. Useful when Prebid Manager cannot handle properly params setting…
if (adgGlobalConf.useAdUnitCodeAsPlacement === true || bid.params.useAdUnitCodeAsPlacement === true) {
// `useAdUnitCodeAsPlacement` is an edge case. Useful when a Prebid Manager cannot handle properly params setting.
// In Prebid.js 9, `placement` should be defined in ortb2Imp and the `useAdUnitCodeAsPlacement` param should be removed
bid.params.placement = deepAccess(bid, 'ortb2Imp.ext.data.placement', bid.params.placement);
if (!bid.params.placement && (adgGlobalConf.useAdUnitCodeAsPlacement === true || bid.params.useAdUnitCodeAsPlacement === true)) {
bid.params.placement = bid.adUnitCode;
}

bid.params.adUnitElementId = deepAccess(bid, 'ortb2Imp.ext.data.elementId', null) || bid.params.adUnitElementId;

bid.params.adUnitElementId = deepAccess(bid, 'ortb2Imp.ext.data.divId', bid.params.adUnitElementId);
if (!bid.params.adUnitElementId) {
if (adgGlobalConf.useAdUnitCodeAsAdUnitElementId === true || bid.params.useAdUnitCodeAsAdUnitElementId === true) {
bid.params.adUnitElementId = bid.adUnitCode;
Expand Down Expand Up @@ -959,14 +960,14 @@ const OUTSTREAM_RENDERER = {
* @returns
*/
const _getFeatures = (bidRequest) => {
const f = { ...deepAccess(bidRequest, 'ortb2.ext.features', GlobalExchange.getOrSetGlobalFeatures()) } || {};
const f = { ...deepAccess(bidRequest, 'ortb2.site.ext.data.adg_rtd.features', GlobalExchange.getOrSetGlobalFeatures()) } || {};

f.print_number = deepAccess(bidRequest, 'bidderRequestsCount', 1).toString();

if (f.type === 'bidAdapter') {
f.adunit_position = getSlotPosition(bidRequest.params.adUnitElementId)
} else {
f.adunit_position = deepAccess(bidRequest, 'ortb2Imp.ext.data.adunit_position');
f.adunit_position = deepAccess(bidRequest, 'ortb2Imp.ext.data.adg_rtd.adunit_position');
}

Object.keys(f).forEach((prop) => {
Expand Down Expand Up @@ -1019,7 +1020,7 @@ export const spec = {
// We don't validate the dsa object in adapter and let our server do it.
const dsa = deepAccess(bidderRequest, 'ortb2.regs.ext.dsa');

let rtdSamplingSession = deepAccess(bidderRequest, 'ortb2.ext.session');
let rtdSamplingSession = deepAccess(bidderRequest, 'ortb2.site.ext.data.adg_rtd.session');
const dataExchange = (rtdSamplingSession) ? { session: rtdSamplingSession } : GlobalExchange.getExchangeData();

const aucId = generateUUID()
Expand Down
33 changes: 33 additions & 0 deletions test/spec/modules/adagioBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,39 @@ describe('Adagio bid adapter', () => {
adagioMock.verify();
});

describe('with Adagio Rtd Provider', function() {
it('it dont enqueue features from the bidder adapter', function() {
sandbox.stub(adagio, 'hasRtd').returns(true);
const bid01 = new BidRequestBuilder().withParams().build();
const bidderRequest = new BidderRequestBuilder().build();
spec.buildRequests([bid01], bidderRequest);
adagioMock.expects('enqueue').withArgs(sinon.match({ action: 'features' })).never();
adagioMock.verify();
});

it('get feature from ortb2', function() {
sandbox.stub(adagio, 'hasRtd').returns(true);
const bid01 = new BidRequestBuilder().withParams().build();
bid01.ortb2Imp = {
ext: { data: {adg_rtd: {adunit_position: '1x1'}} }
};
bid01.ortb2 = {
site: {
ext:
{
data: {
adg_rtd: { features: {} }
}
}
}
};
const bidderRequest = new BidderRequestBuilder().build();
const requests = spec.buildRequests([bid01], bidderRequest);
expect(requests[0].data.adUnits[0].features).to.exist;
expect(requests[0].data.adUnits[0].features.adunit_position).to.equal('1x1');
});
});

it('should filter some props in case refererDetection.reachedTop is false', function() {
const bid01 = new BidRequestBuilder().withParams().build();
const bidderRequest = new BidderRequestBuilder({
Expand Down