Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Beachfront Bid Adapter: add Halo ID support #7225

Merged
merged 1 commit into from
Jul 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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