Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nativo Bid Adapter: Identify refreshed inventory to bidder endpoint #7201

Merged
merged 13 commits into from
Jul 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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'
)
})
})