Skip to content

Commit 8b528a1

Browse files
sander-adheseafewcc
authored andcommitted
Make adhese adapter prebid 3.0 compatible (prebid#4507)
* 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 * Read sizes from mediaTypes.banner.sizes + Apply Eslint suggestions * Use map and join, add originData to response * properly use originData obj * Remove duplicated ids * Update tests
1 parent b8c3229 commit 8b528a1

File tree

2 files changed

+63
-10
lines changed

2 files changed

+63
-10
lines changed

modules/adheseBidAdapter.js

+30-10
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export const spec = {
1111
supportedMediaTypes: [BANNER, VIDEO],
1212

1313
isBidRequestValid: function(bid) {
14-
return !!(bid.params.account && bid.params.location && bid.params.format);
14+
return !!(bid.params.account && bid.params.location && (bid.params.format || bid.mediaTypes.banner.sizes));
1515
},
1616

1717
buildRequests: function(validBidRequests, bidderRequest) {
@@ -83,7 +83,10 @@ function adResponse(bid, ad) {
8383
width: Number(ad.width),
8484
height: Number(ad.height),
8585
creativeId: adDetails.creativeId,
86-
dealId: adDetails.dealId
86+
dealId: adDetails.dealId,
87+
adhese: {
88+
originData: adDetails.originData
89+
}
8790
});
8891

8992
if (bidResponse.mediaType === VIDEO) {
@@ -112,7 +115,19 @@ function mergeTargets(targets, target) {
112115
}
113116

114117
function bidToSlotName(bid) {
115-
return bid.params.location + '-' + bid.params.format;
118+
if (bid.params.format) {
119+
return bid.params.location + '-' + bid.params.format;
120+
}
121+
122+
var sizes = bid.mediaTypes.banner.sizes;
123+
sizes.sort();
124+
var format = sizes.map(size => size[0] + 'x' + size[1]).join('_');
125+
126+
if (format.length > 0) {
127+
return bid.params.location + '-' + format;
128+
} else {
129+
return bid.params.location;
130+
}
116131
}
117132

118133
function getAccount(validBidRequests) {
@@ -150,22 +165,27 @@ function getPrice(ad) {
150165
function getAdDetails(ad) {
151166
let creativeId = '';
152167
let dealId = '';
168+
let originData = {};
153169

154170
if (isAdheseAd(ad)) {
155171
creativeId = ad.id;
156172
dealId = ad.orderId;
173+
originData = { priority: ad.priority, orderProperty: ad.orderProperty, adFormat: ad.adFormat, adType: ad.adType, libId: ad.libId, adspaceId: ad.adspaceId, viewableImpressionCounter: ad.viewableImpressionCounter };
157174
} else {
158175
creativeId = ad.origin + (ad.originInstance ? '-' + ad.originInstance : '');
159-
if (ad.originData && ad.originData.seatbid && ad.originData.seatbid.length) {
160-
const seatbid = ad.originData.seatbid[0];
161-
if (seatbid.bid && seatbid.bid.length) {
162-
const bid = seatbid.bid[0];
163-
creativeId = String(bid.crid || '');
164-
dealId = String(bid.dealid || '');
176+
if (ad.originData) {
177+
originData = ad.originData;
178+
if (ad.originData.seatbid && ad.originData.seatbid.length) {
179+
const seatbid = ad.originData.seatbid[0];
180+
if (seatbid.bid && seatbid.bid.length) {
181+
const bid = seatbid.bid[0];
182+
creativeId = String(bid.crid || '');
183+
dealId = String(bid.dealid || '');
184+
}
165185
}
166186
}
167187
}
168-
return { creativeId: creativeId, dealId: dealId };
188+
return { creativeId: creativeId, dealId: dealId, originData: originData };
169189
}
170190

171191
function base64urlEncode(s) {

test/spec/modules/adheseBidAdapter_spec.js

+33
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,16 @@ describe('AdheseAdapter', function () {
153153
mediaType: 'banner',
154154
netRevenue: NET_REVENUE,
155155
ttl: TTL,
156+
adhese: {
157+
originData: {
158+
seatbid: [
159+
{
160+
bid: [ { crid: '60613369', dealid: null } ],
161+
seat: '958'
162+
}
163+
]
164+
}
165+
}
156166
}];
157167
expect(spec.interpretResponse(sspBannerResponse, bidRequest)).to.deep.equal(expectedResponse);
158168
});
@@ -185,6 +195,7 @@ describe('AdheseAdapter', function () {
185195
mediaType: 'video',
186196
netRevenue: NET_REVENUE,
187197
ttl: TTL,
198+
adhese: { originData: {} }
188199
}];
189200
expect(spec.interpretResponse(sspVideoResponse, bidRequest)).to.deep.equal(expectedResponse);
190201
});
@@ -235,6 +246,17 @@ describe('AdheseAdapter', function () {
235246
let expectedResponse = [{
236247
requestId: BID_ID,
237248
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;\'/>',
249+
adhese: {
250+
originData: {
251+
adFormat: 'largeleaderboard',
252+
adType: 'largeleaderboard',
253+
adspaceId: '162363',
254+
libId: '90511',
255+
orderProperty: undefined,
256+
priority: undefined,
257+
viewableImpressionCounter: undefined
258+
}
259+
},
238260
cpm: 5.96,
239261
currency: 'USD',
240262
creativeId: '742898',
@@ -279,6 +301,17 @@ describe('AdheseAdapter', function () {
279301
let expectedResponse = [{
280302
requestId: BID_ID,
281303
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>',
304+
adhese: {
305+
originData: {
306+
adFormat: '',
307+
adType: 'preroll',
308+
adspaceId: '164196',
309+
libId: '89860',
310+
orderProperty: undefined,
311+
priority: undefined,
312+
viewableImpressionCounter: undefined
313+
}
314+
},
282315
cpm: 0,
283316
currency: 'USD',
284317
creativeId: '742470',

0 commit comments

Comments
 (0)