Skip to content

Commit

Permalink
Add support for External Id (prebid#3594)
Browse files Browse the repository at this point in the history
The External Id is a dynamic reporting dimension, that can be passed through Yieldlab's adtag via the "id"-parameter. E.g.  https://ad.yieldlab.net/d/1111/2222/728x90?ts=123456789&id=abc
  • Loading branch information
mirkorean authored and robertrmartinez committed Mar 5, 2019
1 parent 6dc8094 commit efdee9c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
6 changes: 4 additions & 2 deletions modules/yieldlabBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ export const spec = {
if (matchedBid) {
const primarysize = bidRequest.sizes.length === 2 && !utils.isArray(bidRequest.sizes[0]) ? bidRequest.sizes : bidRequest.sizes[0]
const customsize = bidRequest.params.adSize !== undefined ? parseSize(bidRequest.params.adSize) : primarysize
const extId = bidRequest.params.extId !== undefined ? '&id=' + bidRequest.params.extId : ''
const bidResponse = {
requestId: bidRequest.bidId,
cpm: matchedBid.price / 100,
Expand All @@ -88,11 +89,12 @@ export const spec = {
netRevenue: false,
ttl: BID_RESPONSE_TTL_SEC,
referrer: '',
ad: `<script src="${ENDPOINT}/d/${matchedBid.id}/${bidRequest.params.supplyId}/${customsize[0]}x${customsize[1]}?ts=${timestamp}"></script>`
ad: `<script src="${ENDPOINT}/d/${matchedBid.id}/${bidRequest.params.supplyId}/${customsize[0]}x${customsize[1]}?ts=${timestamp}${extId}"></script>`
}

if (isVideo(bidRequest)) {
bidResponse.mediaType = VIDEO
bidResponse.vastUrl = `${ENDPOINT}/d/${matchedBid.id}/${bidRequest.params.supplyId}/${customsize[0]}x${customsize[1]}?ts=${timestamp}`
bidResponse.vastUrl = `${ENDPOINT}/d/${matchedBid.id}/${bidRequest.params.supplyId}/${customsize[0]}x${customsize[1]}?ts=${timestamp}${extId}`
}

bidResponses.push(bidResponse)
Expand Down
3 changes: 2 additions & 1 deletion modules/yieldlabBidAdapter.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ Module that connects to Yieldlab's demand sources
targeting: {
key1: "value1",
key2: "value2"
}
},
extId: "abc"
}
}]
}, {
Expand Down
6 changes: 5 additions & 1 deletion test/spec/modules/yieldlabBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ const REQUEST = {
'targeting': {
'key1': 'value1',
'key2': 'value2'
}
},
'extId': 'abc'
},
'bidderRequestId': '143346cf0f1731',
'auctionId': '2e41f65424c87c',
Expand Down Expand Up @@ -104,6 +105,7 @@ describe('yieldlabBidAdapter', function () {
expect(result[0].ttl).to.equal(300)
expect(result[0].referrer).to.equal('')
expect(result[0].ad).to.include('<script src="https://ad.yieldlab.net/d/1111/2222/728x90?ts=')
expect(result[0].ad).to.include('&id=abc')
})

it('should get correct bid response when passing more than one size', function () {
Expand All @@ -127,6 +129,7 @@ describe('yieldlabBidAdapter', function () {
expect(result[0].ttl).to.equal(300)
expect(result[0].referrer).to.equal('')
expect(result[0].ad).to.include('<script src="https://ad.yieldlab.net/d/1111/2222/728x90?ts=')
expect(result[0].ad).to.include('&id=abc')
})

it('should add vastUrl when type is video', function () {
Expand All @@ -143,6 +146,7 @@ describe('yieldlabBidAdapter', function () {
expect(result[0].cpm).to.equal(0.01)
expect(result[0].mediaType).to.equal('video')
expect(result[0].vastUrl).to.include('https://ad.yieldlab.net/d/1111/2222/728x90?ts=')
expect(result[0].vastUrl).to.include('&id=abc')
})
})
})

0 comments on commit efdee9c

Please sign in to comment.