forked from prebid/Prebid.js
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prebid Server: Include adUnitCode in PBS Adapter Requests (prebid#9337)
* changes * added support to pass adunitcode to pbs * updated comment * removed console log statements * addressed feedback
- Loading branch information
1 parent
f242e63
commit c231734
Showing
4 changed files
with
42 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import {deepSetValue} from '../../../src/utils.js'; | ||
|
||
export function setImpAdUnitCode(imp, bidRequest) { | ||
const adUnitCode = bidRequest.adUnitCode; | ||
|
||
if (adUnitCode) { | ||
deepSetValue( | ||
imp, | ||
`ext.prebid.adunitcode`, | ||
adUnitCode | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import {setImpAdUnitCode} from '../../../../libraries/pbsExtensions/processors/adUnitCode.js'; | ||
|
||
describe('pbjs -> ortb adunit code to imp[].ext.prebid.adunitcode', () => { | ||
function setImp(bidRequest) { | ||
const imp = {}; | ||
setImpAdUnitCode(imp, bidRequest); | ||
return imp; | ||
} | ||
|
||
it('it sets adunitcode in ext.prebid.adunitcode when adUnitCode is present', () => { | ||
expect(setImp({bidder: 'mockBidder', adUnitCode: 'mockAdUnit'})).to.eql({ | ||
'ext': { | ||
'prebid': { | ||
'adunitcode': 'mockAdUnit' | ||
} | ||
} | ||
}) | ||
}); | ||
|
||
it('does not set adunitcode in ext.prebid.adunitcode if adUnit is undefined', () => { | ||
expect(setImp({bidder: 'mockBidder'})).to.eql({}); | ||
}); | ||
}); |