-
Notifications
You must be signed in to change notification settings - Fork 769
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
AMP additionalConsent #2378
AMP additionalConsent #2378
Conversation
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.
Looks good, comments related to test coverage
endpoints/openrtb2/amp_auction.go
Outdated
} else { | ||
return err | ||
} | ||
if err := reqWrap.RebuildRequest(); err != nil { | ||
return err | ||
} |
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.
Is there a way to add tests to trigger these errors?
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.
Done. Added two additional test cases.
openrtb_ext/request_wrapper.go
Outdated
if hasCPSettings { | ||
ue.consentedProvidersSettings = &ExtUserCPSettings{} | ||
if err := json.Unmarshal(consentedProviderSettingsJson, ue.consentedProvidersSettings); err != nil { | ||
return err |
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.
This block isn't covered by tests, can this be covered?
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.
Done. Added a bunch of tests to cover this entire function and some other scenarios.
openrtb_ext/request_wrapper.go
Outdated
delete(ue.ext, "ConsentedProvidersSettings") | ||
} | ||
} else { | ||
delete(ue.ext, "ConsentedProvidersSettings") |
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.
Can these delete cases be covered?
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.
Covered
inAdditionalConsent string | ||
inBidRequest *openrtb2.BidRequest |
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.
Nitpick: Could these be renamed to givenAdditionalConsent
and givenBidRequest
?
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.
Done
privacy/gdpr/consentwriter.go
Outdated
} | ||
reqWrap := &openrtb_ext.RequestWrapper{BidRequest: req} | ||
|
||
// set GDPR value |
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.
I think you can delete this comment
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.
Removed
privacy/gdpr/consentwriter.go
Outdated
|
||
if req.User == nil { | ||
req.User = &openrtb2.User{} | ||
// set Consent string |
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.
I think you can delete this comment
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.
Deleted
@@ -446,6 +446,10 @@ func (deps *endpointDeps) overrideWithParams(ampParams amp.Params, req *openrtb2 | |||
req.Imp[0].TagID = ampParams.Slot | |||
} | |||
|
|||
if err := setConsentedProviders(req, ampParams); err != nil { | |||
return []error{err} |
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.
This error return isn't covered by tests, is it possible to cover/trigger this?
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.
Added TestOverrideWithParams
to add coverage to various uncovered scenarios in the overrideWithParams
function.
openrtb_ext/request_wrapper.go
Outdated
// this field is dirty | ||
if ue.consentedProvidersDirty { | ||
if ue.consentedProvidersSettings == nil { | ||
ue.consentedProvidersSettings = &ExtUserCPSettings{} |
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.
This line is not covered by tests
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.
Added test to cover line 385
openrtb_ext/user.go
Outdated
@@ -10,6 +10,8 @@ type ExtUser struct { | |||
// https://iabtechlab.com/wp-content/uploads/2018/02/OpenRTB_Advisory_GDPR_2018-02.pdf | |||
Consent string `json:"consent,omitempty"` | |||
|
|||
ConsentedProvidersSettings *ExtUserCPSettings `json:"ConsentedProvidersSettings,omitempty"` |
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.
Is it a reason json mapping value starts from uppercase? Feels like it should start from lowercase.
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.
It does look odd but I used the exact format described in issue #1817 and that's also how it was implemented in Prebid Server Java. Below an excerpt from a PBS-Java JSON test file:
70 "user": {
71 "buyeruid": "J5VLCWQP-26-CWFT",
72 "ext": {
73 "ConsentedProvidersSettings": {
74 "consented_providers": "someConsent"
75 }
76 }
77 },
./src/test/resources/org/prebid/server/it/amp/test-rubicon-bid-request.json
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.
json mapping is not case sensitive, it should work with ConsentedProvidersSettings
and consentedproviderssettings
. We can discuss it with the team.
openrtb_ext/request_wrapper.go
Outdated
@@ -333,6 +337,13 @@ func (ue *UserExt) unmarshal(extJson json.RawMessage) error { | |||
} | |||
} | |||
|
|||
if consentedProviderSettingsJson, hasCPSettings := ue.ext["ConsentedProvidersSettings"]; hasCPSettings { |
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.
Please extract this value to constant - you use it in many places. Also should it start from lowercase?
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.
I'm not sure what value to put into a constant. consentedProviderSettingsJson
? Inside (ue *UserExt) unmarshal(extJson json.RawMessage) error
it is only used once.
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.
Oh I meant string constant "ConsentedProvidersSettings"
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.
Has this string been extracted?
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.
Has not, corrected
openrtb_ext/request_wrapper.go
Outdated
eidsDirty bool | ||
consentedProvidersSettings *ExtUserCPSettings | ||
consentedProvidersSettingsDirty bool | ||
consentedProviders string |
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.
Do you think it will be easier to handle consentedProvidersSettings *ExtUserCPSettings
only? Keep track of consentedProviders
looks redundant.
Look at `other fields - there is just one tracker for each object, no trackers for nested fields. What do you think?
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.
Good catch, modified to get rid of this unecessary field in openrtb_ext/request_wrapper.go
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.
Gus, I meant to keep track of object, not field.
consentedProvidersSettings *ExtUserCPSettings -> leave this
consentedProvidersSettingsDirty bool
consentedProviders string -> remove this
consentedProvidersDirty bool
In case you add more fields to the object - it will have everything to keep track of it without significant changes
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.
🤦♂️
I misread your comment.
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.
It's looks good. Just left one comment
openrtb_ext/request_wrapper.go
Outdated
@@ -333,6 +337,13 @@ func (ue *UserExt) unmarshal(extJson json.RawMessage) error { | |||
} | |||
} | |||
|
|||
if consentedProviderSettingsJson, hasCPSettings := ue.ext["ConsentedProvidersSettings"]; hasCPSettings { |
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.
Has this string been extracted?
…oviderSettingsOut() in amp_auction.go
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.
Commit messages are pure gold. LGTM
This pull request implements the second part of issue #1817. Particularly, the
addtl_consent
query field described in point number 5 of the issue's description:addtl_consent
is supplied, copy its value touser.ext.ConsentedProvidersSettings.consented_providers
According to specs, is set independently of the
consent_type
. This pull request's core change happens inside theendpoints/openrtb2/amp_auction.go
and is shown below:All other changes are to support or test the addition shown above.