-
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
Huaweiadsadapter gdpr #2345
Huaweiadsadapter gdpr #2345
Conversation
clho40
commented
Aug 8, 2022
- Get the country value from the MCC code
- Get the GAID from the Openrtb.device.ifa field by default
parse and send GDPR consent string to Huawei Adx
remove unwanted consent element
Update huaweiads.go
gofmt
adapters/huaweiads/huaweiads.go
Outdated
return errors.New("Unmarshal: openRTBRequest.User.Ext -> extUserDataHuaweiAds failed") | ||
} | ||
var deviceId = extUserDataHuaweiAds.Data | ||
if len(deviceId.Imei) == 0 && len(deviceId.Gaid) == 0 && len(device.Gaid) == 0 && len(deviceId.Oaid) == 0 { |
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.
Did you mean to check for the length of device.Gaid
or was that added by mistake? Looks like you already have a conditional before that to check length of deviceId.Gaid
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.
sorry for the confusion. at line#665 we tried to assign device.ifa to device.gaid field. Therefore we are checking for the existence of this value at this point, if all of them are empty we'll return an error
Hello @clho-huawei, @clho40, |
@bsardo Hello. Thanks for reminding. We are doing some final checks and will merge them soon :) |
Hello @clho40, a couple of tests are failing due to formatting issues. Can you please run |
adapters/huaweiads/huaweiads.go
Outdated
if userObjExist { | ||
var extUserDataHuaweiAds openrtb_ext.ExtUserDataHuaweiAds | ||
if err := json.Unmarshal(openRTBRequest.User.Ext, &extUserDataHuaweiAds); err != nil { | ||
return errors.New("get gaid from openrtb Device.IFA failed, and get device id failed: Unmarshal openRTBRequest.User.Ext -> extUserDataHuaweiAds.") |
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'd recommend appending the actual unmarshal error to your error message so that it can be helpful in debugging. Something like:
return fmt.Errorf("get gaid from openrtb Device.IFA failed, and get device id failed: Unmarshal error: %v", err)
adapters/huaweiads/huaweiads.go
Outdated
@@ -459,10 +459,14 @@ func getReqJson(request *huaweiAdsRequest, openRTBRequest *openrtb2.BidRequest, | |||
func getReqAdslot30(huaweiAdsImpExt *openrtb_ext.ExtImpHuaweiAds, | |||
openRTBImp *openrtb2.Imp, openRTBRequest *openrtb2.BidRequest) (adslot30, error) { |
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.
openRTBRequest *openrtb2.BidRequest
parameter became unused, can you please delete it?
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.
Parameter is deleted.
adapters/huaweiads/huaweiads.go
Outdated
@@ -459,10 +459,14 @@ func getReqJson(request *huaweiAdsRequest, openRTBRequest *openrtb2.BidRequest, | |||
func getReqAdslot30(huaweiAdsImpExt *openrtb_ext.ExtImpHuaweiAds, | |||
openRTBImp *openrtb2.Imp, openRTBRequest *openrtb2.BidRequest) (adslot30, error) { | |||
adtype := convertAdtypeStringToInteger(strings.ToLower(huaweiAdsImpExt.Adtype)) | |||
testStatus := 0 | |||
if huaweiAdsImpExt != nil && huaweiAdsImpExt.IsTestAuthorization == "true" { |
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.
if huaweiAdsImpExt != nil
check is not needed here, it's executed before the getReqAdslot30
function call, L281
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.
Null check is removed
adapters/huaweiads/huaweiads.go
Outdated
} | ||
} | ||
} | ||
|
||
// getDeviceID include oaid gaid imei. In prebid mobile, use TargetingParams.addUserData("imei", "imei-test"); | ||
// When ifa: gaid exists, other device id can be passed by TargetingParams.addUserData("oaid", "oaid-test"); | ||
// When getGaidFromDeviceIFA success, getDeviceIDFromUserExt failed, no error will be reported. |
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.
Function getGaidFromDeviceIFA
doesn't exist anymore, please modify comment accordingly
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.
Because "getGaidFromDeviceIFA" function is removed, the comment is removed also.
adapters/huaweiads/huaweiads.go
Outdated
return errors.New("get gaid from openrtb Device.IFA failed, and get device id failed: Unmarshal openRTBRequest.User.Ext -> extUserDataHuaweiAds. Error: " + err.Error()) | ||
} | ||
var deviceId = extUserDataHuaweiAds.Data | ||
if len(deviceId.Imei) == 0 && len(deviceId.Gaid) == 0 && len(device.Gaid) == 0 && len(deviceId.Oaid) == 0 { |
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.
Small optional optimization: to avoid double evaluation of len(deviceId.Imei) == 0
and others, this if
condition can be removed. Instead do this:
isValidDeviceId := false
if len(deviceId.Oaid) > 0 {
device.Oaid = deviceId.Oaid[0]
isValidDeviceId = true
}
if len(deviceId.Gaid) > 0 {
device.Gaid = deviceId.Gaid[0]
isValidDeviceId = true
}
if len(deviceId.Imei) > 0 {
if len(deviceId.Imei) > 0{
device.Imei = deviceId.Imei[0]
isValidDeviceId = true
}
}
if !isValidDeviceId{
return errors.New("getDeviceID: Imei ,Oaid, Gaid are all empty.")
}
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.
Recommendation is applied
PR 2345
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.
Thank you for the updates, LGTM
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.
Just some comments related to code coverage
intVar, err := strconv.Atoi(countryMCC) | ||
|
||
if err != nil { | ||
return defaultCountryName |
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 any way to trigger/cover this line of 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.
banner4_mccmnc.json file is used to cover line 783.
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.
@GenarC I still see this line uncovered when I run the tests in the huaweiads package
Thank you for adding test. However it doesn't add coverage for the places Alex mentioned.
This should add needed coverage |
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.
Thank you for adding tests, LGTM
Thanks for the help and the feedbacks |
* origin/master: (316 commits) Fix alt bidder code test broken by imp wrapper commit (prebid#2405) ImpWrapper (prebid#2375) Update sspBC adapter to v5.7 (prebid#2394) Change errors to warnings (prebid#2385) TheMediaGrid: support native mediaType (prebid#2377) Huaweiadsadapter gdpr (prebid#2345) Add alternatebiddercodes in Prebid request ext (prebid#2339) Changed FS bidder names to mixed case (prebid#2390) Load bidders names from file system in lowercase (prebid#2388) consumable adapter: add schain and coppa support (prebid#2361) Adapter aliases: moved adapter related configs to bidder.yaml files (prebid#2353) pubmatic adapter: add param prebiddealpriority (prebid#2281) Yieldlab Adapter: Add support for ad unit sizes (prebid#2364) GDPR: add enforce_algo config flag and convert enforce_purpose to bool (prebid#2330) Resolves CVE-2022-27664 (prebid#2376) AMP Endpoint: support parameters consentType and gdprApplies (prebid#2338) Dianomi - added usync for redirect (prebid#2368) Create issue_prioritization.yml (prebid#2372) Update yaml files for gzip supported bidders (prebid#2365) Adnuntius Adapter: Set no cookies as a parameter (prebid#2352) ...
Co-authored-by: Ho Chia Leung <[email protected]> Co-authored-by: Cem Genar <[email protected]>