Skip to content

Commit

Permalink
AOL Adapter: User ID Support (#5886)
Browse files Browse the repository at this point in the history
* Added support for passing VMUID to SSP endpoints

* Remove 'only' command

* Do not create user.ext object unless required

* Add support for passing Liveramp envelope to VM SSP

* WIP

* Updated tests

* Remove trailing comma

Co-authored-by: slimkrazy <[email protected]>
  • Loading branch information
slimkrazy and slimkrazy authored Oct 23, 2020
1 parent 22677c1 commit da480f2
Show file tree
Hide file tree
Showing 2 changed files with 90 additions and 1 deletion.
34 changes: 34 additions & 0 deletions modules/aolBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,17 @@ const SYNC_TYPES = {
}
};

const SUPPORTED_USER_ID_SOURCES = [
'adserver.org',
'criteo.com',
'id5-sync.com',
'intentiq.com',
'liveintent.com',
'quantcast.com',
'verizonmedia.com',
'liveramp.com'
];

const pubapiTemplate = template`${'host'}/pubapi/3.0/${'network'}/${'placement'}/${'pageid'}/${'sizeid'}/ADTECH;v=2;cmd=bid;cors=yes;alias=${'alias'};misc=${'misc'};${'dynamicParams'}`;
const nexageBaseApiTemplate = template`${'host'}/bidRequest?`;
const nexageGetApiTemplate = template`dcn=${'dcn'}&pos=${'pos'}&cmd=bid${'dynamicParams'}`;
Expand Down Expand Up @@ -103,6 +114,12 @@ function resolveEndpointCode(bid) {
}
}

function getSupportedEids(bid) {
return bid.userIdAsEids.filter(eid => {
return SUPPORTED_USER_ID_SOURCES.includes(eid.source)
});
}

export const spec = {
code: AOL_BIDDERS_CODES.AOL,
gvlid: 25,
Expand Down Expand Up @@ -226,6 +243,13 @@ export const spec = {
},
buildOneMobileGetUrl(bid, consentData) {
let { dcn, pos, ext } = bid.params;
if (typeof bid.userId === 'object') {
ext = ext || {};
let eids = getSupportedEids(bid);
eids.forEach(eid => {
ext['eid' + eid.source] = eid.uids[0].id;
});
}
let nexageApi = this.buildOneMobileBaseUrl(bid);
if (dcn && pos) {
let dynamicParams = this.formatOneMobileDynamicParams(ext, consentData);
Expand Down Expand Up @@ -292,6 +316,16 @@ export const spec = {
utils.deepSetValue(openRtbObject, 'regs.ext.us_privacy', consentData.uspConsent);
}

if (typeof bid.userId === 'object') {
openRtbObject.user = openRtbObject.user || {};
openRtbObject.user.ext = openRtbObject.user.ext || {};

let eids = getSupportedEids(bid);
if (eids.length > 0) {
openRtbObject.user.ext.eids = eids
}
}

return openRtbObject;
},
isEUConsentRequired(consentData) {
Expand Down
57 changes: 56 additions & 1 deletion test/spec/modules/aolBidAdapter_spec.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {expect} from 'chai';
import * as utils from 'src/utils.js';
import {spec} from 'modules/aolBidAdapter.js';
import {config} from 'src/config.js';
import {createEidsArray} from '../../../modules/userId/eids.js';

const DEFAULT_AD_CONTENT = '<script>logInfo(\'ad\');</script>';

Expand Down Expand Up @@ -80,6 +80,33 @@ describe('AolAdapter', function () {
const NEXAGE_URL = 'https://c2shb.ssp.yahoo.com/bidRequest?';
const ONE_DISPLAY_TTL = 60;
const ONE_MOBILE_TTL = 3600;
const SUPPORTED_USER_ID_SOURCES = {
'adserver.org': '100',
'criteo.com': '200',
'id5-sync.com': '300',
'intentiq.com': '400',
'liveintent.com': '500',
'quantcast.com': '600',
'verizonmedia.com': '700',
'liveramp.com': '800'
};

const USER_ID_DATA = {
criteoId: SUPPORTED_USER_ID_SOURCES['criteo.com'],
vmuid: SUPPORTED_USER_ID_SOURCES['verizonmedia.com'],
idl_env: SUPPORTED_USER_ID_SOURCES['liveramp.com'],
lipb: {
lipbid: SUPPORTED_USER_ID_SOURCES['liveintent.com'],
segments: ['100', '200']
},
tdid: SUPPORTED_USER_ID_SOURCES['adserver.org'],
id5id: {
uid: SUPPORTED_USER_ID_SOURCES['id5-sync.com'],
ext: {foo: 'bar'}
},
intentIqId: SUPPORTED_USER_ID_SOURCES['intentiq.com'],
quantcastId: SUPPORTED_USER_ID_SOURCES['quantcast.com']
};

function createCustomBidRequest({bids, params} = {}) {
var bidderRequest = getDefaultBidRequest();
Expand Down Expand Up @@ -463,6 +490,18 @@ describe('AolAdapter', function () {
'&param1=val1&param2=val2&param3=val3&param4=val4');
});

for (const [source, idValue] of Object.entries(SUPPORTED_USER_ID_SOURCES)) {
it(`should set the user ID query param for ${source}`, function () {
let bidRequest = createCustomBidRequest({
params: getNexageGetBidParams()
});
bidRequest.bids[0].userId = {};
bidRequest.bids[0].userIdAsEids = createEidsArray(USER_ID_DATA);
let [request] = spec.buildRequests(bidRequest.bids);
expect(request.url).to.contain(`&eid${source}=${encodeURIComponent(idValue)}`);
});
}

it('should return request object for One Mobile POST endpoint when POST configuration is present', function () {
let bidConfig = getNexagePostBidParams();
let bidRequest = createCustomBidRequest({
Expand Down Expand Up @@ -581,6 +620,22 @@ describe('AolAdapter', function () {
}
});
});

it('returns the bid object with eid array populated with PB set eids', () => {
let userIdBid = Object.assign({
userId: {}
}, bid);
userIdBid.userIdAsEids = createEidsArray(USER_ID_DATA);
expect(spec.buildOpenRtbRequestData(userIdBid)).to.deep.equal({
id: 'bid-id',
imp: [],
user: {
ext: {
eids: userIdBid.userIdAsEids
}
}
});
});
});

describe('getUserSyncs()', function () {
Expand Down

0 comments on commit da480f2

Please sign in to comment.