-
Notifications
You must be signed in to change notification settings - Fork 0
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
Support page type and position #5
Open
thetalkeren
wants to merge
22
commits into
master
Choose a base branch
from
support-page-type-and-position
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
9b6abb6
support-native
ahmadlob 4135d81
added page type and position to bidder params
f22b460
support-native
ahmadlob a7c6c87
support-native
ahmadlob 1d98949
support-native
ahmadlob d1b9ce2
support-native
ahmadlob 60de3a5
support-native
ahmadlob 749c15e
Merge remote-tracking branch 'origin/master' into support-page-type-a…
587d569
fixed position code and test
3061236
support-native
ahmadlob 38fefab
Merge pull request #4 from taboola/support-native
ahmadlob fdd3b57
Merge remote-tracking branch 'origin/master' into support-page-type-a…
58b9ae2
merged from master (native support) and resolved conflicts
cbacb42
put pageType in requestExt instead of siteExt
a93c138
support-native
ahmadlob 0a81621
support-native
ahmadlob 3e242bd
Merge pull request #6 from taboola/support-native
ahmadlob 6a628a5
Merge remote-tracking branch 'origin/master' into support-page-type-a…
b7b28e1
Merge remote-tracking branch 'upstream/master' into support-page-type…
d3f938a
merged from upstream
f045be8
removed redundant override adm (ahmad)
b81d7ed
changed Position *int8 to *int
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
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 |
---|---|---|
|
@@ -3,8 +3,7 @@ package taboola | |
import ( | ||
"encoding/json" | ||
"fmt" | ||
"github.com/prebid/openrtb/v17/native1" | ||
nativeResponse "github.com/prebid/openrtb/v17/native1/response" | ||
"github.com/prebid/openrtb/v17/adcom1" | ||
"github.com/prebid/openrtb/v17/openrtb2" | ||
"github.com/prebid/prebid-server/adapters" | ||
"github.com/prebid/prebid-server/config" | ||
|
@@ -103,20 +102,6 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.R | |
errs = append(errs, err) | ||
continue | ||
} | ||
if bidType == openrtb_ext.BidTypeNative { | ||
var nativePayload nativeResponse.Response | ||
if err := json.Unmarshal(json.RawMessage(seatBid.Bid[i].AdM), &nativePayload); err != nil { | ||
errs = append(errs, err) | ||
continue | ||
} | ||
overrideEventTrackers(&nativePayload) | ||
nativePayloadJson, err := json.Marshal(nativePayload) | ||
if err != nil { | ||
errs = append(errs, err) | ||
continue | ||
} | ||
seatBid.Bid[i].AdM = string(nativePayloadJson) | ||
} | ||
b := &adapters.TypedBid{ | ||
Bid: &seatBid.Bid[i], | ||
BidType: bidType, | ||
|
@@ -201,10 +186,17 @@ func createTaboolaRequests(request *openrtb2.BidRequest) (taboolaRequests []*ope | |
} | ||
|
||
if modifiedRequest.Imp[i].Banner != nil { | ||
if taboolaExt.Position != nil { | ||
bannerCopy := *imp.Banner | ||
bannerCopy.Pos = adcom1.PlacementPosition(*taboolaExt.Position).Ptr() | ||
imp.Banner = &bannerCopy | ||
modifiedRequest.Imp[i] = imp | ||
} | ||
bannerImp = append(bannerImp, modifiedRequest.Imp[i]) | ||
} else if modifiedRequest.Imp[i].Native != nil { | ||
nativeImp = append(nativeImp, modifiedRequest.Imp[i]) | ||
} | ||
|
||
} | ||
|
||
publisher := &openrtb2.Publisher{ | ||
|
@@ -236,12 +228,35 @@ func createTaboolaRequests(request *openrtb2.BidRequest) (taboolaRequests []*ope | |
modifiedRequest.BAdv = taboolaExt.BAdv | ||
} | ||
|
||
if taboolaExt.PageType != "" { | ||
requestExt, requestExtErr := makeRequestExt(taboolaExt.PageType) | ||
if requestExtErr == nil { | ||
modifiedRequest.Ext = requestExt | ||
} else { | ||
errs = append(errs, requestExtErr) | ||
} | ||
} | ||
|
||
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. |
||
taboolaRequests = append(taboolaRequests, overrideBidRequestImp(&modifiedRequest, nativeImp)) | ||
taboolaRequests = append(taboolaRequests, overrideBidRequestImp(&modifiedRequest, bannerImp)) | ||
|
||
return taboolaRequests, errs | ||
} | ||
|
||
func makeRequestExt(pageType string) (json.RawMessage, error) { | ||
requestExt := &RequestExt{ | ||
PageType: pageType, | ||
} | ||
|
||
requestExtJson, err := json.Marshal(requestExt) | ||
if err != nil { | ||
fmt.Errorf("could not marshal %s", requestExt) | ||
return nil, err | ||
} | ||
return requestExtJson, nil | ||
|
||
} | ||
|
||
func getMediaType(impID string, imps []openrtb2.Imp) (openrtb_ext.BidType, error) { | ||
for _, imp := range imps { | ||
if imp.ID == impID { | ||
|
@@ -273,19 +288,3 @@ func overrideBidRequestImp(originBidRequest *openrtb2.BidRequest, imp []openrtb2 | |
bidRequestResult.Imp = imp | ||
return &bidRequestResult | ||
} | ||
|
||
func overrideEventTrackers(nativePayload *nativeResponse.Response) { | ||
// convert eventrackers to the deprecated imptrackers and jstracker because it's not supported in native 1.1v | ||
for _, eventTracker := range nativePayload.EventTrackers { | ||
if eventTracker.Event != native1.EventTypeImpression { | ||
continue | ||
} | ||
switch eventTracker.Method { | ||
case native1.EventTrackingMethodImage: | ||
nativePayload.ImpTrackers = append(nativePayload.ImpTrackers, eventTracker.URL) | ||
case native1.EventTrackingMethodJS: | ||
nativePayload.JSTracker = fmt.Sprintf("<script src=\"%s\"></script>", eventTracker.URL) | ||
} | ||
} | ||
nativePayload.EventTrackers = 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
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
157 changes: 157 additions & 0 deletions
157
adapters/taboola/taboolatest/exemplary/withPageType.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,157 @@ | ||
{ | ||
"mockBidRequest": { | ||
"id": "request-id", | ||
"imp": [ | ||
{ | ||
"id": "impression-id", | ||
"banner": { | ||
"format": [ | ||
{ | ||
"w": 300, | ||
"h": 250 | ||
}, | ||
{ | ||
"w": 300, | ||
"h": 600 | ||
}, | ||
{ | ||
"w": 160, | ||
"h": 600 | ||
} | ||
] | ||
}, | ||
"ext": { | ||
"bidder": { | ||
"publisherId": "publisher-id", | ||
"tagid": "tag-id", | ||
"pageType": "homepage" | ||
} | ||
} | ||
} | ||
], | ||
"site": { | ||
"domain": "http://domain.com", | ||
"page": "http://page-domain.com", | ||
"ref": "http://page-domain.com" | ||
}, | ||
"device": { | ||
"ua": "Mozilla/5.0 (Linux; Android 12; Pixel 6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.62 Mobile Safari/537.36", | ||
"h": 300, | ||
"w": 300 | ||
} | ||
}, | ||
"httpCalls": [ | ||
{ | ||
"expectedRequest": { | ||
"uri": "http://display.whatever.com/hosturl.com/publisher-id", | ||
"body": { | ||
"id": "request-id", | ||
"imp": [ | ||
{ | ||
"id": "impression-id", | ||
"banner": { | ||
"format": [ | ||
{ | ||
"w": 300, | ||
"h": 250 | ||
}, | ||
{ | ||
"w": 300, | ||
"h": 600 | ||
}, | ||
{ | ||
"w": 160, | ||
"h": 600 | ||
} | ||
] | ||
}, | ||
"tagid" : "tag-id", | ||
"ext": { | ||
"bidder": { | ||
"publisherId": "publisher-id", | ||
"tagid": "tag-id", | ||
"pageType": "homepage" | ||
} | ||
} | ||
} | ||
], | ||
"site": { | ||
"id": "publisher-id", | ||
"name": "publisher-id", | ||
"domain": "http://domain.com", | ||
"page": "http://page-domain.com", | ||
"ref": "http://page-domain.com", | ||
"publisher": { | ||
"id": "publisher-id" | ||
} | ||
}, | ||
"device": { | ||
"ua": "Mozilla/5.0 (Linux; Android 12; Pixel 6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.62 Mobile Safari/537.36", | ||
"h": 300, | ||
"w": 300 | ||
}, | ||
"ext": { | ||
"pageType": "homepage" | ||
} | ||
} | ||
}, | ||
"mockResponse": { | ||
"status": 200, | ||
"body": { | ||
"id": "123", | ||
"seatbid": [ | ||
{ | ||
"bid": [ | ||
{ | ||
"id": "request-id", | ||
"impid": "impression-id", | ||
"price": 2.1, | ||
"adid": "1", | ||
"adm": "<hrml></html>", | ||
"adomain": [ | ||
"adomain.com" | ||
], | ||
"cid": "cid", | ||
"crid": "crid", | ||
"w": 300, | ||
"h": 250, | ||
"exp": 60, | ||
"lurl": "https://lurl.domain.com/" | ||
} | ||
], | ||
"seat": "1111" | ||
} | ||
], | ||
"bidid": "123", | ||
"cur": "USD" | ||
} | ||
} | ||
} | ||
], | ||
"expectedBidResponses": [ | ||
{ | ||
"currency": "USD", | ||
"bids": [ | ||
{ | ||
"bid": { | ||
"id": "request-id", | ||
"impid": "impression-id", | ||
"price": 2.1, | ||
"adid": "1", | ||
"adm": "<hrml></html>", | ||
"adomain": [ | ||
"adomain.com" | ||
], | ||
"cid": "cid", | ||
"crid": "crid", | ||
"w": 300, | ||
"h": 250, | ||
"exp": 60, | ||
"lurl": "https://lurl.domain.com/" | ||
}, | ||
"type": "banner" | ||
} | ||
] | ||
} | ||
] | ||
} |
Oops, something went wrong.
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.
@ahmadlob please take a look here