Skip to content

Adhese Bid Adapter: add support for caching video content #6501

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

Merged
merged 9 commits into from
Apr 1, 2021
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
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