Skip to content

Commit

Permalink
Adhese Bid Adapter: add support for caching video content (#6501)
Browse files Browse the repository at this point in the history
* adpod category support test

* Revert "adpod category support test"

This reverts commit 70a3cf2.

* adpod category support test

* Revert "adpod category support test"

This reverts commit 70a3cf2.

* Adhese Bid Adapter: cache video content

Co-authored-by: Tim Sturtewagen <[email protected]>
Co-authored-by: Mateusz <[email protected]>
  • Loading branch information
3 people authored Apr 1, 2021
1 parent 7f9f0a2 commit 65c1079
Show file tree
Hide file tree
Showing 2 changed files with 122 additions and 11 deletions.
14 changes: 7 additions & 7 deletions modules/adheseBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export const spec = {
const payload = {
slots: slots,
parameters: commonParams,
vastContentAsUrl: true,
user: {
ext: {
eids: getEids(validBidRequests),
Expand Down Expand Up @@ -95,7 +96,7 @@ function adResponse(bid, ad) {

const bidResponse = getbaseAdResponse({
requestId: bid.bidId,
mediaType: getMediaType(markup),
mediaType: ad.extension.mediaType,
cpm: Number(price.amount),
currency: price.currency,
width: Number(ad.width),
Expand All @@ -110,7 +111,11 @@ function adResponse(bid, ad) {
});

if (bidResponse.mediaType === VIDEO) {
bidResponse.vastXml = markup;
if (ad.cachedBodyUrl) {
bidResponse.vastUrl = ad.cachedBodyUrl
} else {
bidResponse.vastXml = markup;
}
} else {
const counter = ad.impressionCounter ? "<img src='" + ad.impressionCounter + "' style='height:1px; width:1px; margin: -1px -1px; display:none;'/>" : '';
bidResponse.ad = markup + counter;
Expand Down Expand Up @@ -172,11 +177,6 @@ function isAdheseAd(ad) {
return !ad.origin || ad.origin === 'JERLICIA';
}

function getMediaType(markup) {
const isVideo = markup.trim().toLowerCase().match(/<\?xml|<vast/);
return isVideo ? VIDEO : BANNER;
}

function getAdMarkup(ad) {
if (!isAdheseAd(ad) || (ad.ext === 'js' && ad.body !== undefined && ad.body !== '' && ad.body.match(/<script|<SCRIPT|<html|<HTML|<\?xml/))) {
return ad.body
Expand Down
119 changes: 115 additions & 4 deletions test/spec/modules/adheseBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,12 @@ describe('AdheseAdapter', function () {
expect(JSON.parse(req.data)).to.not.have.key('eids');
});

it('should request vast content as url', function () {
let req = spec.buildRequests([ minimalBid() ], bidderRequest);

expect(JSON.parse(req.data).vastContentAsUrl).to.equal(true);
});

it('should include bids', function () {
let bid = minimalBid();
let req = spec.buildRequests([ bid ], bidderRequest);
Expand Down Expand Up @@ -180,7 +186,7 @@ describe('AdheseAdapter', function () {
body: '<div style="background-color:red; height:250px; width:300px"></div>',
tracker: 'https://hosts-demo.adhese.com/rtb_gateway/handlers/client/track/?id=a2f39296-6dd0-4b3c-be85-7baa22e7ff4a',
impressionCounter: 'https://hosts-demo.adhese.com/rtb_gateway/handlers/client/track/?id=a2f39296-6dd0-4b3c-be85-7baa22e7ff4a',
extension: {'prebid': {'cpm': {'amount': '1.000000', 'currency': 'USD'}}}
extension: {'prebid': {'cpm': {'amount': '1.000000', 'currency': 'USD'}}, mediaType: 'banner'}
}
]
};
Expand Down Expand Up @@ -227,7 +233,7 @@ describe('AdheseAdapter', function () {
width: '640',
height: '350',
body: '<?xml version="1.0" encoding="UTF-8"?><VAST xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.0" xsi:noNamespaceSchemaLocation="vast.xsd"></VAST>',
extension: {'prebid': {'cpm': {'amount': '2.1', 'currency': 'USD'}}}
extension: {'prebid': {'cpm': {'amount': '2.1', 'currency': 'USD'}}, mediaType: 'video'}
}
]
};
Expand All @@ -253,6 +259,43 @@ describe('AdheseAdapter', function () {
expect(spec.interpretResponse(sspVideoResponse, bidRequest)).to.deep.equal(expectedResponse);
});

it('should get correct ssp cache video response', () => {
let sspCachedVideoResponse = {
body: [
{
origin: 'RUBICON',
ext: 'js',
slotName: '_main_page_-leaderboard',
adType: 'leaderboard',
width: '640',
height: '350',
cachedBodyUrl: 'https://ads-demo.adhese.com/content/38983ccc-4083-4c24-932c-96f798d969b3',
extension: {'prebid': {'cpm': {'amount': '2.1', 'currency': 'USD'}}, mediaType: 'video'}
}
]
};

let expectedResponse = [{
requestId: BID_ID,
vastUrl: 'https://ads-demo.adhese.com/content/38983ccc-4083-4c24-932c-96f798d969b3',
cpm: 2.1,
currency: 'USD',
creativeId: 'RUBICON',
dealId: '',
width: 640,
height: 350,
mediaType: 'video',
netRevenue: NET_REVENUE,
ttl: TTL,
adhese: {
origin: 'RUBICON',
originInstance: '',
originData: {}
}
}];
expect(spec.interpretResponse(sspCachedVideoResponse, bidRequest)).to.deep.equal(expectedResponse);
});

it('should get correct Adhese banner response', () => {
const adheseBannerResponse = {
body: [
Expand Down Expand Up @@ -290,7 +333,8 @@ describe('AdheseAdapter', function () {
amount: '5.96',
currency: 'USD'
}
}
},
mediaType: 'banner'
}
}
]
Expand Down Expand Up @@ -352,7 +396,10 @@ describe('AdheseAdapter', function () {
impressionCounter: 'https://hosts-demo.adhese.com/track/742898',
origin: 'JERLICIA',
originData: {},
auctionable: true
auctionable: true,
extension: {
mediaType: 'video'
}
}
]
};
Expand Down Expand Up @@ -390,6 +437,70 @@ describe('AdheseAdapter', function () {
expect(spec.interpretResponse(adheseVideoResponse, bidRequest)).to.deep.equal(expectedResponse);
});

it('should get correct Adhese cached video response', () => {
const adheseVideoResponse = {
body: [
{
adType: 'preroll',
adFormat: '',
orderId: '22248',
adspaceId: '164196',
body: '<ADHESE_BODY>',
height: '360',
width: '640',
extension: {
mediaType: 'video'
},
cachedBodyUrl: 'https://ads-demo.adhese.com/content/38983ccc-4083-4c24-932c-96f798d969b3',
libId: '89860',
id: '742470',
advertiserId: '2263',
ext: 'advar',
orderName: 'Smartphoto EOY-20181112',
creativeName: 'PREROLL',
slotName: '_main_page_-leaderboard',
slotID: '41711',
impressionCounter: 'https://hosts-demo.adhese.com/track/742898',
origin: 'JERLICIA',
originData: {},
auctionable: true
}
]
};

let expectedResponse = [{
requestId: BID_ID,
vastUrl: 'https://ads-demo.adhese.com/content/38983ccc-4083-4c24-932c-96f798d969b3',
adhese: {
origin: '',
originInstance: '',
originData: {
adFormat: '',
adId: '742470',
adType: 'preroll',
adspaceId: '164196',
libId: '89860',
orderProperty: undefined,
priority: undefined,
viewableImpressionCounter: undefined,
slotId: '41711',
slotName: '_main_page_-leaderboard',
advertiserId: '2263',
}
},
cpm: 0,
currency: 'USD',
creativeId: '742470',
dealId: '22248',
width: 640,
height: 360,
mediaType: 'video',
netRevenue: NET_REVENUE,
ttl: TTL,
}];
expect(spec.interpretResponse(adheseVideoResponse, bidRequest)).to.deep.equal(expectedResponse);
});

it('should return no bids for empty adserver response', () => {
let adserverResponse = { body: [] };
expect(spec.interpretResponse(adserverResponse, bidRequest)).to.be.empty;
Expand Down

0 comments on commit 65c1079

Please sign in to comment.