-
Notifications
You must be signed in to change notification settings - Fork 752
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
Account-level override for the list of EEA countries #3678 #4118
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,6 +42,7 @@ type Account struct { | |
DefaultBidLimit int `mapstructure:"default_bid_limit" json:"default_bid_limit"` | ||
BidAdjustments *openrtb_ext.ExtRequestPrebidBidAdjustments `mapstructure:"bidadjustments" json:"bidadjustments"` | ||
Privacy AccountPrivacy `mapstructure:"privacy" json:"privacy"` | ||
EEACountries []string `mapstructure:"eea_countries" json:"eea_countries"` | ||
} | ||
|
||
// CookieSync represents the account-level defaults for the cookie sync endpoint. | ||
|
@@ -381,3 +382,12 @@ func (ip *IPv4) Validate(errs []error) []error { | |
} | ||
return errs | ||
} | ||
|
||
func (a *Account) ValidateEEACountries(errs []error) []error { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This validation method is not called. |
||
for _, country := range a.EEACountries { | ||
if len(country) != 2 { // Check if country code is valid | ||
errs = append(errs, fmt.Errorf("invalid EEA country code: %s", country)) | ||
} | ||
} | ||
return errs | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -316,8 +316,17 @@ func (e *exchange) HoldAuction(ctx context.Context, r *AuctionRequest, debugLog | |
|
||
recordImpMetrics(r.BidRequestWrapper, e.me) | ||
|
||
// Retrieve host and account-level EEA countries config | ||
eeaCountries := SelectEEACountries(e.privacyConfig.GDPR.EEACountries, r.Account.EEACountries) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nitpick: The comment is not necessary. The inputs are clearly host and account level, but if you'd like to make that association clearer consider a revised method name. |
||
|
||
// Create a map for efficient lookup | ||
eeaCountriesMap := make(map[string]struct{}) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The performance benefit of a map only comes into play when the map is used more than once. As it is now, this map is only referenced once in Eventually, this map can live in the account config object when that caching layer is improved. Doesn't make sense there right now though. |
||
for _, country := range eeaCountries { | ||
eeaCountriesMap[strings.ToUpper(country)] = struct{}{} | ||
} | ||
|
||
// Make our best guess if GDPR applies | ||
gdprDefaultValue := e.parseGDPRDefaultValue(r.BidRequestWrapper) | ||
gdprDefaultValue := e.parseGDPRDefaultValue(r.BidRequestWrapper, eeaCountriesMap) | ||
gdprSignal, err := getGDPR(r.BidRequestWrapper) | ||
if err != nil { | ||
return nil, err | ||
|
@@ -571,7 +580,7 @@ func buildMultiBidMap(prebid *openrtb_ext.ExtRequestPrebid) map[string]openrtb_e | |
return multiBidMap | ||
} | ||
|
||
func (e *exchange) parseGDPRDefaultValue(r *openrtb_ext.RequestWrapper) gdpr.Signal { | ||
func (e *exchange) parseGDPRDefaultValue(r *openrtb_ext.RequestWrapper, eeaCountriesMap map[string]struct{}) gdpr.Signal { | ||
gdprDefaultValue := e.gdprDefaultValue | ||
|
||
var geo *openrtb2.Geo | ||
|
@@ -584,7 +593,7 @@ func (e *exchange) parseGDPRDefaultValue(r *openrtb_ext.RequestWrapper) gdpr.Sig | |
if geo != nil { | ||
// If we have a country set, and it is on the list, we assume GDPR applies if not set on the request. | ||
// Otherwise we assume it does not apply as long as it appears "valid" (is 3 characters long). | ||
if _, found := e.privacyConfig.GDPR.EEACountriesMap[strings.ToUpper(geo.Country)]; found { | ||
if _, found := eeaCountriesMap[strings.ToUpper(geo.Country)]; found { | ||
gdprDefaultValue = gdpr.SignalYes | ||
} else if len(geo.Country) == 3 { | ||
// The country field is formatted properly as a three character country code | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps it would be better to include this within the AccountGDPR object since it's only used for GDPR enforcement and to match the host configuration of
.privacy.gdpr. eea_countries
.