From 81139c42cfdf32bc63625490977cb92e028fe9fc Mon Sep 17 00:00:00 2001 From: karentnarvaez <61426156+karentnarvaez@users.noreply.github.com> Date: Sat, 10 Apr 2021 06:37:00 -0400 Subject: [PATCH] Sortable Bid Adapter: add eids support (#6565) * Add Sortable adapter for Prebid 3.x Update tests to reflect changes. * Add .js in imports * hostname not host: don't include port * Trivial change to trigger build: failure wasn't our adapter * More failures in other adapters * PR Feedback - use https for URL - fix examples in markdown - request to endpoint should work now * Feedback: add native and video examples * Update unit tests Co-authored-by: Shannon Broekhoven --- modules/sortableBidAdapter.js | 9 +++++ test/spec/modules/sortableBidAdapter_spec.js | 35 +++++++++++++++++++- 2 files changed, 43 insertions(+), 1 deletion(-) 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); }) });