@@ -613,7 +613,8 @@ export const getPriceGranularity = (mediaType, bidReq) => {
613
613
* @returns {function }
614
614
*/
615
615
export const getPriceByGranularity = ( granularity ) => {
616
- return ( bid ) => {
616
+ return ( bid , bidReq ) => {
617
+ granularity = granularity || getPriceGranularity ( bid . mediaType , bidReq ) ;
617
618
if ( granularity === CONSTANTS . GRANULARITY_OPTIONS . AUTO ) {
618
619
return bid . pbAg ;
619
620
} else if ( granularity === CONSTANTS . GRANULARITY_OPTIONS . DENSE ) {
@@ -646,22 +647,21 @@ export const getAdvertiserDomain = () => {
646
647
* @param {BidRequest } bidReq
647
648
* @returns {* }
648
649
*/
649
- export function getStandardBidderSettings ( mediaType , bidderCode , bidReq ) {
650
+ export function getStandardBidderSettings ( mediaType , bidderCode ) {
650
651
// factory for key value objs
651
652
function createKeyVal ( key , value ) {
652
653
return {
653
654
key,
654
655
val : ( typeof value === 'function' )
655
- ? function ( bidResponse ) {
656
- return value ( bidResponse ) ;
656
+ ? function ( bidResponse , bidReq ) {
657
+ return value ( bidResponse , bidReq ) ;
657
658
}
658
659
: function ( bidResponse ) {
659
660
return getValue ( bidResponse , value ) ;
660
661
}
661
662
} ;
662
663
}
663
664
const TARGETING_KEYS = CONSTANTS . TARGETING_KEYS ;
664
- const granularity = getPriceGranularity ( mediaType , bidReq ) ;
665
665
666
666
let bidderSettings = $$PREBID_GLOBAL$$ . bidderSettings ;
667
667
if ( ! bidderSettings [ CONSTANTS . JSON_MAPPING . BD_SETTING_STANDARD ] ) {
@@ -671,7 +671,7 @@ export function getStandardBidderSettings(mediaType, bidderCode, bidReq) {
671
671
bidderSettings [ CONSTANTS . JSON_MAPPING . BD_SETTING_STANDARD ] [ CONSTANTS . JSON_MAPPING . ADSERVER_TARGETING ] = [
672
672
createKeyVal ( TARGETING_KEYS . BIDDER , 'bidderCode' ) ,
673
673
createKeyVal ( TARGETING_KEYS . AD_ID , 'adId' ) ,
674
- createKeyVal ( TARGETING_KEYS . PRICE_BUCKET , getPriceByGranularity ( granularity ) ) ,
674
+ createKeyVal ( TARGETING_KEYS . PRICE_BUCKET , getPriceByGranularity ( ) ) ,
675
675
createKeyVal ( TARGETING_KEYS . SIZE , 'size' ) ,
676
676
createKeyVal ( TARGETING_KEYS . DEAL , 'dealId' ) ,
677
677
createKeyVal ( TARGETING_KEYS . SOURCE , 'source' ) ,
@@ -716,12 +716,12 @@ export function getKeyValueTargetingPairs(bidderCode, custBidObj, bidReq) {
716
716
// 1) set the keys from "standard" setting or from prebid defaults
717
717
if ( bidderSettings ) {
718
718
// initialize default if not set
719
- const standardSettings = getStandardBidderSettings ( custBidObj . mediaType , bidderCode , bidReq ) ;
720
- setKeys ( keyValues , standardSettings , custBidObj ) ;
719
+ const standardSettings = getStandardBidderSettings ( custBidObj . mediaType , bidderCode ) ;
720
+ setKeys ( keyValues , standardSettings , custBidObj , bidReq ) ;
721
721
722
722
// 2) set keys from specific bidder setting override if they exist
723
723
if ( bidderCode && bidderSettings [ bidderCode ] && bidderSettings [ bidderCode ] [ CONSTANTS . JSON_MAPPING . ADSERVER_TARGETING ] ) {
724
- setKeys ( keyValues , bidderSettings [ bidderCode ] , custBidObj ) ;
724
+ setKeys ( keyValues , bidderSettings [ bidderCode ] , custBidObj , bidReq ) ;
725
725
custBidObj . sendStandardTargeting = bidderSettings [ bidderCode ] . sendStandardTargeting ;
726
726
}
727
727
}
@@ -734,7 +734,7 @@ export function getKeyValueTargetingPairs(bidderCode, custBidObj, bidReq) {
734
734
return keyValues ;
735
735
}
736
736
737
- function setKeys ( keyValues , bidderSettings , custBidObj ) {
737
+ function setKeys ( keyValues , bidderSettings , custBidObj , bidReq ) {
738
738
var targeting = bidderSettings [ CONSTANTS . JSON_MAPPING . ADSERVER_TARGETING ] ;
739
739
custBidObj . size = custBidObj . getSize ( ) ;
740
740
@@ -748,7 +748,7 @@ function setKeys(keyValues, bidderSettings, custBidObj) {
748
748
749
749
if ( isFn ( value ) ) {
750
750
try {
751
- value = value ( custBidObj ) ;
751
+ value = value ( custBidObj , bidReq ) ;
752
752
} catch ( e ) {
753
753
logError ( 'bidmanager' , 'ERROR' , e ) ;
754
754
}
0 commit comments