Skip to content

Commit

Permalink
Fix: Inject default DSA before auction request is rebuilt (#3639)
Browse files Browse the repository at this point in the history
  • Loading branch information
bsardo committed Apr 25, 2024
1 parent 5e7c824 commit ecb50e7
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 194 deletions.
15 changes: 14 additions & 1 deletion exchange/exchange.go
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,19 @@ func (e *exchange) HoldAuction(ctx context.Context, r *AuctionRequest, debugLog

// Make our best guess if GDPR applies
gdprDefaultValue := e.parseGDPRDefaultValue(r.BidRequestWrapper)
gdprSignal, err := getGDPR(r.BidRequestWrapper)
if err != nil {
return nil, err
}
channelEnabled := r.TCF2Config.ChannelEnabled(channelTypeMap[r.LegacyLabels.RType])
gdprEnforced := enforceGDPR(gdprSignal, gdprDefaultValue, channelEnabled)
dsaWriter := dsa.Writer{
Config: r.Account.Privacy.DSA,
GDPRInScope: gdprEnforced,
}
if err := dsaWriter.Write(r.BidRequestWrapper); err != nil {
return nil, err
}

// rebuild/resync the request in the request wrapper.
if err := r.BidRequestWrapper.RebuildRequest(); err != nil {
Expand All @@ -324,7 +337,7 @@ func (e *exchange) HoldAuction(ctx context.Context, r *AuctionRequest, debugLog
Prebid: *requestExtPrebid,
SChain: requestExt.GetSChain(),
}
bidderRequests, privacyLabels, errs := e.requestSplitter.cleanOpenRTBRequests(ctx, *r, requestExtLegacy, gdprDefaultValue, bidAdjustmentFactors)
bidderRequests, privacyLabels, errs := e.requestSplitter.cleanOpenRTBRequests(ctx, *r, requestExtLegacy, gdprSignal, gdprEnforced, bidAdjustmentFactors)
errs = append(errs, floorErrs...)

mergedBidAdj, err := bidadjustment.Merge(r.BidRequestWrapper, r.Account.BidAdjustments)
Expand Down
23 changes: 3 additions & 20 deletions exchange/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import (
"github.com/prebid/openrtb/v20/openrtb2"

"github.com/prebid/prebid-server/v2/config"
"github.com/prebid/prebid-server/v2/dsa"
"github.com/prebid/prebid-server/v2/errortypes"
"github.com/prebid/prebid-server/v2/firstpartydata"
"github.com/prebid/prebid-server/v2/gdpr"
Expand Down Expand Up @@ -60,7 +59,9 @@ type requestSplitter struct {
func (rs *requestSplitter) cleanOpenRTBRequests(ctx context.Context,
auctionReq AuctionRequest,
requestExt *openrtb_ext.ExtRequest,
gdprDefaultValue gdpr.Signal, bidAdjustmentFactors map[string]float64,
gdprSignal gdpr.Signal,
gdprEnforced bool,
bidAdjustmentFactors map[string]float64,
) (allowedBidderRequests []BidderRequest, privacyLabels metrics.PrivacyLabels, errs []error) {
req := auctionReq.BidRequestWrapper
aliases, errs := parseAliases(req.BidRequest)
Expand All @@ -83,24 +84,6 @@ func (rs *requestSplitter) cleanOpenRTBRequests(ctx context.Context,
return
}

gdprSignal, err := getGDPR(req)
if err != nil {
errs = append(errs, err)
}
channelEnabled := auctionReq.TCF2Config.ChannelEnabled(channelTypeMap[auctionReq.LegacyLabels.RType])
gdprEnforced := enforceGDPR(gdprSignal, gdprDefaultValue, channelEnabled)
dsaWriter := dsa.Writer{
Config: auctionReq.Account.Privacy.DSA,
GDPRInScope: gdprEnforced,
}
if err := dsaWriter.Write(req); err != nil {
errs = append(errs, err)
}
if err := req.RebuildRequest(); err != nil {
errs = append(errs, err)
return
}

var allBidderRequests []BidderRequest
var allBidderRequestErrs []error
allBidderRequests, allBidderRequestErrs = getAuctionBidderRequests(auctionReq, requestExt, rs.bidderToSyncerKey, impsByBidder, aliases, rs.hostSChainNode)
Expand Down

0 comments on commit ecb50e7

Please sign in to comment.