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

Synacormedia Bid Adapter: Add GPID and Prebid Ad Slot support #8509

Merged
merged 2 commits into from
Jun 1, 2022
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
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');
});
});
});