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 : add DSA support #10971

Merged
merged 1 commit into from
Jan 26, 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
34 changes: 34 additions & 0 deletions modules/appnexusBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,36 @@ export const spec = {
}
}

if (bidderRequest?.ortb2?.regs?.ext?.dsa) {
const pubDsaObj = bidderRequest.ortb2.regs.ext.dsa;
const dsaObj = {};
['required', 'pubrender', 'datatopub'].forEach((dsaKey) => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there's a small possibility 'required' gets renamed or aliased

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has now happened

if (isNumber(pubDsaObj[dsaKey])) {
if (dsaKey === 'required') {
// our client-side endpoint has a different name for the 'required' field
// ...this is the only exception to the openrtb spec for these fields
dsaObj.dsainfo = pubDsaObj[dsaKey];
} else {
dsaObj[dsaKey] = pubDsaObj[dsaKey];
}
}
});

if (isArray(pubDsaObj.transparency) && pubDsaObj.transparency.every((v) => isPlainObject(v))) {
const tpData = [];
pubDsaObj.transparency.forEach((tpObj) => {
if (isStr(tpObj.domain) && tpObj.domain != '' && isArray(tpObj.params) && tpObj.params.every((v) => isNumber(v))) {
tpData.push(tpObj);
}
});
if (tpData.length > 0) {
dsaObj.transparency = tpData;
}
}

if (!isEmpty(dsaObj)) payload.dsa = dsaObj;
}

if (tags[0].publisher_id) {
payload.publisher_id = tags[0].publisher_id;
}
Expand Down Expand Up @@ -585,6 +615,10 @@ function newBid(serverBid, rtbBid, bidderRequest) {
bid.meta = Object.assign({}, bid.meta, { advertiserId: rtbBid.advertiser_id });
}

if (rtbBid.dsa) {
bid.meta = Object.assign({}, bid.meta, { dsa: rtbBid.dsa });
}

// temporary function; may remove at later date if/when adserver fully supports dchain
function setupDChain(rtbBid) {
let dchain = {
Expand Down
58 changes: 58 additions & 0 deletions test/spec/modules/appnexusBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1204,6 +1204,46 @@ describe('AppNexusAdapter', function () {
expect(payload.privacy.gpp_sid).to.deep.equal([7]);
});

it('should add dsa information to the request via bidderRequest.ortb2.regs.ext.dsa', function () {
let bidderRequest = {
'bidderCode': 'appnexus',
'auctionId': '1d1a030790a475',
'bidderRequestId': '22edbae2733bf6',
'timeout': 3000,
'ortb2': {
'regs': {
'ext': {
'dsa': {
'required': 1,
'pubrender': 0,
'datatopub': 1,
'transparency': [{
'domain': 'good-domain',
'params': [1, 2]
}, {
'domain': 'bad-setup',
'params': ['1', 3]
}]
}
}
}
}
};
bidderRequest.bids = bidRequests;

const request = spec.buildRequests(bidRequests, bidderRequest);
const payload = JSON.parse(request.data);

expect(payload.dsa).to.exist;
expect(payload.dsa.dsainfo).to.equal(1);
expect(payload.dsa.pubrender).to.equal(0);
expect(payload.dsa.datatopub).to.equal(1);
expect(payload.dsa.transparency).to.deep.equal([{
'domain': 'good-domain',
'params': [1, 2]
}]);
});

it('supports sending hybrid mobile app parameters', function () {
let appRequest = Object.assign({},
bidRequests[0],
Expand Down Expand Up @@ -1575,6 +1615,15 @@ describe('AppNexusAdapter', function () {
'viewability': {
'config': '<script type=\'text/javascript\' async=\'true\' src=\'https://cdn.adnxs.com/v/s/152/trk.js#v;vk=appnexus.com-omid;tv=native1-18h;dom_id=%native_dom_id%;st=0;d=1x1;vc=iab;vid_ccr=1;tag_id=13232354;cb=https%3A%2F%2Fams1-ib.adnxs.com%2Fvevent%3Freferrer%3Dhttps253A%252F%252Ftestpages-pmahe.tp.adnxs.net%252F01_basic_single%26e%3DwqT_3QLNB6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Qt8AAAA2AUB4AUB8AWZ9CH6BQQIABAAkAYBmAYAuAYAwQYBITAAAPA_yAYA2gYWChAAOgEAGBAAGADgBgw.%26s%3D971dce9d49b6bee447c8a58774fb30b40fe98171;ts=1551889079;cet=0;cecb=\'></script>'
},
'dsa': {
'behalf': 'test-behalf',
'paid': 'test-paid',
'transparency': [{
'domain': 'good-domain',
'params': [1, 2, 3]
}],
'adrender': 1
},
'rtb': {
'banner': {
'content': '<!-- Creative -->',
Expand Down Expand Up @@ -1623,6 +1672,15 @@ describe('AppNexusAdapter', function () {
'nodes': [{
'bsid': '958'
}]
},
'dsa': {
'behalf': 'test-behalf',
'paid': 'test-paid',
'transparency': [{
'domain': 'good-domain',
'params': [1, 2, 3]
}],
'adrender': 1
}
}
}
Expand Down