From 4025ebbc3520a8a60884900f716f51f8ccf808cd Mon Sep 17 00:00:00 2001 From: Daniela Date: Tue, 19 May 2020 15:32:02 +0200 Subject: [PATCH 1/3] add onBidWon function, add bidder adapter version to bid requests --- modules/ablidaBidAdapter.js | 9 ++++++++- test/spec/modules/ablidaBidAdapter_spec.js | 23 +++++++++++++++++++--- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/modules/ablidaBidAdapter.js b/modules/ablidaBidAdapter.js index ad507c18b24..9bd22ef1f0d 100644 --- a/modules/ablidaBidAdapter.js +++ b/modules/ablidaBidAdapter.js @@ -1,6 +1,7 @@ import * as utils from '../src/utils.js'; import {config} from '../src/config.js'; import {registerBidder} from '../src/adapters/bidderFactory.js'; +import {ajax} from '../src/ajax.js'; const BIDDER_CODE = 'ablida'; const ENDPOINT_URL = 'https://bidder.ablida.net/prebid'; @@ -42,7 +43,8 @@ export const spec = { categories: bidRequest.params.categories, referer: bidderRequest.refererInfo.referer, jaySupported: jaySupported, - device: device + device: device, + adapterVersion: 2 }; return { method: 'POST', @@ -69,6 +71,11 @@ export const spec = { }); return bidResponses; }, + onBidWon: function (bid) { + if (!bid['nurl']) { return false; } + ajax(bid['nurl'], null); + return true; + } }; function getDevice() { diff --git a/test/spec/modules/ablidaBidAdapter_spec.js b/test/spec/modules/ablidaBidAdapter_spec.js index ca4fd4ab0be..0238c14fe5c 100644 --- a/test/spec/modules/ablidaBidAdapter_spec.js +++ b/test/spec/modules/ablidaBidAdapter_spec.js @@ -67,7 +67,8 @@ describe('ablidaBidAdapter', function () { bidId: '2b8c4de0116e54', jaySupported: true, device: 'desktop', - referer: 'www.example.com' + referer: 'www.example.com', + adapterVersion: 2 } }; let serverResponse = { @@ -80,7 +81,8 @@ describe('ablidaBidAdapter', function () { currency: 'EUR', netRevenue: true, ttl: 3000, - ad: '' + ad: '', + nurl: 'https://example.com/some-tracker' }] }; it('should get the correct bid response', function () { @@ -93,10 +95,25 @@ describe('ablidaBidAdapter', function () { currency: 'EUR', netRevenue: true, ttl: 3000, - ad: '' + ad: '', + nurl: 'https://example.com/some-tracker' }]; let result = spec.interpretResponse(serverResponse, bidRequest[0]); expect(Object.keys(result)).to.deep.equal(Object.keys(expectedResponse)); }); }); + + describe('onBidWon', function() { + it('Should not ajax call if bid does not contain nurl', function() { + const result = spec.onBidWon({}); + expect(result).to.equal(false) + }) + + it('Should ajax call if bid nurl', function() { + const result = spec.onBidWon({ + nurl: 'https://example.com/some-tracker' + }); + expect(result).to.equal(true) + }) + }) }); From 672362652acf2cd162c84102b7e988d08d0cfa3f Mon Sep 17 00:00:00 2001 From: Daniela Date: Fri, 24 Jul 2020 14:12:50 +0200 Subject: [PATCH 2/3] add support for native --- modules/ablidaBidAdapter.js | 15 +++++++++------ modules/ablidaBidAdapter.md | 26 +++++++++++++++++++++++++- 2 files changed, 34 insertions(+), 7 deletions(-) diff --git a/modules/ablidaBidAdapter.js b/modules/ablidaBidAdapter.js index 9bd22ef1f0d..d01c16e509b 100644 --- a/modules/ablidaBidAdapter.js +++ b/modules/ablidaBidAdapter.js @@ -1,13 +1,14 @@ import * as utils from '../src/utils.js'; import {config} from '../src/config.js'; import {registerBidder} from '../src/adapters/bidderFactory.js'; -import {ajax} from '../src/ajax.js'; +import { BANNER, NATIVE } from '../src/mediaTypes.js'; const BIDDER_CODE = 'ablida'; const ENDPOINT_URL = 'https://bidder.ablida.net/prebid'; export const spec = { code: BIDDER_CODE, + supportedMediaTypes: [BANNER, NATIVE], /** * Determines whether or not the given bid request is valid. @@ -31,20 +32,22 @@ export const spec = { return []; } return validBidRequests.map(bidRequest => { - const sizes = utils.parseSizesInput(bidRequest.sizes)[0]; - const size = sizes.split('x'); + let sizes = [] + if (bidRequest.mediaTypes && bidRequest.mediaTypes[BANNER] && bidRequest.mediaTypes[BANNER].sizes) { + sizes = bidRequest.mediaTypes[BANNER].sizes; + } const jaySupported = 'atob' in window && 'currentScript' in document; const device = getDevice(); const payload = { placementId: bidRequest.params.placementId, - width: size[0], - height: size[1], + sizes: sizes, bidId: bidRequest.bidId, categories: bidRequest.params.categories, referer: bidderRequest.refererInfo.referer, jaySupported: jaySupported, device: device, - adapterVersion: 2 + adapterVersion: 3, + mediaTypes: bidRequest.mediaTypes }; return { method: 'POST', diff --git a/modules/ablidaBidAdapter.md b/modules/ablidaBidAdapter.md index 70e6576cd30..001bee4f35c 100644 --- a/modules/ablidaBidAdapter.md +++ b/modules/ablidaBidAdapter.md @@ -27,6 +27,30 @@ Module that connects to Ablida's bidder for bids. } } ] + }, { + code: 'native-ad-div', + mediaTypes: { + native: { + image: { + sendId: true, + required: true + }, + title: { + required: true + }, + body: { + required: true + } + } + }, + bids: [ + { + bidder: 'ablida', + params: { + placementId: 'native-demo' + } + } + ] } - ]; + ]; ``` From c20d3a76fa6baaf71ca1b27f4d09556a305bf722 Mon Sep 17 00:00:00 2001 From: Daniela Date: Tue, 28 Jul 2020 11:42:53 +0200 Subject: [PATCH 3/3] use triggerPxel instead of ajax, because ajax was called 3 times with native --- modules/ablidaBidAdapter.js | 5 ++--- test/spec/modules/ablidaBidAdapter_spec.js | 16 ++++++++++++---- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/modules/ablidaBidAdapter.js b/modules/ablidaBidAdapter.js index d01c16e509b..470a845cd20 100644 --- a/modules/ablidaBidAdapter.js +++ b/modules/ablidaBidAdapter.js @@ -75,9 +75,8 @@ export const spec = { return bidResponses; }, onBidWon: function (bid) { - if (!bid['nurl']) { return false; } - ajax(bid['nurl'], null); - return true; + if (!bid['nurl']) { return; } + utils.triggerPixel(bid['nurl']); } }; diff --git a/test/spec/modules/ablidaBidAdapter_spec.js b/test/spec/modules/ablidaBidAdapter_spec.js index 0238c14fe5c..e32531b1eac 100644 --- a/test/spec/modules/ablidaBidAdapter_spec.js +++ b/test/spec/modules/ablidaBidAdapter_spec.js @@ -1,6 +1,7 @@ import {assert, expect} from 'chai'; import {spec} from 'modules/ablidaBidAdapter.js'; import {newBidder} from 'src/adapters/bidderFactory.js'; +import * as utils from 'src/utils.js'; const ENDPOINT_URL = 'https://bidder.ablida.net/prebid'; @@ -104,16 +105,23 @@ describe('ablidaBidAdapter', function () { }); describe('onBidWon', function() { - it('Should not ajax call if bid does not contain nurl', function() { + beforeEach(function() { + sinon.stub(utils, 'triggerPixel'); + }); + afterEach(function() { + utils.triggerPixel.restore(); + }); + + it('Should not trigger pixel if bid does not contain nurl', function() { const result = spec.onBidWon({}); - expect(result).to.equal(false) + expect(utils.triggerPixel.callCount).to.equal(0) }) - it('Should ajax call if bid nurl', function() { + it('Should trigger pixel if bid nurl', function() { const result = spec.onBidWon({ nurl: 'https://example.com/some-tracker' }); - expect(result).to.equal(true) + expect(utils.triggerPixel.callCount).to.equal(1) }) }) });