Skip to content

Commit

Permalink
Support for ID5 (prebid#5345)
Browse files Browse the repository at this point in the history
* Add support for bidderRequest.refererInfo in Adhese Adapter.

* Add support for bidderRequest.refererInfo in Adhese Adapter.

* Jira AD-2462 / add tlall is consent string is present

* Added 'adhese' attribute to bid that contains meta data - Jira AD-2642

* added DALE to adhese determination

* extra config option: no format, but use size array as format string

* Added more values to originData

* Revert "Added more values to originData"

This reverts commit 57f0033.

* Pulled Sander's changes & added more data to originData

* Adhese bid adapter - final version

* add origin and originInstance

make ad.origin and ad.originInstance

* add id5 id to request as x5

* Add support for bidderRequest.refererInfo in Adhese Adapter.

* added DALE to adhese determination

* updated tests to include new fields

* Added test for ID5 id

Co-authored-by: Mateusz Michalowski <[email protected]>
Co-authored-by: Mateusz Michalowski <[email protected]>
Co-authored-by: Tim Sturtewagen <[email protected]>
Co-authored-by: Kim Van Crombrugge <[email protected]>
Co-authored-by: Sander <[email protected]>
Co-authored-by: westerschmal <[email protected]>
  • Loading branch information
7 people authored and iggyfisk committed Jun 22, 2020
1 parent 85cb83f commit 5821377
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 6 deletions.
21 changes: 17 additions & 4 deletions modules/adheseBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,10 @@ export const spec = {
const targets = validBidRequests.map(bid => bid.params.data).reduce(mergeTargets, {});
const gdprParams = (gdprConsent && gdprConsent.consentString) ? [`xt${gdprConsent.consentString}`] : [];
const refererParams = (refererInfo && refererInfo.referer) ? [`xf${base64urlEncode(refererInfo.referer)}`] : [];
const id5Params = (getId5Id(validBidRequests)) ? [`x5${getId5Id(validBidRequests)}`] : [];
const targetsParams = Object.keys(targets).map(targetCode => targetCode + targets[targetCode].join(';'));
const slotsParams = validBidRequests.map(bid => 'sl' + bidToSlotName(bid));
const params = [...slotsParams, ...targetsParams, ...gdprParams, ...refererParams].map(s => `/${s}`).join('');
const params = [...slotsParams, ...targetsParams, ...gdprParams, ...refererParams, ...id5Params].map(s => `/${s}`).join('');
const cacheBuster = '?t=' + new Date().getTime();
const uri = 'https://ads-' + account + '.adhese.com/json' + params + cacheBuster;

Expand Down Expand Up @@ -85,7 +86,9 @@ function adResponse(bid, ad) {
creativeId: adDetails.creativeId,
dealId: adDetails.dealId,
adhese: {
originData: adDetails.originData
originData: adDetails.originData,
origin: adDetails.origin,
originInstance: adDetails.originInstance
}
});

Expand Down Expand Up @@ -134,12 +137,18 @@ function getAccount(validBidRequests) {
return validBidRequests[0].params.account;
}

function getId5Id(validBidRequests) {
if (validBidRequests[0] && validBidRequests[0].userId && validBidRequests[0].userId.id5id) {
return validBidRequests[0].userId.id5id;
}
}

function getbaseAdResponse(response) {
return Object.assign({ netRevenue: true, ttl: 360 }, response);
}

function isAdheseAd(ad) {
return !ad.origin || ad.origin === 'JERLICIA';
return !ad.origin || ad.origin === 'JERLICIA' || ad.origin === 'DALE';
}

function getMediaType(markup) {
Expand All @@ -166,6 +175,8 @@ function getAdDetails(ad) {
let creativeId = '';
let dealId = '';
let originData = {};
let origin = '';
let originInstance = '';

if (isAdheseAd(ad)) {
creativeId = ad.id;
Expand All @@ -188,8 +199,10 @@ function getAdDetails(ad) {
}
}
}
if (ad.originInstance) originInstance = ad.originInstance;
if (ad.origin) origin = ad.origin;
}
return { creativeId: creativeId, dealId: dealId, originData: originData };
return { creativeId: creativeId, dealId: dealId, originData: originData, origin: origin, originInstance: originInstance };
}

function base64urlEncode(s) {
Expand Down
20 changes: 18 additions & 2 deletions test/spec/modules/adheseBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ let minimalBid = function() {
}
};

let bidWithParams = function(data) {
let bidWithParams = function(data, userId) {
let bid = minimalBid();
bid.params.data = data;
bid.userId = userId;
return bid;
};

Expand Down Expand Up @@ -100,6 +101,12 @@ describe('AdheseAdapter', function () {
expect(req.url).to.contain('/xfaHR0cDovL3ByZWJpZC5vcmcvZGV2LWRvY3Mvc3ViamVjdHM_X2Q9MQ');
});

it('should include id5 id as /x5 param', function () {
let req = spec.buildRequests([ bidWithParams({}, {'id5id': 'ID5-1234567890'}) ], bidderRequest);

expect(req.url).to.contain('/x5ID5-1234567890');
});

it('should include bids', function () {
let bid = minimalBid();
let req = spec.buildRequests([ bid ], bidderRequest);
Expand Down Expand Up @@ -155,6 +162,8 @@ describe('AdheseAdapter', function () {
netRevenue: NET_REVENUE,
ttl: TTL,
adhese: {
origin: 'APPNEXUS',
originInstance: '',
originData: {
adType: 'leaderboard',
seatbid: [
Expand Down Expand Up @@ -199,7 +208,10 @@ describe('AdheseAdapter', function () {
mediaType: 'video',
netRevenue: NET_REVENUE,
ttl: TTL,
adhese: { originData: {} }
adhese: {
origin: 'RUBICON',
originInstance: '',
originData: {} }
}];
expect(spec.interpretResponse(sspVideoResponse, bidRequest)).to.deep.equal(expectedResponse);
});
Expand Down Expand Up @@ -251,6 +263,8 @@ describe('AdheseAdapter', function () {
requestId: BID_ID,
ad: '<script id="body" type="text/javascript"></script><img src=\'https://hosts-demo.adhese.com/track/742898\' style=\'height:1px; width:1px; margin: -1px -1px; display:none;\'/>',
adhese: {
origin: '',
originInstance: '',
originData: {
adFormat: 'largeleaderboard',
adId: '742898',
Expand Down Expand Up @@ -310,6 +324,8 @@ describe('AdheseAdapter', function () {
requestId: BID_ID,
vastXml: '<?xml version=\'1.0\' encoding=\'UTF-8\' standalone=\'no\'?><VAST version=\'2.0\' xmlns:xsi=\'http://www.w3.org/2001/XMLSchema-instance\' xsi:noNamespaceSchemaLocation=\'vast.xsd\'></VAST>',
adhese: {
origin: '',
originInstance: '',
originData: {
adFormat: '',
adId: '742470',
Expand Down

0 comments on commit 5821377

Please sign in to comment.