Skip to content

Commit

Permalink
Holid bid adapter: skip user syncs when no bidders in bid response (p…
Browse files Browse the repository at this point in the history
  • Loading branch information
kdesput authored and jorgeluisrocha committed May 18, 2023
1 parent fbf5d79 commit a99f94a
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 4 deletions.
13 changes: 9 additions & 4 deletions modules/holidBidAdapter.js
Expand Up @@ -85,11 +85,12 @@ export const spec = {
}

const syncs = []
const bidders = getBidders(serverResponse)

if (optionsType.iframeEnabled) {
if (optionsType.iframeEnabled && bidders) {
const queryParams = []

queryParams.push('bidders=' + getBidders(serverResponse))
queryParams.push('bidders=' + bidders)
queryParams.push('gdpr=' + +gdprConsent.gdprApplies)
queryParams.push('gdpr_consent=' + gdprConsent.consentString)
queryParams.push('usp_consent=' + (uspConsent || ''))
Expand All @@ -107,6 +108,8 @@ export const spec = {

return syncs
}

return []
},
}

Expand Down Expand Up @@ -136,10 +139,12 @@ function getImp(bid) {

function getBidders(serverResponse) {
const bidders = serverResponse
.map((res) => Object.keys(res.body.ext.responsetimemillis))
.map((res) => Object.keys(res.body.ext.responsetimemillis || []))
.flat(1)

return encodeURIComponent(JSON.stringify([...new Set(bidders)]))
if (bidders.length) {
return encodeURIComponent(JSON.stringify([...new Set(bidders)]))
}
}

function addWurl(auctionId, adId, wurl) {
Expand Down
29 changes: 29 additions & 0 deletions test/spec/modules/holidBidAdapter_spec.js
Expand Up @@ -161,5 +161,34 @@ describe('holidBidAdapterTests', () => {

expect(userSyncs).to.deep.equal(expectedUserSyncs)
})

it('should return empty user syncs when responsetimemillis is not defined', () => {
const optionsType = {
iframeEnabled: true,
pixelEnabled: true,
}
const serverResponse = [
{
body: {
ext: {},
},
},
]
const gdprConsent = {
gdprApplies: 1,
consentString: 'dkj49Sjmfjuj34as:12jaf90123hufabidfy9u23brfpoig',
}
const uspConsent = 'mkjvbiniwot4827obfoy8sdg8203gb'
const expectedUserSyncs = []

const userSyncs = spec.getUserSyncs(
optionsType,
serverResponse,
gdprConsent,
uspConsent
)

expect(userSyncs).to.deep.equal(expectedUserSyncs)
})
})
})

0 comments on commit a99f94a

Please sign in to comment.