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

AMX Bid Adapter: add support for overriding bidderCode (allowAlternateBidderCodes) #11712

Merged
merged 2 commits into from
Jun 7, 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
7 changes: 7 additions & 0 deletions modules/amxBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,10 @@ export const spec = {
setUIDSafe(response.am);
}

const bidderSettings = config.getConfig('bidderSettings');
const settings = bidderSettings?.amx ?? bidderSettings?.standard ?? {};
const allowAlternateBidderCodes = !!settings.allowAlternateBidderCodes;

return flatMap(Object.keys(response.r), (bidID) => {
return flatMap(response.r[bidID], (siteBid) =>
siteBid.b.map((bid) => {
Expand All @@ -466,8 +470,10 @@ export const spec = {

const size = resolveSize(bid, request.data, bidID);
const defaultExpiration = mediaType === BANNER ? 240 : 300;
const { bc: bidderCode, ds: demandSource } = bid.ext ?? {};

return {
...(bidderCode != null && allowAlternateBidderCodes ? { bidderCode } : {}),
requestId: bidID,
cpm: bid.price,
width: size[0],
Expand All @@ -479,6 +485,7 @@ export const spec = {
meta: {
advertiserDomains: bid.adomain,
mediaType,
...(demandSource != null ? { demandSource } : {}),
},
mediaType,
ttl: typeof bid.exp === 'number' ? bid.exp : defaultExpiration,
Expand Down
49 changes: 49 additions & 0 deletions test/spec/modules/amxBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -583,6 +583,55 @@ describe('AmxBidAdapter', () => {
expect(parsed).to.eql([]);
});

it('will read an bidderCode override from bid.ext.prebid.meta', () => {
const currentConfig = config.getConfig();
config.setConfig({
...currentConfig,
bidderSettings: {
amx: {
allowAlternateBidderCodes: true
}
}
});

const parsed = spec.interpretResponse(
{ body: {
...sampleServerResponse,
r: {
[sampleRequestId]: [{
...sampleServerResponse.r[sampleRequestId][0],
b: [{
...sampleServerResponse.r[sampleRequestId][0].b[0],
ext: {
bc: 'amx-pmp',
ds: 'example',
}
}]
}]
}}},
baseRequest
);

config.setConfig(currentConfig);
expect(parsed.length).to.equal(1); // we removed one

// we should have display, video, display
expect(parsed[0]).to.deep.equal({
...baseBidResponse,
meta: {
...baseBidResponse.meta,
mediaType: BANNER,
demandSource: 'example'
},
mediaType: BANNER,
bidderCode: 'amx-pmp',
width: 300,
height: 600, // from the bid itself
ttl: 90,
ad: sampleDisplayAd,
});
});

it('can parse a display ad', () => {
const parsed = spec.interpretResponse(
{ body: sampleServerResponse },
Expand Down