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

PubMatic Bid Adapter : add support for DSA #11245

Merged
merged 1 commit into from
Mar 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
10 changes: 10 additions & 0 deletions modules/pubmaticBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -1010,6 +1010,10 @@ export function prepareMetaObject(br, bid, seat) {
br.meta.secondaryCatIds = bid.cat;
br.meta.primaryCatId = bid.cat[0];
}

if (bid.ext && bid.ext.dsa && Object.keys(bid.ext.dsa).length) {
br.meta.dsa = bid.ext.dsa;
}
}

export const spec = {
Expand Down Expand Up @@ -1217,6 +1221,11 @@ export const spec = {
deepSetValue(payload, 'regs.coppa', 1);
}

// dsa
if (bidderRequest?.ortb2?.regs?.ext?.dsa) {
deepSetValue(payload, 'regs.ext.dsa', bidderRequest.ortb2.regs.ext.dsa);
}

_handleEids(payload, validBidRequests);

// First Party Data
Expand Down Expand Up @@ -1396,6 +1405,7 @@ export const spec = {
} catch (error) {
logError(error);
}

return bidResponses;
},

Expand Down
43 changes: 43 additions & 0 deletions test/spec/modules/pubmaticBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1781,6 +1781,37 @@ describe('PubMatic adapter', function () {
expect(data2.regs).to.equal(undefined);// USP/CCPAs
});

it('Request params should include DSA signals if present', function () {
const dsa = {
dsarequired: 3,
pubrender: 0,
datatopub: 2,
transparency: [
{
domain: 'platform1domain.com',
dsaparams: [1]
},
{
domain: 'SSP2domain.com',
dsaparams: [1, 2]
}
]
};

let bidRequest = {
ortb2: {
regs: {
ext: {
dsa
}
}
}
};
let request = spec.buildRequests(bidRequests, bidRequest);
let data = JSON.parse(request.data);
assert.deepEqual(data.regs.ext.dsa, dsa);
});

it('Request params check with JW player params', function() {
let bidRequests = [
{
Expand Down Expand Up @@ -3753,6 +3784,16 @@ describe('PubMatic adapter', function () {

describe('Preapare metadata', function () {
it('Should copy all fields from ext to meta', function () {
const dsa = {
behalf: 'Advertiser',
paid: 'Advertiser',
transparency: [{
domain: 'dsp1domain.com',
dsaparams: [1, 2]
}],
adrender: 1
};

const bid = {
'adomain': [
'mystartab.com'
Expand All @@ -3764,6 +3805,7 @@ describe('PubMatic adapter', function () {
'deal_channel': 1,
'bidtype': 0,
advertiserId: 'adid',
dsa,
// networkName: 'nwnm',
// primaryCatId: 'pcid',
// advertiserName: 'adnm',
Expand Down Expand Up @@ -3795,6 +3837,7 @@ describe('PubMatic adapter', function () {
expect(br.meta.secondaryCatIds[0]).to.equal('IAB_CATEGORY');
expect(br.meta.advertiserDomains).to.be.an('array').with.length.above(0); // adomain
expect(br.meta.clickUrl).to.equal('mystartab.com'); // adomain
expect(br.meta.dsa).to.equal(dsa); // dsa
});

it('Should be empty, when ext and adomain is absent in bid object', function () {
Expand Down