-
Notifications
You must be signed in to change notification settings - Fork 762
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
RP adapter: use video placement parameter to set size ID #1607
Merged
mansinahar
merged 4 commits into
prebid:master
from
SerhiiNahornyi:rp/video/size_id/logic
Dec 10, 2020
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -489,7 +489,18 @@ func (a *RubiconAdapter) Call(ctx context.Context, req *pbs.PBSRequest, bidder * | |
rubiReq.Device = &deviceCopy | ||
|
||
if thisImp.Video != nil { | ||
videoExt := rubiconVideoExt{Skip: params.Video.Skip, SkipDelay: params.Video.SkipDelay, RP: rubiconVideoExtRP{SizeID: params.Video.VideoSizeID}} | ||
|
||
videoSizeId := params.Video.VideoSizeID | ||
if videoSizeId == 0 { | ||
resolvedSizeId, err := resolveVideoSizeId(thisImp.Video.Placement, thisImp.Instl, thisImp.ID) | ||
if err == nil { | ||
videoSizeId = resolvedSizeId | ||
} else { | ||
continue | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In line 496, if the error turns out to not be
|
||
} | ||
|
||
videoExt := rubiconVideoExt{Skip: params.Video.Skip, SkipDelay: params.Video.SkipDelay, RP: rubiconVideoExtRP{SizeID: videoSizeId}} | ||
thisImp.Video.Ext, err = json.Marshal(&videoExt) | ||
} else { | ||
primarySizeID, altSizeIDs, err := parseRubiconSizes(unit.Sizes) | ||
|
@@ -601,6 +612,24 @@ func (a *RubiconAdapter) Call(ctx context.Context, req *pbs.PBSRequest, bidder * | |
return bids, nil | ||
} | ||
|
||
func resolveVideoSizeId(placement openrtb.VideoPlacementType, instl int8, impId string) (sizeID int, err error) { | ||
if placement != 0 { | ||
if placement == 1 { | ||
return 201, nil | ||
} | ||
if placement == 3 { | ||
return 203, nil | ||
} | ||
} | ||
|
||
if instl == 1 { | ||
return 202, nil | ||
} | ||
return 0, &errortypes.BadInput{ | ||
Message: fmt.Sprintf("video.size_id can not be resolved in impression with id : %s", impId), | ||
} | ||
} | ||
|
||
func appendTrackerToUrl(uri string, tracker string) (res string) { | ||
// Append integration method. Adapter init happens once | ||
urlObject, err := url.Parse(uri) | ||
|
@@ -771,21 +800,24 @@ func (a *RubiconAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adap | |
|
||
isVideo := isVideo(thisImp) | ||
if isVideo { | ||
if rubiconExt.Video.VideoSizeID == 0 { | ||
errs = append(errs, &errortypes.BadInput{ | ||
Message: fmt.Sprintf("imp[%d].ext.bidder.rubicon.video.size_id must be defined for video impression", i), | ||
}) | ||
continue | ||
videoCopy := *thisImp.Video | ||
|
||
videoSizeId := rubiconExt.Video.VideoSizeID | ||
if videoSizeId == 0 { | ||
resolvedSizeId, err := resolveVideoSizeId(thisImp.Video.Placement, thisImp.Instl, thisImp.ID) | ||
if err != nil { | ||
errs = append(errs, err) | ||
continue | ||
} | ||
videoSizeId = resolvedSizeId | ||
} | ||
|
||
// if imp.ext.is_rewarded_inventory = 1, set imp.video.ext.videotype = "rewarded" | ||
var videoType = "" | ||
if bidderExt.Prebid != nil && bidderExt.Prebid.IsRewardedInventory == 1 { | ||
videoType = "rewarded" | ||
} | ||
|
||
videoCopy := *thisImp.Video | ||
videoExt := rubiconVideoExt{Skip: rubiconExt.Video.Skip, SkipDelay: rubiconExt.Video.SkipDelay, VideoType: videoType, RP: rubiconVideoExtRP{SizeID: rubiconExt.Video.VideoSizeID}} | ||
videoExt := rubiconVideoExt{Skip: rubiconExt.Video.Skip, SkipDelay: rubiconExt.Video.SkipDelay, VideoType: videoType, RP: rubiconVideoExtRP{SizeID: videoSizeId}} | ||
videoCopy.Ext, err = json.Marshal(&videoExt) | ||
thisImp.Video = &videoCopy | ||
thisImp.Banner = nil | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
159 changes: 159 additions & 0 deletions
159
adapters/rubicon/rubicontest/exemplary/simple-video.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,159 @@ | ||
{ | ||
"mockBidRequest": { | ||
"id": "test-request-id", | ||
"device": { | ||
"ip": "123.123.123.123", | ||
"ifa": "zxcjbzxmc-zxcbmz-zxbcz-zxczx" | ||
}, | ||
"app": { | ||
"id": "1", | ||
"bundle": "com.wls.testwlsapplication" | ||
}, | ||
"imp": [ | ||
{ | ||
"id": "test-imp-id", | ||
"instl": 1, | ||
"video": { | ||
"placement": 3, | ||
"mimes": [ | ||
"video/mp4" | ||
], | ||
"protocols": [ | ||
2, | ||
5 | ||
], | ||
"w": 1024, | ||
"h": 576 | ||
}, | ||
"ext": { | ||
"bidder": { | ||
"video": { | ||
}, | ||
"accountId": 1001, | ||
"siteId":113932, | ||
"zoneId":535510 | ||
} | ||
} | ||
} | ||
] | ||
}, | ||
"httpCalls": [ | ||
{ | ||
"expectedRequest": { | ||
"uri": "uri?tk_xint=pbs-test-tracker", | ||
"body": { | ||
"id": "test-request-id", | ||
"device": { | ||
"ext": { | ||
"rp": { | ||
"pixelratio": 0 | ||
} | ||
}, | ||
"ip": "123.123.123.123", | ||
"ifa": "zxcjbzxmc-zxcbmz-zxbcz-zxczx" | ||
}, | ||
"app": { | ||
"id": "1", | ||
"ext": { | ||
"rp": { | ||
"site_id": 113932 | ||
} | ||
}, | ||
"publisher": { | ||
"ext": { | ||
"rp": { | ||
"account_id": 1001 | ||
} | ||
} | ||
}, | ||
"bundle": "com.wls.testwlsapplication" | ||
}, | ||
"imp": [ | ||
{ | ||
"id": "test-imp-id", | ||
"instl": 1, | ||
"video": { | ||
"placement": 3, | ||
"ext": { | ||
"rp": { | ||
"size_id": 203 | ||
} | ||
}, | ||
"mimes": [ | ||
"video/mp4" | ||
], | ||
"protocols": [ | ||
2, | ||
5 | ||
], | ||
"w": 1024, | ||
"h": 576 | ||
}, | ||
"ext": { | ||
"rp": { | ||
"track":{ | ||
"mint": "", | ||
"mint_version": "" | ||
}, | ||
"zone_id": 535510 | ||
} | ||
} | ||
} | ||
] | ||
} | ||
}, | ||
"mockResponse": { | ||
"status": 200, | ||
"body": { | ||
"id": "test-request-id", | ||
"seatbid": [ | ||
{ | ||
"bid": [ | ||
{ | ||
"id": "test_bid_id", | ||
"impid": "test-imp-id", | ||
"price": 0.27543, | ||
"adm": "some-test-ad", | ||
"cid": "test_cid", | ||
"crid": "test_crid", | ||
"dealid": "test_dealid", | ||
"ext": { | ||
"prebid": { | ||
"type": "video" | ||
} | ||
} | ||
} | ||
], | ||
"seat": "adman" | ||
} | ||
], | ||
"cur": "USD" | ||
} | ||
} | ||
} | ||
], | ||
"expectedBidResponses": [ | ||
{ | ||
"currency": "USD", | ||
"bids": [ | ||
{ | ||
"bid": { | ||
"id": "test_bid_id", | ||
"impid": "test-imp-id", | ||
"price": 0.27543, | ||
"adm": "some-test-ad", | ||
"cid": "test_cid", | ||
"crid": "test_crid", | ||
"dealid": "test_dealid", | ||
"ext": { | ||
"prebid": { | ||
"type": "video" | ||
} | ||
} | ||
}, | ||
"type": "video" | ||
} | ||
] | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 curious, why is the error behavior for the legacy auction endpoint different from that of the openrtb endpoint i.e. in this case, even if you get an error while resolving the video size ID, you just let it be
0
and move on with processing as usual but in case of openrtb, you actually discard that impThere 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 rubiconExt.Video.VideoSizeID == 0 { errs = append(errs, &errortypes.BadInput{ Message: fmt.Sprintf("imp[%d].ext.bidder.rubicon.video.size_id must be defined for video impression", i), }) continue
this was previous logic in non legacy, haven't found similar in legacy
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 see but if your bidder expects a non-zero
sizeID
and will return an error for requests with an empty/invalid video sizeID then I'd suggest returning an error here and failing fast as you do for non-legacy rather than sending the request to the bidder and the bidder then returning an error back. That will be inefficient use of resources.Also, I'd assume the behavior to be the same as both in legacy and non-legacy endpoints unless your system has a way to differentiate between the two.
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.
Ooops! Looks like I missed your update to
continue
in an error situation for the legacy endpoint as well. Thanks!