Skip to content

Commit

Permalink
Seedtag Bid Adapter: add support for inArticle placement (prebid#6369)
Browse files Browse the repository at this point in the history
* Fix: check mandatory video params

* Simplifying mediaType video existence check

* SQDTAR-42: onWonBid event (#2)

* Adding onBidWon handler.

* Adding nurl to bid.

* Adding nurl field to bid.

* Adding inArticle placement type to seedtag adapter. (#1)

Co-authored-by: Carlos Barreiro Mata <barreymata@gmail.com>
  • Loading branch information
lauramorillo and cabama authored Mar 4, 2021
1 parent 771d2bb commit d9a2430
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 12 deletions.
27 changes: 21 additions & 6 deletions modules/seedtagBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,13 @@ const BIDDER_CODE = 'seedtag';
const SEEDTAG_ALIAS = 'st';
const SEEDTAG_SSP_ENDPOINT = 'https://s.seedtag.com/c/hb/bid';
const SEEDTAG_SSP_ONTIMEOUT_ENDPOINT = 'https://s.seedtag.com/se/hb/timeout';

const ALLOWED_PLACEMENTS = {
inImage: true,
inScreen: true,
inArticle: true,
banner: true,
video: true
}
const mediaTypesMap = {
[BANNER]: 'display',
[VIDEO]: 'video'
Expand All @@ -27,10 +33,7 @@ function hasMandatoryParams(params) {
!!params.publisherId &&
!!params.adUnitId &&
!!params.placement &&
(params.placement === 'inImage' ||
params.placement === 'inScreen' ||
params.placement === 'banner' ||
params.placement === 'video')
!!ALLOWED_PLACEMENTS[params.placement]
);
}

Expand Down Expand Up @@ -88,8 +91,10 @@ function buildBid(seedtagBid) {
currency: seedtagBid.currency,
netRevenue: true,
mediaType: mediaType,
ttl: seedtagBid.ttl
ttl: seedtagBid.ttl,
nurl: seedtagBid.nurl
};

if (mediaType === VIDEO) {
bid.vastXml = seedtagBid.content;
} else {
Expand Down Expand Up @@ -200,6 +205,16 @@ export const spec = {
onTimeout(data) {
getTimeoutUrl(data);
utils.triggerPixel(SEEDTAG_SSP_ONTIMEOUT_ENDPOINT);
},

/**
* Function to call when the adapter wins the auction
* @param {bid} Bid information received from the server
*/
onBidWon: function (bid) {
if (bid && bid.nurl) {
utils.triggerPixel(bid.nurl);
}
}
}
registerBidder(spec);
45 changes: 39 additions & 6 deletions test/spec/modules/seedtagBidAdapter_spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { expect } from 'chai'
import { spec, getTimeoutUrl } from 'modules/seedtagBidAdapter.js'
import * as utils from 'src/utils.js'

const PUBLISHER_ID = '0000-0000-01'
const ADUNIT_ID = '000000'
Expand Down Expand Up @@ -42,7 +43,7 @@ describe('Seedtag Adapter', function() {
}
)
}
const placements = ['banner', 'video', 'inImage', 'inScreen']
const placements = ['banner', 'video', 'inImage', 'inScreen', 'inArticle']
placements.forEach(placement => {
it('should be ' + placement, function() {
const isBidRequestValid = spec.isBidRequestValid(
Expand All @@ -53,7 +54,7 @@ describe('Seedtag Adapter', function() {
})
})
})
describe('when video slot has all mandatory params.', function() {
describe('when video slot has all mandatory params', function() {
it('should return true, when video mediatype object are correct.', function() {
const slotConfig = getSlotConfigs(
{
Expand Down Expand Up @@ -116,7 +117,7 @@ describe('Seedtag Adapter', function() {
expect(isBidRequestValid).to.equal(false)
})
})
describe('when video mediaType object is not correct.', function() {
describe('when video mediaType object is not correct', function() {
function createVideoSlotconfig(mediaType) {
return getSlotConfigs(mediaType, {
publisherId: PUBLISHER_ID,
Expand Down Expand Up @@ -301,7 +302,7 @@ describe('Seedtag Adapter', function() {
expect(typeof bids).to.equal('object')
expect(bids.length).to.equal(0)
})
it('should return a void array, when the server response have not got bids.', function() {
it('should return a void array, when the server response have no bids.', function() {
const request = { data: JSON.stringify({}) }
const serverResponse = { body: { bids: [] } }
const bids = spec.interpretResponse(serverResponse, request)
Expand All @@ -323,7 +324,8 @@ describe('Seedtag Adapter', function() {
width: 728,
height: 90,
mediaType: 'display',
ttl: 360
ttl: 360,
nurl: 'testurl.com/nurl'
}
],
cookieSync: { url: '' }
Expand All @@ -338,6 +340,7 @@ describe('Seedtag Adapter', function() {
expect(bids[0].currency).to.equal('USD')
expect(bids[0].netRevenue).to.equal(true)
expect(bids[0].ad).to.equal('content')
expect(bids[0].nurl).to.equal('testurl.com/nurl')
})
})
describe('the bid is a video', function() {
Expand All @@ -354,7 +357,8 @@ describe('Seedtag Adapter', function() {
width: 728,
height: 90,
mediaType: 'video',
ttl: 360
ttl: 360,
nurl: undefined
}
],
cookieSync: { url: '' }
Expand Down Expand Up @@ -416,4 +420,33 @@ describe('Seedtag Adapter', function() {
)
})
})

describe('onBidWon', function () {
beforeEach(function() {
sinon.stub(utils, 'triggerPixel')
})

afterEach(function() {
utils.triggerPixel.restore()
})

describe('without nurl', function() {
const bid = {}

it('does not create pixel ', function() {
spec.onBidWon(bid)
expect(utils.triggerPixel.called).to.equal(false);
})
})

describe('with nurl', function () {
const nurl = 'http://seedtag_domain/won'
const bid = { nurl }

it('creates nurl pixel if bid nurl', function() {
spec.onBidWon({ nurl })
expect(utils.triggerPixel.calledWith(nurl)).to.equal(true);
})
})
})
})

0 comments on commit d9a2430

Please sign in to comment.