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

TripleLift Prebid S2S Adapter #954

Merged
merged 77 commits into from
Aug 6, 2019
Merged

TripleLift Prebid S2S Adapter #954

merged 77 commits into from
Aug 6, 2019

Conversation

Kevin-P-Kerr
Copy link
Contributor

The TripleLift prebid S2S adapter.

request to prebid

{ "id": "some-request-id",
   "site": {
    "page": "https://www.123greetings.com/events/fathers_day/happy_fathers_day",
    "publisher": {
      "id": "pub-4627517680249670",
      "ext": {
        "country": "US"
      }
    } 
    },
    "imp": [
      {
        "tagid" : "makersalley_plain",
        "id": "some-impression-id",
        "banner": {
          "format": [
            {
              "w": 300,
              "h": 250
            },
            {
              "w": 300,
              "h": 600
            }
          ]
        },
        "ext": {
          "triplelift" : { "inventoryCode":"makersalley_main"} 
        }
      }
    ],
    "tmax": 500
  }

request from prebid to tl

"{
  "id": "some-request-id",
  "imp": [
    {
      "id": "some-impression-id",
      "banner": {
        "format": [
          {
            "w": 300,
            "h": 250
          },
          {
            "w": 300,
            "h": 600
          }
        ]
      },
      "tagid": "makersalley_plain",
      "ext": {
        "bidder": {
          "inventoryCode": "makersalley_main"
        }
      }
    }
  ],
  "site": {
    "page": "https://www.123greetings.com/events/fathers_day/happy_fathers_day",
    "publisher": {
      "id": "pub-4627517680249670",
      "ext": {
        "country": "US"
      }
    },
    "ext": {
      "amp": 0
    }
  },
  "device": {
    "ua": "curl/7.43.0",
    "ip": "::1"
  },
  "at": 1,
  "tmax": 500
}"

response from prebid

"{
  "id": "some-request-id",
  "seatbid": [
    {
      "bid": [
        {
          "id": "21524535241656531860",
          "impid": "some-impression-id",
          "price": 3.338,
          "adm": "<script>document.createElement('IMG').src=\"https://tlx.3lift.net/s2s/notify?px=1&ts=1560870964&aid=21524535241656531860&ec=260_9_2763332&n=GqsBaHR0cDovL2V4Y2hhbmdlLXRlc3Rlci50cmlwbGVsaWZ0Lm5ldDo4MDc3L25vdGlmeT9pZD0yMTUyNDUzNTI0MTY1NjUzMTg2MCZwcmljZT0ke0FVQ1RJT05fUFJJQ0V9JmFiaWQ9MTU2MzA5ODUzODIwODY3NjYwNyZhaW1waWQ9MTU2MzA5ODUzODIwODY3NjYwNy0xLW51bGwmdHlwZT1CaWQyMlNlYXRz8gKeAQgAEhQyMTUyNDUzNTI0MTY1NjUzMTg2MBgAIAEohAIwCUABSABQAGABaABwmKMFkAEAmAEAqAH%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F8BsAGPKLgBAMABihrIAY8o4AGKGvABAPgB0imAAogbiAKKGpECAAAAAAAA8D%2BZAmZmZmZmZtY%2FoQIAAAAAAAAAAKgCALACBMgCAtgCAPECZmZmZmZm5j%2F4AoQCkAMA%2BAITiAMAkgMEYmNkZQ%3D%3D\";window.tl_auction_response_644731={\"settings\":{\"advertiser_name\":\"TEST ADVERTISER NAME\",\"viewability\":{},\"impression_pixels\":[\"https:\\/\\/ad.doubleclick22222.net\\/ad\\/N4406.282142.ADARAMEDIAINC.\\/B8015471.114430570;sz=1x1;ord=142248259412135895294\"],\"type\":\"image\",\"additional_data\":{\"uid\":\"8947252401186410784\",\"brid\":\"86424\",\"bmid\":\"260\",\"aid\":\"21524535241656531860\",\"ts\":\"1560870964\",\"sid\":\"9\"},\"logo_image_url\":\"http:\\/\\/ep.yimg.com\\/ay\\/entirelypets\\/animal-planet-bat-dog-costume-large-21.jpg\",\"format_id\":1,\"render_options_bm\":0},\"assets\":[{\"image_id\":-1,\"image_url\":\"https:\\/\\/fublag.files.wordpress.com\\/2009\\/04\\/gen66337.png\",\"heading\":\"Renaissance Curacao Seat 3\",\"caption\":\"Discover the hidden gem of the Caribbean\",\"clickthrough_url\":\"http:\\/\\/ag.yieldoptimizer22222.com\\/ag\\/event?type=click&gi=vHH2MVL_SjnGKP62Cib00jK0s2o-vYF4fY9KN-ZMFBizsiWz6ErQ6BZVg_BuhEdSMwuOZFakknl2X_IMznDSZwult3EAcf-2t5bLa92B_a55wqXvj8LVNcUw5THdrYVDkzGglcgDIGNJBHMXOMtXE8627ymU1e3DANpWp1TQam6TMsQptW1GkKjvN34QhFK0&ref_url=123greetings.com\"}]};</script><script src=\"//ib.3lift.net/ttj?inv_code=makersalley_main\" data-auction-response-id=\"644731\"></script>",
          "adomain": [
            "marriott.com"
          ],
          "iurl": "https://fublag.files.wordpress.com/2009/04/gen66337.png",
          "crid": "260_9_2763332",
          "w": 300,
          "h": 250,
          "ext": {
            "prebid": {
              "type": "native"
            },
            "bidder": {
              "triplelift_pb": {
                "format": 1
              }
            }
          }
        }
      ],
      "seat": "triplelift"
    }
  ],
  "ext": {
    "responsetimemillis": {
      "triplelift": 121
    },
    "tmaxrequest": 500
  }
}"

@Kevin-P-Kerr
Copy link
Contributor Author

@hhhjort I've added some tests into the triplelifttest/exemplary directory. can you take a look?

adapters/triplelift/triplelift.go Show resolved Hide resolved
adapters/triplelift/triplelift.go Show resolved Hide resolved
@@ -135,7 +137,7 @@ func NewBidderParamsValidator(schemaDirectory string) (BidderParamValidator, err
for _, fileInfo := range fileInfos {
bidderName := strings.TrimSuffix(fileInfo.Name(), ".json")
if _, isValid := BidderMap[bidderName]; !isValid {
return nil, fmt.Errorf("File %s/%s does not match a valid BidderName.", schemaDirectory, fileInfo.Name())
return nil, fmt.Errorf("File %s/%s does not match a valid BidderName.", schemaDirectory, bidderName)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please change line 140 to

140             return nil, fmt.Errorf("File %s/%s does not match a valid BidderName.", schemaDirectory, fileInfo.Name())

Copy link
Contributor

@guscarreon guscarreon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left a question regarding the banner's width and height properties and: Can we add more test cases so we get a 95% code coverage?

╰─➤  go test -coverprofile=c.out
PASS
coverage: 80.6% of statements
ok      github.com/prebid/prebid-server/adapters/triplelift     0.019s
╰─➤  go tool cover -func=c.out
github.com/prebid/prebid-server/adapters/triplelift/triplelift.go:26:   getBidType              100.0%
github.com/prebid/prebid-server/adapters/triplelift/triplelift.go:34:   processImp              76.9%
github.com/prebid/prebid-server/adapters/triplelift/triplelift.go:58:   MakeRequests            73.9%
github.com/prebid/prebid-server/adapters/triplelift/triplelift.go:96:   getBidCount             100.0%
github.com/prebid/prebid-server/adapters/triplelift/triplelift.go:104:  MakeBids                81.0%
github.com/prebid/prebid-server/adapters/triplelift/triplelift.go:144:  NewTripleliftBidder     100.0%
github.com/prebid/prebid-server/adapters/triplelift/usersync.go:10:     NewTripleliftSyncer     100.0%
total:                                                                  (statements)            80.6%

adapters/triplelift/triplelift.go Show resolved Hide resolved
@Kevin-P-Kerr
Copy link
Contributor Author

github.com/prebid/prebid-server/adapters/triplelift/triplelift.go:58: MakeRequests 73.9%

will do

@Kevin-P-Kerr
Copy link
Contributor Author

Hey, @guscarreon , it seems that most of the lines not covered by the unit tests cover error conditions, like

 if response.StatusCode != http.StatusOK {
        return nil, []error{fmt.Errorf("Unexpected status code: %d. Run with request.debug = 1 for more info", response.StatusCode)}
    }

Even though it's just a few lines, since these functions are all so short, that they aren't covered by the test procedures reduces code coverage pretty significantly.
But if I were to add a broken a request to the test, the test would fail.
Do you have any insight into how to test error conditions?

@guscarreon
Copy link
Contributor

Hey, @guscarreon , it seems that most of the lines not covered by the unit tests cover error conditions, like

 if response.StatusCode != http.StatusOK {
        return nil, []error{fmt.Errorf("Unexpected status code: %d. Run with request.debug = 1 for more info", response.StatusCode)}
    }

Even though it's just a few lines, since these functions are all so short, that they aren't covered by the test procedures reduces code coverage pretty significantly.
But if I were to add a broken a request to the test, the test would fail.
Do you have any insight into how to test error conditions?

Hi @Kevin-P-Kerr. I believe the EqualError() function is useful for this purpose. Some test cases throughout the code base use it extensively:

./config/config_test.go:        assert.EqualError(t, errs[0], message)
./openrtb_ext/device_test.go:   assert.EqualError(t, json.Unmarshal([]byte(`{"prebid":{"interstitial":{"minwidthperc":85,"minheightperc":"75"}}}`), &s), "request.device.ext.prebid.interstitial.minheightperc must be a number between 0 and 100")
./openrtb_ext/site_test.go:     assert.EqualError(t, json.Unmarshal([]byte(`{"amp":-1}`), &s), "request.site.ext.amp must be either 1, 0, or undefined")
./adapters/info_test.go:        assert.EqualError(t, errs[0], "this bidder does not support app requests")

@Kevin-P-Kerr
Copy link
Contributor Author

@guscarreon cumulative test coverage is now 95 percent.

[kkerr_local triplelift]$ go test -coverprofile=c.out
PASS
coverage: 95.5% of statements
ok  	github.com/prebid/prebid-server/adapters/triplelift	0.017s
[kkerr_local triplelift]$ go tool cover -func=c.out
github.com/prebid/prebid-server/adapters/triplelift/triplelift.go:26:	getBidType		100.0%
github.com/prebid/prebid-server/adapters/triplelift/triplelift.go:34:	processImp		100.0%
github.com/prebid/prebid-server/adapters/triplelift/triplelift.go:58:	MakeRequests		91.3%
github.com/prebid/prebid-server/adapters/triplelift/triplelift.go:96:	getBidCount		100.0%
github.com/prebid/prebid-server/adapters/triplelift/triplelift.go:104:	MakeBids		95.2%
github.com/prebid/prebid-server/adapters/triplelift/triplelift.go:144:	NewTripleliftBidder	100.0%
github.com/prebid/prebid-server/adapters/triplelift/usersync.go:10:	NewTripleliftSyncer	100.0%
total:									(statements)		95.5%

@guscarreon
Copy link
Contributor

@guscarreon cumulative test coverage is now 95 percent.

[kkerr_local triplelift]$ go test -coverprofile=c.out
PASS
coverage: 95.5% of statements
ok  	github.com/prebid/prebid-server/adapters/triplelift	0.017s
[kkerr_local triplelift]$ go tool cover -func=c.out
github.com/prebid/prebid-server/adapters/triplelift/triplelift.go:26:	getBidType		100.0%
github.com/prebid/prebid-server/adapters/triplelift/triplelift.go:34:	processImp		100.0%
github.com/prebid/prebid-server/adapters/triplelift/triplelift.go:58:	MakeRequests		91.3%
github.com/prebid/prebid-server/adapters/triplelift/triplelift.go:96:	getBidCount		100.0%
github.com/prebid/prebid-server/adapters/triplelift/triplelift.go:104:	MakeBids		95.2%
github.com/prebid/prebid-server/adapters/triplelift/triplelift.go:144:	NewTripleliftBidder	100.0%
github.com/prebid/prebid-server/adapters/triplelift/usersync.go:10:	NewTripleliftSyncer	100.0%
total:									(statements)		95.5%

Kevin, some Travis errors seem to have popped up with this last update, can we correct them?

@Kevin-P-Kerr
Copy link
Contributor Author

@guscarreon cumulative test coverage is now 95 percent.

[kkerr_local triplelift]$ go test -coverprofile=c.out
PASS
coverage: 95.5% of statements
ok  	github.com/prebid/prebid-server/adapters/triplelift	0.017s
[kkerr_local triplelift]$ go tool cover -func=c.out
github.com/prebid/prebid-server/adapters/triplelift/triplelift.go:26:	getBidType		100.0%
github.com/prebid/prebid-server/adapters/triplelift/triplelift.go:34:	processImp		100.0%
github.com/prebid/prebid-server/adapters/triplelift/triplelift.go:58:	MakeRequests		91.3%
github.com/prebid/prebid-server/adapters/triplelift/triplelift.go:96:	getBidCount		100.0%
github.com/prebid/prebid-server/adapters/triplelift/triplelift.go:104:	MakeBids		95.2%
github.com/prebid/prebid-server/adapters/triplelift/triplelift.go:144:	NewTripleliftBidder	100.0%
github.com/prebid/prebid-server/adapters/triplelift/usersync.go:10:	NewTripleliftSyncer	100.0%
total:									(statements)		95.5%

Kevin, some Travis errors seem to have popped up with this last update, can we correct them?

hey @guscarreon I think github might have just froze up or something.

 Cloning into '/home/travis/gopath/pkg/dep/sources/https---github.com-stretchr-objx'...
485fatal: unable to access 'https://github.com/stretchr/objx/': Failed to connect to github.com port 443: Connection timed out
486: command failed: [git clone --recursive -v --progress https://github.com/stretchr/objx /home/travis/gopath/pkg/dep/sources/https---github.com-stretchr-objx]: exit status 128
487The command "$GOPATH/bin/dep ensure" failed and exited with 1 during .

seems like it couldn't access this strechr-objx dependency. Anyway we can retrigger?

Copy link
Contributor

@guscarreon guscarreon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Kevin-P-Kerr seems like Github was having problems because for some reason the Travis build seems to have built correctly this time around. Thanks for your patience, your adapter looks awesome.

@guscarreon guscarreon assigned hhhjort and unassigned guscarreon Aug 5, 2019
@Kevin-P-Kerr
Copy link
Contributor Author

@Kevin-P-Kerr seems like Github was having problems because for some reason the Travis build seems to have built correctly this time around. Thanks for your patience, your adapter looks awesome.

Thanks! What are the next steps in this process?

}
imp.TagID = tlext.InvCode
// floor is optional
if tlext.Floor == nil {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could just have if tlext.Floor != nil { imp.BidFloor = *tlext.Floor } as you return nil in either case

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah good point, that's a bit more parsimonious. but it seems this is already merged. if I have to patch later I'll take this idea and apply it though.

Copy link
Collaborator

@hhhjort hhhjort left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, one minor thing, but shouldn't block approval.

@guscarreon guscarreon merged commit 1de99fa into prebid:master Aug 6, 2019
@hhhjort
Copy link
Collaborator

hhhjort commented Sep 9, 2019

@Kevin-P-Kerr : Just noticed that the user sync URL makes no reference to the PBS URL ... there is no way for your usersync endpoint to send the user ID back to the particular PBS installation.

@Kevin-P-Kerr
Copy link
Contributor Author

@hhhjort I'm not totally following. Can you elaborate? What steps should I take to rectify this?

@hhhjort
Copy link
Collaborator

hhhjort commented Sep 11, 2019

Look at https://github.com/prebid/prebid-server/blob/master/docs/developers/cookie-syncs.md

Basically, your cookie sync endpoint needs to redirect back to the supplied URL and include the user's Triplelift ID so that PBS can populate user.id in the request with your ID. This will allow you to do user targeting. You cannot rely on your own cookie, as the bid request will come from the PBS machine, and it does not have access to the user's triplelift cookie.

@Kevin-P-Kerr
Copy link
Contributor Author

Look at https://github.com/prebid/prebid-server/blob/master/docs/developers/cookie-syncs.md

Basically, your cookie sync endpoint needs to redirect back to the supplied URL and include the user's Triplelift ID so that PBS can populate user.id in the request with your ID. This will allow you to do user targeting. You cannot rely on your own cookie, as the bid request will come from the PBS machine, and it does not have access to the user's triplelift cookie.

Ok, thanks for the clarification. We'll schedule some time to get a fix in.

katsuo5 pushed a commit to flux-dev-team/prebid-server-1 that referenced this pull request Dec 1, 2020
* ignore swp files

* start small

* start really small

* add a user sync

* justify

* triplelift adapter

* add our endpoint

* fix syntax

* config stuff

* compiler fixes

* more config

* add params

* making progress

* make our ext more exty

* start making responses

* more logic

* fix compilation errors

* can we just nil this out?

* augment our json

* radically simplify our json

* fix errs

* infer the bid type

* fix syntax

* fix comilation errors

* rename

* fix compilation error

* config stuff

* simplify params

* more config stuff

* fixes

* revert this

* fix up the extension

* getting closer

* add a test

* update config

* update bidder params

* add the floor here, too

* add a usersync test

* validation, ws, and a test

* update tests

* fix test

* update email

* why not

* change email

* preprocess requests

* do some parsing

* take care of some errors

* floor is optional

* ws

* remove native

* everything is either banner or video

* this should be a float

* floor to floor

* fix compilation errors

* add some tests

* more tests

* more tests

* simplify

* more progress

* format

* ws

* rm

* don't need this

* fix test

* fix test

* don't ignore swap

* change line back

* report an error if there are no valid impressions for triplelift

* check for either a Banner or Video object on the impression

* more tests

* mv

* more tests
katsuo5 pushed a commit to flux-dev-team/prebid-server-1 that referenced this pull request Dec 2, 2020
* ignore swp files

* start small

* start really small

* add a user sync

* justify

* triplelift adapter

* add our endpoint

* fix syntax

* config stuff

* compiler fixes

* more config

* add params

* making progress

* make our ext more exty

* start making responses

* more logic

* fix compilation errors

* can we just nil this out?

* augment our json

* radically simplify our json

* fix errs

* infer the bid type

* fix syntax

* fix comilation errors

* rename

* fix compilation error

* config stuff

* simplify params

* more config stuff

* fixes

* revert this

* fix up the extension

* getting closer

* add a test

* update config

* update bidder params

* add the floor here, too

* add a usersync test

* validation, ws, and a test

* update tests

* fix test

* update email

* why not

* change email

* preprocess requests

* do some parsing

* take care of some errors

* floor is optional

* ws

* remove native

* everything is either banner or video

* this should be a float

* floor to floor

* fix compilation errors

* add some tests

* more tests

* more tests

* simplify

* more progress

* format

* ws

* rm

* don't need this

* fix test

* fix test

* don't ignore swap

* change line back

* report an error if there are no valid impressions for triplelift

* check for either a Banner or Video object on the impression

* more tests

* mv

* more tests
katsuo5 pushed a commit to flux-dev-team/prebid-server-1 that referenced this pull request Dec 4, 2020
* ignore swp files

* start small

* start really small

* add a user sync

* justify

* triplelift adapter

* add our endpoint

* fix syntax

* config stuff

* compiler fixes

* more config

* add params

* making progress

* make our ext more exty

* start making responses

* more logic

* fix compilation errors

* can we just nil this out?

* augment our json

* radically simplify our json

* fix errs

* infer the bid type

* fix syntax

* fix comilation errors

* rename

* fix compilation error

* config stuff

* simplify params

* more config stuff

* fixes

* revert this

* fix up the extension

* getting closer

* add a test

* update config

* update bidder params

* add the floor here, too

* add a usersync test

* validation, ws, and a test

* update tests

* fix test

* update email

* why not

* change email

* preprocess requests

* do some parsing

* take care of some errors

* floor is optional

* ws

* remove native

* everything is either banner or video

* this should be a float

* floor to floor

* fix compilation errors

* add some tests

* more tests

* more tests

* simplify

* more progress

* format

* ws

* rm

* don't need this

* fix test

* fix test

* don't ignore swap

* change line back

* report an error if there are no valid impressions for triplelift

* check for either a Banner or Video object on the impression

* more tests

* mv

* more tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants