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 BidAdapter: Add support for userIds #5927

Merged
merged 1 commit into from
Nov 4, 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
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