From 6b2e7a6ecabb32950dd7cbfa8e9620788b38792a Mon Sep 17 00:00:00 2001 From: John Salis Date: Tue, 27 Jul 2021 15:37:18 -0400 Subject: [PATCH] add halo id support to beachfront adapter --- modules/beachfrontBidAdapter.js | 23 ++-- .../spec/modules/beachfrontBidAdapter_spec.js | 128 ++++++++---------- 2 files changed, 70 insertions(+), 81 deletions(-) diff --git a/modules/beachfrontBidAdapter.js b/modules/beachfrontBidAdapter.js index 1bff77f29ce..d633359eb8e 100644 --- a/modules/beachfrontBidAdapter.js +++ b/modules/beachfrontBidAdapter.js @@ -6,7 +6,7 @@ import { VIDEO, BANNER } from '../src/mediaTypes.js'; import find from 'core-js-pure/features/array/find.js'; import includes from 'core-js-pure/features/array/includes.js'; -const ADAPTER_VERSION = '1.16'; +const ADAPTER_VERSION = '1.17'; const ADAPTER_NAME = 'BFIO_PREBID'; const OUTSTREAM = 'outstream'; const CURRENCY = 'USD'; @@ -21,7 +21,8 @@ export const DEFAULT_MIMES = ['video/mp4', 'application/javascript']; export const SUPPORTED_USER_IDS = [ { key: 'tdid', source: 'adserver.org', rtiPartner: 'TDID', queryParam: 'tdid' }, { key: 'idl_env', source: 'liveramp.com', rtiPartner: 'idl', queryParam: 'idl' }, - { key: 'uid2.id', source: 'uidapi.com', rtiPartner: 'UID2', queryParam: 'uid2' } + { key: 'uid2.id', source: 'uidapi.com', rtiPartner: 'UID2', queryParam: 'uid2' }, + { key: 'haloId', source: 'audigent.com', atype: 1, queryParam: 'haloid' } ]; let appId = ''; @@ -294,19 +295,23 @@ function getEids(bid) { } function getUserId(bid) { - return ({ key, source, rtiPartner }) => { + return ({ key, source, rtiPartner, atype }) => { let id = utils.deepAccess(bid, `userId.${key}`); - return id ? formatEid(id, source, rtiPartner) : null; + return id ? formatEid(id, source, rtiPartner, atype) : null; }; } -function formatEid(id, source, rtiPartner) { +function formatEid(id, source, rtiPartner, atype) { + let uid = { id }; + if (rtiPartner) { + uid.ext = { rtiPartner }; + } + if (atype) { + uid.atype = atype; + } return { source, - uids: [{ - id, - ext: { rtiPartner } - }] + uids: [uid] }; } diff --git a/test/spec/modules/beachfrontBidAdapter_spec.js b/test/spec/modules/beachfrontBidAdapter_spec.js index 555f2c21262..e29994eba44 100644 --- a/test/spec/modules/beachfrontBidAdapter_spec.js +++ b/test/spec/modules/beachfrontBidAdapter_spec.js @@ -316,58 +316,54 @@ describe('BeachfrontAdapter', function () { expect(data.source.ext.schain).to.deep.equal(schain); }); - it('must add the Trade Desk User ID to the request', () => { - const tdid = '4321'; - const bidRequest = bidRequests[0]; - bidRequest.mediaTypes = { video: {} }; - bidRequest.userId = { tdid }; - const requests = spec.buildRequests([ bidRequest ]); - const data = requests[0].data; - expect(data.user.ext.eids[0]).to.deep.equal({ - source: 'adserver.org', - uids: [{ - id: tdid, - ext: { - rtiPartner: 'TDID' - } - }] - }); - }); - - it('must add the IdentityLink ID to the request', () => { - const idl_env = '4321'; - const bidRequest = bidRequests[0]; - bidRequest.mediaTypes = { video: {} }; - bidRequest.userId = { idl_env }; - const requests = spec.buildRequests([ bidRequest ]); - const data = requests[0].data; - expect(data.user.ext.eids[0]).to.deep.equal({ - source: 'liveramp.com', - uids: [{ - id: idl_env, - ext: { - rtiPartner: 'idl' - } - }] - }); - }); - - it('must add the Unified ID 2.0 to the request', () => { - const uid2 = { id: '4321' }; + it('must add supported user IDs to the request', () => { + const userId = { + tdid: '54017816', + idl_env: '13024996', + uid2: { id: '45843401' }, + haloId: { haloId: '60314917', auSeg: ['segment1', 'segment2'] } + }; const bidRequest = bidRequests[0]; bidRequest.mediaTypes = { video: {} }; - bidRequest.userId = { uid2 }; + bidRequest.userId = userId; const requests = spec.buildRequests([ bidRequest ]); const data = requests[0].data; - expect(data.user.ext.eids[0]).to.deep.equal({ - source: 'uidapi.com', - uids: [{ - id: uid2.id, - ext: { - rtiPartner: 'UID2' - } - }] - }); + expect(data.user.ext.eids).to.deep.equal([ + { + source: 'adserver.org', + uids: [{ + id: userId.tdid, + ext: { + rtiPartner: 'TDID' + } + }] + }, + { + source: 'liveramp.com', + uids: [{ + id: userId.idl_env, + ext: { + rtiPartner: 'idl' + } + }] + }, + { + source: 'uidapi.com', + uids: [{ + id: userId.uid2.id, + ext: { + rtiPartner: 'UID2' + } + }] + }, + { + source: 'audigent.com', + uids: [{ + id: userId.haloId, + atype: 1, + }] + } + ]); }); }); @@ -541,34 +537,22 @@ describe('BeachfrontAdapter', function () { expect(data.schain).to.deep.equal(schain); }); - it('must add the Trade Desk User ID to the request', () => { - const tdid = '4321'; - const bidRequest = bidRequests[0]; - bidRequest.mediaTypes = { banner: {} }; - bidRequest.userId = { tdid }; - const requests = spec.buildRequests([ bidRequest ]); - const data = requests[0].data; - expect(data.tdid).to.equal(tdid); - }); - - it('must add the IdentityLink ID to the request', () => { - const idl_env = '4321'; - const bidRequest = bidRequests[0]; - bidRequest.mediaTypes = { banner: {} }; - bidRequest.userId = { idl_env }; - const requests = spec.buildRequests([ bidRequest ]); - const data = requests[0].data; - expect(data.idl).to.equal(idl_env); - }); - - it('must add the Unified ID 2.0 to the request', () => { - const uid2 = { id: '4321' }; + it('must add supported user IDs to the request', () => { + const userId = { + tdid: '54017816', + idl_env: '13024996', + uid2: { id: '45843401' }, + haloId: { haloId: '60314917', auSeg: ['segment1', 'segment2'] } + }; const bidRequest = bidRequests[0]; bidRequest.mediaTypes = { banner: {} }; - bidRequest.userId = { uid2 }; + bidRequest.userId = userId; const requests = spec.buildRequests([ bidRequest ]); const data = requests[0].data; - expect(data.uid2).to.equal(uid2.id); + expect(data.tdid).to.equal(userId.tdid); + expect(data.idl).to.equal(userId.idl_env); + expect(data.uid2).to.equal(userId.uid2.id); + expect(data.haloid).to.equal(userId.haloId); }); });