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

Aniview Bid Adapter : pass replacements and s2s winning ad source in bid meta #12810

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
19 changes: 18 additions & 1 deletion modules/aniviewBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ const converter = ortbConverter({

request(buildRequest, imps, bidderRequest, context) {
const request = buildRequest(imps, bidderRequest, context);
const replacements = context.bidRequests[0]?.params?.replacements;

mergeDeep(request, {
ext: {
Expand All @@ -56,7 +57,11 @@ const converter = ortbConverter({
pbv: '$prebid.version$',
}
}
})
});

if (isPlainObject(replacements)) {
mergeDeep(request, { ext: { [BIDDER_CODE]: { replacements } } });
}

return request;
},
Expand All @@ -82,6 +87,18 @@ const converter = ortbConverter({

mergeDeep(prebidBid, { meta: { advertiserDomains: bid.adomain || [] } });

if (bid.ext?.aniview) {
prebidBid.meta.aniview = bid.ext.aniview

if (prebidBid.meta.aniview.tag) {
try {
prebidBid.meta.aniview.tag = JSON.parse(bid.ext.aniview.tag)
} catch {
// Ignore the error
}
}
}

if (isVideoType(mediaType)) {
if (bidRequest.mediaTypes.video.context === 'outstream') {
prebidBid.renderer = createRenderer(bidRequest);
Expand Down
12 changes: 12 additions & 0 deletions test/spec/modules/aniviewBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ const BANNER_SIZE = { width: 250, height: 250 };
const CUSTOM_RENDERER_URL = `https://${CUSTOM_DOMAIN}/script/6.1/prebidRenderer.js`;
const DEFAULT_RENDERER_URL = `https://player.aniview.com/script/6.1/prebidRenderer.js`;

const REPLACEMENT_1 = '12345';

const MOCK = {
bidRequest: () => ({
bidderCode: 'aniview',
Expand Down Expand Up @@ -67,6 +69,9 @@ const MOCK = {
AV_PUBLISHERID: PUBLISHER_ID_2,
AV_CHANNELID: CHANNEL_ID_2,
playerDomain: CUSTOM_DOMAIN,
replacements: {
AV_CDIM1: REPLACEMENT_1,
},
},
mediaTypes: {
video: {
Expand Down Expand Up @@ -200,6 +205,13 @@ describe('Aniview Bid Adapter', function () {
expect(imp.bidfloorcur).equal(CURRENCY);
});

it('should have replacements in request', function () {
const bidRequest = spec.buildRequests(videoBidRequest.bids, videoBidRequest);
const { replacements } = bidRequest[1].data.ext.aniview;

expect(replacements.AV_CDIM1).equal(REPLACEMENT_1);
});

it('should not have floor data in imp if getFloor returns empty object', function () {
videoBidRequest.bids[1].getFloor = () => ({});

Expand Down