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

Adgeneration Bid Adpter: add Criteo system and ID5 system and update test. #8642

Merged
merged 7 commits into from
Jul 11, 2022
25 changes: 24 additions & 1 deletion modules/adgenerationBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,16 @@ export const spec = {
* @return ServerRequest Info describing the request to the server.
*/
buildRequests: function (validBidRequests, bidderRequest) {
const ADGENE_PREBID_VERSION = '1.3.0';
const ADGENE_PREBID_VERSION = '1.4.0';
let serverRequests = [];
for (let i = 0, len = validBidRequests.length; i < len; i++) {
const validReq = validBidRequests[i];
const DEBUG_URL = 'https://api-test.scaleout.jp/adsv/v1';
const URL = 'https://d.socdm.com/adsv/v1';
const url = validReq.params.debug ? DEBUG_URL : URL;
const criteoId = getCriteoId(validReq);
const id5id = getId5Id(validReq);
const id5LinkType = getId5LinkType(validReq);
let data = ``;
data = tryAppendQueryString(data, 'posall', 'SSPLOC');
const id = getBidIdParameter('id', validReq.params);
Expand All @@ -45,10 +48,14 @@ export const spec = {
data = tryAppendQueryString(data, 'pbver', '$prebid.version$');
data = tryAppendQueryString(data, 'sdkname', 'prebidjs');
data = tryAppendQueryString(data, 'adapterver', ADGENE_PREBID_VERSION);
data = tryAppendQueryString(data, 'adgext_criteo_id', criteoId);
data = tryAppendQueryString(data, 'adgext_id5_id', id5id);
data = tryAppendQueryString(data, 'adgext_id5_id_link_type', id5LinkType);
// native以外にvideo等の対応が入った場合は要修正
if (!validReq.mediaTypes || !validReq.mediaTypes.native) {
data = tryAppendQueryString(data, 'imark', '1');
}

// TODO: is 'page' the right value here?
data = tryAppendQueryString(data, 'tp', bidderRequest.refererInfo.page);
if (isIos()) {
Expand Down Expand Up @@ -275,6 +282,22 @@ function getCurrencyType() {
* @param validReq request
* @return {null|string}
*/
function getCriteoId(validReq) {
return (validReq.userId && validReq.userId.criteoId) ? validReq.userId.criteoId : null
}

function getId5Id(validReq) {
return validId5(validReq) ? validReq.userId.id5id.uid : null
}

function getId5LinkType(validReq) {
return validId5(validReq) ? validReq.userId.id5id.ext.linkType : null
}

function validId5(validReq) {
return validReq.userId && validReq.userId.id5id && validReq.userId.id5id.uid && validReq.userId.id5id.ext.linkType
}

function getHyperId(validReq) {
if (validReq.userId && validReq.userId.novatiq && validReq.userId.novatiq.snowflake.syncResponse === 1) {
return validReq.userId.novatiq.snowflake.id;
Expand Down
56 changes: 52 additions & 4 deletions test/spec/modules/adgenerationBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,41 @@ describe('AdgenerationAdapter', function () {
snowflake: {'id': 'novatiqId', syncResponse: 1}
}
}
},
{ // bannerWithAdgextCriteoId
bidder: 'adg',
params: {
id: '58278', // banner
},
adUnitCode: 'adunit-code',
sizes: [[320, 100]],
bidId: '2f6ac468a9c15e',
bidderRequestId: '14a9f773e30243',
auctionId: '4aae9f05-18c6-4fcd-80cf-282708cd584a',
transactionTd: 'f76f6dfd-d64f-4645-a29f-682bac7f431a',
userId: {
criteoId: 'criteo-id-test-1234567890'
}
},
{ // bannerWithAdgextId5Id
bidder: 'adg',
params: {
id: '58278', // banner
},
adUnitCode: 'adunit-code',
sizes: [[320, 100]],
bidId: '2f6ac468a9c15e',
bidderRequestId: '14a9f773e30243',
auctionId: '4aae9f05-18c6-4fcd-80cf-282708cd584a',
transactionTd: 'f76f6dfd-d64f-4645-a29f-682bac7f431a',
userId: {
id5id: {
ext: {
linkType: 2
},
uid: 'id5-id-test-1234567890'
}
}
}
];
const bidderRequest = {
Expand All @@ -109,10 +144,12 @@ describe('AdgenerationAdapter', function () {
}
};
const data = {
banner: `posall=SSPLOC&id=58278&sdktype=0&hb=true&t=json3&sizes=300x250%2C320x100&currency=JPY&pbver=${prebid.version}&sdkname=prebidjs&adapterver=1.3.0&imark=1&tp=https%3A%2F%2Fexample.com`,
bannerUSD: `posall=SSPLOC&id=58278&sdktype=0&hb=true&t=json3&sizes=300x250%2C320x100&currency=USD&pbver=${prebid.version}&sdkname=prebidjs&adapterver=1.3.0&imark=1&tp=https%3A%2F%2Fexample.com`,
native: `posall=SSPLOC&id=58278&sdktype=0&hb=true&t=json3&sizes=1x1&currency=JPY&pbver=${prebid.version}&sdkname=prebidjs&adapterver=1.3.0&tp=https%3A%2F%2Fexample.com`,
bannerWithHyperId: `posall=SSPLOC&id=58278&sdktype=0&hb=true&t=json3&sizes=320x100&currency=JPY&pbver=${prebid.version}&sdkname=prebidjs&adapterver=1.3.0&imark=1&tp=https%3A%2F%2Fexample.com&hyper_id=novatiqId`,
banner: `posall=SSPLOC&id=58278&sdktype=0&hb=true&t=json3&sizes=300x250%2C320x100&currency=JPY&pbver=${prebid.version}&sdkname=prebidjs&adapterver=1.4.0&imark=1&tp=https%3A%2F%2Fexample.com`,
bannerUSD: `posall=SSPLOC&id=58278&sdktype=0&hb=true&t=json3&sizes=300x250%2C320x100&currency=USD&pbver=${prebid.version}&sdkname=prebidjs&adapterver=1.4.0&imark=1&tp=https%3A%2F%2Fexample.com`,
native: `posall=SSPLOC&id=58278&sdktype=0&hb=true&t=json3&sizes=1x1&currency=JPY&pbver=${prebid.version}&sdkname=prebidjs&adapterver=1.4.0&tp=https%3A%2F%2Fexample.com`,
bannerWithHyperId: `posall=SSPLOC&id=58278&sdktype=0&hb=true&t=json3&sizes=320x100&currency=JPY&pbver=${prebid.version}&sdkname=prebidjs&adapterver=1.4.0&imark=1&tp=https%3A%2F%2Fexample.com&hyper_id=novatiqId`,
bannerWithAdgextCriteoId: `posall=SSPLOC&id=58278&sdktype=0&hb=true&t=json3&sizes=320x100&currency=JPY&pbver=${prebid.version}&sdkname=prebidjs&adapterver=1.4.0&adgext_criteo_id=criteo-id-test-1234567890&imark=1&tp=https%3A%2F%2Fexample.com`,
bannerWithAdgextId5Id: `posall=SSPLOC&id=58278&sdktype=0&hb=true&t=json3&sizes=320x100&currency=JPY&pbver=${prebid.version}&sdkname=prebidjs&adapterver=1.4.0&adgext_id5_id=id5-id-test-1234567890&adgext_id5_id_link_type=2&imark=1&tp=https%3A%2F%2Fexample.com`,
};
it('sends bid request to ENDPOINT via GET', function () {
const request = spec.buildRequests(bidRequests, bidderRequest)[0];
Expand Down Expand Up @@ -149,6 +186,17 @@ describe('AdgenerationAdapter', function () {
});
expect(request.data).to.equal(data.bannerWithHyperId);
});

it('should attache params to the bannerWithAdgextCriteoId request', function () {
const request = spec.buildRequests(bidRequests, bidderRequest)[3];
expect(request.data).to.equal(data.bannerWithAdgextCriteoId);
});

it('should attache params to the bannerWithAdgextId5Id request', function () {
const request = spec.buildRequests(bidRequests, bidderRequest)[4];
expect(request.data).to.equal(data.bannerWithAdgextId5Id);
});

it('allows setConfig to set bidder currency for JPY', function () {
config.setConfig({
currency: {
Expand Down