Skip to content

Commit

Permalink
Standardize Privacy User Scrubbing (#2820)
Browse files Browse the repository at this point in the history
  • Loading branch information
SyntaxNode authored Jun 7, 2023
1 parent 332af98 commit 6764f3f
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 73 deletions.
1 change: 1 addition & 0 deletions exchange/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2294,6 +2294,7 @@ func TestCleanOpenRTBRequestsWithOpenRTBDowngrade(t *testing.T) {
bidReq.Regs.GPPSID = []int8{6}
bidReq.User.ID = ""
bidReq.User.BuyerUID = ""
bidReq.User.Yob = 0

downgradedRegs := *bidReq.Regs
downgradedUser := *bidReq.User
Expand Down
10 changes: 1 addition & 9 deletions privacy/enforcement.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,17 +69,9 @@ func (e Enforcement) getGeoScrubStrategy() ScrubStrategyGeo {
}

func (e Enforcement) getUserScrubStrategy() ScrubStrategyUser {
if e.COPPA {
if e.COPPA || e.CCPA || e.LMT || e.GDPRID {
return ScrubStrategyUserIDAndDemographic
}

if e.CCPA || e.LMT {
return ScrubStrategyUserID
}

if e.GDPRID {
return ScrubStrategyUserID
}

return ScrubStrategyUserNone
}
8 changes: 4 additions & 4 deletions privacy/enforcement_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ func TestApply(t *testing.T) {
expectedDeviceIPv4: ScrubStrategyIPV4Lowest8,
expectedDeviceIPv6: ScrubStrategyIPV6Lowest16,
expectedDeviceGeo: ScrubStrategyGeoReducedPrecision,
expectedUser: ScrubStrategyUserID,
expectedUser: ScrubStrategyUserIDAndDemographic,
expectedUserGeo: ScrubStrategyGeoReducedPrecision,
},
{
Expand Down Expand Up @@ -127,7 +127,7 @@ func TestApply(t *testing.T) {
expectedDeviceIPv4: ScrubStrategyIPV4Lowest8,
expectedDeviceIPv6: ScrubStrategyIPV6Lowest16,
expectedDeviceGeo: ScrubStrategyGeoReducedPrecision,
expectedUser: ScrubStrategyUserID,
expectedUser: ScrubStrategyUserIDAndDemographic,
expectedUserGeo: ScrubStrategyGeoReducedPrecision,
},
{
Expand All @@ -143,7 +143,7 @@ func TestApply(t *testing.T) {
expectedDeviceIPv4: ScrubStrategyIPV4None,
expectedDeviceIPv6: ScrubStrategyIPV6None,
expectedDeviceGeo: ScrubStrategyGeoNone,
expectedUser: ScrubStrategyUserID,
expectedUser: ScrubStrategyUserIDAndDemographic,
expectedUserGeo: ScrubStrategyGeoNone,
},
{
Expand Down Expand Up @@ -175,7 +175,7 @@ func TestApply(t *testing.T) {
expectedDeviceIPv4: ScrubStrategyIPV4Lowest8,
expectedDeviceIPv6: ScrubStrategyIPV6Lowest16,
expectedDeviceGeo: ScrubStrategyGeoReducedPrecision,
expectedUser: ScrubStrategyUserID,
expectedUser: ScrubStrategyUserIDAndDemographic,
expectedUserGeo: ScrubStrategyGeoReducedPrecision,
},
{
Expand Down
10 changes: 1 addition & 9 deletions privacy/scrubber.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,6 @@ const (

// ScrubStrategyUserIDAndDemographic removes the user's buyer id, exchange id year of birth, and gender.
ScrubStrategyUserIDAndDemographic

// ScrubStrategyUserID removes the user's buyer id.
ScrubStrategyUserID
)

// ScrubStrategyDeviceID defines the approach to remove hardware id and device id data.
Expand Down Expand Up @@ -131,17 +128,12 @@ func (scrubber) ScrubUser(user *openrtb2.User, strategy ScrubStrategyUser, geo S

userCopy := *user

switch strategy {
case ScrubStrategyUserIDAndDemographic:
if strategy == ScrubStrategyUserIDAndDemographic {
userCopy.BuyerUID = ""
userCopy.ID = ""
userCopy.Ext = scrubUserExtIDs(userCopy.Ext)
userCopy.Yob = 0
userCopy.Gender = ""
case ScrubStrategyUserID:
userCopy.BuyerUID = ""
userCopy.ID = ""
userCopy.Ext = scrubUserExtIDs(userCopy.Ext)
}

switch geo {
Expand Down
51 changes: 0 additions & 51 deletions privacy/scrubber_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -269,57 +269,6 @@ func TestScrubUser(t *testing.T) {
scrubUser: ScrubStrategyUserIDAndDemographic,
scrubGeo: ScrubStrategyGeoNone,
},
{
description: "User ID & Geo Full",
expected: &openrtb2.User{
ID: "",
BuyerUID: "",
Yob: 42,
Gender: "anyGender",
Ext: json.RawMessage(`{}`),
Geo: &openrtb2.Geo{},
},
scrubUser: ScrubStrategyUserID,
scrubGeo: ScrubStrategyGeoFull,
},
{
description: "User ID & Geo Reduced",
expected: &openrtb2.User{
ID: "",
BuyerUID: "",
Yob: 42,
Gender: "anyGender",
Ext: json.RawMessage(`{}`),
Geo: &openrtb2.Geo{
Lat: 123.46,
Lon: 678.89,
Metro: "some metro",
City: "some city",
ZIP: "some zip",
},
},
scrubUser: ScrubStrategyUserID,
scrubGeo: ScrubStrategyGeoReducedPrecision,
},
{
description: "User ID & Geo None",
expected: &openrtb2.User{
ID: "",
BuyerUID: "",
Yob: 42,
Gender: "anyGender",
Ext: json.RawMessage(`{}`),
Geo: &openrtb2.Geo{
Lat: 123.456,
Lon: 678.89,
Metro: "some metro",
City: "some city",
ZIP: "some zip",
},
},
scrubUser: ScrubStrategyUserID,
scrubGeo: ScrubStrategyGeoNone,
},
{
description: "User None & Geo Full",
expected: &openrtb2.User{
Expand Down

0 comments on commit 6764f3f

Please sign in to comment.