Skip to content

Commit

Permalink
Beachfront bidder (prebid#538)
Browse files Browse the repository at this point in the history
* copied beachfront bidder from defunct fork.

* debugging cookies

* debugging cookies

* debugging cookies

* debugging cookies

* debugging cookies

* debugging cookies

* trying live endpoint because qa is returning non-usable stuff

* back to qa

* back to qa

* back to qa

* back to qa

* back to qa

* back to qa

* back to qa

* back to qa

* back to qa

* back to qa

* back to qa

* back to qa

* back to qa

* back to qa

* back to qa

* back to qa

* back to qa

* back to qa

* back to qa

* back to qa

* back to qa

* back to qa

* back to qa

* back to qa

* back to qa

* back to qa

* back to qa

* back to qa

* back to qa

* back to qa

* back to qa

* back to qa

* back to qa

* got a jam

* is that how they want the bid response returned? What happens to bidType?

* so adapters.bidResponse is just a wrapper?

* so adapters.bidResponse is just a wrapper?

* maybe that gets it?

* maybe that gets it?

* cleaned up debugging a bit

* cleaned up debugging a bit

* cleaned up debugging a bit

* cleaned up debugging a bit

* trying a config file

* trying a config file

* trying a config file

* trying a config file

* trying a config file

* trying a config file

* trying a config file

* trying a config file

* trying a config file

* trying a config file

* trying a config file

* trying a config file

* trying a config file

* looking at publisher id as the key for getting __io_cid

* looking at publisher id as the key for getting __io_cid

* looking at publisher id as the key for getting __io_cid

* looking at publisher id as the key for getting __io_cid

* looking at publisher id as the key for getting __io_cid

* looking at publisher id as the key for getting __io_cid

* looking at publisher id as the key for getting __io_cid

* The usersync endpoint was working yesterday! WHat the hell happened????

* The usersync endpoint was working yesterday! WHat the hell happened????

* The usersync endpoint was working yesterday! WHat the hell happened????

* simplifying usersync

* simplifying usersync

* simplifying usersync

* switched banner request back to a string user and passing the publisher id in for that.

* debugging

* debugging

* debugging

* switched banner request back to a string user and passing the publisher id in for that.

* switched to a configured usersync URL

* typo in the syncer

* typo in the syncer

* messing with syncer url formatting

* messing with syncer url formatting

* messing with syncer url formatting

* trying live endpoint

* trying live endpoint worked - trying live nurl

* some code cleanup - making the endpoint selection better

* some code cleanup - making the endpoint selection better

* some code cleanup - making the endpoint selection better

* some code cleanup - making the endpoint selection better

* removed some redundant debugging

* removed some redundant debugging

* trying a test endpoint

* nope.

* trying to use the built in cookie

* trying to use the built in cookie

* trying to use the built in cookie

* trying to use the built in cookie

* trying to use the built in cookie

* trying to use the built in cookie

* added cookie back to request

* added cookie back to request

* testing with skip_no_cookie=true

* trying platform ID as sync ID.

* straightening pout request cookies

* Almost ready for my pull request. About to do a merge from upstream which may break it ALLgit add .

* trying a default platfor_id

* testing a host cookie

* that didn't work

* cleaned out some glog.Infos

* trying multis

* trying multis

* trying multis

* trying multis

* trying multis

* trying multis

* trying multis

* trying multis

* trying multis

* trying multis

* trying multis

* trying multis

* trying multis

* got multi banners working, but video still fails.

* I've got the 'prefer video' behavior working correctly. Also, video is going to have to be single response only because that's what I get from Beachfront

* a few changes to get mixed media working with aliases

* added some error tests and multiple format tests

* Might fix validation error prebid#538 -

The validation error came from this command on the Travis CI build:

./validate.sh --nofmt --cov --race 10

The command worked for me when I ran it locally on go version 1.10.1 and 1.9.3.
 * go version go1.9.3 darwin/amd64
 * go version go1.10.1 darwin/amd64
 * both installed with homebrew

I then did a pull and ran the command on Beachfront's staging server
go version go1.10 linux/amd64

That reproduced the error :
gofmt needs to be run, 1 files have issues.  Below is a list of files to review:
adapters/beachfront/beachfront.go

So I ran go fmt to see what it would fix. The diff of this commit will show
that the problem was several conditionals where I, being new to Go, used
parenthesis. The Darwin builds were letting that slide for whatever reason.
The Linux builds were not (I assume that Travis CL is running in a Linux VM
somewhere).

* Eliminates the JSON template mechanism for the beachfront requests as commented by hhhjort for prebid#538. Also corrected my accidental .gitignore commit.

* Eliminates the JSON template mechanism for the beachfront Video requests.

* No empty beachfrontReq.Imp by default - they all just get appended as needed. I'm still looking at how to do this using len(req.Imp) as suggested by @hhhjort.

* Hit another 'go fmt' discrepency between Mac/Linux.

* That straightens out the index clunckyness and gets the test cases back to matching what those produce. I still need to change that to slice.

* eliminated some weirdness that resulted from working on this on 2 different boxes so that I can use Linux version of 'go fmt'

* cleaned up some of logic related to video / banner requests

* Another correction related to Mac/Linux go fmt - prebid#538. This was a result of differences in comment formating. @dbemiller - note that this time when I ran go fmt on the Linux box it 'corrected' some comments in pbs_light.go. I'm not sure if that's OK, as it seems weird that, if the formating was 'wrong' on your master, then all travis CL tests would fail, and specificly brightroll's tests as the 'wrong' formating is in a commented out block of viper.SetDefault code. I've taken care of most of what @hhhjort pointed out, but still not quite there. I'll hold of on commiting though because this looks weird to me..

* forgot to add the len() based index to video.

* reformated in Linux to match Travis CI

* some documentation updates

* Failed on a previous conflict resolution

* added some documentation and parameter testing

* migrated beachfront viper defaults into the updated config setup

* reverted .gitignore to upstream master. I think that in the process of rmoving some changes that I made while debugging, to avoid pushing some notes I was keeping, I accidentally removed a line that I should not have and pushed it. (e6fdab3, )

* Changed the endpoint to a named function. Also added 'expectedBids' to my video tests, but they don't actually seem to be processed. I can put known errors in and validation still passes. I tried putting a known error into the tests for another bidder's expectedBids, and also passed validation. So I'll go over these carefully to make sure that they look right, but I don't think that they are currently being run in the tests.

* Moved regex out of the postProcessbanner function, so it will only get compiled once instead of recompiling fro evey banner

* This covers all the points that dbemiller pointed out, except the errors for audio / native. So the post processing now works with a slice of bids instead packing and unpacking a seatbid etc.

* eliminated the regex for the banner crid. I'm assuming that the string functions are less expensive than compiling a regex.

* added race condition parameters and modified some of the Domain/Page logic

* updated expectedBids for video to reflect changes to crid extraction

* fixed an index out of range error in post process video response

* Removed some dead code, some glog output and corrected error type for bad response.

* ... except that error needs to be pushed to the stack, not just returned.

* improved non-fatal error handling and some clean up
  • Loading branch information
muncha authored and dbemiller committed Jul 9, 2018
1 parent 0fd8dd2 commit df05e99
Show file tree
Hide file tree
Showing 24 changed files with 1,707 additions and 1 deletion.
512 changes: 512 additions & 0 deletions adapters/beachfront/beachfront.go

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions adapters/beachfront/beachfront_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package beachfront

import (
"github.com/prebid/prebid-server/adapters/adapterstest"
"testing"
)

func TestJsonSamples(t *testing.T) {
adapterstest.RunJSONBidderTest(t, "beachfronttest", new(BeachfrontAdapter))
}
92 changes: 92 additions & 0 deletions adapters/beachfront/beachfronttest/exemplary/minimal-banner.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
{
"mockBidRequest": {
"id": "some_test_ad",
"site": {
"page": "https://test.opposingviews.com/i/society/republican-sen-collins-may-change-vote-tax-bill?cb=1234534"
},
"imp": [
{
"bidfloor": 0.02,
"banner": {
"format": [
{
"w": 300,
"h": 250
}
]
},
"ext": {
"bidder": {
"bidfloor": 0.02,
"appId": "3b16770b-17af-4d22-daff-9606bdf2c9c3"
}
}
}
]
},

"httpCalls": [
{
"expectedRequest": {
"uri": "https://display.bfmio.com/prebid_display",
"body": {
"slots": [
{
"slot": "",
"id": "3b16770b-17af-4d22-daff-9606bdf2c9c3",
"bidfloor": 0.02,
"sizes": [
{
"w": 300,
"h": 250
}
]
}
],
"domain": "test.opposingviews.com",
"page": "https://test.opposingviews.com/i/society/republican-sen-collins-may-change-vote-tax-bill?cb=1234534",
"referrer": "",
"search": "",
"secure": 0,
"isMobile": 0,
"ip": "",
"deviceModel": "",
"deviceOs": "",
"dnt": 0,
"ua": "",
"adapterName": "BF_PREBID_S2S",
"adapterVersion": "0.1.1",
"user": ""
}
},
"mockResponse": {
"status": 200,
"body": [
{
"crid":"crid_1",
"price":2.942808,
"w":300,
"h":250,
"slot":"div-gpt-ad-1460505748561-0",
"adm":"<div id=\"44861168\"><script>!function(){console.log\"Hello, ad.\";}();<\/script><\/div>"
}
]
}
}
],

"expectedBids": [
{
"bid": {
"id": "12345678",
"impid": "test-slot",
"price": 2,
"adm": "\u003cdiv id=\"12345678\" style=\"width:300;height:250;background-color:black;color:white;\"\u003e300x250\u003c\\div\u003e",
"crid": "crid_1",
"w": 300,
"h": 250
},
"type": "banner"
}
]
}
151 changes: 151 additions & 0 deletions adapters/beachfront/beachfronttest/exemplary/simple-video.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
{
"mockBidRequest":
{
"id":"61b87329-8790-47b7-90dd-c53ae7ce1723",
"tmax":1000,
"source":{
"tid":"61b87329-8790-47b7-90dd-c53ae7ce1723"
},
"imp":[
{
"id":"video1",
"ext":{
"bidder":{
"bidfloor":0.01,
"appId":"11bc5dd5-7421-4dd8-c926-40fa653bec76"
}
},
"video":{
"mimes":[
"video/mp4"
],
"context":"instream",
"w":300,
"h":250
}
}
],
"site":{
"publisher":{
"id":"publisher1"
},
"page": "https://test.opposingviews.com/i/society/republican-sen-collins-may-change-vote-tax-bill?cb=1234534"
},
"user": {
"id": "some-user",
"buyeruid": "some-buyer"
},
"device": {
"ip": "127.0.0.1",
"ua": "Opera/9.80 (X11; Linux i686; Ubuntu/14.10) Presto/2.12.388 Version/12.16"
}
},

"httpCalls": [
{
"expectedRequest": {
"uri": "https://reachms.bfmio.com/bid.json?exchange_id=11bc5dd5-7421-4dd8-c926-40fa653bec76&prebidserver",
"body": {
"isPrebid": true,
"appId": "11bc5dd5-7421-4dd8-c926-40fa653bec76",
"domain": "test.opposingviews.com",
"id": "61b87329-8790-47b7-90dd-c53ae7ce1723",
"imp": [
{
"video": {
"w": 300,
"h": 250
},
"bidfloor": 0.01,
"id": 0,
"impid": "video1"
}
],
"site": {
"page": "https://test.opposingviews.com/i/society/republican-sen-collins-may-change-vote-tax-bill?cb=1234534"
},
"device": {
"ua": "Opera/9.80 (X11; Linux i686; Ubuntu/14.10) Presto/2.12.388 Version/12.16",
"deviceType": 0,
"geo": {
"ip": "127.0.0.1"
}
},
"cur": [
"USD"
],
"user": {
"id": "some-user",
"buyeruid": "some-buyer"
}
}
},
"mockResponse": {
"body": {
"id":"61b87329-8790-47b7-90dd-c53ae7ce1723",
"seatBid":[
{
"bid":[
{
"w":0,
"h":0,
"id": "0",
"impid":"",
"price":0.01,
"adid":"",
"nurl":"https://evt.bfmio.com/getmu?aid=bid:0d32aea6-d199-4803-a188-bd7cf7be1e12:11bc5dd5-7421-4dd8-c926-40fa653bec76:0.01:0.01&v=1&dsp=5afda03c7c2d2bfaee55a3f0,0.01&i_type=pre",
"adm":"",
"adomain":[

],
"iurl":"",
"cid":"",
"crid":"",
"attr":[

],
"ext":{

},
"cat":[

]
}
],
"seat":"",
"group":0,
"ext":{

}
}
]
}
}
}
],

"expectedBids": [
{

"bid":[
{
"id":"61b87329-8790-47b7-90dd-c53ae7ce1723",
"impid":"video1",
"price":9.605201,
"nurl":"https://evt.bfmio.com/getmu?aid=bid:0d32aea6-d199-4803-a188-bd7cf7be1e12:11bc5dd5-7421-4dd8-c926-40fa653bec76:0.01:0.01&v=1&dsp=5afda03c7c2d2bfaee55a3f0,0.01&i_type=pre",
"crid":"0d32aea6-d199-4803-a188-bd7cf7be1e12",
"w":1500,
"h":1280,
"ext":{
"prebid":{
"type":"video"
},
"bidder":{

}
}
}
]
}
]
}
4 changes: 4 additions & 0 deletions adapters/beachfront/beachfronttest/params/race/banner.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"bidfloor": 0.02,
"appId": "3b16770b-17af-4d22-daff-9606bdf2c9c3"
}
4 changes: 4 additions & 0 deletions adapters/beachfront/beachfronttest/params/race/video.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"bidfloor":0.01,
"appId":"11bc5dd5-7421-4dd8-c926-40fa653bec76"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
{
"mockBidRequest": {
"id": "some_test_ad",
"app": {
"domain": "yourmomshouse.com",
"id": "some-mobile-app"
},
"imp": [
{
"bidfloor": 0.02,
"banner": {
"format": [
{
"w": 300,
"h": 250
}
]
},
"ext": {
"bidder": {
"bidfloor": 0.02,
"appId": "3b16770b-17af-4d22-daff-9606bdf2c9c3"
}
}
}
]
},

"httpCalls": [
{
"expectedRequest": {
"uri": "https://display.bfmio.com/prebid_display",
"body": {
"slots": [
{
"slot": "",
"id": "3b16770b-17af-4d22-daff-9606bdf2c9c3",
"bidfloor": 0.02,
"sizes": [
{
"w": 300,
"h": 250
}
]
}
],
"domain": "yourmomshouse.com",
"page": "some-mobile-app",
"referrer": "",
"search": "",
"secure": 0,
"isMobile": 0,
"ip": "",
"deviceModel": "",
"deviceOs": "",
"dnt": 0,
"ua": "",
"adapterName": "BF_PREBID_S2S",
"adapterVersion": "0.1.1",
"user": ""
}
},
"mockResponse": {
"status": 200,
"body": [
{
"crid":"crid_1",
"price":2.942808,
"w":300,
"h":250,
"slot":"div-gpt-ad-1460505748561-0",
"adm":"<div id=\"44861168\"><script>!function(){console.log\"Hello, ad.\";}();<\/script><\/div>"
}
]
}
}
],

"expectedBids": [
{
"Bid": {
"id": "12345678",
"impid": "test-slot",
"price": 2,
"adm": "\u003cdiv id=\"12345678\" style=\"width:300;height:250;background-color:black;color:white;\"\u003e300x250\u003c\\div\u003e",
"crid": "crid_1",
"w": 300,
"h": 250
},
"type": "banner"
}
]
}
Loading

0 comments on commit df05e99

Please sign in to comment.