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

Sortable Bid Adapter: add eids support #6565

Merged
merged 9 commits into from Apr 10, 2021
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: 9 additions & 0 deletions modules/sortableBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import * as utils from '../src/utils.js';
import { registerBidder } from '../src/adapters/bidderFactory.js';
import { config } from '../src/config.js';
import { BANNER, NATIVE, VIDEO } from '../src/mediaTypes.js';
import { createEidsArray } from './userId/eids.js';

const BIDDER_CODE = 'sortable';
const SERVER_URL = 'https://c.deployads.com';
Expand Down Expand Up @@ -218,6 +219,8 @@ export const spec = {
return rv;
});
const gdprConsent = bidderRequest && bidderRequest.gdprConsent;
const bidUserId = validBidReqs[0].userId;
const eids = createEidsArray(bidUserId);
const sortableBidReq = {
id: utils.getUniqueIdentifierStr(),
imp: sortableImps,
Expand All @@ -241,6 +244,9 @@ export const spec = {
h: screen.height
},
},
user: {
ext: {}
}
};
if (bidderRequest && bidderRequest.timeout > 0) {
sortableBidReq.tmax = bidderRequest.timeout;
Expand All @@ -255,6 +261,9 @@ export const spec = {
sortableBidReq.regs.ext.gdpr = gdprConsent.gdprApplies ? 1 : 0
}
}
if (eids.length) {
sortableBidReq.user.ext.eids = eids;
}
if (bidderRequest.uspConsent) {
sortableBidReq.regs.ext.us_privacy = bidderRequest.uspConsent;
}
Expand Down
35 changes: 34 additions & 1 deletion test/spec/modules/sortableBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,40 @@ describe('sortableBidAdapter', function() {
const gdprRequest = spec.buildRequests(gdprBidRequests, {refererInfo: { referer: 'http://localhost:9876/' }});
const gdprRequestBody = JSON.parse(gdprRequest.data);
expect(gdprRequestBody.regs).to.deep.equal({ext: {}});
expect(gdprRequestBody.user).to.equal(undefined);
expect(gdprRequestBody.user.ext.consent).to.equal(undefined);
})

const eidsBidRequests = [{
'bidder': 'sortable',
'params': {
'tagId': '403370',
'siteId': 'example.com',
'floor': 0.21,
'keywords': {},
'floorSizeMap': {}
},
'bidId': '30b31c1838de1e',
'bidderRequestId': '22edbae2733bf6',
'auctionId': '1d1a030790a475'
}];

it('should not set user ids when none present', function() {
const eidsRequest = spec.buildRequests(eidsBidRequests, {refererInfo: {
referer: 'http://localhost:9876/'
}});
const eidsRequestBody = JSON.parse(eidsRequest.data);

expect(eidsRequestBody.user.ext.eids).to.equal(undefined);
})

it('should set user ids when present', function() {
eidsBidRequests[0].userId = { criteoId: 'sample-userid' };
const eidsRequest = spec.buildRequests(eidsBidRequests, {refererInfo: {
referer: 'http://localhost:9876/'
}});
const eidsRequestBody = JSON.parse(eidsRequest.data);

expect(eidsRequestBody.user.ext.eids.length).to.equal(1);
})
});

Expand Down