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

Smaato bid adapter: Optional bidder params to support in-app webview use cases #5765

Merged
merged 1 commit into from
Sep 25, 2020
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
9 changes: 8 additions & 1 deletion modules/smaatoBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,13 @@ const buildOpenRtbBidRequestPayload = (validBidRequests, bidderRequest) => {
utils.deepSetValue(request, 'regs.ext.us_privacy', bidderRequest.uspConsent);
}

if (utils.deepAccess(validBidRequests[0], 'params.app')) {
const geo = utils.deepAccess(validBidRequests[0], 'params.app.geo');
utils.deepSetValue(request, 'device.geo', geo);
const ifa = utils.deepAccess(validBidRequests[0], 'params.app.ifa')
utils.deepSetValue(request, 'device.ifa', ifa);
}

utils.logInfo('[SMAATO] OpenRTB Request:', request);
return JSON.stringify(request);
}
Expand Down Expand Up @@ -185,7 +192,7 @@ export const spec = {
ttl: ttlSec,
creativeId: b.crid,
dealId: b.dealid || null,
netRevenue: true,
netRevenue: utils.deepAccess(b, 'ext.net', true),
currency: res.cur,
meta: {
advertiserDomains: b.adomain,
Expand Down
57 changes: 57 additions & 0 deletions test/spec/modules/smaatoBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,36 @@ const combinedBannerAndVideoBidRequest = {
bidderWinsCount: 0
};

const inAppBidRequest = {
bidder: 'smaato',
params: {
publisherId: 'publisherId',
adspaceId: 'adspaceId',
app: {
ifa: 'aDeviceId',
geo: {
lat: 33.3,
lon: -88.8
}
}
},
mediaTypes: {
banner: {
sizes: [[300, 50]]
}
},
adUnitCode: '/19968336/header-bid-tag-0',
transactionId: 'transactionId',
sizes: [[300, 50]],
bidId: 'bidId',
bidderRequestId: 'bidderRequestId',
auctionId: 'auctionId',
src: 'client',
bidRequestsCount: 1,
bidderRequestsCount: 1,
bidderWinsCount: 0
};

describe('smaatoBidAdapterTest', () => {
describe('isBidRequestValid', () => {
it('has valid params', () => {
Expand Down Expand Up @@ -462,6 +492,27 @@ describe('smaatoBidAdapterTest', () => {
});
});

describe('in-app requests', () => {
it('add geo and ifa info to device object', () => {
let req = JSON.parse(spec.buildRequests([inAppBidRequest], defaultBidderRequest).data);
expect(req.device.geo).to.deep.equal({'lat': 33.3, 'lon': -88.8});
expect(req.device.ifa).to.equal('aDeviceId');
});
it('add only ifa to device object', () => {
let inAppBidRequestWithoutGeo = utils.deepClone(inAppBidRequest);
delete inAppBidRequestWithoutGeo.params.app.geo
let req = JSON.parse(spec.buildRequests([inAppBidRequestWithoutGeo], defaultBidderRequest).data);

expect(req.device.geo).to.not.exist;
expect(req.device.ifa).to.equal('aDeviceId');
});
it('add no specific device info if param does not exist', () => {
let req = JSON.parse(spec.buildRequests([singleBannerBidRequest], defaultBidderRequest).data);
expect(req.device.geo).to.not.exist;
expect(req.device.ifa).to.not.exist;
});
});

describe('interpretResponse', () => {
it('single image reponse', () => {
const bids = spec.interpretResponse(openRtbBidResponse(ADTYPE_IMG), request);
Expand Down Expand Up @@ -501,5 +552,11 @@ describe('smaatoBidAdapterTest', () => {
expect(bids[0].ttl).to.equal(400);
clock.restore();
});
it('uses net revenue flag send from server', () => {
let resp = openRtbBidResponse(ADTYPE_IMG);
resp.body.seatbid[0].bid[0].ext = {net: false};
const bids = spec.interpretResponse(resp, request);
expect(bids[0].netRevenue).to.equal(false);
})
});
});