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

Update AdGenerationAdapter: update userSync #13

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
19 changes: 14 additions & 5 deletions modules/adgenerationBidAdapter.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {tryAppendQueryString, getBidIdParameter, escapeUnsafeChars} from '../src/utils.js';
import {tryAppendQueryString, getBidIdParameter, escapeUnsafeChars, deepAccess} from '../src/utils.js';
import {registerBidder} from '../src/adapters/bidderFactory.js';
import {BANNER, NATIVE} from '../src/mediaTypes.js';
import {config} from '../src/config.js';
import { convertOrtbRequestToProprietaryNative } from '../src/native.js';
import {convertOrtbRequestToProprietaryNative} from '../src/native.js';

const ADG_BIDDER_CODE = 'adgeneration';

Expand All @@ -21,14 +21,14 @@ export const spec = {
},
/**
* Make a server request from the list of BidRequests.
*
* @param {validBidRequests[]} - an array of bids
* @param validBidRequests
* @param bidderRequest
* @return ServerRequest Info describing the request to the server.
*/
buildRequests: function (validBidRequests, bidderRequest) {
// convert Native ORTB definition to old-style prebid native definition
validBidRequests = convertOrtbRequestToProprietaryNative(validBidRequests);
const ADGENE_PREBID_VERSION = '1.5.0';
const ADGENE_PREBID_VERSION = '1.6.0';
let serverRequests = [];
for (let i = 0, len = validBidRequests.length; i < len; i++) {
const validReq = validBidRequests[i];
Expand All @@ -38,6 +38,9 @@ export const spec = {
const criteoId = getCriteoId(validReq);
const id5id = getId5Id(validReq);
const id5LinkType = getId5LinkType(validReq);
const imuid = deepAccess(validReq, 'userId.imuid');
const gpid = deepAccess(validReq, 'ortb2Imp.ext.gpid');
const sua = deepAccess(validReq, 'ortb2.device.sua');
let data = ``;
data = tryAppendQueryString(data, 'posall', 'SSPLOC');
const id = getBidIdParameter('id', validReq.params);
Expand All @@ -54,6 +57,12 @@ export const spec = {
data = tryAppendQueryString(data, 'adgext_criteo_id', criteoId);
data = tryAppendQueryString(data, 'adgext_id5_id', id5id);
data = tryAppendQueryString(data, 'adgext_id5_id_link_type', id5LinkType);
data = tryAppendQueryString(data, 'adgext_imuid', imuid);
data = tryAppendQueryString(data, 'adgext_uid2', validReq.userId ? validReq.userId.uid2 : null);
data = tryAppendQueryString(data, 'gpid', gpid ? encodeURIComponent(gpid) : null);
data = tryAppendQueryString(data, 'uach', sua ? JSON.stringify(sua) : null);
data = tryAppendQueryString(data, 'schain', validReq.schain ? encodeURIComponent(JSON.stringify(validReq.schain)) : null);

// native以外にvideo等の対応が入った場合は要修正
if (!validReq.mediaTypes || !validReq.mediaTypes.native) {
data = tryAppendQueryString(data, 'imark', '1');
Expand Down
64 changes: 52 additions & 12 deletions test/spec/modules/adgenerationBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ describe('AdgenerationAdapter', function () {
criteoId: 'criteo-id-test-1234567890'
}
},
{ // bannerWithAdgextId5Id
{ // bannerWithAdgextIds
bidder: 'adg',
params: {
id: '58278', // banner
Expand All @@ -134,8 +134,48 @@ describe('AdgenerationAdapter', function () {
linkType: 2
},
uid: 'id5-id-test-1234567890'
},
imuid: 'i.KrAH6ZAZTJOnH5S4N2sogA',
uid2: {id: 'AgAAAAVacu1uAxgAxH+HJ8+nWlS2H4uVqr6i+HBDCNREHD8WKsio/x7D8xXFuq1cJycUU86yXfTH9Xe/4C8KkH+7UCiU7uQxhyD7Qxnv251pEs6K8oK+BPLYR+8BLY/sJKesa/koKwx1FHgUzIBum582tSy2Oo+7C6wYUaaV4QcLr/4LPA='},
},
ortb2Imp: {ext: {gpid: '/1111/homepage#300x250'}},
ortb2: {
site: {
domain: 'localhost:9999',
publisher: {'domain': 'localhost:9999'},
page: 'http://localhost:9999/integrationExamples/gpt/hello_world.html',
ref: 'http://localhost:9999/integrationExamples/gpt/hello_world.html'
},
device: {
w: 570,
h: 969,
dnt: 0,
ua: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML,like Gecko)Chrome / 112.0.0.0Safari / 537.36',
language: 'ja',
sua: {
source: 2,
platform: {
brand: 'macOS'
},
browsers: [
{
brand: 'Chromium',
version: ['112']
},
{
brand: 'Google Chrome',
version: ['112']
},
{
brand: 'Not:A-Brand',
version: ['99']
}
],
mobile: 0
}
}
}
},
schain: {ver: '1.0', complete: 1, nodes: [{asi: 'indirectseller.com', sid: '00001', hp: 1}]}
}
];
const bidderRequest = {
Expand All @@ -144,12 +184,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.5.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.5.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.5.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.5.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.5.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.5.0&adgext_id5_id=id5-id-test-1234567890&adgext_id5_id_link_type=2&imark=1&tp=https%3A%2F%2Fexample.com`,
banner: `posall=SSPLOC&id=58278&sdktype=0&hb=true&t=json3&sizes=300x250%2C320x100&currency=JPY&pbver=${prebid.version}&sdkname=prebidjs&adapterver=1.6.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.6.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.6.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.6.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.6.0&adgext_criteo_id=criteo-id-test-1234567890&imark=1&tp=https%3A%2F%2Fexample.com`,
bannerWithAdgextIds: `posall=SSPLOC&id=58278&sdktype=0&hb=true&t=json3&sizes=320x100&currency=JPY&pbver=${prebid.version}&sdkname=prebidjs&adapterver=1.6.0&adgext_id5_id=id5-id-test-1234567890&adgext_id5_id_link_type=2&adgext_imuid=i.KrAH6ZAZTJOnH5S4N2sogA&adgext_uid2=%5Bobject%20Object%5D&gpid=%252F1111%252Fhomepage%2523300x250&uach=%7B%22source%22%3A2%2C%22platform%22%3A%7B%22brand%22%3A%22macOS%22%7D%2C%22browsers%22%3A%5B%7B%22brand%22%3A%22Chromium%22%2C%22version%22%3A%5B%22112%22%5D%7D%2C%7B%22brand%22%3A%22Google%20Chrome%22%2C%22version%22%3A%5B%22112%22%5D%7D%2C%7B%22brand%22%3A%22Not%3AA-Brand%22%2C%22version%22%3A%5B%2299%22%5D%7D%5D%2C%22mobile%22%3A0%7D&schain=%257B%2522ver%2522%253A%25221.0%2522%252C%2522complete%2522%253A1%252C%2522nodes%2522%253A%255B%257B%2522asi%2522%253A%2522indirectseller.com%2522%252C%2522sid%2522%253A%252200001%2522%252C%2522hp%2522%253A1%257D%255D%257D&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 All @@ -176,12 +216,12 @@ describe('AdgenerationAdapter', function () {

it('should attache params to the bannerWithHyperId request', function () {
const defaultUA = window.navigator.userAgent;
window.navigator.__defineGetter__('userAgent', function() {
window.navigator.__defineGetter__('userAgent', function () {
return 'Mozilla/5.0 (iPhone; CPU iPhone OS 14_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0 Mobile/15E148 Safari/604.1';
});
const request = spec.buildRequests(bidRequests, bidderRequest)[2];

window.navigator.__defineGetter__('userAgent', function() {
window.navigator.__defineGetter__('userAgent', function () {
return defaultUA;
});
expect(request.data).to.equal(data.bannerWithHyperId);
Expand All @@ -192,9 +232,9 @@ describe('AdgenerationAdapter', function () {
expect(request.data).to.equal(data.bannerWithAdgextCriteoId);
});

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

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