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

Appnexus: Add omid support #5821

Merged
merged 4 commits into from
Oct 7, 2020
Merged
Show file tree
Hide file tree
Changes from 2 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
29 changes: 29 additions & 0 deletions modules/appnexusBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ export const spec = {
const memberIdBid = find(bidRequests, hasMemberId);
const member = memberIdBid ? parseInt(memberIdBid.params.member, 10) : 0;
const schain = bidRequests[0].schain;
const omidSupport = find(bidRequests, hasOmidSupport);

const payload = {
tags: [...tags],
Expand All @@ -168,6 +169,13 @@ export const spec = {
schain: schain
};

if (omidSupport) {
payload['iab_support'] = {
omidpn: 'Appnexus',
omidpv: '$prebid.version$'
}
}

if (member > 0) {
payload.member_id = member;
}
Expand Down Expand Up @@ -770,12 +778,20 @@ function bidToTag(bid) {
tag.video[param] = bid.params.video[param];
}
});

if (bid.params.video.frameworks && utils.isArray(bid.params.video.frameworks)) {
tag['video_frameworks'] = bid.params.video.frameworks;
}
}

if (bid.renderer) {
tag.video = Object.assign({}, tag.video, { custom_renderer_present: true });
}

if (bid.params.frameworks && utils.isArray(bid.params.frameworks)) {
tag['banner_frameworks'] = bid.params.frameworks;
}

let adUnit = find(auctionManager.getAdUnits(), au => bid.transactionId === au.transactionId);
if (adUnit && adUnit.mediaTypes && adUnit.mediaTypes.banner) {
tag.ad_types.push(BANNER);
Expand Down Expand Up @@ -844,6 +860,19 @@ function hasAdPod(bid) {
);
}

function hasOmidSupport(bid) {
let hasOmid = false;
const bidderParams = bid.params;
const videoParams = bid.params.video;
if (bidderParams.frameworks && utils.isArray(bidderParams.frameworks)) {
hasOmid = includes(bid.params.frameworks, 6);
}
if (!hasOmid && videoParams && videoParams.frameworks && utils.isArray(videoParams.frameworks)) {
hasOmid = includes(bid.params.video.frameworks, 6);
}
return hasOmid;
}

/**
* Expand an adpod placement into a set of request objects according to the
* total adpod duration and the range of duration seconds. Sets minduration/
Expand Down
45 changes: 45 additions & 0 deletions test/spec/modules/appnexusBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -829,6 +829,51 @@ describe('AppNexusAdapter', function () {
user_id: 'sample-criteo-userid',
});
});

it('should populate iab_support object at the root level if omid support is detected', function () {
// with bid.params.frameworks
let bidRequest_A = Object.assign({}, bidRequests[0], {
params: {
frameworks: [1, 2, 5, 6],
video: {
frameworks: [1, 2, 5, 6]
}
}
});
let request = spec.buildRequests([bidRequest_A]);
let payload = JSON.parse(request.data);
expect(payload.iab_support).to.be.an('object');
expect(payload.iab_support).to.deep.equal({
omidpn: 'Appnexus',
omidpv: '$prebid.version$'
});
expect(payload.tags[0].banner_frameworks).to.be.an('array');
expect(payload.tags[0].banner_frameworks).to.deep.equal([1, 2, 5, 6]);
expect(payload.tags[0].video_frameworks).to.be.an('array');
expect(payload.tags[0].video_frameworks).to.deep.equal([1, 2, 5, 6]);

// without bid.params.frameworks
const bidRequest_B = Object.assign({}, bidRequests[0]);
request = spec.buildRequests([bidRequest_B]);
payload = JSON.parse(request.data);
expect(payload.iab_support).to.not.exist;
expect(payload.tags[0].banner_frameworks).to.not.exist;
expect(payload.tags[0].video_frameworks).to.not.exist;

// with video.frameworks but it is not an array
const bidRequest_C = Object.assign({}, bidRequests[0], {
params: {
video: {
frameworks: "'1', '2', '3', '6'"
}
}
});
request = spec.buildRequests([bidRequest_C]);
payload = JSON.parse(request.data);
expect(payload.iab_support).to.not.exist;
expect(payload.tags[0].banner_frameworks).to.not.exist;
expect(payload.tags[0].video_frameworks).to.not.exist;
});
})

describe('interpretResponse', function () {
Expand Down