diff --git a/modules/sortableBidAdapter.js b/modules/sortableBidAdapter.js index f5d3a6b1bb5..6989abff143 100644 --- a/modules/sortableBidAdapter.js +++ b/modules/sortableBidAdapter.js @@ -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'; @@ -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, @@ -241,6 +244,9 @@ export const spec = { h: screen.height }, }, + user: { + ext: {} + } }; if (bidderRequest && bidderRequest.timeout > 0) { sortableBidReq.tmax = bidderRequest.timeout; @@ -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; } diff --git a/test/spec/modules/sortableBidAdapter_spec.js b/test/spec/modules/sortableBidAdapter_spec.js index 8d2b4eea87d..97f80e8dfeb 100644 --- a/test/spec/modules/sortableBidAdapter_spec.js +++ b/test/spec/modules/sortableBidAdapter_spec.js @@ -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); }) });