Skip to content

Commit

Permalink
Add GDPR parameters to yieldlab delivery adtag (#5658)
Browse files Browse the repository at this point in the history
  • Loading branch information
mirkorean authored Aug 26, 2020
1 parent 71ff934 commit e2c4e69
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 7 deletions.
10 changes: 7 additions & 3 deletions modules/yieldlabBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ export const spec = {
return {
method: 'GET',
url: `${ENDPOINT}/yp/${adslots}?${queryString}`,
validBidRequests: validBidRequests
validBidRequests: validBidRequests,
queryParams: query
}
},

Expand All @@ -80,6 +81,7 @@ export const spec = {
interpretResponse: function (serverResponse, originalBidRequest) {
const bidResponses = []
const timestamp = Date.now()
const reqParams = originalBidRequest.queryParams

originalBidRequest.validBidRequests.forEach(function (bidRequest) {
if (!serverResponse.body) {
Expand All @@ -95,6 +97,8 @@ export const spec = {
const customsize = bidRequest.params.adSize !== undefined ? parseSize(bidRequest.params.adSize) : primarysize
const extId = bidRequest.params.extId !== undefined ? '&id=' + bidRequest.params.extId : ''
const adType = matchedBid.adtype !== undefined ? matchedBid.adtype : ''
const gdprApplies = reqParams.gdpr ? '&gdpr=' + reqParams.gdpr : ''
const gdprConsent = reqParams.consent ? '&consent=' + reqParams.consent : ''

const bidResponse = {
requestId: bidRequest.bidId,
Expand All @@ -107,7 +111,7 @@ 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}${extId}"></script>`
ad: `<script src="${ENDPOINT}/d/${matchedBid.id}/${bidRequest.params.supplyId}/${customsize[0]}x${customsize[1]}?ts=${timestamp}${extId}${gdprApplies}${gdprConsent}"></script>`
}

if (isVideo(bidRequest, adType)) {
Expand All @@ -117,7 +121,7 @@ export const spec = {
bidResponse.height = playersize[1]
}
bidResponse.mediaType = VIDEO
bidResponse.vastUrl = `${ENDPOINT}/d/${matchedBid.id}/${bidRequest.params.supplyId}/${customsize[0]}x${customsize[1]}?ts=${timestamp}${extId}`
bidResponse.vastUrl = `${ENDPOINT}/d/${matchedBid.id}/${bidRequest.params.supplyId}/${customsize[0]}x${customsize[1]}?ts=${timestamp}${extId}${gdprApplies}${gdprConsent}`

if (isOutstream(bidRequest)) {
const renderer = Renderer.install({
Expand Down
39 changes: 35 additions & 4 deletions test/spec/modules/yieldlabBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,16 @@ const VIDEO_RESPONSE = Object.assign({}, RESPONSE, {
'adtype': 'VIDEO'
})

const REQPARAMS = {
json: true,
ts: 1234567890
}

const REQPARAMS_GDPR = Object.assign({}, REQPARAMS, {
gdpr: true,
consent: 'BN5lERiOMYEdiAKAWXEND1AAAAE6DABACMA'
})

describe('yieldlabBidAdapter', function () {
const adapter = newBidder(spec)

Expand Down Expand Up @@ -131,7 +141,7 @@ describe('yieldlabBidAdapter', function () {
})

it('should get correct bid response', function () {
const result = spec.interpretResponse({body: [RESPONSE]}, {validBidRequests: [REQUEST]})
const result = spec.interpretResponse({body: [RESPONSE]}, {validBidRequests: [REQUEST], queryParams: REQPARAMS})

expect(result[0].requestId).to.equal('2d925f27f5079f')
expect(result[0].cpm).to.equal(0.01)
Expand All @@ -147,6 +157,13 @@ describe('yieldlabBidAdapter', function () {
expect(result[0].ad).to.include('&id=abc')
})

it('should append gdpr parameters to adtag', function () {
const result = spec.interpretResponse({body: [RESPONSE]}, {validBidRequests: [REQUEST], queryParams: REQPARAMS_GDPR})

expect(result[0].ad).to.include('&gdpr=true')
expect(result[0].ad).to.include('&consent=BN5lERiOMYEdiAKAWXEND1AAAAE6DABACMA')
})

it('should get correct bid response when passing more than one size', function () {
const REQUEST2 = Object.assign({}, REQUEST, {
'sizes': [
Expand All @@ -155,7 +172,7 @@ describe('yieldlabBidAdapter', function () {
[970, 90],
]
})
const result = spec.interpretResponse({body: [RESPONSE]}, {validBidRequests: [REQUEST2]})
const result = spec.interpretResponse({body: [RESPONSE]}, {validBidRequests: [REQUEST2], queryParams: REQPARAMS})

expect(result[0].requestId).to.equal('2d925f27f5079f')
expect(result[0].cpm).to.equal(0.01)
Expand All @@ -179,7 +196,7 @@ describe('yieldlabBidAdapter', function () {
}
}
})
const result = spec.interpretResponse({body: [VIDEO_RESPONSE]}, {validBidRequests: [VIDEO_REQUEST]})
const result = spec.interpretResponse({body: [VIDEO_RESPONSE]}, {validBidRequests: [VIDEO_REQUEST], queryParams: REQPARAMS})

expect(result[0].requestId).to.equal('2d925f27f5079f')
expect(result[0].cpm).to.equal(0.01)
Expand All @@ -188,6 +205,20 @@ describe('yieldlabBidAdapter', function () {
expect(result[0].vastUrl).to.include('&id=abc')
})

it('should append gdpr parameters to vastUrl', function () {
const VIDEO_REQUEST = Object.assign({}, REQUEST, {
'mediaTypes': {
'video': {
'context': 'instream'
}
}
})
const result = spec.interpretResponse({body: [VIDEO_RESPONSE]}, {validBidRequests: [VIDEO_REQUEST], queryParams: REQPARAMS_GDPR})

expect(result[0].vastUrl).to.include('&gdpr=true')
expect(result[0].vastUrl).to.include('&consent=BN5lERiOMYEdiAKAWXEND1AAAAE6DABACMA')
})

it('should add renderer if outstream context', function () {
const OUTSTREAM_REQUEST = Object.assign({}, REQUEST, {
'mediaTypes': {
Expand All @@ -197,7 +228,7 @@ describe('yieldlabBidAdapter', function () {
}
}
})
const result = spec.interpretResponse({body: [VIDEO_RESPONSE]}, {validBidRequests: [OUTSTREAM_REQUEST]})
const result = spec.interpretResponse({body: [VIDEO_RESPONSE]}, {validBidRequests: [OUTSTREAM_REQUEST], queryParams: REQPARAMS})

expect(result[0].renderer.id).to.equal('2d925f27f5079f')
expect(result[0].renderer.url).to.equal('https://ad2.movad.net/dynamic.ad?a=o193092&ma_loadEvent=ma-start-event')
Expand Down

0 comments on commit e2c4e69

Please sign in to comment.