Skip to content

Commit

Permalink
Smaato: Add userIds to BidRequest (#5927)
Browse files Browse the repository at this point in the history
  • Loading branch information
sbrosinski authored Nov 4, 2020
1 parent fa2394f commit 7bbb053
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 1 deletion.
5 changes: 5 additions & 0 deletions modules/smaatoBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,11 @@ const buildOpenRtbBidRequestPayload = (validBidRequests, bidderRequest) => {
utils.deepSetValue(request, 'device.ifa', ifa);
}

const eids = utils.deepAccess(validBidRequests[0], 'userIdAsEids');
if (eids && eids.length) {
utils.deepSetValue(request, 'user.ext.eids', eids);
}

utils.logInfo('[SMAATO] OpenRTB Request:', request);
return JSON.stringify(request);
}
Expand Down
46 changes: 45 additions & 1 deletion test/spec/modules/smaatoBidAdapter_spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { spec } from 'modules/smaatoBidAdapter.js';
import * as utils from 'src/utils.js';
import {config} from 'src/config.js';
import {createEidsArray} from 'modules/userId/eids.js';

const imageAd = {
image: {
Expand Down Expand Up @@ -321,6 +322,37 @@ const inAppBidRequest = {
bidderWinsCount: 0
};

const userIdBidRequest = {
bidder: 'smaato',
params: {
publisherId: 'publisherId',
adspaceId: 'adspaceId'
},
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,
userId: {
criteoId: '123456',
tdid: '89145'
},
userIdAsEids: createEidsArray({
criteoId: '123456',
tdid: '89145'
})
};

describe('smaatoBidAdapterTest', () => {
describe('isBidRequestValid', () => {
it('has valid params', () => {
Expand Down Expand Up @@ -422,7 +454,11 @@ describe('smaatoBidAdapterTest', () => {
expect(req_fpd.user.ext.consent).to.equal('HFIDUYFIUYIUYWIPOI87392DSU');
expect(req_fpd.site.keywords).to.eql('power tools,drills');
expect(req_fpd.site.publisher.id).to.equal('publisherId');
})
});

it('has no user ids', () => {
expect(this.req.user.ext.eids).to.not.exist;
});
});

describe('buildRequests for video imps', () => {
Expand Down Expand Up @@ -513,6 +549,14 @@ describe('smaatoBidAdapterTest', () => {
});
});

describe('user ids in requests', () => {
it('user ids are added to user.ext.eids', () => {
let req = JSON.parse(spec.buildRequests([userIdBidRequest], defaultBidderRequest).data);
expect(req.user.ext.eids).to.exist;
expect(req.user.ext.eids).to.have.length(2);
});
});

describe('interpretResponse', () => {
it('single image reponse', () => {
const bids = spec.interpretResponse(openRtbBidResponse(ADTYPE_IMG), request);
Expand Down

0 comments on commit 7bbb053

Please sign in to comment.