Skip to content

Commit

Permalink
Remove Outdated GDPR AMP Special Case (#1283)
Browse files Browse the repository at this point in the history
  • Loading branch information
SyntaxNode authored May 6, 2020
1 parent 42d5281 commit cd90991
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 63 deletions.
3 changes: 1 addition & 2 deletions exchange/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ func cleanOpenRTBRequests(ctx context.Context,

gdpr := extractGDPR(orig, usersyncIfAmbiguous)
consent := extractConsent(orig)
isAMP := labels.RType == pbsmetrics.ReqTypeAMP

privacyEnforcement := privacy.Enforcement{
COPPA: orig.Regs != nil && orig.Regs.COPPA == 1,
Expand All @@ -66,7 +65,7 @@ func cleanOpenRTBRequests(ctx context.Context,
privacyEnforcement.GDPR = false
}

privacyEnforcement.Apply(bidReq, isAMP)
privacyEnforcement.Apply(bidReq)
}

return
Expand Down
17 changes: 5 additions & 12 deletions privacy/enforcement.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ func (e Enforcement) Any() bool {
}

// Apply cleans personally identifiable information from an OpenRTB bid request.
func (e Enforcement) Apply(bidRequest *openrtb.BidRequest, isAMP bool) {
e.apply(bidRequest, isAMP, NewScrubber())
func (e Enforcement) Apply(bidRequest *openrtb.BidRequest) {
e.apply(bidRequest, NewScrubber())
}

func (e Enforcement) apply(bidRequest *openrtb.BidRequest, isAMP bool, scrubber Scrubber) {
func (e Enforcement) apply(bidRequest *openrtb.BidRequest, scrubber Scrubber) {
if bidRequest != nil && e.Any() {
bidRequest.Device = scrubber.ScrubDevice(bidRequest.Device, e.getDeviceMacAndIFA(), e.getIPv6ScrubStrategy(), e.getGeoScrubStrategy())
bidRequest.User = scrubber.ScrubUser(bidRequest.User, e.getUserScrubStrategy(isAMP), e.getGeoScrubStrategy())
bidRequest.User = scrubber.ScrubUser(bidRequest.User, e.getUserScrubStrategy(), e.getGeoScrubStrategy())
}
}

Expand Down Expand Up @@ -56,18 +56,11 @@ func (e Enforcement) getGeoScrubStrategy() ScrubStrategyGeo {
return ScrubStrategyGeoNone
}

func (e Enforcement) getUserScrubStrategy(isAMP bool) ScrubStrategyUser {
func (e Enforcement) getUserScrubStrategy() ScrubStrategyUser {
if e.COPPA {
return ScrubStrategyUserFull
}

// There's no way for AMP to send a GDPR consent string yet so it's hard
// to know if the vendor is consented or not and therefore for AMP requests
// we keep the BuyerUID as is for GDPR.
if e.GDPR && isAMP {
return ScrubStrategyUserNone
}

if e.GDPR || e.CCPA {
return ScrubStrategyUserBuyerIDOnly
}
Expand Down
51 changes: 2 additions & 49 deletions privacy/enforcement_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ func TestAny(t *testing.T) {
func TestApply(t *testing.T) {
testCases := []struct {
enforcement Enforcement
isAMP bool
expectedDeviceMacAndIFA bool
expectedDeviceIPv6 ScrubStrategyIPV6
expectedDeviceGeo ScrubStrategyGeo
Expand All @@ -66,7 +65,6 @@ func TestApply(t *testing.T) {
COPPA: true,
GDPR: true,
},
isAMP: true,
expectedDeviceMacAndIFA: true,
expectedDeviceIPv6: ScrubStrategyIPV6Lowest32,
expectedDeviceGeo: ScrubStrategyGeoFull,
Expand All @@ -80,7 +78,6 @@ func TestApply(t *testing.T) {
COPPA: true,
GDPR: false,
},
isAMP: false,
expectedDeviceMacAndIFA: true,
expectedDeviceIPv6: ScrubStrategyIPV6Lowest32,
expectedDeviceGeo: ScrubStrategyGeoFull,
Expand All @@ -94,70 +91,26 @@ func TestApply(t *testing.T) {
COPPA: false,
GDPR: true,
},
isAMP: false,
expectedDeviceMacAndIFA: false,
expectedDeviceIPv6: ScrubStrategyIPV6Lowest16,
expectedDeviceGeo: ScrubStrategyGeoReducedPrecision,
expectedUser: ScrubStrategyUserBuyerIDOnly,
expectedUserGeo: ScrubStrategyGeoReducedPrecision,
description: "GDPR",
},
{
enforcement: Enforcement{
CCPA: false,
COPPA: false,
GDPR: true,
},
isAMP: true,
expectedDeviceMacAndIFA: false,
expectedDeviceIPv6: ScrubStrategyIPV6Lowest16,
expectedDeviceGeo: ScrubStrategyGeoReducedPrecision,
expectedUser: ScrubStrategyUserNone,
expectedUserGeo: ScrubStrategyGeoReducedPrecision,
description: "GDPR For AMP",
},
{
enforcement: Enforcement{
CCPA: true,
COPPA: false,
GDPR: false,
},
isAMP: false,
expectedDeviceMacAndIFA: false,
expectedDeviceIPv6: ScrubStrategyIPV6Lowest16,
expectedDeviceGeo: ScrubStrategyGeoReducedPrecision,
expectedUser: ScrubStrategyUserBuyerIDOnly,
expectedUserGeo: ScrubStrategyGeoReducedPrecision,
description: "CCPA",
},
{
enforcement: Enforcement{
CCPA: true,
COPPA: false,
GDPR: false,
},
isAMP: true,
expectedDeviceMacAndIFA: false,
expectedDeviceIPv6: ScrubStrategyIPV6Lowest16,
expectedDeviceGeo: ScrubStrategyGeoReducedPrecision,
expectedUser: ScrubStrategyUserBuyerIDOnly,
expectedUserGeo: ScrubStrategyGeoReducedPrecision,
description: "CCPA For AMP",
},
{
enforcement: Enforcement{
CCPA: true,
COPPA: false,
GDPR: true,
},
isAMP: true,
expectedDeviceMacAndIFA: false,
expectedDeviceIPv6: ScrubStrategyIPV6Lowest16,
expectedDeviceGeo: ScrubStrategyGeoReducedPrecision,
expectedUser: ScrubStrategyUserNone,
expectedUserGeo: ScrubStrategyGeoReducedPrecision,
description: "GDPR And CCPA For AMP",
},
}

for _, test := range testCases {
Expand All @@ -172,7 +125,7 @@ func TestApply(t *testing.T) {
m.On("ScrubDevice", req.Device, test.expectedDeviceMacAndIFA, test.expectedDeviceIPv6, test.expectedDeviceGeo).Return(device).Once()
m.On("ScrubUser", req.User, test.expectedUser, test.expectedUserGeo).Return(user).Once()

test.enforcement.apply(req, test.isAMP, m)
test.enforcement.apply(req, m)

m.AssertExpectations(t)
assert.Equal(t, device, req.Device, "Device Set Correctly")
Expand All @@ -191,7 +144,7 @@ func TestApplyNoneApplicable(t *testing.T) {

m := &mockScrubber{}

enforcement.apply(req, true, m)
enforcement.apply(req, m)

m.AssertNotCalled(t, "ScrubDevice")
m.AssertNotCalled(t, "ScrubUser")
Expand Down

0 comments on commit cd90991

Please sign in to comment.