Skip to content
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
16 changes: 15 additions & 1 deletion modules/taboolaBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,9 @@ const converter = ortbConverter({
bidResponse(buildBidResponse, bid, context) {
const bidResponse = buildBidResponse(bid, context);
bidResponse.nurl = bid.nurl;
if (bid.burl) {
bidResponse.burl = bid.burl;
}
bidResponse.ad = replaceAuctionPrice(bid.adm, bid.price);
if (bid.ext && bid.ext.dchain) {
deepSetValue(bidResponse, 'meta.dchain', bid.ext.dchain);
Expand Down Expand Up @@ -212,9 +215,20 @@ export const spec = {
return bids;
},
onBidWon: (bid) => {
if (bid.nurl) {
if (bid.nurl && !bid.deferBilling) {
const resolvedNurl = replaceAuctionPrice(bid.nurl, bid.originalCpm);
ajax(resolvedNurl);
bid.taboolaBillingFired = true;
}
},
onBidBillable: (bid) => {
if (bid.taboolaBillingFired) {
return;
}
const billingUrl = bid.burl || bid.nurl;
if (billingUrl) {
const resolvedBillingUrl = replaceAuctionPrice(billingUrl, bid.originalCpm);
ajax(resolvedBillingUrl);
}
},
getUserSyncs: function(syncOptions, serverResponses, gdprConsent, uspConsent, gppConsent) {
Expand Down
83 changes: 83 additions & 0 deletions test/spec/modules/taboolaBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,89 @@ describe('Taboola Adapter', function () {
spec.onBidWon(bid);
expect(server.requests[0].url).to.equals('http://win.example.com/3.4')
});

it('should not fire nurl when deferBilling is true', function () {
const nurl = 'http://win.example.com/${AUCTION_PRICE}';
const bid = {
requestId: 1,
cpm: 2,
originalCpm: 3.4,
creativeId: 1,
ttl: 60,
netRevenue: true,
mediaType: 'banner',
ad: '...',
width: 300,
height: 250,
nurl: nurl,
deferBilling: true
}
spec.onBidWon(bid);
expect(server.requests.length).to.equal(0);
});
});

describe('onBidBillable', function () {
it('onBidBillable exist as a function', () => {
expect(spec.onBidBillable).to.exist.and.to.be.a('function');
});

it('should fire burl when available', function () {
const burl = 'http://billing.example.com/${AUCTION_PRICE}';
const nurl = 'http://win.example.com/${AUCTION_PRICE}';
const bid = {
requestId: 1,
cpm: 2,
originalCpm: 3.4,
creativeId: 1,
ttl: 60,
netRevenue: true,
mediaType: 'banner',
ad: '...',
width: 300,
height: 250,
nurl: nurl,
burl: burl
}
spec.onBidBillable(bid);
expect(server.requests[0].url).to.equals('http://billing.example.com/3.4');
});

it('should fall back to nurl when burl is not available', function () {
const nurl = 'http://win.example.com/${AUCTION_PRICE}';
const bid = {
requestId: 1,
cpm: 2,
originalCpm: 3.4,
creativeId: 1,
ttl: 60,
netRevenue: true,
mediaType: 'banner',
ad: '...',
width: 300,
height: 250,
nurl: nurl
}
spec.onBidBillable(bid);
expect(server.requests[0].url).to.equals('http://win.example.com/3.4');
});

it('should not fire anything when neither burl nor nurl is available', function () {
const bid = {
requestId: 1,
cpm: 2,
originalCpm: 3.4,
creativeId: 1,
ttl: 60,
netRevenue: true,
mediaType: 'banner',
ad: '...',
width: 300,
height: 250
}
spec.onBidBillable(bid);
expect(server.requests.length).to.equal(0);
});
});

describe('onTimeout', function () {
Expand Down
Loading