profile
viewpoint
Jim Naumann muncha Ormond Beach, FL, USA

jsalis/Prebid.js 0

Setup and manage header bidding advertising partners without writing code or confusing line items. Prebid.js is open source and free.

muncha/android-udev-rules 0

Android udev rules list aimed to be the most comprehensive on the net

muncha/prebid-server 0

Server side component to offload prebid processing to the cloud

muncha/Prebid.js 0

Setup and manage header bidding advertising partners without writing code or confusing line items. Prebid.js is open source and free.

Pull request review commentprebid/prebid-server

Added usersync support to Between SSP adapter; Major fixes and refactor

 package between import ( 	"encoding/json" 	"fmt"-	"github.com/golang/glog"+	"github.com/prebid/prebid-server/macros"+	"net/http"+	"net/url"+	"strconv"+	"text/template"+ 	"github.com/mxmCherry/openrtb" 	"github.com/prebid/prebid-server/adapters" 	"github.com/prebid/prebid-server/errortypes"-	"github.com/prebid/prebid-server/macros" 	"github.com/prebid/prebid-server/openrtb_ext"--	"net/http"-	"text/template" )  type BetweenAdapter struct { 	EndpointTemplate template.Template } -func (a *BetweenAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) {--	errs := make([]error, 0, len(request.Imp))-	headers := http.Header{-		"Content-Type": {"application/json"},-		"Accept":       {"application/json"},-	}--	// Pull the host info from the bidder params.-	reqImps, errs := splitImpressions(request.Imp)+const (+	defaultBidfloor = 0.00001 // BetweenSSP requires bidfloor > 0. If BidFloor of openrtb_ext.ExtImpBetween is zero, set it to defaultBidFloor value, see addImpProps+) -	if len(reqImps) == 0 {+func (a *BetweenAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) {+	var errors []error+	if len(request.Imp) == 0 { 		return nil, []error{&errortypes.BadInput{ 			Message: fmt.Sprintf("No valid Imps in Bid Request"), 		}} 	}--	requests := []*adapters.RequestData{}--	for reqExt, reqImp := range reqImps {-		request.Imp = reqImp-		reqJson, err := json.Marshal(request)--		if err != nil {-			errs = append(errs, err)-			continue+	ext, errors := preprocess(request)+	if errors != nil && len(errors) > 0 {+		return nil, errors+	}+	endpoint, err := a.buildEndpointURL(ext)+	if err != nil {+		return nil, []error{&errortypes.BadInput{+			Message: fmt.Sprintf("Failed to build endpoint URL: %s", err),+		}}+	}+	data, err := json.Marshal(request)+	if err != nil {+		return nil, []error{&errortypes.BadInput{+			Message: fmt.Sprintf("Error in packaging request to JSON"),+		}}+	}+	headers := http.Header{}+	headers.Add("Content-Type", "application/json;charset=utf-8")+	headers.Add("Accept", "application/json")+	if request.Device != nil {+		addHeaderIfNonEmpty(headers, "User-Agent", request.Device.UA)+		addHeaderIfNonEmpty(headers, "X-Forwarded-For", request.Device.IP)+		addHeaderIfNonEmpty(headers, "Accept-Language", request.Device.Language)+		if request.Device.DNT != nil {+			addHeaderIfNonEmpty(headers, "DNT", strconv.Itoa(int(*request.Device.DNT))) 		}+	}+	if request.Site != nil {+		addHeaderIfNonEmpty(headers, "Referer", request.Site.Page)+	} -		urlParams := macros.EndpointTemplateParams{Host: reqExt.Host}-		url, err := macros.ResolveMacros(a.EndpointTemplate, urlParams)+	return []*adapters.RequestData{{+		Method:  "POST",+		Uri:     endpoint,+		Body:    data,+		Headers: headers,+	}}, errors+} -		if err != nil {-			errs = append(errs, err)-			continue+func unpackImpExt(imp *openrtb.Imp) (*openrtb_ext.ExtImpBetween, error) {+	var bidderExt adapters.ExtImpBidder+	if err := json.Unmarshal(imp.Ext, &bidderExt); err != nil {+		return nil, &errortypes.BadInput{+			Message: "ignoring BidRequest: no valid Imps", 		}+	} -		request := adapters.RequestData{-			Method:  "POST",-			Uri:     url,-			Body:    reqJson,-			Headers: headers}--		requests = append(requests, &request)+	var betweenExt openrtb_ext.ExtImpBetween+	if err := json.Unmarshal(bidderExt.Bidder, &betweenExt); err != nil {+		return nil, &errortypes.BadInput{+			Message: fmt.Sprintf("ignoring imp id=%s, invalid ImpExt", imp.ID),+		} 	} -	return requests, errs+	return &betweenExt, nil } -func (a *BetweenAdapter) MakeBids(-	internalRequest *openrtb.BidRequest,-	externalRequest *adapters.RequestData,-	response *adapters.ResponseData,-) (*adapters.BidderResponse, []error) {--	if response.StatusCode == http.StatusNoContent {-		return nil, nil+func (a *BetweenAdapter) buildEndpointURL(e *openrtb_ext.ExtImpBetween) (string, error) {+	missingRequiredParameterMessage := "required BetweenSSP parameter \"%s\" is missing"+	if e.Host == "" {+		return "", &errortypes.BadInput{+			Message: fmt.Sprintf(missingRequiredParameterMessage, "host"),+		}+	}+	if e.PublisherID == "" {+		return "", &errortypes.BadInput{+			Message: fmt.Sprintf(missingRequiredParameterMessage, "publisher_id"),+		} 	}+	return macros.ResolveMacros(a.EndpointTemplate, macros.EndpointTemplateParams{Host: e.Host, PublisherID: e.PublisherID})+} -	if response.StatusCode == http.StatusBadRequest {-		return nil, []error{&errortypes.BadInput{-			Message: fmt.Sprintf("Unexpected status code: %d. Bad request to dsp", response.StatusCode),-		}}-	} else if response.StatusCode != http.StatusOK {-		return nil, []error{&errortypes.BadServerResponse{-			Message: fmt.Sprintf("ERR, response with status %d", response.StatusCode),-		}}+func buildImpBanner(imp *openrtb.Imp) error {+	if imp.Banner == nil {+		return &errortypes.BadInput{+			Message: fmt.Sprintf("Request needs to include a Banner object"),+		} 	} -	var bidResp openrtb.BidResponse+	bannerCopy := *imp.Banner+	banner := &bannerCopy -	if err := json.Unmarshal(response.Body, &bidResp); err != nil {-		return nil, []error{err}+	if banner.W == nil && banner.H == nil {+		if len(banner.Format) == 0 {+			return &errortypes.BadInput{+				Message: fmt.Sprintf("Need at least one size to build request"),+			}+		}+		format := banner.Format[0]+		banner.Format = banner.Format[1:]+		banner.W = &format.W+		banner.H = &format.H+		imp.Banner = banner 	} -	adapterResponse := adapters.NewBidderResponse()-	adapterResponse.Currency = bidResp.Cur+	return nil+} -	for _, seatBid := range bidResp.SeatBid {-		for i := 0; i < len(seatBid.Bid); i++ {-			bid := seatBid.Bid[i]-			adapterResponse.Bids = append(adapterResponse.Bids, &adapters.TypedBid{-				Bid:     &bid,-				BidType: getMediaType(bid.ImpID, internalRequest.Imp),-			})-		}+// Add Between required properties to Imp object+func addImpProps(imp *openrtb.Imp, secure *int8, betweenExt *openrtb_ext.ExtImpBetween) {+	imp.Secure = secure+	bidFloor, err := strconv.ParseFloat(betweenExt.BidFloor, 64)+	if err != nil {

Please consider simplifying this as follows:

if bidFloor, err := strconv.ParseFloat(betweenExt.BidFloor, 64); err != nil || bidFloor <= 0 {
	imp.BidFloor = defaultBidfloor
} else {
	imp.BidFloor = bidFloor
}
egsk

comment created time in 16 hours

Pull request review commentprebid/prebid-server

Added usersync support to Between SSP adapter; Major fixes and refactor

 package between import ( 	"encoding/json" 	"fmt"-	"github.com/golang/glog"+	"github.com/prebid/prebid-server/macros"+	"net/http"+	"net/url"+	"strconv"+	"text/template"+ 	"github.com/mxmCherry/openrtb" 	"github.com/prebid/prebid-server/adapters" 	"github.com/prebid/prebid-server/errortypes"-	"github.com/prebid/prebid-server/macros" 	"github.com/prebid/prebid-server/openrtb_ext"--	"net/http"-	"text/template" )  type BetweenAdapter struct { 	EndpointTemplate template.Template } -func (a *BetweenAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) {--	errs := make([]error, 0, len(request.Imp))-	headers := http.Header{-		"Content-Type": {"application/json"},-		"Accept":       {"application/json"},-	}--	// Pull the host info from the bidder params.-	reqImps, errs := splitImpressions(request.Imp)+const (+	defaultBidfloor = 0.00001 // BetweenSSP requires bidfloor > 0. If BidFloor of openrtb_ext.ExtImpBetween is zero, set it to defaultBidFloor value, see addImpProps+) -	if len(reqImps) == 0 {+func (a *BetweenAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) {+	var errors []error+	if len(request.Imp) == 0 { 		return nil, []error{&errortypes.BadInput{ 			Message: fmt.Sprintf("No valid Imps in Bid Request"), 		}} 	}--	requests := []*adapters.RequestData{}--	for reqExt, reqImp := range reqImps {-		request.Imp = reqImp-		reqJson, err := json.Marshal(request)--		if err != nil {-			errs = append(errs, err)-			continue+	ext, errors := preprocess(request)+	if errors != nil && len(errors) > 0 {+		return nil, errors+	}+	endpoint, err := a.buildEndpointURL(ext)+	if err != nil {+		return nil, []error{&errortypes.BadInput{+			Message: fmt.Sprintf("Failed to build endpoint URL: %s", err),+		}}+	}+	data, err := json.Marshal(request)+	if err != nil {+		return nil, []error{&errortypes.BadInput{+			Message: fmt.Sprintf("Error in packaging request to JSON"),+		}}+	}+	headers := http.Header{}+	headers.Add("Content-Type", "application/json;charset=utf-8")+	headers.Add("Accept", "application/json")+	if request.Device != nil {+		addHeaderIfNonEmpty(headers, "User-Agent", request.Device.UA)+		addHeaderIfNonEmpty(headers, "X-Forwarded-For", request.Device.IP)+		addHeaderIfNonEmpty(headers, "Accept-Language", request.Device.Language)+		if request.Device.DNT != nil {+			addHeaderIfNonEmpty(headers, "DNT", strconv.Itoa(int(*request.Device.DNT))) 		}+	}+	if request.Site != nil {+		addHeaderIfNonEmpty(headers, "Referer", request.Site.Page)+	} -		urlParams := macros.EndpointTemplateParams{Host: reqExt.Host}-		url, err := macros.ResolveMacros(a.EndpointTemplate, urlParams)+	return []*adapters.RequestData{{+		Method:  "POST",+		Uri:     endpoint,+		Body:    data,+		Headers: headers,+	}}, errors+} -		if err != nil {-			errs = append(errs, err)-			continue+func unpackImpExt(imp *openrtb.Imp) (*openrtb_ext.ExtImpBetween, error) {+	var bidderExt adapters.ExtImpBidder+	if err := json.Unmarshal(imp.Ext, &bidderExt); err != nil {+		return nil, &errortypes.BadInput{+			Message: "ignoring BidRequest: no valid Imps", 		}+	} -		request := adapters.RequestData{-			Method:  "POST",-			Uri:     url,-			Body:    reqJson,-			Headers: headers}--		requests = append(requests, &request)+	var betweenExt openrtb_ext.ExtImpBetween+	if err := json.Unmarshal(bidderExt.Bidder, &betweenExt); err != nil {+		return nil, &errortypes.BadInput{+			Message: fmt.Sprintf("ignoring imp id=%s, invalid ImpExt", imp.ID),+		} 	} -	return requests, errs+	return &betweenExt, nil } -func (a *BetweenAdapter) MakeBids(-	internalRequest *openrtb.BidRequest,-	externalRequest *adapters.RequestData,-	response *adapters.ResponseData,-) (*adapters.BidderResponse, []error) {--	if response.StatusCode == http.StatusNoContent {-		return nil, nil+func (a *BetweenAdapter) buildEndpointURL(e *openrtb_ext.ExtImpBetween) (string, error) {+	missingRequiredParameterMessage := "required BetweenSSP parameter \"%s\" is missing"+	if e.Host == "" {+		return "", &errortypes.BadInput{+			Message: fmt.Sprintf(missingRequiredParameterMessage, "host"),+		}+	}+	if e.PublisherID == "" {+		return "", &errortypes.BadInput{+			Message: fmt.Sprintf(missingRequiredParameterMessage, "publisher_id"),+		} 	}+	return macros.ResolveMacros(a.EndpointTemplate, macros.EndpointTemplateParams{Host: e.Host, PublisherID: e.PublisherID})+} -	if response.StatusCode == http.StatusBadRequest {-		return nil, []error{&errortypes.BadInput{-			Message: fmt.Sprintf("Unexpected status code: %d. Bad request to dsp", response.StatusCode),-		}}-	} else if response.StatusCode != http.StatusOK {-		return nil, []error{&errortypes.BadServerResponse{-			Message: fmt.Sprintf("ERR, response with status %d", response.StatusCode),-		}}+func buildImpBanner(imp *openrtb.Imp) error {+	if imp.Banner == nil {+		return &errortypes.BadInput{+			Message: fmt.Sprintf("Request needs to include a Banner object"),+		} 	} -	var bidResp openrtb.BidResponse+	bannerCopy := *imp.Banner+	banner := &bannerCopy -	if err := json.Unmarshal(response.Body, &bidResp); err != nil {-		return nil, []error{err}+	if banner.W == nil && banner.H == nil {+		if len(banner.Format) == 0 {+			return &errortypes.BadInput{+				Message: fmt.Sprintf("Need at least one size to build request"),+			}+		}+		format := banner.Format[0]+		banner.Format = banner.Format[1:]+		banner.W = &format.W+		banner.H = &format.H+		imp.Banner = banner 	} -	adapterResponse := adapters.NewBidderResponse()-	adapterResponse.Currency = bidResp.Cur+	return nil+} -	for _, seatBid := range bidResp.SeatBid {-		for i := 0; i < len(seatBid.Bid); i++ {-			bid := seatBid.Bid[i]-			adapterResponse.Bids = append(adapterResponse.Bids, &adapters.TypedBid{-				Bid:     &bid,-				BidType: getMediaType(bid.ImpID, internalRequest.Imp),-			})-		}+// Add Between required properties to Imp object+func addImpProps(imp *openrtb.Imp, secure *int8, betweenExt *openrtb_ext.ExtImpBetween) {+	imp.Secure = secure+	bidFloor, err := strconv.ParseFloat(betweenExt.BidFloor, 64)+	if err != nil {+		bidFloor = 0+	}+	if bidFloor > 0 {+		imp.BidFloor = bidFloor+	} else {+		imp.BidFloor = defaultBidfloor 	}+} -	return adapterResponse, nil+// Adding header fields to request header+func addHeaderIfNonEmpty(headers http.Header, headerName string, headerValue string) {+	if len(headerValue) > 0 {+		headers.Add(headerName, headerValue)+	} } -func splitImpressions(imps []openrtb.Imp) (map[openrtb_ext.ExtImpBetween][]openrtb.Imp, []error) {-	var errors = make([]error, 0)-	var m = make(map[openrtb_ext.ExtImpBetween][]openrtb.Imp)+// Handle request errors and formatting to be sent to Between+func preprocess(request *openrtb.BidRequest) (*openrtb_ext.ExtImpBetween, []error) {+	errors := make([]error, 0, len(request.Imp))+	resImps := make([]openrtb.Imp, 0, len(request.Imp))+	secure := int8(0) -	for _, imp := range imps {-		bidderParams, err := getBidderParams(&imp)+	if request.Site != nil && request.Site.Page != "" {+		pageURL, err := url.Parse(request.Site.Page)+		if err == nil && pageURL.Scheme == "https" {+			secure = int8(1)+		}+	}++	var betweenExt *openrtb_ext.ExtImpBetween+	for _, imp := range request.Imp {+		var err error+		betweenExt, err = unpackImpExt(&imp) 		if err != nil { 			errors = append(errors, err)-			continue+			return nil, errors

Are you sure you want to return at this point even if there was an error in unpacking only one of the imp ext? The other imps could still be valid and in that case you'd be throwing away those too. It might make more sense to append the error as you're doing now and ignore this imp but continue with the rest of them

egsk

comment created time in 16 hours

Pull request review commentprebid/prebid-server

Added usersync support to Between SSP adapter; Major fixes and refactor

 package between import ( 	"encoding/json" 	"fmt"-	"github.com/golang/glog"+	"github.com/prebid/prebid-server/macros"+	"net/http"+	"net/url"+	"strconv"+	"text/template"+ 	"github.com/mxmCherry/openrtb" 	"github.com/prebid/prebid-server/adapters" 	"github.com/prebid/prebid-server/errortypes"-	"github.com/prebid/prebid-server/macros" 	"github.com/prebid/prebid-server/openrtb_ext"--	"net/http"-	"text/template" )  type BetweenAdapter struct { 	EndpointTemplate template.Template } -func (a *BetweenAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) {--	errs := make([]error, 0, len(request.Imp))-	headers := http.Header{-		"Content-Type": {"application/json"},-		"Accept":       {"application/json"},-	}--	// Pull the host info from the bidder params.-	reqImps, errs := splitImpressions(request.Imp)+const (+	defaultBidfloor = 0.00001 // BetweenSSP requires bidfloor > 0. If BidFloor of openrtb_ext.ExtImpBetween is zero, set it to defaultBidFloor value, see addImpProps+) -	if len(reqImps) == 0 {+func (a *BetweenAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) {+	var errors []error+	if len(request.Imp) == 0 { 		return nil, []error{&errortypes.BadInput{ 			Message: fmt.Sprintf("No valid Imps in Bid Request"), 		}} 	}--	requests := []*adapters.RequestData{}--	for reqExt, reqImp := range reqImps {-		request.Imp = reqImp-		reqJson, err := json.Marshal(request)--		if err != nil {-			errs = append(errs, err)-			continue+	ext, errors := preprocess(request)+	if errors != nil && len(errors) > 0 {+		return nil, errors+	}+	endpoint, err := a.buildEndpointURL(ext)+	if err != nil {+		return nil, []error{&errortypes.BadInput{+			Message: fmt.Sprintf("Failed to build endpoint URL: %s", err),+		}}+	}+	data, err := json.Marshal(request)+	if err != nil {+		return nil, []error{&errortypes.BadInput{+			Message: fmt.Sprintf("Error in packaging request to JSON"),+		}}+	}+	headers := http.Header{}+	headers.Add("Content-Type", "application/json;charset=utf-8")+	headers.Add("Accept", "application/json")+	if request.Device != nil {+		addHeaderIfNonEmpty(headers, "User-Agent", request.Device.UA)+		addHeaderIfNonEmpty(headers, "X-Forwarded-For", request.Device.IP)+		addHeaderIfNonEmpty(headers, "Accept-Language", request.Device.Language)+		if request.Device.DNT != nil {+			addHeaderIfNonEmpty(headers, "DNT", strconv.Itoa(int(*request.Device.DNT))) 		}+	}+	if request.Site != nil {+		addHeaderIfNonEmpty(headers, "Referer", request.Site.Page)+	} -		urlParams := macros.EndpointTemplateParams{Host: reqExt.Host}-		url, err := macros.ResolveMacros(a.EndpointTemplate, urlParams)+	return []*adapters.RequestData{{+		Method:  "POST",+		Uri:     endpoint,+		Body:    data,+		Headers: headers,+	}}, errors+} -		if err != nil {-			errs = append(errs, err)-			continue+func unpackImpExt(imp *openrtb.Imp) (*openrtb_ext.ExtImpBetween, error) {+	var bidderExt adapters.ExtImpBidder+	if err := json.Unmarshal(imp.Ext, &bidderExt); err != nil {+		return nil, &errortypes.BadInput{+			Message: "ignoring BidRequest: no valid Imps", 		}+	} -		request := adapters.RequestData{-			Method:  "POST",-			Uri:     url,-			Body:    reqJson,-			Headers: headers}--		requests = append(requests, &request)+	var betweenExt openrtb_ext.ExtImpBetween+	if err := json.Unmarshal(bidderExt.Bidder, &betweenExt); err != nil {+		return nil, &errortypes.BadInput{+			Message: fmt.Sprintf("ignoring imp id=%s, invalid ImpExt", imp.ID),+		} 	} -	return requests, errs+	return &betweenExt, nil } -func (a *BetweenAdapter) MakeBids(-	internalRequest *openrtb.BidRequest,-	externalRequest *adapters.RequestData,-	response *adapters.ResponseData,-) (*adapters.BidderResponse, []error) {--	if response.StatusCode == http.StatusNoContent {-		return nil, nil+func (a *BetweenAdapter) buildEndpointURL(e *openrtb_ext.ExtImpBetween) (string, error) {+	missingRequiredParameterMessage := "required BetweenSSP parameter \"%s\" is missing"+	if e.Host == "" {+		return "", &errortypes.BadInput{+			Message: fmt.Sprintf(missingRequiredParameterMessage, "host"),+		}+	}+	if e.PublisherID == "" {+		return "", &errortypes.BadInput{+			Message: fmt.Sprintf(missingRequiredParameterMessage, "publisher_id"),+		} 	}+	return macros.ResolveMacros(a.EndpointTemplate, macros.EndpointTemplateParams{Host: e.Host, PublisherID: e.PublisherID})+} -	if response.StatusCode == http.StatusBadRequest {-		return nil, []error{&errortypes.BadInput{-			Message: fmt.Sprintf("Unexpected status code: %d. Bad request to dsp", response.StatusCode),-		}}-	} else if response.StatusCode != http.StatusOK {-		return nil, []error{&errortypes.BadServerResponse{-			Message: fmt.Sprintf("ERR, response with status %d", response.StatusCode),-		}}+func buildImpBanner(imp *openrtb.Imp) error {+	if imp.Banner == nil {+		return &errortypes.BadInput{+			Message: fmt.Sprintf("Request needs to include a Banner object"),+		} 	} -	var bidResp openrtb.BidResponse+	bannerCopy := *imp.Banner+	banner := &bannerCopy -	if err := json.Unmarshal(response.Body, &bidResp); err != nil {-		return nil, []error{err}+	if banner.W == nil && banner.H == nil {+		if len(banner.Format) == 0 {+			return &errortypes.BadInput{+				Message: fmt.Sprintf("Need at least one size to build request"),+			}+		}+		format := banner.Format[0]+		banner.Format = banner.Format[1:]+		banner.W = &format.W+		banner.H = &format.H+		imp.Banner = banner 	} -	adapterResponse := adapters.NewBidderResponse()-	adapterResponse.Currency = bidResp.Cur+	return nil+} -	for _, seatBid := range bidResp.SeatBid {-		for i := 0; i < len(seatBid.Bid); i++ {-			bid := seatBid.Bid[i]-			adapterResponse.Bids = append(adapterResponse.Bids, &adapters.TypedBid{-				Bid:     &bid,-				BidType: getMediaType(bid.ImpID, internalRequest.Imp),-			})-		}+// Add Between required properties to Imp object+func addImpProps(imp *openrtb.Imp, secure *int8, betweenExt *openrtb_ext.ExtImpBetween) {+	imp.Secure = secure+	bidFloor, err := strconv.ParseFloat(betweenExt.BidFloor, 64)+	if err != nil {+		bidFloor = 0+	}+	if bidFloor > 0 {+		imp.BidFloor = bidFloor+	} else {+		imp.BidFloor = defaultBidfloor 	}+} -	return adapterResponse, nil+// Adding header fields to request header+func addHeaderIfNonEmpty(headers http.Header, headerName string, headerValue string) {+	if len(headerValue) > 0 {+		headers.Add(headerName, headerValue)+	} } -func splitImpressions(imps []openrtb.Imp) (map[openrtb_ext.ExtImpBetween][]openrtb.Imp, []error) {-	var errors = make([]error, 0)-	var m = make(map[openrtb_ext.ExtImpBetween][]openrtb.Imp)+// Handle request errors and formatting to be sent to Between+func preprocess(request *openrtb.BidRequest) (*openrtb_ext.ExtImpBetween, []error) {+	errors := make([]error, 0, len(request.Imp))+	resImps := make([]openrtb.Imp, 0, len(request.Imp))+	secure := int8(0) -	for _, imp := range imps {-		bidderParams, err := getBidderParams(&imp)+	if request.Site != nil && request.Site.Page != "" {+		pageURL, err := url.Parse(request.Site.Page)+		if err == nil && pageURL.Scheme == "https" {+			secure = int8(1)+		}+	}++	var betweenExt *openrtb_ext.ExtImpBetween+	for _, imp := range request.Imp {+		var err error+		betweenExt, err = unpackImpExt(&imp) 		if err != nil { 			errors = append(errors, err)-			continue+			return nil, errors 		} -		v, ok := m[bidderParams]-		if ok {-			m[bidderParams] = append(v, imp)-		} else {-			m[bidderParams] = []openrtb.Imp{imp}+		addImpProps(&imp, &secure, betweenExt)++		if err := buildImpBanner(&imp); err != nil {+			errors = append(errors, err)+			return nil, errors

Similar comment as above

egsk

comment created time in 16 hours

Pull request review commentprebid/prebid-server

Added usersync support to Between SSP adapter; Major fixes and refactor

 package between import ( 	"encoding/json" 	"fmt"-	"github.com/golang/glog"+	"github.com/prebid/prebid-server/macros"+	"net/http"+	"net/url"+	"strconv"+	"text/template"+ 	"github.com/mxmCherry/openrtb" 	"github.com/prebid/prebid-server/adapters" 	"github.com/prebid/prebid-server/errortypes"-	"github.com/prebid/prebid-server/macros" 	"github.com/prebid/prebid-server/openrtb_ext"--	"net/http"-	"text/template" )  type BetweenAdapter struct { 	EndpointTemplate template.Template } -func (a *BetweenAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) {--	errs := make([]error, 0, len(request.Imp))-	headers := http.Header{-		"Content-Type": {"application/json"},-		"Accept":       {"application/json"},-	}--	// Pull the host info from the bidder params.-	reqImps, errs := splitImpressions(request.Imp)+const (+	defaultBidfloor = 0.00001 // BetweenSSP requires bidfloor > 0. If BidFloor of openrtb_ext.ExtImpBetween is zero, set it to defaultBidFloor value, see addImpProps+) -	if len(reqImps) == 0 {+func (a *BetweenAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) {+	var errors []error+	if len(request.Imp) == 0 { 		return nil, []error{&errortypes.BadInput{ 			Message: fmt.Sprintf("No valid Imps in Bid Request"), 		}} 	}--	requests := []*adapters.RequestData{}--	for reqExt, reqImp := range reqImps {-		request.Imp = reqImp-		reqJson, err := json.Marshal(request)--		if err != nil {-			errs = append(errs, err)-			continue+	ext, errors := preprocess(request)+	if errors != nil && len(errors) > 0 {+		return nil, errors+	}+	endpoint, err := a.buildEndpointURL(ext)+	if err != nil {+		return nil, []error{&errortypes.BadInput{+			Message: fmt.Sprintf("Failed to build endpoint URL: %s", err),+		}}+	}+	data, err := json.Marshal(request)+	if err != nil {+		return nil, []error{&errortypes.BadInput{+			Message: fmt.Sprintf("Error in packaging request to JSON"),+		}}+	}+	headers := http.Header{}+	headers.Add("Content-Type", "application/json;charset=utf-8")+	headers.Add("Accept", "application/json")+	if request.Device != nil {+		addHeaderIfNonEmpty(headers, "User-Agent", request.Device.UA)+		addHeaderIfNonEmpty(headers, "X-Forwarded-For", request.Device.IP)+		addHeaderIfNonEmpty(headers, "Accept-Language", request.Device.Language)+		if request.Device.DNT != nil {+			addHeaderIfNonEmpty(headers, "DNT", strconv.Itoa(int(*request.Device.DNT))) 		}+	}+	if request.Site != nil {+		addHeaderIfNonEmpty(headers, "Referer", request.Site.Page)+	} -		urlParams := macros.EndpointTemplateParams{Host: reqExt.Host}-		url, err := macros.ResolveMacros(a.EndpointTemplate, urlParams)+	return []*adapters.RequestData{{+		Method:  "POST",+		Uri:     endpoint,+		Body:    data,+		Headers: headers,+	}}, errors+} -		if err != nil {-			errs = append(errs, err)-			continue+func unpackImpExt(imp *openrtb.Imp) (*openrtb_ext.ExtImpBetween, error) {+	var bidderExt adapters.ExtImpBidder+	if err := json.Unmarshal(imp.Ext, &bidderExt); err != nil {+		return nil, &errortypes.BadInput{+			Message: "ignoring BidRequest: no valid Imps",

Please consider changing this message to saying Invalid Bidder ext or something along those lines. Similar to what you have below on L83

egsk

comment created time in 16 hours

Pull request review commentprebid/prebid-server

Added usersync support to Between SSP adapter; Major fixes and refactor

 package between import ( 	"encoding/json" 	"fmt"-	"github.com/golang/glog"+	"github.com/prebid/prebid-server/macros"+	"net/http"+	"net/url"+	"strconv"+	"text/template"+ 	"github.com/mxmCherry/openrtb" 	"github.com/prebid/prebid-server/adapters" 	"github.com/prebid/prebid-server/errortypes"-	"github.com/prebid/prebid-server/macros" 	"github.com/prebid/prebid-server/openrtb_ext"--	"net/http"-	"text/template" )  type BetweenAdapter struct { 	EndpointTemplate template.Template } -func (a *BetweenAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) {--	errs := make([]error, 0, len(request.Imp))-	headers := http.Header{-		"Content-Type": {"application/json"},-		"Accept":       {"application/json"},-	}--	// Pull the host info from the bidder params.-	reqImps, errs := splitImpressions(request.Imp)+const (+	defaultBidfloor = 0.00001 // BetweenSSP requires bidfloor > 0. If BidFloor of openrtb_ext.ExtImpBetween is zero, set it to defaultBidFloor value, see addImpProps

Nitpick: Since you're defining a single constant, you can just use the const keyword in front of the variable name. Enclosing it into a block makes more sense if you have more than one constants being defined

egsk

comment created time in 6 days

Pull request review commentprebid/prebid-server

New mobfox prebid server adapter

+{

Yep, really there was two duplicates

mobfxoHB

comment created time in 17 hours

Pull request review commentprebid/prebid-server

New mobfox prebid server adapter

+package mobfoxpb++import (+	"encoding/json"+	"fmt"+	"net/http"++	"github.com/buger/jsonparser"+	"github.com/mxmCherry/openrtb"+	"github.com/prebid/prebid-server/adapters"+	"github.com/prebid/prebid-server/errortypes"+	"github.com/prebid/prebid-server/openrtb_ext"+)++type MobfoxpbAdapter struct {+	URI string+}++// NewMobfoxpbBidder Initializes the Bidder+func NewMobfoxpbBidder(endpoint string) *MobfoxpbAdapter {+	return &MobfoxpbAdapter{+		URI: endpoint,+	}+}++// MakeRequests create bid request for mobfoxpb demand+func (a *MobfoxpbAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) {+	var errs []error+	var err error+	var tagID string++	var adapterRequests []*adapters.RequestData++	reqCopy := *request+	for _, imp := range request.Imp {+		reqCopy.Imp = []openrtb.Imp{imp}++		tagID, err = jsonparser.GetString(reqCopy.Imp[0].Ext, "bidder", "TagID")+		if err != nil {+			errs = append(errs, err)+			continue+		}++		reqCopy.Imp[0].TagID = tagID++		adapterReq, errors := a.makeRequest(&reqCopy)+		if adapterReq != nil {+			adapterRequests = append(adapterRequests, adapterReq)+		}+		errs = append(errs, errors...)+	}+	return adapterRequests, errs+}++func (a *MobfoxpbAdapter) makeRequest(request *openrtb.BidRequest) (*adapters.RequestData, []error) {++	var errs []error++	reqJSON, err := json.Marshal(request)++	if err != nil {+		errs = append(errs, err)+		return nil, errs+	}++	headers := http.Header{}+	headers.Add("Content-Type", "application/json;charset=utf-8")+	headers.Add("Accept", "application/json")+	return &adapters.RequestData{+		Method:  "POST",+		Uri:     a.URI,+		Body:    reqJSON,+		Headers: headers,+	}, errs+}++// MakeBids makes the bids+func (a *MobfoxpbAdapter) MakeBids(internalRequest *openrtb.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) {+	var errs []error++	if response.StatusCode == http.StatusNoContent {+		return nil, nil+	}++	if response.StatusCode == http.StatusNotFound {+		return nil, []error{&errortypes.BadServerResponse{+			Message: fmt.Sprintf("Unexpected status code: %d. Run with request.debug = 1 for more info", response.StatusCode),+		}}+	}++	if response.StatusCode != http.StatusOK {+		return nil, []error{&errortypes.BadServerResponse{+			Message: fmt.Sprintf("Unexpected status code: %d. Run with request.debug = 1 for more info", response.StatusCode),+		}}+	}++	var bidResp openrtb.BidResponse++	if err := json.Unmarshal(response.Body, &bidResp); err != nil {+		return nil, []error{err}+	}++	bidResponse := adapters.NewBidderResponseWithBidsCapacity(1)++	for _, sb := range bidResp.SeatBid {+		for i := range sb.Bid {+			bidType, err := getMediaTypeForImp(sb.Bid[i].ImpID, internalRequest.Imp)+			if err != nil {+				errs = append(errs, err)+			} else {+				b := &adapters.TypedBid{+					Bid:     &sb.Bid[i],+					BidType: bidType,+				}+				bidResponse.Bids = append(bidResponse.Bids, b)+			}+		}+	}+	return bidResponse, errs+}++func getMediaTypeForImp(impID string, imps []openrtb.Imp) (openrtb_ext.BidType, error) {+	mediaType := openrtb_ext.BidTypeBanner+	for _, imp := range imps {+		if imp.ID == impID {+			if imp.Banner == nil && imp.Video != nil {+				mediaType = openrtb_ext.BidTypeVideo

first bid.imp (bid.imp[0]) will be taken into account

mobfxoHB

comment created time in 17 hours

Pull request review commentprebid/prebid-server

New mobfox prebid server adapter

+package mobfoxpb++import (+	"encoding/json"+	"fmt"+	"net/http"++	"github.com/buger/jsonparser"+	"github.com/mxmCherry/openrtb"+	"github.com/prebid/prebid-server/adapters"+	"github.com/prebid/prebid-server/errortypes"+	"github.com/prebid/prebid-server/openrtb_ext"+)++// MobfoxpbAdapter adapter structure+type MobfoxpbAdapter struct {+	URI string+}++// NewMobfoxpbBidder Initializes the Bidder+func NewMobfoxpbBidder(endpoint string) *MobfoxpbAdapter {+	return &MobfoxpbAdapter{+		URI: endpoint,+	}+}++// MakeRequests create bid request for mobfoxpb demand+func (a *MobfoxpbAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) {+	var errs []error+	var err error+	var tagID string++	var adapterRequests []*adapters.RequestData++	reqCopy := *request+	for _, imp := range request.Imp {

Some thoughts on the for loop inside MakeRequests: I read above that you expect arrays with a single Imp. Even if that's always the case, I left some comments below:

28   func (a *MobfoxpbAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) {
29   *--  5 lines: var errs []error--------------------------------------------------------------------------
34  
35       reqCopy := *request
36       for _, imp := range request.Imp {
   +         // No need to manually create a local copy, the foreach statement creates a local copy of the current element
37 -         reqCopy.Imp = []openrtb.Imp{imp}
38  
39 -         tagID, err = jsonparser.GetString(reqCopy.Imp[0].Ext, "bidder", "TagID")
   +         // Unmarshalling the current element is safe
   +         tagID, err = jsonparser.GetString(imp.Ext, "bidder", "TagID")
40           if err != nil {
41               errs = append(errs, err)
42               continue
43           }
44  
45 -         reqCopy.Imp[0].TagID = tagID
   +         // In golang, the foreach statement creates a local copy of the elements of the array
   +         // it is traversing. Therefore, it's safe to overwrite `TagID`
   +         imp.TagID = tagID
   +         // It might be better to move the `Imp` slice creation down here in order to do it only after after we
   +         // made sure `jsonparser.GetString(reqCopy.Imp[0].Ext, "bidder", "TagID")` did not return an error
   +         reqCopy.Imp = []openrtb.Imp{imp}
46  
47           adapterReq, err := a.makeRequest(&reqCopy)
48           if err != nil {
49               errs = append(errs, err)
50           }
51           if adapterReq != nil {
52               adapterRequests = append(adapterRequests, adapterReq)
   +             // Given that we succeeded, we should break here, isn't it? Unless, we want 
   +             // to append more than one "valid" `adapterReq` in the `adapterRequests` array
   +             break
53           }
54       }
55       return adapterRequests, errs
56   }
adapters/mobfoxpb/mobfoxpb.go
mobfxoHB

comment created time in 20 hours

push eventprebid/prebid-server

Laurentiu Badea

commit sha 7c7097a43b27710ee32a683fffac7e648895eb35

Add timestamp to analytics and response.ext.prebid.auctiontimestamp l… (#1584)

view details

push time in a day

PR merged prebid/prebid-server

Reviewers
Add timestamp to analytics and response.ext.prebid.auctiontimestamp l…

…estamp (like PBS-Java)

In addition to analytics, this timestamp will be used later for generating event urls for #1470 and #1015

  "ext": {
    "prebid": {
      "auctiontimestamp": 1605231385254
    }
  }
+53 -23

1 comment

7 changed files

laurb9

pr closed time in a day

PR opened prebid/prebid-server

Fix appnexus adapter not setting currency in the bid response

It has been reported that appnexus may not be behaving properly in foreign currency contexts. It appears that the adapter does not set the curr (currency), field in the bid response. This pull request makes this correction and adds a JSON test file but proper assertion of the Currency field of the BidderResponse inside adapters/adapterstest/test_json.go will be implemented in a separate PR being developed by @mansinahar

+146 -0

0 comment

2 changed files

pr created time in a day

issue commentprebid/prebid-server

PBS video impression tracking

I've implemented most of the logic in #1597 . The goal was to get the unit tests to a point where we can validate the behavior, then do some refactoring.

I see a few differences between what PBS-Java does and the algorithm above:

  • Only the cached VAST is modified, the VAST returned in adm field is not. Is this intentional ? I have copied this behavior in the PR above.
  • bid caching and vast modification are not exclusive as the else above suggests. PBS-Java will change both VAST and cached bids if enabled. This made sense to me, so that's what I did too.
  • int (integration) does not get a value, so I didn't add it yet.

Need some clarification on what controls vast rewriting. I currently only look at bidder, but I think this could be bidder.modifyingVastXmlAllowed & account.modifyingVastXmlAllowed & (account.eventsEnabled | request.ext.prebid.events). Thoughts ?

bretg

comment created time in a day

Pull request review commentprebid/prebid-server

New mobfox prebid server adapter

+package mobfoxpb++import (+	"encoding/json"+	"fmt"+	"net/http"++	"github.com/buger/jsonparser"+	"github.com/mxmCherry/openrtb"+	"github.com/prebid/prebid-server/adapters"+	"github.com/prebid/prebid-server/errortypes"+	"github.com/prebid/prebid-server/openrtb_ext"+)++type MobfoxpbAdapter struct {+	URI string+}++// NewMobfoxpbBidder Initializes the Bidder+func NewMobfoxpbBidder(endpoint string) *MobfoxpbAdapter {+	return &MobfoxpbAdapter{

Github circle ci, after failed commit - i've reverted changes

mobfxoHB

comment created time in 2 days

Pull request review commentprebid/prebid-server

Fix GDPR consent assumption when gdpr req signal is unambiguous and s…

 func TestMalformedConsent(t *testing.T) { }  func TestAllowPersonalInfo(t *testing.T) {+	tests := []struct {+		description string+		bidderName  openrtb_ext.BidderName+		publisherID string+		gdpr        GDPRState+		consent     string+		allowPI     bool+	}{+		{+			description: "Allow PI - Non standard publisher",+			bidderName:  openrtb_ext.BidderAppnexus,+			publisherID: "appNexusAppID",+			gdpr:        YesGDPR,+			consent:     "BOS2bx5OS2bx5ABABBAAABoAAAABBwAA",+			allowPI:     true,+		},+		{+			description: "Allow PI - No GDPR",+			bidderName:  openrtb_ext.BidderPubmatic,

Please add a comment here similar to what you have below with " known vendor...."

bsardo

comment created time in 2 days

Pull request review commentprebid/prebid-server

Fix GDPR consent assumption when gdpr req signal is unambiguous and s…

 import ( 	"github.com/prebid/go-gdpr/vendorlist" 	"github.com/prebid/prebid-server/config" 	"github.com/prebid/prebid-server/openrtb_ext"+	// "github.com/prebid/prebid-server/exchange"

Please remove commented out import.

bsardo

comment created time in 2 days

Pull request review commentprebid/prebid-server

Fix GDPR consent assumption when gdpr req signal is unambiguous and s…

 func cleanOpenRTBRequests(ctx context.Context, 		return 	} -	gdpr := extractGDPR(orig, usersyncIfAmbiguous)+	//TODO(bfs): if an error is encountered while extracing GDPR or Consent, should user syncing be considered ambiguous or don't sync?+	subjectToGDPR := extractGDPR(orig)

Consider renaming to gdprState or gdprSignal.

bsardo

comment created time in 2 days

Pull request review commentprebid/prebid-server

Fix GDPR consent assumption when gdpr req signal is unambiguous and s…

 import ( 	"encoding/json"  	"github.com/mxmCherry/openrtb"+	"github.com/prebid/prebid-server/gdpr" )  // ExtractGDPR will pull the gdpr flag from an openrtb request-func extractGDPR(bidRequest *openrtb.BidRequest, usersyncIfAmbiguous bool) (gdpr int) {+func extractGDPR(bidRequest *openrtb.BidRequest) (subjectToGDPR gdpr.GDPRState) {

I read subjectToGDPR as a noun instead of a verb. There's really no need to give it a name, IMHO. How about switching to specific return statements? The last else statement can also be unwrapped to improve flow clarity:

func extractGDPR(bidRequest *openrtb.BidRequest) gdpr.GDPRState {
	var re regsExt
	var err error
	if bidRequest.Regs != nil {
		err = json.Unmarshal(bidRequest.Regs.Ext, &re)
	}
	if re.GDPR == nil || err != nil {
		return gdpr.AmbiguousGDPR
	}
	return gdpr.GDPRState(*re.GDPR)
}
bsardo

comment created time in 2 days

Pull request review commentprebid/prebid-server

Fix GDPR consent assumption when gdpr req signal is unambiguous and s…

 import ( 	"github.com/prebid/go-gdpr/vendorlist" 	"github.com/prebid/prebid-server/config" 	"github.com/prebid/prebid-server/openrtb_ext"+	// "github.com/prebid/prebid-server/exchange" )  // This file implements GDPR permissions for the app. // For more info, see https://github.com/prebid/prebid-server/issues/501 // // Nothing in this file is exported. Public APIs can be found in gdpr.go +type GDPRState int

We're already in the GDPR package. The repetitiveness in the names ins't necessary. Consider names long the lines of:

type Signal int

const (
	Ambiguous Signal = -1
	Disabled        Signal = 0
	Enabled      Signal = 1
)
bsardo

comment created time in 2 days

push eventprebid/prebid-server

Scott Kay

commit sha 5f6c1d5b14cdac9f16a77b753091400de1f0b302

Work In Progress

view details

push time in 2 days

create barnchprebid/prebid-server

branch : refactor-getAllBids-take2

created branch time in 2 days

create barnchprebid/prebid-server

branch : PR1524

created branch time in 2 days

Pull request review commentprebid/prebid-server

New mobfox prebid server adapter

+{

Umm.. I see both of them having ext set as an empty string.

Ref: https://github.com/prebid/prebid-server/pull/1585/files#diff-068bd5de743e84f0ea42bf24b78266a42b133d1c56746f07f05e29250e53b9c6R20, https://github.com/prebid/prebid-server/pull/1585/files#diff-b3db1ea0f32285de8f539bf8eab4dfce6a8ccbba76a29d79a1fc9756616428caR20

imp_ext_empty_object.json and empty_imp_ext.json also look similar. They are the ones that have bid.Ext set as an empty object rather than an empty string

Ref: https://github.com/prebid/prebid-server/pull/1585/files#diff-fcc47bc4b52242c11553e49496206a1c37641d1c3e62d97bce2c6d130b38499dR20, https://github.com/prebid/prebid-server/pull/1585/files#diff-827dd6469890439efd8f99990038cfd8ca56cb10ac6d886423b5b99d83bb49ceR20

mobfxoHB

comment created time in 2 days

Pull request review commentprebid/prebid-server

New mobfox prebid server adapter

+package mobfoxpb++import (+	"encoding/json"+	"fmt"+	"net/http"++	"github.com/buger/jsonparser"+	"github.com/mxmCherry/openrtb"+	"github.com/prebid/prebid-server/adapters"+	"github.com/prebid/prebid-server/errortypes"+	"github.com/prebid/prebid-server/openrtb_ext"+)++type MobfoxpbAdapter struct {+	URI string+}++// NewMobfoxpbBidder Initializes the Bidder+func NewMobfoxpbBidder(endpoint string) *MobfoxpbAdapter {+	return &MobfoxpbAdapter{+		URI: endpoint,+	}+}++// MakeRequests create bid request for mobfoxpb demand+func (a *MobfoxpbAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) {+	var errs []error+	var err error+	var tagID string++	var adapterRequests []*adapters.RequestData++	reqCopy := *request+	for _, imp := range request.Imp {+		reqCopy.Imp = []openrtb.Imp{imp}++		tagID, err = jsonparser.GetString(reqCopy.Imp[0].Ext, "bidder", "TagID")+		if err != nil {+			errs = append(errs, err)+			continue+		}++		reqCopy.Imp[0].TagID = tagID++		adapterReq, errors := a.makeRequest(&reqCopy)+		if adapterReq != nil {+			adapterRequests = append(adapterRequests, adapterReq)+		}+		errs = append(errs, errors...)+	}+	return adapterRequests, errs+}++func (a *MobfoxpbAdapter) makeRequest(request *openrtb.BidRequest) (*adapters.RequestData, []error) {++	var errs []error++	reqJSON, err := json.Marshal(request)++	if err != nil {+		errs = append(errs, err)+		return nil, errs+	}++	headers := http.Header{}+	headers.Add("Content-Type", "application/json;charset=utf-8")+	headers.Add("Accept", "application/json")+	return &adapters.RequestData{+		Method:  "POST",+		Uri:     a.URI,+		Body:    reqJSON,+		Headers: headers,+	}, errs+}++// MakeBids makes the bids+func (a *MobfoxpbAdapter) MakeBids(internalRequest *openrtb.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) {+	var errs []error++	if response.StatusCode == http.StatusNoContent {+		return nil, nil+	}++	if response.StatusCode == http.StatusNotFound {+		return nil, []error{&errortypes.BadServerResponse{+			Message: fmt.Sprintf("Unexpected status code: %d. Run with request.debug = 1 for more info", response.StatusCode),+		}}+	}++	if response.StatusCode != http.StatusOK {+		return nil, []error{&errortypes.BadServerResponse{+			Message: fmt.Sprintf("Unexpected status code: %d. Run with request.debug = 1 for more info", response.StatusCode),+		}}+	}++	var bidResp openrtb.BidResponse++	if err := json.Unmarshal(response.Body, &bidResp); err != nil {+		return nil, []error{err}+	}++	bidResponse := adapters.NewBidderResponseWithBidsCapacity(1)++	for _, sb := range bidResp.SeatBid {+		for i := range sb.Bid {+			bidType, err := getMediaTypeForImp(sb.Bid[i].ImpID, internalRequest.Imp)+			if err != nil {+				errs = append(errs, err)+			} else {+				b := &adapters.TypedBid{+					Bid:     &sb.Bid[i],+					BidType: bidType,+				}+				bidResponse.Bids = append(bidResponse.Bids, b)+			}+		}+	}+	return bidResponse, errs+}++func getMediaTypeForImp(impID string, imps []openrtb.Imp) (openrtb_ext.BidType, error) {+	mediaType := openrtb_ext.BidTypeBanner+	for _, imp := range imps {+		if imp.ID == impID {+			if imp.Banner == nil && imp.Video != nil {+				mediaType = openrtb_ext.BidTypeVideo

Does that mean your system discards requests that have multiple formats or that you always just consider the banner part in that request and return bids just for that?

mobfxoHB

comment created time in 2 days

Pull request review commentprebid/prebid-server

New mobfox prebid server adapter

+package mobfoxpb++import (+	"encoding/json"+	"fmt"+	"net/http"++	"github.com/buger/jsonparser"+	"github.com/mxmCherry/openrtb"+	"github.com/prebid/prebid-server/adapters"+	"github.com/prebid/prebid-server/errortypes"+	"github.com/prebid/prebid-server/openrtb_ext"+)++type MobfoxpbAdapter struct {+	URI string+}++// NewMobfoxpbBidder Initializes the Bidder+func NewMobfoxpbBidder(endpoint string) *MobfoxpbAdapter {+	return &MobfoxpbAdapter{

@mobfxoHB Can I ask which CI are you referring to here?

mobfxoHB

comment created time in 2 days

push eventjsalis/Prebid.js

Jaimin Panchal

commit sha 172df7f455fe2bf0605026ab0e21af1c5edf9be3

Appnexus: Update maintainer (#5987) * Update maintainer * change maintainer Co-authored-by: Jaimin Panchal <email@example.com> Co-authored-by: fawke <neelanjan.sen@gmail.com>

view details

Stephen Johnston

commit sha 578213ccb52f5db858026b436f5c249e6f9e418e

Fix import warning for webpack 5 (#5933) Webpack 5 emits a warning when importing named exports from json files: ``` "WARNING in ../../node_modules/prebid.js/src/secureCreatives.js 15:16-30 Should not import the named export 'EVENTS'.'BID_WON' (imported as 'EVENTS') from default-exporting module (only default export is available soon)" ``` Co-authored-by: Garth Poitras <411908+gpoitch@users.noreply.github.com> Co-authored-by: gpoitch <garth22@gmail.com>

view details

Anand Venkatraman

commit sha c98a6334011bb3738885b2240cc8687170ec9bf7

PulsePoint Adapter: Fixing issue with multi-format requests (#5995) * ET-1691: Pulsepoint Analytics adapter for Prebid. (#1) * ET-1691: Adding pulsepoint analytics and tests for pulsepoint adapter * ET-1691: Adding pulsepoint analytics and tests for pulsepoint adapter * ET-1691: cleanup * ET-1691: minor * ET-1691: revert package.json change * Adding bidRequest to bidFactory.createBid method as per https://github.com/prebid/Prebid.js/issues/509 * ET-1765: Adding support for additional params in PulsePoint adapter (#2) * ET-1850: Fixing https://github.com/prebid/Prebid.js/issues/866 * Minor fix * Adding mandatory parameters to Bid * APPS-3793: Fixing multi-format request issue * Added test

view details

relaido

commit sha 1e98aef06bbe470838ee67779756747e962bdcec

Fix/test code set cookie (#5996) * add relaido adapter * remove event listener * fixed UserSyncs and e.data * fix conflicts * use storage Class Co-authored-by: ishigami_shingo <s.ishigami@relaido.co.jp> Co-authored-by: cmertv-sishigami <s.ishigami@cmertv.com> Co-authored-by: t_bun <t.bun@cmertv.com>

view details

Monis Qadri

commit sha 04c941fcff2d4fb0581e363c81df4753f90be0af

Honour bidFloor key in params (#5999) Co-authored-by: monis.q <monis.q@media.net>

view details

Jurij Sinickij

commit sha 8135e5d0045dfd3a045164f29624837a7c77289b

adform adapter - allow to pass custom eids param (#6008)

view details

John Salis

commit sha e5e899d2a8fca90f7b03e8e72e1d910a640cc6a0

Add video response type param to Beachfront adapter (#6011) * add video response type param to beachfront bidder * run tests Co-authored-by: John Salis <johnsalis@beachfrontmedia.com>

view details

Anthony Lauzon

commit sha 022bcea3e9c72a9a2817c82484adad51fda8dcc0

fix appnexus segment field format (#6013)

view details

push time in 3 days

delete branch jsalis/Prebid.js

delete branch : vast-url-param

delete time in 3 days

Pull request review commentprebid/prebid-server

New mobfox prebid server adapter

+{

Nope, they are differs - one receives empty object to bid.ext property, other receives string

mobfxoHB

comment created time in 3 days

Pull request review commentprebid/prebid-server

New mobfox prebid server adapter

+package mobfoxpb++import (+	"encoding/json"+	"fmt"+	"net/http"++	"github.com/buger/jsonparser"+	"github.com/mxmCherry/openrtb"+	"github.com/prebid/prebid-server/adapters"+	"github.com/prebid/prebid-server/errortypes"+	"github.com/prebid/prebid-server/openrtb_ext"+)++type MobfoxpbAdapter struct {+	URI string+}++// NewMobfoxpbBidder Initializes the Bidder+func NewMobfoxpbBidder(endpoint string) *MobfoxpbAdapter {+	return &MobfoxpbAdapter{+		URI: endpoint,+	}+}++// MakeRequests create bid request for mobfoxpb demand+func (a *MobfoxpbAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) {+	var errs []error+	var err error+	var tagID string++	var adapterRequests []*adapters.RequestData++	reqCopy := *request+	for _, imp := range request.Imp {+		reqCopy.Imp = []openrtb.Imp{imp}++		tagID, err = jsonparser.GetString(reqCopy.Imp[0].Ext, "bidder", "TagID")+		if err != nil {+			errs = append(errs, err)+			continue+		}++		reqCopy.Imp[0].TagID = tagID++		adapterReq, errors := a.makeRequest(&reqCopy)+		if adapterReq != nil {+			adapterRequests = append(adapterRequests, adapterReq)+		}+		errs = append(errs, errors...)+	}+	return adapterRequests, errs+}++func (a *MobfoxpbAdapter) makeRequest(request *openrtb.BidRequest) (*adapters.RequestData, []error) {++	var errs []error++	reqJSON, err := json.Marshal(request)++	if err != nil {+		errs = append(errs, err)+		return nil, errs+	}++	headers := http.Header{}+	headers.Add("Content-Type", "application/json;charset=utf-8")+	headers.Add("Accept", "application/json")+	return &adapters.RequestData{+		Method:  "POST",+		Uri:     a.URI,+		Body:    reqJSON,+		Headers: headers,+	}, errs+}++// MakeBids makes the bids+func (a *MobfoxpbAdapter) MakeBids(internalRequest *openrtb.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) {+	var errs []error++	if response.StatusCode == http.StatusNoContent {+		return nil, nil+	}++	if response.StatusCode == http.StatusNotFound {+		return nil, []error{&errortypes.BadServerResponse{+			Message: fmt.Sprintf("Unexpected status code: %d. Run with request.debug = 1 for more info", response.StatusCode),+		}}+	}++	if response.StatusCode != http.StatusOK {+		return nil, []error{&errortypes.BadServerResponse{+			Message: fmt.Sprintf("Unexpected status code: %d. Run with request.debug = 1 for more info", response.StatusCode),+		}}+	}++	var bidResp openrtb.BidResponse++	if err := json.Unmarshal(response.Body, &bidResp); err != nil {+		return nil, []error{err}+	}++	bidResponse := adapters.NewBidderResponseWithBidsCapacity(1)++	for _, sb := range bidResp.SeatBid {+		for i := range sb.Bid {+			bidType, err := getMediaTypeForImp(sb.Bid[i].ImpID, internalRequest.Imp)+			if err != nil {+				errs = append(errs, err)+			} else {+				b := &adapters.TypedBid{+					Bid:     &sb.Bid[i],+					BidType: bidType,+				}+				bidResponse.Bids = append(bidResponse.Bids, b)+			}+		}+	}+	return bidResponse, errs+}++func getMediaTypeForImp(impID string, imps []openrtb.Imp) (openrtb_ext.BidType, error) {+	mediaType := openrtb_ext.BidTypeBanner+	for _, imp := range imps {+		if imp.ID == impID {+			if imp.Banner == nil && imp.Video != nil {+				mediaType = openrtb_ext.BidTypeVideo

Actually we do not support multi bid

mobfxoHB

comment created time in 3 days

more