From 4b1fece773441c9b17b22202e0b3fd7800ee64d3 Mon Sep 17 00:00:00 2001 From: azuryo <108641852+azuryo@users.noreply.github.com> Date: Tue, 26 Jul 2022 00:19:58 +0900 Subject: [PATCH] Miocroad Bid Adapter: Added Support for Audience IDs (#8662) * Microad Bid Adapter: Add IM-UID * Microad Bid Adapter: Add ID5 ID * Microad Bid Adapter: Add Unified ID * Microad Bid Adapter: Add Novatiq Hyper ID * Microad Bid Adapter: Add Parrable ID * Microad Bid Adapter: Add AudienceOne User ID * Microad BidAdapter: Add Audience ID spec * Microad BidAdapter: Add Ramp ID in params * Microad BidAdapter: Fix Audience ID * Microad BidAdapter: Add Criteo ID and Shared ID * Microad BidAdapter: Fix typo * Microad BidAdapter: Fix variable name --- modules/microadBidAdapter.js | 26 +++++++- test/spec/modules/microadBidAdapter_spec.js | 71 +++++++++++++++------ 2 files changed, 76 insertions(+), 21 deletions(-) diff --git a/modules/microadBidAdapter.js b/modules/microadBidAdapter.js index 77710584f41..d5116b1dcb0 100644 --- a/modules/microadBidAdapter.js +++ b/modules/microadBidAdapter.js @@ -22,6 +22,18 @@ const BANNER_CODE = 1; const NATIVE_CODE = 2; const VIDEO_CODE = 4; +const AUDIENCE_IDS = [ + {type: 6, bidKey: 'userId.imuid'}, + {type: 8, bidKey: 'userId.id5id.uid'}, + {type: 9, bidKey: 'userId.tdid'}, + {type: 10, bidKey: 'userId.novatiq.snowflake'}, + {type: 11, bidKey: 'userId.parrableId.eid'}, + {type: 12, bidKey: 'userId.dacId.id'}, + {type: 13, bidKey: 'userId.idl_env'}, + {type: 14, bidKey: 'userId.criteoId'}, + {type: 15, bidKey: 'userId.pubcid'} +] + function createCBT() { const randomValue = Math.floor(Math.random() * Math.pow(10, 18)).toString(16); const date = new Date().getTime().toString(16); @@ -83,9 +95,17 @@ export const spec = { } } - const idlEnv = deepAccess(bid, 'userId.idl_env') - if (!isEmpty(idlEnv) && isStr(idlEnv)) { - params['idl_env'] = idlEnv + const aidsParams = [] + AUDIENCE_IDS.forEach((audienceId) => { + const bidAudienceId = deepAccess(bid, audienceId.bidKey); + if (!isEmpty(bidAudienceId) && isStr(bidAudienceId)) { + aidsParams.push({ type: audienceId.type, id: bidAudienceId }); + // Set Ramp ID + if (audienceId.type === 13) params['idl_env'] = bidAudienceId; + } + }) + if (aidsParams.length > 0) { + params['aids'] = JSON.stringify(aidsParams) } requests.push({ diff --git a/test/spec/modules/microadBidAdapter_spec.js b/test/spec/modules/microadBidAdapter_spec.js index ff0b705594b..cca337c83f2 100644 --- a/test/spec/modules/microadBidAdapter_spec.js +++ b/test/spec/modules/microadBidAdapter_spec.js @@ -266,35 +266,70 @@ describe('microadBidAdapter', () => { }); }); - it('should add Liveramp identity link if it is available in request parameters', () => { - const bidRequestWithLiveramp = Object.assign({}, bidRequestTemplate, { - userId: {idl_env: 'idl-env-sample'} + it('should not add Liveramp identity link and Audience ID if it is not available in request parameters', () => { + const bidRequestWithOutLiveramp = Object.assign({}, bidRequestTemplate, { + userId: {} }); - const requests = spec.buildRequests([bidRequestWithLiveramp], bidderRequest) + const requests = spec.buildRequests([bidRequestWithOutLiveramp], bidderRequest) requests.forEach(request => { expect(request.data).to.deep.equal( Object.assign({}, expectedResultTemplate, { - cbt: request.data.cbt, - idl_env: 'idl-env-sample' + cbt: request.data.cbt }) ); }) }); - it('should not add Liveramp identity link if it is not available in request parameters', () => { - const bidRequestWithLiveramp = Object.assign({}, bidRequestTemplate, { - userId: {} - }); - const requests = spec.buildRequests([bidRequestWithLiveramp], bidderRequest) - const expectedResult = Object.assign({}, expectedResultTemplate) - requests.forEach(request => { - expect(request.data).to.deep.equal( - Object.assign({}, expectedResultTemplate, { - cbt: request.data.cbt + Object.entries({ + 'IM-UID': { + userId: {imuid: 'imuid-sample'}, + expected: {aids: JSON.stringify([{type: 6, id: 'imuid-sample'}])} + }, + 'ID5 ID': { + userId: {id5id: {uid: 'id5id-sample'}}, + expected: {aids: JSON.stringify([{type: 8, id: 'id5id-sample'}])} + }, + 'Unified ID': { + userId: {tdid: 'unified-sample'}, + expected: {aids: JSON.stringify([{type: 9, id: 'unified-sample'}])} + }, + 'Novatiq Snowflake ID': { + userId: {novatiq: {snowflake: 'novatiq-sample'}}, + expected: {aids: JSON.stringify([{type: 10, id: 'novatiq-sample'}])} + }, + 'Parrable ID': { + userId: {parrableId: {eid: 'parrable-sample'}}, + expected: {aids: JSON.stringify([{type: 11, id: 'parrable-sample'}])} + }, + 'AudienceOne User ID': { + userId: {dacId: {id: 'audience-one-sample'}}, + expected: {aids: JSON.stringify([{type: 12, id: 'audience-one-sample'}])} + }, + 'Ramp ID and Liveramp identity': { + userId: {idl_env: 'idl-env-sample'}, + expected: {idl_env: 'idl-env-sample', aids: JSON.stringify([{type: 13, id: 'idl-env-sample'}])} + }, + 'Criteo ID': { + userId: {criteoId: 'criteo-id-sample'}, + expected: {aids: JSON.stringify([{type: 14, id: 'criteo-id-sample'}])} + }, + 'Shared ID': { + userId: {pubcid: 'shared-id-sample'}, + expected: {aids: JSON.stringify([{type: 15, id: 'shared-id-sample'}])} + } + }).forEach(([test, arg]) => { + it(`should add ${test} if it is available in request parameters`, () => { + const bidRequestWithUserId = { ...bidRequestTemplate, userId: arg.userId } + const requests = spec.buildRequests([bidRequestWithUserId], bidderRequest) + requests.forEach((request) => { + expect(request.data).to.deep.equal({ + ...expectedResultTemplate, + cbt: request.data.cbt, + ...arg.expected }) - ); + }) }) - }); + }) }); describe('interpretResponse', () => {