From 0d9b707e58256568d64e83166ab65ea2076bedd1 Mon Sep 17 00:00:00 2001 From: John Rosendahl Date: Tue, 6 Oct 2020 19:43:10 -0600 Subject: [PATCH] Added basic support for ID Module --- modules/sovrnBidAdapter.js | 37 +++++++++++++---------- test/spec/modules/sovrnBidAdapter_spec.js | 23 +++++++++----- 2 files changed, 37 insertions(+), 23 deletions(-) diff --git a/modules/sovrnBidAdapter.js b/modules/sovrnBidAdapter.js index f3260668b74..935b0ceb489 100644 --- a/modules/sovrnBidAdapter.js +++ b/modules/sovrnBidAdapter.js @@ -1,10 +1,12 @@ import * as utils from '../src/utils.js' import { registerBidder } from '../src/adapters/bidderFactory.js' import { BANNER } from '../src/mediaTypes.js' +import { createEidsArray } from './userId/eids.js'; export const spec = { code: 'sovrn', supportedMediaTypes: [BANNER], + gvlid: 13, /** * Check if the bid is a valid zone ID in either number or string form @@ -25,11 +27,21 @@ export const spec = { let sovrnImps = []; let iv; let schain; - let unifiedID; + let eids; + let tpid = [] + let criteoId; utils._each(bidReqs, function (bid) { - if (!unifiedID) { - unifiedID = utils.deepAccess(bid, 'userId.tdid'); + if (!eids && bid.userId) { + eids = createEidsArray(bid.userId) + eids.forEach(function (id) { + if (id.uids && id.uids[0]) { + if (id.source === 'criteo.com') { + criteoId = id.uids[0].id + } + tpid.push({source: id.source, uid: id.uids[0].id}) + } + }) } if (bid.schain) { @@ -84,19 +96,12 @@ export const spec = { utils.deepSetValue(sovrnBidReq, 'regs.ext.us_privacy', bidderRequest.uspConsent); } - if (unifiedID) { - const idArray = [{ - source: 'adserver.org', - uids: [ - { - id: unifiedID, - ext: { - rtiPartner: 'TDID' - } - } - ] - }] - utils.deepSetValue(sovrnBidReq, 'user.ext.eids', idArray) + if (eids) { + utils.deepSetValue(sovrnBidReq, 'user.ext.eids', eids) + utils.deepSetValue(sovrnBidReq, 'user.ext.tpid', tpid) + if (criteoId) { + utils.deepSetValue(sovrnBidReq, 'user.ext.prebid_criteoid', criteoId) + } } let url = `https://ap.lijit.com/rtb/bid?src=$$REPO_AND_VERSION$$`; diff --git a/test/spec/modules/sovrnBidAdapter_spec.js b/test/spec/modules/sovrnBidAdapter_spec.js index 54ccff870eb..321fed40d83 100644 --- a/test/spec/modules/sovrnBidAdapter_spec.js +++ b/test/spec/modules/sovrnBidAdapter_spec.js @@ -239,8 +239,8 @@ describe('sovrnBidAdapter', function() { expect(data.source.ext.schain.nodes.length).to.equal(1) }); - it('should add the unifiedID if present', function() { - const digitrustRequests = [{ + it('should add ids to the bid request', function() { + const criteoIdRequest = [{ 'bidder': 'sovrn', 'params': { 'tagid': 403370 @@ -254,6 +254,7 @@ describe('sovrnBidAdapter', function() { 'bidderRequestId': '22edbae2733bf6', 'auctionId': '1d1a030790a475', 'userId': { + 'criteoId': 'A_CRITEO_ID', 'tdid': 'SOMESORTOFID', } }].concat(bidRequests); @@ -263,12 +264,20 @@ describe('sovrnBidAdapter', function() { } }; - const data = JSON.parse(spec.buildRequests(digitrustRequests, bidderRequest).data); - expect(data.user.ext.eids[0].source).to.equal('adserver.org') - expect(data.user.ext.eids[0].uids[0].id).to.equal('SOMESORTOFID') - expect(data.user.ext.eids[0].uids[0].ext.rtiPartner).to.equal('TDID') - }) + const data = JSON.parse(spec.buildRequests(criteoIdRequest, bidderRequest).data); + expect(data.user.ext.eids[0].source).to.equal('criteo.com') + expect(data.user.ext.eids[0].uids[0].id).to.equal('A_CRITEO_ID') + expect(data.user.ext.eids[0].uids[0].atype).to.equal(1) + expect(data.user.ext.eids[1].source).to.equal('adserver.org') + expect(data.user.ext.eids[1].uids[0].id).to.equal('SOMESORTOFID') + expect(data.user.ext.eids[1].uids[0].ext.rtiPartner).to.equal('TDID') + expect(data.user.ext.eids[1].uids[0].atype).to.equal(1) + expect(data.user.ext.tpid[0].source).to.equal('criteo.com') + expect(data.user.ext.tpid[0].uid).to.equal('A_CRITEO_ID') + expect(data.user.ext.prebid_criteoid).to.equal('A_CRITEO_ID') + }); }); + describe('interpretResponse', function () { let response; beforeEach(function () {