Skip to content
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

Seedtag Bid Adapter: add support for a new type of placement #6369

Merged
merged 6 commits into from
Mar 4, 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
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);
})
})
})
})