From 877483da743c7db6a483085e4c69d1d3e0238d73 Mon Sep 17 00:00:00 2001 From: Yoko OYAMA Date: Mon, 7 Feb 2022 18:42:16 +0900 Subject: [PATCH] collect user.eids --- modules/fluctBidAdapter.js | 19 ++++- test/spec/modules/fluctBidAdapter_spec.js | 92 +++++++++++++++++++++++ 2 files changed, 110 insertions(+), 1 deletion(-) diff --git a/modules/fluctBidAdapter.js b/modules/fluctBidAdapter.js index 5b4434ea109..44b9f3bf217 100644 --- a/modules/fluctBidAdapter.js +++ b/modules/fluctBidAdapter.js @@ -7,6 +7,16 @@ const VERSION = '1.2'; const NET_REVENUE = true; const TTL = 300; +/** + * See modules/userId/eids.js for supported sources + */ +const SUPPORTED_USER_ID_SOURCES = [ + 'adserver.org', + 'criteo.com', + 'intimatemerger.com', + 'liveramp.com', +]; + export const spec = { code: BIDDER_CODE, aliases: ['adingo'], @@ -38,6 +48,9 @@ export const spec = { data.adUnitCode = request.adUnitCode; data.bidId = request.bidId; data.transactionId = request.transactionId; + data.user = { + eids: (request.userIdAsEids || []).filter((eid) => SUPPORTED_USER_ID_SOURCES.indexOf(eid.source) !== -1) + }; data.sizes = []; _each(request.sizes, (size) => { @@ -48,7 +61,11 @@ export const spec = { }); data.params = request.params; - const searchParams = new URLSearchParams(request.params); + const searchParams = new URLSearchParams({ + dfpUnitCode: request.params.dfpUnitCode, + tagId: request.params.tagId, + groupId: request.params.groupId, + }); serverRequests.push({ method: 'POST', diff --git a/test/spec/modules/fluctBidAdapter_spec.js b/test/spec/modules/fluctBidAdapter_spec.js index 70666532442..8ef99727ce7 100644 --- a/test/spec/modules/fluctBidAdapter_spec.js +++ b/test/spec/modules/fluctBidAdapter_spec.js @@ -83,6 +83,98 @@ describe('fluctAdapter', function () { const request = spec.buildRequests(bidRequests, bidderRequest)[0]; expect(request.url).to.equal('https://hb.adingo.jp/prebid?dfpUnitCode=%2F100000%2Funit_code&tagId=10000%3A100000001&groupId=1000000002'); }); + + it('includes data.user.eids = [] by default', function () { + const request = spec.buildRequests(bidRequests, bidderRequest)[0]; + expect(request.data.user.eids).to.eql([]); + }); + + it('includes no data.params.kv by default', function () { + const request = spec.buildRequests(bidRequests, bidderRequest)[0]; + expect(request.data.params.kv).to.eql(undefined); + }); + + it('includes filtered user.eids if any exists', function () { + const bidRequests2 = bidRequests.map( + (bidReq) => Object.assign(bidReq, { + userIdAsEids: [ + { + source: 'foobar.com', + uids: [ + { id: 'foobar-id' } + ], + }, + { + source: 'adserver.org', + uids: [ + { id: 'tdid' } + ], + }, + { + source: 'criteo.com', + uids: [ + { id: 'criteo-id' } + ], + }, + { + source: 'intimatemerger.com', + uids: [ + { id: 'imuid' } + ], + }, + { + source: 'liveramp.com', + uids: [ + { id: 'idl-env' } + ], + }, + ], + }) + ); + const request = spec.buildRequests(bidRequests2, bidderRequest)[0]; + expect(request.data.user.eids).to.eql([ + { + source: 'adserver.org', + uids: [ + { id: 'tdid' } + ], + }, + { + source: 'criteo.com', + uids: [ + { id: 'criteo-id' } + ], + }, + { + source: 'intimatemerger.com', + uids: [ + { id: 'imuid' } + ], + }, + { + source: 'liveramp.com', + uids: [ + { id: 'idl-env' } + ], + }, + ]); + }); + + it('includes data.params.kv if any exists', function () { + const bidRequests2 = bidRequests.map( + (bidReq) => Object.assign(bidReq, { + params: { + kv: { + imsids: ['imsid1', 'imsid2'] + } + } + }) + ); + const request = spec.buildRequests(bidRequests2, bidderRequest)[0]; + expect(request.data.params.kv).to.eql({ + imsids: ['imsid1', 'imsid2'] + }); + }); }); describe('interpretResponse', function() {