From 6e5ec18fbad9d17d0a12c40627c5272834bab49f Mon Sep 17 00:00:00 2001 From: Sergi Date: Tue, 26 Nov 2019 16:39:18 +0100 Subject: [PATCH 1/8] Support userIDs + Prebid 3.0 --- modules/richaudienceBidAdapter.js | 104 ++++-- .../modules/richaudienceBidAdapter_spec.js | 327 ++++++++++++++++-- 2 files changed, 370 insertions(+), 61 deletions(-) mode change 100644 => 100755 modules/richaudienceBidAdapter.js mode change 100644 => 100755 test/spec/modules/richaudienceBidAdapter_spec.js diff --git a/modules/richaudienceBidAdapter.js b/modules/richaudienceBidAdapter.js old mode 100644 new mode 100755 index bd47e481a76..dea1722a05b --- a/modules/richaudienceBidAdapter.js +++ b/modules/richaudienceBidAdapter.js @@ -39,22 +39,20 @@ export const spec = { bidder: bid.bidder, bidderRequestId: bid.bidderRequestId, tagId: bid.adUnitCode, - sizes: bid.sizes.map(size => ({ - w: size[0], - h: size[1], - })), + sizes: raiGetSizes(bid), referer: (typeof bidderRequest.refererInfo.referer != 'undefined' ? encodeURIComponent(bidderRequest.refererInfo.referer) : null), numIframes: (typeof bidderRequest.refererInfo.numIframes != 'undefined' ? bidderRequest.refererInfo.numIframes : null), transactionId: bid.transactionId, timeout: config.getConfig('bidderTimeout'), + user: raiSetEids(bid) }; + payload.gdpr_consent = ''; + payload.gdpr = null; + if (bidderRequest && bidderRequest.gdprConsent) { payload.gdpr_consent = bidderRequest.gdprConsent.consentString; - payload.gdpr = bidderRequest.gdprConsent.gdprApplies; // we're handling the undefined case server side - } else { - payload.gdpr_consent = ''; - payload.gdpr = null; + payload.gdpr = bidderRequest.gdprConsent.gdprApplies; } var payloadString = JSON.stringify(payload); @@ -76,34 +74,29 @@ export const spec = { */ interpretResponse: function (serverResponse, bidRequest) { const bidResponses = []; - + // try catch var response = serverResponse.body; + if (response) { + var bidResponse = { + requestId: JSON.parse(bidRequest.data).bidId, + cpm: response.cpm, + width: response.width, + height: response.height, + creativeId: response.creative_id, + mediaType: response.media_type, + netRevenue: response.netRevenue, + currency: response.currency, + ttl: response.ttl, + dealId: response.dealId, + }; - try { - if (response) { - var bidResponse = { - requestId: JSON.parse(bidRequest.data).bidId, - cpm: response.cpm, - width: response.width, - height: response.height, - creativeId: response.creative_id, - mediaType: response.media_type, - netRevenue: response.netRevenue, - currency: response.currency, - ttl: response.ttl, - dealId: response.dealId, - }; - - if (response.media_type === 'video') { - bidResponse.vastXml = response.vastXML; - } else { - bidResponse.ad = response.adm - } - - bidResponses.push(bidResponse); + if (response.media_type === 'video') { + bidResponse.vastXml = response.vastXML; + } else { + bidResponse.ad = response.adm } - } catch (error) { - utils.logError('Error while parsing Rich Audience response', error); + + bidResponses.push(bidResponse); } return bidResponses }, @@ -121,11 +114,7 @@ export const spec = { var rand = Math.floor(Math.random() * 9999999999); var syncUrl = ''; - if (gdprConsent && typeof gdprConsent.consentString === 'string') { - syncUrl = 'https://sync.richaudience.com/dcf3528a0b8aa83634892d50e91c306e/?ord=' + rand + '&pubconsent=' + gdprConsent.consentString + '&euconsent=' + gdprConsent.consentString; - } else { - syncUrl = 'https://sync.richaudience.com/dcf3528a0b8aa83634892d50e91c306e/?ord=' + rand; - } + gdprConsent && typeof gdprConsent.consentString === 'string' ? syncUrl = 'https://sync.richaudience.com/dcf3528a0b8aa83634892d50e91c306e/?ord=' + rand + '&pubconsent=' + gdprConsent.consentString + '&euconsent=' + gdprConsent.consentString : syncUrl = 'https://sync.richaudience.com/dcf3528a0b8aa83634892d50e91c306e/?ord=' + rand; if (syncOptions.iframeEnabled) { syncs.push({ @@ -138,3 +127,42 @@ export const spec = { }; registerBidder(spec); + +function raiGetSizes(bid) { + let raiNewSizes; + if (bid.mediaTypes && bid.mediaTypes.banner && bid.mediaTypes.banner.sizes) { + raiNewSizes = bid.mediaTypes.banner.sizes + } else { + raiNewSizes = bid.sizes + } + if (raiNewSizes != null) { + return raiNewSizes.map(size => ({ + w: size[0], + h: size[1] + })); + } +} + +function raiSetEids(bid) { + let eids = []; + + if (bid && bid.userId) { + raiSetUserId(bid, eids, 'd5-sync.com', utils.deepAccess(bid, `userId.id5id`)); + raiSetUserId(bid, eids, 'pubcommon', utils.deepAccess(bid, `userId.pubcid`)); + raiSetUserId(bid, eids, 'criteo.com', utils.deepAccess(bid, `userId.criteoId`)); + raiSetUserId(bid, eids, 'liveramp.com', utils.deepAccess(bid, `userId.idl_env`)); + raiSetUserId(bid, eids, 'liveintent.com', utils.deepAccess(bid, `userId.lipb.lipbid`)); + raiSetUserId(bid, eids, 'adserver.org', utils.deepAccess(bid, `userId.tdid`)) + } + + return eids; +} + +function raiSetUserId(bid, eids, source, value, userId) { + if (utils.isStr(value)) { + eids.push({ + userId: source, + source: value + }); + } +} diff --git a/test/spec/modules/richaudienceBidAdapter_spec.js b/test/spec/modules/richaudienceBidAdapter_spec.js old mode 100644 new mode 100755 index 16d67ce7ceb..1bc1bd73408 --- a/test/spec/modules/richaudienceBidAdapter_spec.js +++ b/test/spec/modules/richaudienceBidAdapter_spec.js @@ -25,7 +25,30 @@ describe('Richaudience adapter tests', function () { auctionId: '0cb3144c-d084-4686-b0d6-f5dbe917c563', bidRequestsCount: 1, bidderRequestId: '1858b7382993ca', - transactionId: '29df2112-348b-4961-8863-1b33684d95e6' + transactionId: '29df2112-348b-4961-8863-1b33684d95e6', + user: {} + }]; + + var DEFAULT_PARAMS_NEW_SIZES = [{ + adUnitCode: 'test-div', + bidId: '2c7c8e9c900244', + mediaTypes: { + banner: { + sizes: [ + [300, 250], [300, 600], [728, 90], [970, 250]] + } + }, + bidder: 'richaudience', + params: { + bidfloor: 0.5, + pid: 'ADb1f40rmi', + supplyType: 'site' + }, + auctionId: '0cb3144c-d084-4686-b0d6-f5dbe917c563', + bidRequestsCount: 1, + bidderRequestId: '1858b7382993ca', + transactionId: '29df2112-348b-4961-8863-1b33684d95e6', + user: {} }]; var DEFAULT_PARAMS_APP = [{ @@ -101,6 +124,17 @@ describe('Richaudience adapter tests', function () { } }; + var DEFAULT_PARAMS_GDPR = { + gdprConsent: { + consentString: 'BOZcQl_ObPFjWAeABAESCD-AAAAjx7_______9______9uz_Ov_v_f__33e8__9v_l_7_-___u_-33d4-_1vf99yfm1-7ftr3tp_87ues2_Xur__59__3z3_NohBgA', + gdprApplies: true + }, + refererInfo: { + referer: 'http://domain.com', + numIframes: 0 + } + } + it('Verify build request', function () { config.setConfig({ 'currency': { @@ -108,7 +142,40 @@ describe('Richaudience adapter tests', function () { } }); + const request = spec.buildRequests(DEFAULT_PARAMS, DEFAULT_PARAMS_GDPR); + + expect(request[0]).to.have.property('method').and.to.equal('POST'); + const requestContent = JSON.parse(request[0].data); + expect(requestContent).to.have.property('sizes'); + expect(requestContent.sizes[0]).to.have.property('w').and.to.equal(300); + expect(requestContent.sizes[0]).to.have.property('h').and.to.equal(250); + expect(requestContent.sizes[1]).to.have.property('w').and.to.equal(300); + expect(requestContent.sizes[1]).to.have.property('h').and.to.equal(600); + expect(requestContent.sizes[2]).to.have.property('w').and.to.equal(728); + expect(requestContent.sizes[2]).to.have.property('h').and.to.equal(90); + expect(requestContent.sizes[3]).to.have.property('w').and.to.equal(970); + expect(requestContent.sizes[3]).to.have.property('h').and.to.equal(250); + }); + + it('Referer undefined', function() { + config.setConfig({ + 'currency': {'adServerCurrency': 'USD'} + }) + const request = spec.buildRequests(DEFAULT_PARAMS, { + gdprConsent: { + consentString: 'BOZcQl_ObPFjWAeABAESCD-AAAAjx7_______9______9uz_Ov_v_f__33e8__9v_l_7_-___u_-33d4-_1vf99yfm1-7ftr3tp_87ues2_Xur__59__3z3_NohBgA', + gdprApplies: true + }, + refererInfo: {} + }) + const requestContent = JSON.parse(request[0].data); + expect(requestContent).to.have.property('referer').and.to.equal(null); + expect(requestContent).to.have.property('referer').and.to.equal(null); + }) + + it('Verify build request to prebid 3.0', function() { + const request = spec.buildRequests(DEFAULT_PARAMS_NEW_SIZES, { gdprConsent: { consentString: 'BOZcQl_ObPFjWAeABAESCD-AAAAjx7_______9______9uz_Ov_v_f__33e8__9v_l_7_-___u_-33d4-_1vf99yfm1-7ftr3tp_87ues2_Xur__59__3z3_NohBgA', gdprApplies: true @@ -131,14 +198,18 @@ describe('Richaudience adapter tests', function () { expect(requestContent).to.have.property('bidderRequestId').and.to.equal('1858b7382993ca'); expect(requestContent).to.have.property('tagId').and.to.equal('test-div'); expect(requestContent).to.have.property('referer').and.to.equal('http%3A%2F%2Fdomain.com'); - expect(requestContent).to.have.property('sizes'); expect(requestContent.sizes[0]).to.have.property('w').and.to.equal(300); expect(requestContent.sizes[0]).to.have.property('h').and.to.equal(250); expect(requestContent.sizes[1]).to.have.property('w').and.to.equal(300); expect(requestContent.sizes[1]).to.have.property('h').and.to.equal(600); + expect(requestContent.sizes[2]).to.have.property('w').and.to.equal(728); + expect(requestContent.sizes[2]).to.have.property('h').and.to.equal(90); + expect(requestContent.sizes[3]).to.have.property('w').and.to.equal(970); + expect(requestContent.sizes[3]).to.have.property('h').and.to.equal(250); expect(requestContent).to.have.property('transactionId').and.to.equal('29df2112-348b-4961-8863-1b33684d95e6'); expect(requestContent).to.have.property('timeout').and.to.equal(3000); - }); + expect(requestContent).to.have.property('numIframes').and.to.equal(0); + }) describe('gdpr test', function () { it('Verify build request with GDPR', function () { @@ -153,31 +224,15 @@ describe('Richaudience adapter tests', function () { } }); - const request = spec.buildRequests(DEFAULT_PARAMS_WO_OPTIONAL, { - gdprConsent: { - consentString: 'BOZcQl_ObPFjWAeABAESCD-AAAAjx7_______9______9uz_Ov_v_f__33e8__9v_l_7_-___u_-33d4-_1vf99yfm1-7ftr3tp_87ues2_Xur__59__3z3_NohBgA', - gdprApplies: true - }, - refererInfo: { - referer: 'http://domain.com', - numIframes: 0 - } - }); + const request = spec.buildRequests(DEFAULT_PARAMS_WO_OPTIONAL, DEFAULT_PARAMS_GDPR); const requestContent = JSON.parse(request[0].data); expect(requestContent).to.have.property('gdpr_consent').and.to.equal('BOZcQl_ObPFjWAeABAESCD-AAAAjx7_______9______9uz_Ov_v_f__33e8__9v_l_7_-___u_-33d4-_1vf99yfm1-7ftr3tp_87ues2_Xur__59__3z3_NohBgA'); }); it('Verify adding ifa when supplyType equal to app', function () { - const request = spec.buildRequests(DEFAULT_PARAMS_APP, { - gdprConsent: { - consentString: 'BOZcQl_ObPFjWAeABAESCD-AAAAjx7_______9______9uz_Ov_v_f__33e8__9v_l_7_-___u_-33d4-_1vf99yfm1-7ftr3tp_87ues2_Xur__59__3z3_NohBgA', - gdprApplies: true - }, - refererInfo: { - referer: 'http://domain.com', - numIframes: 0 - } - }); + const request = spec.buildRequests(DEFAULT_PARAMS_APP, DEFAULT_PARAMS_GDPR); + const requestContent = JSON.parse(request[0].data); + expect(requestContent).to.have.property('gdpr_consent').and.to.equal('BOZcQl_ObPFjWAeABAESCD-AAAAjx7_______9______9uz_Ov_v_f__33e8__9v_l_7_-___u_-33d4-_1vf99yfm1-7ftr3tp_87ues2_Xur__59__3z3_NohBgA'); }); it('Verify build request with GDPR without gdprApplies', function () { @@ -206,6 +261,227 @@ describe('Richaudience adapter tests', function () { }); }); + describe('UID test', function () { + raPBJS.setConfig({ + consentManagement: { + cmpApi: 'iab', + timeout: 5000, + allowAuctionWithoutConsent: true + }, + pubcid: { + enable: false + } + }); + it('Verify build id5', function () { + DEFAULT_PARAMS_WO_OPTIONAL[0].userId = {}; + DEFAULT_PARAMS_WO_OPTIONAL[0].userId.id5id = 'id5-user-id'; + + var request = spec.buildRequests(DEFAULT_PARAMS_WO_OPTIONAL, DEFAULT_PARAMS_GDPR); + var requestContent = JSON.parse(request[0].data); + + expect(requestContent.user).to.deep.equal([{ + 'userId': 'd5-sync.com', + 'source': 'id5-user-id' + }]); + + var request; + DEFAULT_PARAMS_WO_OPTIONAL[0].userId = {}; + DEFAULT_PARAMS_WO_OPTIONAL[0].userId.id5id = 1; + request = spec.buildRequests(DEFAULT_PARAMS_WO_OPTIONAL, DEFAULT_PARAMS_GDPR); + var requestContent = JSON.parse(request[0].data); + + expect(requestContent.user.eids).to.equal(undefined); + + DEFAULT_PARAMS_WO_OPTIONAL[0].userId.id5id = []; + request = spec.buildRequests(DEFAULT_PARAMS_WO_OPTIONAL, DEFAULT_PARAMS_GDPR); + requestContent = JSON.parse(request[0].data); + expect(requestContent.user.eids).to.equal(undefined); + + DEFAULT_PARAMS_WO_OPTIONAL[0].userId.id5id = null; + request = spec.buildRequests(DEFAULT_PARAMS_WO_OPTIONAL, DEFAULT_PARAMS_GDPR); + requestContent = JSON.parse(request[0].data); + expect(requestContent.user.eids).to.equal(undefined); + + DEFAULT_PARAMS_WO_OPTIONAL[0].userId.id5id = {}; + request = spec.buildRequests(DEFAULT_PARAMS_WO_OPTIONAL, DEFAULT_PARAMS_GDPR); + requestContent = JSON.parse(request[0].data); + expect(requestContent.user.eids).to.equal(undefined); + }); + + it('Verify build pubCommonId', function () { + DEFAULT_PARAMS_WO_OPTIONAL[0].userId = {}; + DEFAULT_PARAMS_WO_OPTIONAL[0].userId.pubcid = 'pub_common_user_id'; + + var request = spec.buildRequests(DEFAULT_PARAMS_WO_OPTIONAL, DEFAULT_PARAMS_GDPR); + var requestContent = JSON.parse(request[0].data); + + expect(requestContent.user).to.deep.equal([{ + 'userId': 'pubcommon', + 'source': 'pub_common_user_id' + }]); + + var request; + DEFAULT_PARAMS_WO_OPTIONAL[0].userId = {}; + DEFAULT_PARAMS_WO_OPTIONAL[0].userId.pubcid = 1; + request = spec.buildRequests(DEFAULT_PARAMS_WO_OPTIONAL, DEFAULT_PARAMS_GDPR); + var requestContent = JSON.parse(request[0].data); + expect(requestContent.user.eids).to.equal(undefined); + + DEFAULT_PARAMS_WO_OPTIONAL[0].userId.pubcid = []; + request = spec.buildRequests(DEFAULT_PARAMS_WO_OPTIONAL, DEFAULT_PARAMS_GDPR); + requestContent = JSON.parse(request[0].data); + expect(requestContent.user.eids).to.equal(undefined); + + DEFAULT_PARAMS_WO_OPTIONAL[0].userId.pubcid = null; + request = spec.buildRequests(DEFAULT_PARAMS_WO_OPTIONAL, DEFAULT_PARAMS_GDPR); + requestContent = JSON.parse(request[0].data); + expect(requestContent.user.eids).to.equal(undefined); + + DEFAULT_PARAMS_WO_OPTIONAL[0].userId.pubcid = {}; + request = spec.buildRequests(DEFAULT_PARAMS_WO_OPTIONAL, DEFAULT_PARAMS_GDPR); + requestContent = JSON.parse(request[0].data); + expect(requestContent.user.eids).to.equal(undefined); + }); + + it('Verify build criteoId', function () { + DEFAULT_PARAMS_WO_OPTIONAL[0].userId = {}; + DEFAULT_PARAMS_WO_OPTIONAL[0].userId.criteoId = 'criteo-user-id'; + + var request = spec.buildRequests(DEFAULT_PARAMS_WO_OPTIONAL, DEFAULT_PARAMS_GDPR); + var requestContent = JSON.parse(request[0].data); + + expect(requestContent.user).to.deep.equal([{ + 'userId': 'criteo.com', + 'source': 'criteo-user-id' + }]); + + var request; + DEFAULT_PARAMS_WO_OPTIONAL[0].userId = {}; + DEFAULT_PARAMS_WO_OPTIONAL[0].userId.criteoId = 1; + request = spec.buildRequests(DEFAULT_PARAMS_WO_OPTIONAL, DEFAULT_PARAMS_GDPR); + var requestContent = JSON.parse(request[0].data); + expect(requestContent.user.eids).to.equal(undefined); + + DEFAULT_PARAMS_WO_OPTIONAL[0].userId.criteoId = []; + request = spec.buildRequests(DEFAULT_PARAMS_WO_OPTIONAL, DEFAULT_PARAMS_GDPR); + requestContent = JSON.parse(request[0].data); + expect(requestContent.user.eids).to.equal(undefined); + + DEFAULT_PARAMS_WO_OPTIONAL[0].userId.criteoId = null; + request = spec.buildRequests(DEFAULT_PARAMS_WO_OPTIONAL, DEFAULT_PARAMS_GDPR); + requestContent = JSON.parse(request[0].data); + expect(requestContent.user.eids).to.equal(undefined); + + DEFAULT_PARAMS_WO_OPTIONAL[0].userId.criteoId = {}; + request = spec.buildRequests(DEFAULT_PARAMS_WO_OPTIONAL, DEFAULT_PARAMS_GDPR); + requestContent = JSON.parse(request[0].data); + expect(requestContent.user.eids).to.equal(undefined); + }); + + it('Verify build identityLink', function () { + DEFAULT_PARAMS_WO_OPTIONAL[0].userId = {}; + DEFAULT_PARAMS_WO_OPTIONAL[0].userId.idl_env = 'identity-link-user-id'; + + var request = spec.buildRequests(DEFAULT_PARAMS_WO_OPTIONAL, DEFAULT_PARAMS_GDPR); + var requestContent = JSON.parse(request[0].data); + + expect(requestContent.user).to.deep.equal([{ + 'userId': 'liveramp.com', + 'source': 'identity-link-user-id' + }]); + + var request; + DEFAULT_PARAMS_WO_OPTIONAL[0].userId = {}; + DEFAULT_PARAMS_WO_OPTIONAL[0].userId.idl_env = 1; + request = spec.buildRequests(DEFAULT_PARAMS_WO_OPTIONAL, DEFAULT_PARAMS_GDPR); + var requestContent = JSON.parse(request[0].data); + expect(requestContent.user.eids).to.equal(undefined); + + DEFAULT_PARAMS_WO_OPTIONAL[0].userId.criteoId = []; + request = spec.buildRequests(DEFAULT_PARAMS_WO_OPTIONAL, DEFAULT_PARAMS_GDPR); + requestContent = JSON.parse(request[0].data); + expect(requestContent.user.eids).to.equal(undefined); + + DEFAULT_PARAMS_WO_OPTIONAL[0].userId.idl_env = null; + request = spec.buildRequests(DEFAULT_PARAMS_WO_OPTIONAL, DEFAULT_PARAMS_GDPR); + requestContent = JSON.parse(request[0].data); + expect(requestContent.user.eids).to.equal(undefined); + + DEFAULT_PARAMS_WO_OPTIONAL[0].userId.idl_env = {}; + request = spec.buildRequests(DEFAULT_PARAMS_WO_OPTIONAL, DEFAULT_PARAMS_GDPR); + requestContent = JSON.parse(request[0].data); + expect(requestContent.user.eids).to.equal(undefined); + }); + it('Verify build liveIntentId', function () { + DEFAULT_PARAMS_WO_OPTIONAL[0].userId = {}; + DEFAULT_PARAMS_WO_OPTIONAL[0].userId.idl_env = 'identity-link-user-id'; + + var request = spec.buildRequests(DEFAULT_PARAMS_WO_OPTIONAL, DEFAULT_PARAMS_GDPR); + var requestContent = JSON.parse(request[0].data) + + expect(requestContent.user).to.deep.equal([{ + 'userId': 'liveramp.com', + 'source': 'identity-link-user-id' + }]); + + var request; + DEFAULT_PARAMS_WO_OPTIONAL[0].userId = {}; + DEFAULT_PARAMS_WO_OPTIONAL[0].userId.idl_env = 1; + request = spec.buildRequests(DEFAULT_PARAMS_WO_OPTIONAL, DEFAULT_PARAMS_GDPR); + var requestContent = JSON.parse(request[0].data); + expect(requestContent.user.eids).to.equal(undefined); + + DEFAULT_PARAMS_WO_OPTIONAL[0].userId.criteoId = []; + request = spec.buildRequests(DEFAULT_PARAMS_WO_OPTIONAL, DEFAULT_PARAMS_GDPR); + requestContent = JSON.parse(request[0].data); + expect(requestContent.user.eids).to.equal(undefined); + + DEFAULT_PARAMS_WO_OPTIONAL[0].userId.idl_env = null; + request = spec.buildRequests(DEFAULT_PARAMS_WO_OPTIONAL, DEFAULT_PARAMS_GDPR); + requestContent = JSON.parse(request[0].data); + expect(requestContent.user.eids).to.equal(undefined); + + DEFAULT_PARAMS_WO_OPTIONAL[0].userId.idl_env = {}; + request = spec.buildRequests(DEFAULT_PARAMS_WO_OPTIONAL, DEFAULT_PARAMS_GDPR); + requestContent = JSON.parse(request[0].data); + expect(requestContent.user.eids).to.equal(undefined); + }); + it('Verify build TradeDesk', function () { + DEFAULT_PARAMS_WO_OPTIONAL[0].userId = {}; + DEFAULT_PARAMS_WO_OPTIONAL[0].userId.tdid = 'tdid-user-id'; + + var request = spec.buildRequests(DEFAULT_PARAMS_WO_OPTIONAL, DEFAULT_PARAMS_GDPR); + var requestContent = JSON.parse(request[0].data) + + expect(requestContent.user).to.deep.equal([{ + 'userId': 'adserver.org', + 'source': 'tdid-user-id' + }]); + + request; + DEFAULT_PARAMS_WO_OPTIONAL[0].userId = {}; + DEFAULT_PARAMS_WO_OPTIONAL[0].userId.idl_env = 1; + request = spec.buildRequests(DEFAULT_PARAMS_WO_OPTIONAL, DEFAULT_PARAMS_GDPR); + requestContent = JSON.parse(request[0].data); + expect(requestContent.user.eids).to.equal(undefined); + + DEFAULT_PARAMS_WO_OPTIONAL[0].userId.criteoId = []; + request = spec.buildRequests(DEFAULT_PARAMS_WO_OPTIONAL, DEFAULT_PARAMS_GDPR); + requestContent = JSON.parse(request[0].data); + expect(requestContent.user.eids).to.equal(undefined); + + DEFAULT_PARAMS_WO_OPTIONAL[0].userId.idl_env = null; + request = spec.buildRequests(DEFAULT_PARAMS_WO_OPTIONAL, DEFAULT_PARAMS_GDPR); + requestContent = JSON.parse(request[0].data); + expect(requestContent.user.eids).to.equal(undefined); + + DEFAULT_PARAMS_WO_OPTIONAL[0].userId.idl_env = {}; + request = spec.buildRequests(DEFAULT_PARAMS_WO_OPTIONAL, DEFAULT_PARAMS_GDPR); + requestContent = JSON.parse(request[0].data); + expect(requestContent.user.eids).to.equal(undefined); + }); + }); + it('Verify interprete response', function () { const request = spec.buildRequests(DEFAULT_PARAMS, { gdprConsent: { @@ -343,5 +619,10 @@ describe('Richaudience adapter tests', function () { iframeEnabled: true }, [], {consentString: '', gdprApplies: false}); expect(syncs).to.have.lengthOf(1); + + syncs = spec.getUserSyncs({ + iframeEnabled: false + }, [], {consentString: '', gdprApplies: true}); + expect(syncs).to.have.lengthOf(0); }); }); From 9af593dea7725b67d5dcf7f9b8f7746783e168fb Mon Sep 17 00:00:00 2001 From: Sergi Date: Tue, 26 Nov 2019 17:47:52 +0100 Subject: [PATCH 2/8] Fix bug in richAudienceBidAddapter_spec.js --- test/spec/modules/richaudienceBidAdapter_spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/spec/modules/richaudienceBidAdapter_spec.js b/test/spec/modules/richaudienceBidAdapter_spec.js index 1bc1bd73408..e0e2209215e 100755 --- a/test/spec/modules/richaudienceBidAdapter_spec.js +++ b/test/spec/modules/richaudienceBidAdapter_spec.js @@ -262,7 +262,7 @@ describe('Richaudience adapter tests', function () { }); describe('UID test', function () { - raPBJS.setConfig({ + pbjs.setConfig({ consentManagement: { cmpApi: 'iab', timeout: 5000, From 661effdbf503c76e662a9f948c6e999c418a6a70 Mon Sep 17 00:00:00 2001 From: Sergi Date: Tue, 26 Nov 2019 18:15:52 +0100 Subject: [PATCH 3/8] Fix bug pubCommonId --- test/spec/modules/richaudienceBidAdapter_spec.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/test/spec/modules/richaudienceBidAdapter_spec.js b/test/spec/modules/richaudienceBidAdapter_spec.js index e0e2209215e..601aa335e5f 100755 --- a/test/spec/modules/richaudienceBidAdapter_spec.js +++ b/test/spec/modules/richaudienceBidAdapter_spec.js @@ -267,9 +267,6 @@ describe('Richaudience adapter tests', function () { cmpApi: 'iab', timeout: 5000, allowAuctionWithoutConsent: true - }, - pubcid: { - enable: false } }); it('Verify build id5', function () { From 9bf6381bd78cb9c71a797b2f847b312710d29214 Mon Sep 17 00:00:00 2001 From: Sergi Date: Fri, 29 Nov 2019 14:55:13 +0100 Subject: [PATCH 4/8] Fix bug RichaudienceAdapter --- modules/richaudienceBidAdapter.js | 2 +- test/spec/modules/richaudienceBidAdapter_spec.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/richaudienceBidAdapter.js b/modules/richaudienceBidAdapter.js index dea1722a05b..6761e1f00f8 100755 --- a/modules/richaudienceBidAdapter.js +++ b/modules/richaudienceBidAdapter.js @@ -147,7 +147,7 @@ function raiSetEids(bid) { let eids = []; if (bid && bid.userId) { - raiSetUserId(bid, eids, 'd5-sync.com', utils.deepAccess(bid, `userId.id5id`)); + raiSetUserId(bid, eids, 'id5-sync.com', utils.deepAccess(bid, `userId.id5id`)); raiSetUserId(bid, eids, 'pubcommon', utils.deepAccess(bid, `userId.pubcid`)); raiSetUserId(bid, eids, 'criteo.com', utils.deepAccess(bid, `userId.criteoId`)); raiSetUserId(bid, eids, 'liveramp.com', utils.deepAccess(bid, `userId.idl_env`)); diff --git a/test/spec/modules/richaudienceBidAdapter_spec.js b/test/spec/modules/richaudienceBidAdapter_spec.js index 601aa335e5f..467124224f4 100755 --- a/test/spec/modules/richaudienceBidAdapter_spec.js +++ b/test/spec/modules/richaudienceBidAdapter_spec.js @@ -277,7 +277,7 @@ describe('Richaudience adapter tests', function () { var requestContent = JSON.parse(request[0].data); expect(requestContent.user).to.deep.equal([{ - 'userId': 'd5-sync.com', + 'userId': 'id5-sync.com', 'source': 'id5-user-id' }]); From ca1728a0c9b7ee9191745825f01a80b27930ce77 Mon Sep 17 00:00:00 2001 From: Sergi Date: Mon, 2 Dec 2019 15:38:21 +0100 Subject: [PATCH 5/8] Fix UserID5 --- modules/richaudienceBidAdapter.js | 0 test/spec/modules/richaudienceBidAdapter_spec.js | 0 2 files changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 modules/richaudienceBidAdapter.js mode change 100755 => 100644 test/spec/modules/richaudienceBidAdapter_spec.js diff --git a/modules/richaudienceBidAdapter.js b/modules/richaudienceBidAdapter.js old mode 100755 new mode 100644 diff --git a/test/spec/modules/richaudienceBidAdapter_spec.js b/test/spec/modules/richaudienceBidAdapter_spec.js old mode 100755 new mode 100644 From 5774bf8dd9274258d719c0cf9c67b15aa312a4a7 Mon Sep 17 00:00:00 2001 From: Sergi Date: Tue, 3 Dec 2019 10:04:55 +0100 Subject: [PATCH 6/8] Fix bug ID5 change Source for Value --- modules/richaudienceBidAdapter.js | 4 ++-- .../modules/richaudienceBidAdapter_spec.js | 24 +++++++++---------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/modules/richaudienceBidAdapter.js b/modules/richaudienceBidAdapter.js index 6761e1f00f8..c53d5396d08 100644 --- a/modules/richaudienceBidAdapter.js +++ b/modules/richaudienceBidAdapter.js @@ -161,8 +161,8 @@ function raiSetEids(bid) { function raiSetUserId(bid, eids, source, value, userId) { if (utils.isStr(value)) { eids.push({ - userId: source, - source: value + userId: value, + source }); } } diff --git a/test/spec/modules/richaudienceBidAdapter_spec.js b/test/spec/modules/richaudienceBidAdapter_spec.js index 467124224f4..884984b2b6a 100644 --- a/test/spec/modules/richaudienceBidAdapter_spec.js +++ b/test/spec/modules/richaudienceBidAdapter_spec.js @@ -277,8 +277,8 @@ describe('Richaudience adapter tests', function () { var requestContent = JSON.parse(request[0].data); expect(requestContent.user).to.deep.equal([{ - 'userId': 'id5-sync.com', - 'source': 'id5-user-id' + 'userId': 'id5-user-id', + 'source': 'id5-sync.com' }]); var request; @@ -313,8 +313,8 @@ describe('Richaudience adapter tests', function () { var requestContent = JSON.parse(request[0].data); expect(requestContent.user).to.deep.equal([{ - 'userId': 'pubcommon', - 'source': 'pub_common_user_id' + 'userId': 'pub_common_user_id', + 'source': 'pubcommon' }]); var request; @@ -348,8 +348,8 @@ describe('Richaudience adapter tests', function () { var requestContent = JSON.parse(request[0].data); expect(requestContent.user).to.deep.equal([{ - 'userId': 'criteo.com', - 'source': 'criteo-user-id' + 'userId': 'criteo-user-id', + 'source': 'criteo.com' }]); var request; @@ -383,8 +383,8 @@ describe('Richaudience adapter tests', function () { var requestContent = JSON.parse(request[0].data); expect(requestContent.user).to.deep.equal([{ - 'userId': 'liveramp.com', - 'source': 'identity-link-user-id' + 'userId': 'identity-link-user-id', + 'source': 'liveramp.com' }]); var request; @@ -417,8 +417,8 @@ describe('Richaudience adapter tests', function () { var requestContent = JSON.parse(request[0].data) expect(requestContent.user).to.deep.equal([{ - 'userId': 'liveramp.com', - 'source': 'identity-link-user-id' + 'userId': 'identity-link-user-id', + 'source': 'liveramp.com' }]); var request; @@ -451,8 +451,8 @@ describe('Richaudience adapter tests', function () { var requestContent = JSON.parse(request[0].data) expect(requestContent.user).to.deep.equal([{ - 'userId': 'adserver.org', - 'source': 'tdid-user-id' + 'userId': 'tdid-user-id', + 'source': 'adserver.org' }]); request; From 0378054ed4ee0be0cbacfedfd23d41445a49a1be Mon Sep 17 00:00:00 2001 From: Sergi Date: Thu, 5 Dec 2019 18:34:24 +0100 Subject: [PATCH 7/8] Fix bug richaudienceAdapter && Add userSync pixelEnabled --- modules/richaudienceBidAdapter.js | 14 +++++++-- .../modules/richaudienceBidAdapter_spec.js | 29 +++++++++++++++++++ 2 files changed, 40 insertions(+), 3 deletions(-) mode change 100644 => 100755 modules/richaudienceBidAdapter.js diff --git a/modules/richaudienceBidAdapter.js b/modules/richaudienceBidAdapter.js old mode 100644 new mode 100755 index c53d5396d08..0d03871978e --- a/modules/richaudienceBidAdapter.js +++ b/modules/richaudienceBidAdapter.js @@ -4,6 +4,7 @@ import {BANNER, VIDEO} from '../src/mediaTypes'; import * as utils from '../src/utils'; const BIDDER_CODE = 'richaudience'; +let REFERER = ''; export const spec = { code: BIDDER_CODE, @@ -47,6 +48,8 @@ export const spec = { user: raiSetEids(bid) }; + REFERER = (typeof bidderRequest.refererInfo.referer != 'undefined' ? encodeURIComponent(bidderRequest.refererInfo.referer) : null) + payload.gdpr_consent = ''; payload.gdpr = null; @@ -121,6 +124,11 @@ export const spec = { type: 'iframe', url: syncUrl }); + }else if (syncOptions.pixelEnabled && REFERER != null) { + syncs.push({ + type: 'image', + url: `https://sync.richaudience.com/bf7c142f4339da0278e83698a02b0854/?euconsent=${gdprConsent.consentString}&referrer=${REFERER}` + }); } return syncs }, @@ -152,17 +160,17 @@ function raiSetEids(bid) { raiSetUserId(bid, eids, 'criteo.com', utils.deepAccess(bid, `userId.criteoId`)); raiSetUserId(bid, eids, 'liveramp.com', utils.deepAccess(bid, `userId.idl_env`)); raiSetUserId(bid, eids, 'liveintent.com', utils.deepAccess(bid, `userId.lipb.lipbid`)); - raiSetUserId(bid, eids, 'adserver.org', utils.deepAccess(bid, `userId.tdid`)) + raiSetUserId(bid, eids, 'adserver.org', utils.deepAccess(bid, `userId.tdid`)); } return eids; } -function raiSetUserId(bid, eids, source, value, userId) { +function raiSetUserId(bid, eids, source, value) { if (utils.isStr(value)) { eids.push({ userId: value, - source + source: source }); } } diff --git a/test/spec/modules/richaudienceBidAdapter_spec.js b/test/spec/modules/richaudienceBidAdapter_spec.js index 884984b2b6a..6c7030676c7 100644 --- a/test/spec/modules/richaudienceBidAdapter_spec.js +++ b/test/spec/modules/richaudienceBidAdapter_spec.js @@ -621,5 +621,34 @@ describe('Richaudience adapter tests', function () { iframeEnabled: false }, [], {consentString: '', gdprApplies: true}); expect(syncs).to.have.lengthOf(0); + + pbjs.setConfig({ + consentManagement: { + cmpApi: 'iab', + timeout: 5000, + allowAuctionWithoutConsent: true, + pixelEnabled: true + } + }); + + syncs = spec.getUserSyncs({ + pixelEnabled: true + }, [], { + consentString: 'BOZcQl_ObPFjWAeABAESCD-AAAAjx7_______9______9uz_Ov_v_f__33e8__9v_l_7_-___u_-33d4-_1vf99yfm1-7ftr3tp_87ues2_Xur__59__3z3_NohBgA', + referer: 'http://domain.com', + gdprApplies: true + }) + expect(syncs).to.have.lengthOf(1); + expect(syncs[0].type).to.equal('image'); + + syncs = spec.getUserSyncs({ + pixelEnabled: true + }, [], { + consentString: '', + referer: 'http://domain.com', + gdprApplies: true + }) + expect(syncs).to.have.lengthOf(1); + expect(syncs[0].type).to.equal('image'); }); }); From 378be244696dae1c5682056b3548fad45f4aeda6 Mon Sep 17 00:00:00 2001 From: Sergi Date: Thu, 5 Dec 2019 18:41:21 +0100 Subject: [PATCH 8/8] Fix bug richaudienceAdapter --- modules/richaudienceBidAdapter.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/richaudienceBidAdapter.js b/modules/richaudienceBidAdapter.js index 0d03871978e..2a4fa03c7d6 100755 --- a/modules/richaudienceBidAdapter.js +++ b/modules/richaudienceBidAdapter.js @@ -124,7 +124,7 @@ export const spec = { type: 'iframe', url: syncUrl }); - }else if (syncOptions.pixelEnabled && REFERER != null) { + } else if (syncOptions.pixelEnabled && REFERER != null) { syncs.push({ type: 'image', url: `https://sync.richaudience.com/bf7c142f4339da0278e83698a02b0854/?euconsent=${gdprConsent.consentString}&referrer=${REFERER}`