Skip to content

Commit

Permalink
add halo id support to beachfront adapter (#7225)
Browse files Browse the repository at this point in the history
Co-authored-by: John Salis <john@beachfront.com>
  • Loading branch information
jsalis and John Salis authored Jul 28, 2021
1 parent 3bbcf66 commit e130657
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 81 deletions.
23 changes: 14 additions & 9 deletions modules/beachfrontBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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 = '';
Expand Down Expand Up @@ -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]
};
}

Expand Down
128 changes: 56 additions & 72 deletions test/spec/modules/beachfrontBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}]
}
]);
});
});

Expand Down Expand Up @@ -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);
});
});

Expand Down

0 comments on commit e130657

Please sign in to comment.