Skip to content

Commit d9a2430

Browse files
lauramorillocabama
andauthored
Seedtag Bid Adapter: add support for inArticle placement (#6369)
* 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 <[email protected]>
1 parent 771d2bb commit d9a2430

File tree

2 files changed

+60
-12
lines changed

2 files changed

+60
-12
lines changed

modules/seedtagBidAdapter.js

+21-6
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,13 @@ const BIDDER_CODE = 'seedtag';
66
const SEEDTAG_ALIAS = 'st';
77
const SEEDTAG_SSP_ENDPOINT = 'https://s.seedtag.com/c/hb/bid';
88
const SEEDTAG_SSP_ONTIMEOUT_ENDPOINT = 'https://s.seedtag.com/se/hb/timeout';
9-
9+
const ALLOWED_PLACEMENTS = {
10+
inImage: true,
11+
inScreen: true,
12+
inArticle: true,
13+
banner: true,
14+
video: true
15+
}
1016
const mediaTypesMap = {
1117
[BANNER]: 'display',
1218
[VIDEO]: 'video'
@@ -27,10 +33,7 @@ function hasMandatoryParams(params) {
2733
!!params.publisherId &&
2834
!!params.adUnitId &&
2935
!!params.placement &&
30-
(params.placement === 'inImage' ||
31-
params.placement === 'inScreen' ||
32-
params.placement === 'banner' ||
33-
params.placement === 'video')
36+
!!ALLOWED_PLACEMENTS[params.placement]
3437
);
3538
}
3639

@@ -88,8 +91,10 @@ function buildBid(seedtagBid) {
8891
currency: seedtagBid.currency,
8992
netRevenue: true,
9093
mediaType: mediaType,
91-
ttl: seedtagBid.ttl
94+
ttl: seedtagBid.ttl,
95+
nurl: seedtagBid.nurl
9296
};
97+
9398
if (mediaType === VIDEO) {
9499
bid.vastXml = seedtagBid.content;
95100
} else {
@@ -200,6 +205,16 @@ export const spec = {
200205
onTimeout(data) {
201206
getTimeoutUrl(data);
202207
utils.triggerPixel(SEEDTAG_SSP_ONTIMEOUT_ENDPOINT);
208+
},
209+
210+
/**
211+
* Function to call when the adapter wins the auction
212+
* @param {bid} Bid information received from the server
213+
*/
214+
onBidWon: function (bid) {
215+
if (bid && bid.nurl) {
216+
utils.triggerPixel(bid.nurl);
217+
}
203218
}
204219
}
205220
registerBidder(spec);

test/spec/modules/seedtagBidAdapter_spec.js

+39-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { expect } from 'chai'
22
import { spec, getTimeoutUrl } from 'modules/seedtagBidAdapter.js'
3+
import * as utils from 'src/utils.js'
34

45
const PUBLISHER_ID = '0000-0000-01'
56
const ADUNIT_ID = '000000'
@@ -42,7 +43,7 @@ describe('Seedtag Adapter', function() {
4243
}
4344
)
4445
}
45-
const placements = ['banner', 'video', 'inImage', 'inScreen']
46+
const placements = ['banner', 'video', 'inImage', 'inScreen', 'inArticle']
4647
placements.forEach(placement => {
4748
it('should be ' + placement, function() {
4849
const isBidRequestValid = spec.isBidRequestValid(
@@ -53,7 +54,7 @@ describe('Seedtag Adapter', function() {
5354
})
5455
})
5556
})
56-
describe('when video slot has all mandatory params.', function() {
57+
describe('when video slot has all mandatory params', function() {
5758
it('should return true, when video mediatype object are correct.', function() {
5859
const slotConfig = getSlotConfigs(
5960
{
@@ -116,7 +117,7 @@ describe('Seedtag Adapter', function() {
116117
expect(isBidRequestValid).to.equal(false)
117118
})
118119
})
119-
describe('when video mediaType object is not correct.', function() {
120+
describe('when video mediaType object is not correct', function() {
120121
function createVideoSlotconfig(mediaType) {
121122
return getSlotConfigs(mediaType, {
122123
publisherId: PUBLISHER_ID,
@@ -301,7 +302,7 @@ describe('Seedtag Adapter', function() {
301302
expect(typeof bids).to.equal('object')
302303
expect(bids.length).to.equal(0)
303304
})
304-
it('should return a void array, when the server response have not got bids.', function() {
305+
it('should return a void array, when the server response have no bids.', function() {
305306
const request = { data: JSON.stringify({}) }
306307
const serverResponse = { body: { bids: [] } }
307308
const bids = spec.interpretResponse(serverResponse, request)
@@ -323,7 +324,8 @@ describe('Seedtag Adapter', function() {
323324
width: 728,
324325
height: 90,
325326
mediaType: 'display',
326-
ttl: 360
327+
ttl: 360,
328+
nurl: 'testurl.com/nurl'
327329
}
328330
],
329331
cookieSync: { url: '' }
@@ -338,6 +340,7 @@ describe('Seedtag Adapter', function() {
338340
expect(bids[0].currency).to.equal('USD')
339341
expect(bids[0].netRevenue).to.equal(true)
340342
expect(bids[0].ad).to.equal('content')
343+
expect(bids[0].nurl).to.equal('testurl.com/nurl')
341344
})
342345
})
343346
describe('the bid is a video', function() {
@@ -354,7 +357,8 @@ describe('Seedtag Adapter', function() {
354357
width: 728,
355358
height: 90,
356359
mediaType: 'video',
357-
ttl: 360
360+
ttl: 360,
361+
nurl: undefined
358362
}
359363
],
360364
cookieSync: { url: '' }
@@ -416,4 +420,33 @@ describe('Seedtag Adapter', function() {
416420
)
417421
})
418422
})
423+
424+
describe('onBidWon', function () {
425+
beforeEach(function() {
426+
sinon.stub(utils, 'triggerPixel')
427+
})
428+
429+
afterEach(function() {
430+
utils.triggerPixel.restore()
431+
})
432+
433+
describe('without nurl', function() {
434+
const bid = {}
435+
436+
it('does not create pixel ', function() {
437+
spec.onBidWon(bid)
438+
expect(utils.triggerPixel.called).to.equal(false);
439+
})
440+
})
441+
442+
describe('with nurl', function () {
443+
const nurl = 'http://seedtag_domain/won'
444+
const bid = { nurl }
445+
446+
it('creates nurl pixel if bid nurl', function() {
447+
spec.onBidWon({ nurl })
448+
expect(utils.triggerPixel.calledWith(nurl)).to.equal(true);
449+
})
450+
})
451+
})
419452
})

0 commit comments

Comments
 (0)