Skip to content
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

Rubicon: Remove eids logic #3111

Merged
merged 2 commits into from
Sep 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 4 additions & 78 deletions adapters/rubicon/rubicon.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,10 @@ type rubiconDataExt struct {
}

type rubiconUserExt struct {
Eids []openrtb2.EID `json:"eids,omitempty"`
RP rubiconUserExtRP `json:"rp"`
LiverampIdl string `json:"liveramp_idl,omitempty"`
Data json.RawMessage `json:"data,omitempty"`
Consent string `json:"consent,omitempty"`
Eids []openrtb2.EID `json:"eids,omitempty"`
RP rubiconUserExtRP `json:"rp"`
Data json.RawMessage `json:"data,omitempty"`
Consent string `json:"consent,omitempty"`
}

type rubiconSiteExtRP struct {
Expand Down Expand Up @@ -340,19 +339,6 @@ func (a *RubiconAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *ada
if userBuyerUID == "" {
userBuyerUID = extractUserBuyerUID(userExtRP.Eids)
}

mappedRubiconUidsParam, errors := getSegments(userExtRP.Eids)
if len(errors) > 0 {
errs = append(errs, errors...)
continue
}

if err := updateUserExtWithSegments(&userExtRP, mappedRubiconUidsParam); err != nil {
errs = append(errs, err)
continue
}

userExtRP.LiverampIdl = mappedRubiconUidsParam.liverampIdl
}

if userCopy.Consent != "" {
Expand Down Expand Up @@ -941,66 +927,6 @@ func extractUserBuyerUID(eids []openrtb2.EID) string {
return ""
}

func getSegments(eids []openrtb2.EID) (mappedRubiconUidsParam, []error) {
rubiconUidsParam := mappedRubiconUidsParam{
segments: make([]string, 0),
}
errs := make([]error, 0)

for _, eid := range eids {
switch eid.Source {
case "liveintent.com":
uids := eid.UIDs
if len(uids) > 0 {
if eid.Ext != nil {
var eidExt rubiconUserExtEidExt
if err := json.Unmarshal(eid.Ext, &eidExt); err != nil {
errs = append(errs, &errortypes.BadInput{
Message: err.Error(),
})
continue
}
rubiconUidsParam.segments = eidExt.Segments
}
}
case "liveramp.com":
uids := eid.UIDs
if len(uids) > 0 {
uidId := uids[0].ID
if uidId != "" && rubiconUidsParam.liverampIdl == "" {
rubiconUidsParam.liverampIdl = uidId
}
}
}
}

return rubiconUidsParam, errs
}

func updateUserExtWithSegments(userExtRP *rubiconUserExt, rubiconUidsParam mappedRubiconUidsParam) error {
if len(rubiconUidsParam.segments) > 0 {

if rubiconUidsParam.segments != nil {
userExtRPTarget := make(map[string]interface{})

if userExtRP.RP.Target != nil {
if err := json.Unmarshal(userExtRP.RP.Target, &userExtRPTarget); err != nil {
return &errortypes.BadInput{Message: err.Error()}
}
}

userExtRPTarget["LIseg"] = rubiconUidsParam.segments

if target, err := json.Marshal(&userExtRPTarget); err != nil {
return &errortypes.BadInput{Message: err.Error()}
} else {
userExtRP.RP.Target = target
}
}
}
return nil
}

func isVideo(imp openrtb2.Imp) bool {
video := imp.Video
if video != nil {
Expand Down
91 changes: 0 additions & 91 deletions adapters/rubicon/rubicon_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -644,97 +644,6 @@ func TestOpenRTBRequestWithBadvOverflowed(t *testing.T) {
assert.Equal(t, badvOverflowed[:50], badvRequest, "Unexpected dfp_ad_unit_code: %s")
}

func TestOpenRTBRequestWithSpecificExtUserEids(t *testing.T) {
bidder := new(RubiconAdapter)

request := &openrtb2.BidRequest{
ID: "test-request-id",
Imp: []openrtb2.Imp{{
ID: "test-imp-id",
Banner: &openrtb2.Banner{
Format: []openrtb2.Format{
{W: 300, H: 250},
},
},
Ext: json.RawMessage(`{"bidder": {
"zoneId": 8394,
"siteId": 283282,
"accountId": 7891
}}`),
}},
App: &openrtb2.App{
ID: "com.test",
Name: "testApp",
},
User: &openrtb2.User{
Ext: json.RawMessage(`{"eids": [
{
"source": "pubcid",
"uids": [{
"id": "2402fc76-7b39-4f0e-bfc2-060ef7693648"
}]
},
{
"source": "adserver.org",
"uids": [{
"id": "3d50a262-bd8e-4be3-90b8-246291523907",
"ext": {
"rtiPartner": "TDID"
}
}]
},
{
"source": "liveintent.com",
"uids": [{
"id": "T7JiRRvsRAmh88"
}],
"ext": {
"segments": ["999","888"]
}
},
{
"source": "liveramp.com",
"uids": [{
"id": "LIVERAMPID"
}],
"ext": {
"segments": ["111","222"]
}
}
]}`),
},
}

reqs, _ := bidder.MakeRequests(request, &adapters.ExtraRequestInfo{})

rubiconReq := &openrtb2.BidRequest{}
if err := json.Unmarshal(reqs[0].Body, rubiconReq); err != nil {
t.Fatalf("Unexpected error while decoding request: %s", err)
}

assert.NotNil(t, rubiconReq.User.Ext, "User.Ext object should not be nil.")

var userExt rubiconUserExt
if err := json.Unmarshal(rubiconReq.User.Ext, &userExt); err != nil {
t.Fatal("Error unmarshalling request.user.ext object.")
}

assert.NotNil(t, userExt.Eids)
assert.Equal(t, 4, len(userExt.Eids), "Eids values are not as expected!")

// liveramp.com
assert.Equal(t, "LIVERAMPID", userExt.LiverampIdl, "Liveramp_idl value is not as expected!")

userExtRPTarget := make(map[string]interface{})
if err := json.Unmarshal(userExt.RP.Target, &userExtRPTarget); err != nil {
t.Fatal("Error unmarshalling request.user.ext.rp.target object.")
}

assert.Contains(t, userExtRPTarget, "LIseg", "request.user.ext.rp.target value is not as expected!")
assert.Contains(t, userExtRPTarget["LIseg"], "888", "No segment with 888 as expected!")
assert.Contains(t, userExtRPTarget["LIseg"], "999", "No segment with 999 as expected!")
}

func TestOpenRTBRequestWithVideoImpEvenIfImpHasBannerButAllRequiredVideoFields(t *testing.T) {
bidder := new(RubiconAdapter)

Expand Down
Loading