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 support for SDA user and site #9231

Merged
merged 4 commits into from
Nov 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
6 changes: 5 additions & 1 deletion modules/smartadserverBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ export const spec = {
// use bidderRequest.bids[] to get bidder-dependent request info

const adServerCurrency = config.getConfig('currency.adServerCurrency');
const sellerDefinedAudience = deepAccess(bidderRequest, 'ortb2.user.data', config.getAnyConfig('ortb2.user.data'));
const sellerDefinedContext = deepAccess(bidderRequest, 'ortb2.site.content.data', config.getAnyConfig('ortb2.site.content.data'));

// pull requested transaction ID from bidderRequest.bids[].transactionId
return validBidRequests.reduce((bidRequests, bid) => {
Expand All @@ -154,7 +156,9 @@ export const spec = {
timeout: config.getConfig('bidderTimeout'),
bidId: bid.bidId,
prebidVersion: '$prebid.version$',
schain: spec.serializeSupplyChain(bid.schain)
schain: spec.serializeSupplyChain(bid.schain),
sda: sellerDefinedAudience,
sdc: sellerDefinedContext
};

if (bidderRequest && bidderRequest.gdprConsent) {
Expand Down
59 changes: 59 additions & 0 deletions test/spec/modules/smartadserverBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,12 +158,44 @@ describe('Smart bid adapter tests', function () {
}
};

var sellerDefinedAudience = [
{
'name': 'hearst.com',
'ext': { 'segtax': 1 },
'segment': [
{ 'id': '1001' },
{ 'id': '1002' }
]
}
];

var sellerDefinedContext = [
{
'name': 'cnn.com',
'ext': { 'segtax': 2 },
'segment': [
{ 'id': '2002' }
]
}
];

it('Verify build request', function () {
config.setConfig({
'currency': {
'adServerCurrency': 'EUR'
},
ortb2: {
'user': {
'data': sellerDefinedAudience
},
'site': {
'content': {
'data': sellerDefinedContext
}
}
}
});

const request = spec.buildRequests(DEFAULT_PARAMS);
expect(request[0]).to.have.property('url').and.to.equal('https://prg.smartadserver.com/prebid/v1');
expect(request[0]).to.have.property('method').and.to.equal('POST');
Expand All @@ -186,6 +218,8 @@ describe('Smart bid adapter tests', function () {
expect(requestContent).to.have.property('buid').and.to.equal('7569');
expect(requestContent).to.have.property('appname').and.to.equal('Mozilla');
expect(requestContent).to.have.property('ckid').and.to.equal(42);
expect(requestContent).to.have.property('sda').and.to.deep.equal(sellerDefinedAudience);
expect(requestContent).to.have.property('sdc').and.to.deep.equal(sellerDefinedContext);
});

it('Verify parse response with no ad', function () {
Expand Down Expand Up @@ -358,6 +392,7 @@ describe('Smart bid adapter tests', function () {

describe('gdpr tests', function () {
afterEach(function () {
config.setConfig({ ortb2: undefined });
config.resetConfig();
$$PREBID_GLOBAL$$.requestBids.removeAll();
});
Expand Down Expand Up @@ -489,6 +524,16 @@ describe('Smart bid adapter tests', function () {
config.setConfig({
'currency': {
'adServerCurrency': 'EUR'
},
ortb2: {
'user': {
'data': sellerDefinedAudience
},
'site': {
'content': {
'data': sellerDefinedContext
}
}
}
});
const request = spec.buildRequests(INSTREAM_DEFAULT_PARAMS);
Expand All @@ -507,6 +552,8 @@ describe('Smart bid adapter tests', function () {
expect(requestContent).to.have.property('buid').and.to.equal('7569');
expect(requestContent).to.have.property('appname').and.to.equal('Mozilla');
expect(requestContent).to.have.property('ckid').and.to.equal(42);
expect(requestContent).to.have.property('sda').and.to.deep.equal(sellerDefinedAudience);
expect(requestContent).to.have.property('sdc').and.to.deep.equal(sellerDefinedContext);
expect(requestContent).to.have.property('isVideo').and.to.equal(true);
expect(requestContent).to.have.property('videoData');
expect(requestContent.videoData).to.have.property('videoProtocol').and.to.equal(6);
Expand Down Expand Up @@ -748,6 +795,16 @@ describe('Smart bid adapter tests', function () {
config.setConfig({
'currency': {
'adServerCurrency': 'EUR'
},
ortb2: {
'user': {
'data': sellerDefinedAudience
},
'site': {
'content': {
'data': sellerDefinedContext
}
}
}
});
const request = spec.buildRequests(OUTSTREAM_DEFAULT_PARAMS);
Expand All @@ -766,6 +823,8 @@ describe('Smart bid adapter tests', function () {
expect(requestContent).to.have.property('buid').and.to.equal('7579');
expect(requestContent).to.have.property('appname').and.to.equal('Mozilla');
expect(requestContent).to.have.property('ckid').and.to.equal(43);
expect(requestContent).to.have.property('sda').and.to.deep.equal(sellerDefinedAudience);
expect(requestContent).to.have.property('sdc').and.to.deep.equal(sellerDefinedContext);
expect(requestContent).to.have.property('isVideo').and.to.equal(false);
expect(requestContent).to.have.property('videoData');
expect(requestContent.videoData).to.have.property('videoProtocol').and.to.equal(7);
Expand Down