Skip to content

Commit

Permalink
PREB-42 Add GPID support
Browse files Browse the repository at this point in the history
  • Loading branch information
Enigo committed Oct 18, 2024
1 parent bcf6491 commit 4d58f1f
Show file tree
Hide file tree
Showing 32 changed files with 58 additions and 210 deletions.
43 changes: 22 additions & 21 deletions adapters/smaato/smaato.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
"github.com/prebid/prebid-server/v2/util/timeutil"
)

const clientVersion = "prebid_server_1.1"
const clientVersion = "prebid_server_1.2"

type adMarkupType string

Expand Down Expand Up @@ -471,14 +471,13 @@ func setImpForAdspace(imp *openrtb2.Imp) error {
return &errortypes.BadInput{Message: "Missing adspaceId parameter."}
}

impExt, err := makeImpExt(&imp.Ext)
err = removeBidderNodeFromImpExt(imp)
if err != nil {
return err
}

if imp.Banner != nil || imp.Video != nil || imp.Native != nil {
imp.TagID = adSpaceID
imp.Ext = impExt
return nil
}

Expand All @@ -490,15 +489,17 @@ func setImpForAdBreak(imps []openrtb2.Imp) error {
return &errortypes.BadInput{Message: "No impressions in bid request."}
}

adBreakID, err := jsonparser.GetString(imps[0].Ext, "bidder", "adbreakId")
firstImp := imps[0]
adBreakID, err := jsonparser.GetString(firstImp.Ext, "bidder", "adbreakId")
if err != nil {
return &errortypes.BadInput{Message: "Missing adbreakId parameter."}
}

impExt, err := makeImpExt(&imps[0].Ext)
err = removeBidderNodeFromImpExt(&firstImp)
if err != nil {
return err
}
ext := firstImp.Ext

for i := range imps {
imps[i].TagID = adBreakID
Expand All @@ -512,33 +513,33 @@ func setImpForAdBreak(imps []openrtb2.Imp) error {
imps[i].Video = &videoCopy
}

imps[0].Ext = impExt
imps[0].Ext = ext

return nil
}

func makeImpExt(impExtRaw *json.RawMessage) (json.RawMessage, error) {
var impExt openrtb_ext.ExtImpExtraDataSmaato

if err := json.Unmarshal(*impExtRaw, &impExt); err != nil {
return nil, &errortypes.BadInput{Message: "Invalid imp.ext."}
func removeBidderNodeFromImpExt(imp *openrtb2.Imp) error {
if imp.Ext == nil {
return nil
}
updatedExt := jsonparser.Delete(imp.Ext, "bidder")
isEmpty := true
err := jsonparser.ObjectEach(updatedExt, func(key []byte, value []byte, dataType jsonparser.ValueType, offset int) error {
isEmpty = false
return nil
})

if impExtSkadnRaw := impExt.Skadn; impExtSkadnRaw != nil {
var impExtSkadn map[string]json.RawMessage

if err := json.Unmarshal(impExtSkadnRaw, &impExtSkadn); err != nil {
return nil, &errortypes.BadInput{Message: "Invalid imp.ext.skadn."}
}
if err != nil {
return err
}

if impExtJson, err := json.Marshal(impExt); string(impExtJson) != "{}" {
return impExtJson, err
if isEmpty {
imp.Ext = nil
} else {
return nil, nil
imp.Ext = updatedExt
}
return nil
}

func groupImpressionsByPod(imps []openrtb2.Imp) (map[string]([]openrtb2.Imp), []string, []error) {
pods := make(map[string][]openrtb2.Imp)
orderKeys := make([]string, 0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@
"keywords": "power tools"
},
"ext": {
"client": "prebid_server_1.1"
"client": "prebid_server_1.2"
}
},
"impIDs":["1C86242D-9535-47D6-9576-7B1FE87F282C"]
Expand Down Expand Up @@ -350,7 +350,7 @@
"keywords": "power tools"
},
"ext": {
"client": "prebid_server_1.1"
"client": "prebid_server_1.2"
}
},
"impIDs":["postbid_iframe"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@
"keywords": "power tools"
},
"ext": {
"client": "prebid_server_1.1"
"client": "prebid_server_1.2"
}
},
"impIDs":["1C86242D-9535-47D6-9576-7B1FE87F282C"]
Expand Down Expand Up @@ -270,7 +270,7 @@
"keywords": "power tools"
},
"ext": {
"client": "prebid_server_1.1"
"client": "prebid_server_1.2"
}
},
"impIDs":["postbid_iframe"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@
"keywords": "power tools"
},
"ext": {
"client": "prebid_server_1.1"
"client": "prebid_server_1.2"
}
},
"impIDs":["1C86242D-9535-47D6-9576-7B1FE87F282C"]
Expand Down Expand Up @@ -327,7 +327,7 @@
"keywords": "power tools"
},
"ext": {
"client": "prebid_server_1.1"
"client": "prebid_server_1.2"
}
},
"impIDs":["1C86242D-9535-47D6-9576-7B1FE87F282C"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@
"keywords": "power tools"
},
"ext": {
"client": "prebid_server_1.1"
"client": "prebid_server_1.2"
}
},
"impIDs":["1C86242D-9535-47D6-9576-7B1FE87F282C"]
Expand Down Expand Up @@ -260,7 +260,7 @@
"keywords": "power tools"
},
"ext": {
"client": "prebid_server_1.1"
"client": "prebid_server_1.2"
}
},
"impIDs":["1C86242D-9535-47D6-9576-7B1FE87F282C"]
Expand Down
2 changes: 1 addition & 1 deletion adapters/smaato/smaatotest/exemplary/native.json
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@
}
},
"ext": {
"client": "prebid_server_1.1"
"client": "prebid_server_1.2"
}
},
"impIDs":["postbid_iframe"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@
"keywords": "keywords"
},
"ext": {
"client": "prebid_server_1.1"
"client": "prebid_server_1.2"
}
},
"impIDs":["1C86242D-9535-47D6-9576-7B1FE87F282C"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@
"keywords": "keywords"
},
"ext": {
"client": "prebid_server_1.1"
"client": "prebid_server_1.2"
}
},
"impIDs":["1C86242D-9535-47D6-9576-7B1FE87F282C"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@
"keywords": "power tools"
},
"ext": {
"client": "prebid_server_1.1"
"client": "prebid_server_1.2"
}
},
"impIDs":["1C86242D-9535-47D6-9576-7B1FE87F282C"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"publisherId": "1100042525",
"adspaceId": "130563103"
},
"gpid": 1,
"skadn": {
"versions": ["2.0", "2.1", "2.2", "3.0", "4.0"],
"sourceapp": "880047117",
Expand Down Expand Up @@ -118,6 +119,7 @@
]
},
"ext": {
"gpid": 1,
"skadn": {
"versions": ["2.0", "2.1", "2.2", "3.0", "4.0"],
"sourceapp": "880047117",
Expand Down Expand Up @@ -167,7 +169,7 @@
"keywords": "power tools"
},
"ext": {
"client": "prebid_server_1.1"
"client": "prebid_server_1.2"
}
},
"impIDs":["1C86242D-9535-47D6-9576-7B1FE87F282C"]
Expand Down
2 changes: 1 addition & 1 deletion adapters/smaato/smaatotest/exemplary/simple-banner.json
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@
"keywords": "power tools"
},
"ext": {
"client": "prebid_server_1.1"
"client": "prebid_server_1.2"
}
},
"impIDs":["1C86242D-9535-47D6-9576-7B1FE87F282C"]
Expand Down
2 changes: 1 addition & 1 deletion adapters/smaato/smaatotest/exemplary/video-app.json
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@
"keywords": "keywords"
},
"ext": {
"client": "prebid_server_1.1"
"client": "prebid_server_1.2"
}
},
"impIDs":["postbid_iframe"]
Expand Down
2 changes: 1 addition & 1 deletion adapters/smaato/smaatotest/exemplary/video-dooh.json
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@
"keywords": "keywords"
},
"ext": {
"client": "prebid_server_1.1"
"client": "prebid_server_1.2"
}
},
"impIDs":["postbid_iframe"]
Expand Down
2 changes: 1 addition & 1 deletion adapters/smaato/smaatotest/exemplary/video.json
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@
}
},
"ext": {
"client": "prebid_server_1.1"
"client": "prebid_server_1.2"
}
},
"impIDs":["postbid_iframe"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@
"keywords": "power tools"
},
"ext": {
"client": "prebid_server_1.1"
"client": "prebid_server_1.2"
}
},
"impIDs":["1C86242D-9535-47D6-9576-7B1FE87F282C"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@
"keywords": "power tools"
},
"ext": {
"client": "prebid_server_1.1"
"client": "prebid_server_1.2"
}
},
"impIDs":["1C86242D-9535-47D6-9576-7B1FE87F282C"]
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@
"keywords": "power tools"
},
"ext": {
"client": "prebid_server_1.1"
"client": "prebid_server_1.2"
}
},
"impIDs":["1C86242D-9535-47D6-9576-7B1FE87F282C"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@
"keywords": "power tools"
},
"ext": {
"client": "prebid_server_1.1"
"client": "prebid_server_1.2"
}
},
"impIDs":["1C86242D-9535-47D6-9576-7B1FE87F282C"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@
"keywords": "power tools"
},
"ext": {
"client": "prebid_server_1.1"
"client": "prebid_server_1.2"
}
},
"impIDs":["1C86242D-9535-47D6-9576-7B1FE87F282C"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@
"keywords": "power tools"
},
"ext": {
"client": "prebid_server_1.1"
"client": "prebid_server_1.2"
}
},
"impIDs":["1C86242D-9535-47D6-9576-7B1FE87F282C"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@
"keywords": "power tools"
},
"ext": {
"client": "prebid_server_1.1"
"client": "prebid_server_1.2"
}
},
"impIDs":["1C86242D-9535-47D6-9576-7B1FE87F282C"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
}
},
"ext": {
"client": "prebid_server_1.1"
"client": "prebid_server_1.2"
}
},
"impIDs":["1C86242D-9535-47D6-9576-7B1FE87F282C"]
Expand Down
Loading

0 comments on commit 4d58f1f

Please sign in to comment.