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

Smartadserver Bid Adapter : add DSA support #12141

Merged
merged 6 commits into from
Aug 21, 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
22 changes: 20 additions & 2 deletions modules/smartadserverBidAdapter.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
import { deepAccess, deepClone, isArrayOfNums, isFn, isInteger, isPlainObject, logError } from '../src/utils.js';
import {
deepAccess,
deepClone,
isArray,
isArrayOfNums,
isEmpty,
isFn,
isInteger,
isPlainObject,
logError
} from '../src/utils.js';
import { BANNER, VIDEO } from '../src/mediaTypes.js';
import { config } from '../src/config.js';
import { registerBidder } from '../src/adapters/bidderFactory.js';
Expand Down Expand Up @@ -204,6 +214,11 @@ export const spec = {
payload.gpid = gpid;
}

const dsa = deepAccess(bid, 'ortb2.regs.ext.dsa');
if (dsa) {
payload.dsa = dsa;
}

if (bidderRequest) {
if (bidderRequest.gdprConsent) {
payload.addtl_consent = bidderRequest.gdprConsent.addtlConsent;
Expand Down Expand Up @@ -285,7 +300,10 @@ export const spec = {
netRevenue: response.isNetCpm,
ttl: response.ttl,
dspPixels: response.dspPixels,
meta: { advertiserDomains: response.adomain ? response.adomain : [] }
meta: {
...isArray(response.adomain) && !isEmpty(response.adomain) ? { advertiserDomains: response.adomain } : {},
...!isEmpty(response.dsa) ? { dsa: response.dsa } : {}
}
};

if (bidRequest.mediaType === VIDEO) {
Expand Down
58 changes: 58 additions & 0 deletions test/spec/modules/smartadserverBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,32 @@ describe('Smart bid adapter tests', function () {
});
});

it('Verify metadata', function () {
const adomain = ['advertiser-domain.com'];
const dsa = {
dsarequired: 1,
pubrender: 0,
datatopub: 1,
transparency: [{
domain: 'smartadserver.com',
dsaparams: [1, 2]
}]
};
const request = spec.buildRequests(DEFAULT_PARAMS);
const bids = spec.interpretResponse({
body: {
...BID_RESPONSE.body,
adomain,
dsa,
}
}, request[0]);

expect(bids[0].cpm).to.equal(12);
expect(bids[0]).to.have.property('meta');
expect(bids[0].meta).to.have.property('advertiserDomains').and.to.deep.equal(adomain);
expect(bids[0].meta).to.have.property('dsa').and.to.deep.equal(dsa);
});

describe('gdpr tests', function () {
afterEach(function () {
config.setConfig({ ortb2: undefined });
Expand Down Expand Up @@ -1512,6 +1538,38 @@ describe('Smart bid adapter tests', function () {
});
});

describe('Digital Services Act (DSA)', function () {
it('should include dsa if ortb2.regs.ext.dsa available', function () {
const dsa = {
dsarequired: 1,
pubrender: 0,
datatopub: 1,
transparency: [
{
domain: 'ok.domain.com',
dsaparams: [1, 2]
},
{
domain: 'ko.domain.com',
dsaparams: [1, '3']
}
]
};

const bidRequests = deepClone(DEFAULT_PARAMS_WO_OPTIONAL);
bidRequests[0].ortb2 = {
regs: {
ext: { dsa }
}
};

const request = spec.buildRequests(bidRequests);
const requestContent = JSON.parse(request[0].data);

expect(requestContent).to.have.property('dsa').and.to.deep.equal(dsa);
});
});

describe('#getValuableProperty method', function () {
it('should return an object when calling with a number value', () => {
const obj = spec.getValuableProperty('prop', 3);
Expand Down