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 bid adapter - fix in psp keywords conversion logic #8382

Merged
merged 1 commit into from
May 16, 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
15 changes: 13 additions & 2 deletions modules/appnexusBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -394,11 +394,22 @@ export const spec = {
}
},

transformBidParams: function (params, isOpenRtb) {
transformBidParams: function (params, isOpenRtb, adUnit, bidRequests) {
let conversionFn = transformBidderParamKeywords;
if (isOpenRtb === true) {
let s2sEndpointUrl = null;
let s2sConfig = config.getConfig('s2sConfig');
let s2sEndpointUrl = deepAccess(s2sConfig, 'endpoint.p1Consent');

if (isPlainObject(s2sConfig)) {
s2sEndpointUrl = deepAccess(s2sConfig, 'endpoint.p1Consent');
} else if (isArray(s2sConfig)) {
s2sConfig.forEach(s2sCfg => {
if (includes(s2sCfg.bidders, adUnit.bids[0].bidder)) {
s2sEndpointUrl = deepAccess(s2sCfg, 'endpoint.p1Consent');
}
})
}

if (s2sEndpointUrl && s2sEndpointUrl.match('/openrtb2/prebid')) {
conversionFn = convertKeywordsToString;
}
Expand Down
47 changes: 37 additions & 10 deletions test/spec/modules/appnexusBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1549,14 +1549,24 @@ describe('AppNexusAdapter', function () {
});

describe('transformBidParams', function () {
it('convert keywords param differently for psp endpoint', function () {
sinon.stub(config, 'getConfig')
.withArgs('s2sConfig')
.returns({
endpoint: {
p1Consent: 'https://ib.adnxs.com/openrtb2/prebid'
}
});
let gcStub;
let adUnit = { bids: [{ bidder: 'appnexus' }] }; ;

before(function() {
gcStub = sinon.stub(config, 'getConfig');
});

after(function() {
gcStub.restore();
});

it('convert keywords param differently for psp endpoint with single s2sConfig', function () {
gcStub.withArgs('s2sConfig').returns({
bidders: ['appnexus'],
endpoint: {
p1Consent: 'https://ib.adnxs.com/openrtb2/prebid'
}
});

const oldParams = {
keywords: {
Expand All @@ -1565,10 +1575,27 @@ describe('AppNexusAdapter', function () {
}
};

const newParams = spec.transformBidParams(oldParams, true);
const newParams = spec.transformBidParams(oldParams, true, adUnit);
expect(newParams.keywords).to.equal('genre=rock,genre=pop,pets=dog');
});

config.getConfig.restore();
it('convert keywords param differently for psp endpoint with array s2sConfig', function () {
gcStub.withArgs('s2sConfig').returns([{
bidders: ['appnexus'],
endpoint: {
p1Consent: 'https://ib.adnxs.com/openrtb2/prebid'
}
}]);

const oldParams = {
keywords: {
genre: ['rock', 'pop'],
pets: 'dog'
}
};

const newParams = spec.transformBidParams(oldParams, true, adUnit);
expect(newParams.keywords).to.equal('genre=rock,genre=pop,pets=dog');
});
});
});