Skip to content

Commit

Permalink
Miocroad Bid Adapter: Added Support for Audience IDs (prebid#8662)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
azuma-ryotaro authored and Chris Corbo committed Jul 27, 2022
1 parent 4d6e2ef commit 4b1fece
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 21 deletions.
26 changes: 23 additions & 3 deletions modules/microadBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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({
Expand Down
71 changes: 53 additions & 18 deletions test/spec/modules/microadBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down

0 comments on commit 4b1fece

Please sign in to comment.