Skip to content

Commit

Permalink
Nativo Bid Adapter: Identify refreshed inventory to bidder endpoint (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
jsfledd authored Jul 20, 2021
1 parent 9a91886 commit 11ce031
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
9 changes: 8 additions & 1 deletion modules/nativoBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const TIME_TO_LIVE = 360
const SUPPORTED_AD_TYPES = [BANNER]

const bidRequestMap = {}
const adUnitsRequested = {}

// Prebid adapter referrence doc: https://docs.prebid.org/dev-docs/bidder-adaptor.html

Expand Down Expand Up @@ -57,6 +58,8 @@ export const spec = {
// Build adUnit data
const adUnitData = {
adUnits: validBidRequests.map((adUnit) => {
// Track if we've already requested for this ad unit code
adUnitsRequested[adUnit.adUnitCode] = adUnitsRequested[adUnit.adUnitCode] !== undefined ? adUnitsRequested[adUnit.adUnitCode]++ : 0
return {
adUnitCode: adUnit.adUnitCode,
mediaTypes: adUnit.mediaTypes,
Expand All @@ -72,10 +75,14 @@ export const spec = {
key: 'ntv_ppc',
value: btoa(JSON.stringify(adUnitData)), // Convert to Base 64
},
{
key: 'ntv_dbr',
value: btoa(JSON.stringify(adUnitsRequested))
},
{
key: 'ntv_url',
value: encodeURIComponent(pageUrl),
},
}
]

if (bidderRequest.gdprConsent) {
Expand Down
17 changes: 11 additions & 6 deletions test/spec/modules/nativoBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ describe('nativoBidAdapterTests', function () {
expect(request.url).to.include('ntv_pb_rid')
expect(request.url).to.include('ntv_ppc')
expect(request.url).to.include('ntv_url')
expect(request.url).to.include('ntv_dbr')
})
})
})
Expand Down Expand Up @@ -121,8 +122,8 @@ describe('interpretResponse', function () {
bids: [
{
params: {
placementId: 1
}
placementId: 1,
},
},
],
}
Expand Down Expand Up @@ -173,11 +174,11 @@ describe('getUserSyncs', function () {

const gdprConsent = {
gdprApplies: true,
consentString: '111111'
consentString: '111111',
}

const uspConsent = {
uspConsent: '1YYY'
uspConsent: '1YYY',
}

it('Returns empty array if no supported user syncs', function () {
Expand Down Expand Up @@ -207,7 +208,9 @@ describe('getUserSyncs', function () {
expect(userSync[0].type).to.exist
expect(userSync[0].url).to.exist
expect(userSync[0].type).to.be.equal('iframe')
expect(userSync[0].url).to.contain('gdpr=1&gdpr_consent=111111&us_privacy=1YYY')
expect(userSync[0].url).to.contain(
'gdpr=1&gdpr_consent=111111&us_privacy=1YYY'
)
})

it('Returns valid URL and type', function () {
Expand All @@ -224,6 +227,8 @@ describe('getUserSyncs', function () {
expect(userSync[0].type).to.exist
expect(userSync[0].url).to.exist
expect(userSync[0].type).to.be.equal('image')
expect(userSync[0].url).to.contain('gdpr=1&gdpr_consent=111111&us_privacy=1YYY')
expect(userSync[0].url).to.contain(
'gdpr=1&gdpr_consent=111111&us_privacy=1YYY'
)
})
})

0 comments on commit 11ce031

Please sign in to comment.