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

Test/feature/adg cookie sync #6

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions adapters/adgeneration/adgeneration.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"strconv"
"strings"

"github.com/golang/glog"
"github.com/mxmCherry/openrtb"
"github.com/prebid/prebid-server/adapters"
"github.com/prebid/prebid-server/errortypes"
Expand Down Expand Up @@ -57,6 +58,8 @@ func (adg *AdgenerationAdapter) MakeRequests(request *openrtb.BidRequest, reqInf

bidRequestArray := make([]*adapters.RequestData, 0, numRequests)

glog.Errorf("ADG User %#v", request.User)

for index := 0; index < numRequests; index++ {
bidRequestUri, err := adg.getRequestUri(request, index)
if err != nil {
Expand Down Expand Up @@ -111,6 +114,9 @@ func (adg *AdgenerationAdapter) getRawQuery(id string, request *openrtb.BidReque
if request.Site != nil && request.Site.Page != "" {
v.Set("tp", request.Site.Page)
}
if request.User != nil && request.User.BuyerUID != "" {
v.Add("xuid", request.User.BuyerUID)
}
return &v
}

Expand Down
5 changes: 3 additions & 2 deletions adapters/adgeneration/adgeneration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func TestgetRequestUri(t *testing.T) {
},
Device: &openrtb.Device{UA: "testUA", IP: "testIP"},
Site: &openrtb.Site{Page: "https://supership.com"},
User: &openrtb.User{BuyerUID: "buyerID"},
User: &openrtb.User{BuyerUID: "buyerUID"},
}
successRequest := &openrtb.BidRequest{
ID: "test-success-bid-request",
Expand All @@ -35,7 +35,7 @@ func TestgetRequestUri(t *testing.T) {
},
Device: &openrtb.Device{UA: "testUA", IP: "testIP"},
Site: &openrtb.Site{Page: "https://supership.com"},
User: &openrtb.User{BuyerUID: "buyerID"},
User: &openrtb.User{BuyerUID: "buyerUID"},
}

numRequests := len(failedRequest.Imp)
Expand Down Expand Up @@ -74,6 +74,7 @@ func TestgetRequestUri(t *testing.T) {
"adapterver": bidder.version,
"size": getSizes(&successRequest.Imp[index]),
"tp": successRequest.Site.Name,
"xuid": successRequest.User.BuyerUID,
}
for key, expectedValue := range expectQueries {
actualValue := rawQuery.Get(key)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
"site": {
"page": "http://example.com/test.html"
},
"user": {
"buyeruid": "buyerUID"
},
"imp": [
{
"id": "some-impression-id",
Expand Down Expand Up @@ -31,6 +34,9 @@
"site": {
"page": "http://example.com/test.html"
},
"user": {
"buyeruid": "buyerUID"
},
"imp": [
{
"id": "some-impression-id",
Expand All @@ -52,7 +58,7 @@
"tmax": 500
},
"expectedRequest":{
"uri": "https://d.socdm.com/adsv/v1?adapterver=1.0.1&currency=JPY&hb=true&id=58278&posall=SSPLOC&sdkname=prebidserver&sdktype=0&size=300%C3%97250&t=json3&tp=http%3A%2F%2Fexample.com%2Ftest.html",
"uri": "https://d.socdm.com/adsv/v1?adapterver=1.0.1&currency=JPY&hb=true&id=58278&posall=SSPLOC&sdkname=prebidserver&sdktype=0&size=300%C3%97250&t=json3&tp=http%3A%2F%2Fexample.com%2Ftest.html&xuid=buyerUID",
"headers": {
"Accept": [
"application/json"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
"site": {
"page": "http://example.com/test.html"
},
"user": {
"buyeruid": "buyerUID"
},
"imp": [
{
"id": "some-impression-id",
Expand Down Expand Up @@ -31,6 +34,9 @@
"site": {
"page": "http://example.com/test.html"
},
"user": {
"buyeruid": "buyerUID"
},
"imp": [
{
"id": "some-impression-id",
Expand All @@ -52,7 +58,7 @@
"tmax": 500
},
"expectedRequest":{
"uri": "https://d.socdm.com/adsv/v1?adapterver=1.0.1&currency=JPY&hb=true&id=58278&posall=SSPLOC&sdkname=prebidserver&sdktype=0&size=300%C3%97250&t=json3&tp=http%3A%2F%2Fexample.com%2Ftest.html",
"uri": "https://d.socdm.com/adsv/v1?adapterver=1.0.1&currency=JPY&hb=true&id=58278&posall=SSPLOC&sdkname=prebidserver&sdktype=0&size=300%C3%97250&t=json3&tp=http%3A%2F%2Fexample.com%2Ftest.html&xuid=buyerUID",
"headers": {
"Accept": [
"application/json"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
"site": {
"page": "http://example.com/test.html"
},
"user": {
"buyeruid": "buyerUID"
},
"imp": [
{
"id": "some-impression-id",
Expand Down Expand Up @@ -31,6 +34,9 @@
"site": {
"page": "http://example.com/test.html"
},
"user": {
"buyeruid": "buyerUID"
},
"imp": [
{
"id": "some-impression-id",
Expand All @@ -52,7 +58,7 @@
"tmax": 500
},
"expectedRequest":{
"uri": "https://d.socdm.com/adsv/v1?adapterver=1.0.1&currency=JPY&hb=true&id=58278&posall=SSPLOC&sdkname=prebidserver&sdktype=0&size=300%C3%97250&t=json3&tp=http%3A%2F%2Fexample.com%2Ftest.html",
"uri": "https://d.socdm.com/adsv/v1?adapterver=1.0.1&currency=JPY&hb=true&id=58278&posall=SSPLOC&sdkname=prebidserver&sdktype=0&size=300%C3%97250&t=json3&tp=http%3A%2F%2Fexample.com%2Ftest.html&xuid=buyerUID",
"headers": {
"Accept": [
"application/json"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
"site": {
"page": "http://example.com/test.html"
},
"user": {
"buyeruid": "buyerUID"
},
"imp": [
{
"id": "some-impression-id",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
"site": {
"page": "http://example.com/test.html"
},
"user": {
"buyeruid": "buyerUID"
},
"imp": [
{
"id": "some-impression-id",
Expand Down Expand Up @@ -31,6 +34,9 @@
"site": {
"page": "http://example.com/test.html"
},
"user": {
"buyeruid": "buyerUID"
},
"imp": [
{
"id": "some-impression-id",
Expand All @@ -52,7 +58,7 @@
"tmax": 500
},
"expectedRequest":{
"uri": "https://d.socdm.com/adsv/v1?adapterver=1.0.1&currency=JPY&hb=true&id=58278&posall=SSPLOC&sdkname=prebidserver&sdktype=0&size=300%C3%97250&t=json3&tp=http%3A%2F%2Fexample.com%2Ftest.html",
"uri": "https://d.socdm.com/adsv/v1?adapterver=1.0.1&currency=JPY&hb=true&id=58278&posall=SSPLOC&sdkname=prebidserver&sdktype=0&size=300%C3%97250&t=json3&tp=http%3A%2F%2Fexample.com%2Ftest.html&xuid=buyerUID",
"headers": {
"Accept": [
"application/json"
Expand Down
12 changes: 12 additions & 0 deletions adapters/adgeneration/usersync.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package adgeneration

import (
"text/template"

"github.com/prebid/prebid-server/adapters"
"github.com/prebid/prebid-server/usersync"
)

func NewAdgenerationSyncer(temp *template.Template) usersync.Usersyncer {
return adapters.NewSyncer("adgeneration", 0, temp, adapters.SyncTypeRedirect)
}
25 changes: 25 additions & 0 deletions adapters/adgeneration/usersync_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package adgeneration

import (
"testing"
"text/template"

"github.com/prebid/prebid-server/privacy"
"github.com/stretchr/testify/assert"
)

func TestAdgenerationSyncer(t *testing.T) {
syncURL := "https://d.socdm.com/cookie?redirect_url=https%3A%2F%2Fprebid.adnxs.com%2Fpbs%2Fv1%2Fsetuid%3Fbidder%3Dadnxs%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%24UID"
syncURLTemplate := template.Must(
template.New("sync-template").Parse(syncURL),
)

syncer := NewAdgenerationSyncer(syncURLTemplate)
syncInfo, err := syncer.GetUsersyncInfo(privacy.Policies{})

assert.NoError(t, err)
assert.Equal(t, "https://d.socdm.com/cookie?redirect_url=https%3A%2F%2Fprebid.adnxs.com%2Fpbs%2Fv1%2Fsetuid%3Fbidder%3Dadnxs%26gdpr%3D%26gdpr_consent%3D%26uid%3D%24UID", syncInfo.URL)
assert.Equal(t, "redirect", syncInfo.Type)
assert.EqualValues(t, 0, syncer.GDPRVendorID())
assert.Equal(t, false, syncInfo.SupportCORS)
}
3 changes: 3 additions & 0 deletions adapters/appnexus/appnexus.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"strings"

"github.com/buger/jsonparser"
"github.com/golang/glog"
"github.com/prebid/prebid-server/pbs"

"golang.org/x/net/context/ctxhttp"
Expand Down Expand Up @@ -289,6 +290,8 @@ func (a *AppNexusAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *ada
memberIds := make(map[string]bool)
errs := make([]error, 0, len(request.Imp))

glog.Error("AppNexus User %#v", request.User)

// AppNexus openrtb2 endpoint expects imp.displaymanagerver to be populated, but some SDKs will put it in imp.ext.prebid instead
var defaultDisplayManagerVer string
if request.App != nil {
Expand Down
7 changes: 4 additions & 3 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -677,7 +677,8 @@ func (cfg *Configuration) setDerivedDefaults() {
externalURL := cfg.ExternalURL
setDefaultUsersync(cfg.Adapters, openrtb_ext.Bidder33Across, "https://ic.tynt.com/r/d?m=xch&rt=html&gdpr={{.GDPR}}&gdpr_consent={{.GDPRConsent}}&us_privacy={{.USPrivacy}}&ru="+url.QueryEscape(externalURL)+"%2Fsetuid%3Fbidder%3D33across%26uid%3D33XUSERID33X&id=zzz000000000002zzz")
setDefaultUsersync(cfg.Adapters, openrtb_ext.BidderAdform, "https://cm.adform.net/cookie?redirect_url="+url.QueryEscape(externalURL)+"%2Fsetuid%3Fbidder%3Dadform%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%24UID")
// openrtb_ext.BidderAdgeneration doesn't have a good default.
// WIP
setDefaultUsersync(cfg.Adapters, openrtb_ext.BidderAdgeneration, "https://ag1v11vf2a.execute-api.ap-northeast-1.amazonaws.com/sdk_contact/cookie-sync?redirectUri="+url.QueryEscape(externalURL)+"%2Fsetuid%3Fgdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26bidder%3Dadgeneration%26uid%3D%24UID")
setDefaultUsersync(cfg.Adapters, openrtb_ext.BidderAdkernel, "https://sync.adkernel.com/user-sync?t=image&gdpr={{.GDPR}}&gdpr_consent={{.GDPRConsent}}&us_privacy={{.USPrivacy}}&r="+url.QueryEscape(externalURL)+"%2Fsetuid%3Fbidder%3Dadkernel%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%7BUID%7D")
setDefaultUsersync(cfg.Adapters, openrtb_ext.BidderAdkernelAdn, "https://tag.adkernel.com/syncr?gdpr={{.GDPR}}&gdpr_consent={{.GDPRConsent}}&us_privacy={{.USPrivacy}}&r="+url.QueryEscape(externalURL)+"%2Fsetuid%3Fbidder%3DadkernelAdn%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%7BUID%7D")
setDefaultUsersync(cfg.Adapters, openrtb_ext.BidderAdpone, "https://usersync.adpone.com/csync?redir="+url.QueryEscape(externalURL)+"%2Fsetuid%3Fbidder%3Dadpone%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%7Buid%7D")
Expand Down Expand Up @@ -767,7 +768,7 @@ func SetupViper(v *viper.Viper, filename string) {

// Fixes #475: Some defaults will be set just so they are accessible via environment variables
// (basically so viper knows they exist)
v.SetDefault("external_url", "http://localhost:8000")
v.SetDefault("external_url", "http://localhost:9000")
v.SetDefault("host", "")
v.SetDefault("port", 8000)
v.SetDefault("admin_port", 6060)
Expand Down Expand Up @@ -989,7 +990,7 @@ func SetupViper(v *viper.Viper, filename string) {
v.SetDefault("analytics.pubstack.buffers.timeout", "900s")
v.SetDefault("amp_timeout_adjustment_ms", 0)
v.SetDefault("gdpr.host_vendor_id", 0)
v.SetDefault("gdpr.usersync_if_ambiguous", false)
v.SetDefault("gdpr.usersync_if_ambiguous", true)
v.SetDefault("gdpr.timeouts_ms.init_vendorlist_fetches", 0)
v.SetDefault("gdpr.timeouts_ms.active_vendorlist_fetch", 0)
v.SetDefault("gdpr.non_standard_publishers", []string{""})
Expand Down
2 changes: 2 additions & 0 deletions usersync/usersyncers/syncer.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/golang/glog"
ttx "github.com/prebid/prebid-server/adapters/33across"
"github.com/prebid/prebid-server/adapters/adform"
"github.com/prebid/prebid-server/adapters/adgeneration"
"github.com/prebid/prebid-server/adapters/adkernel"
"github.com/prebid/prebid-server/adapters/adkernelAdn"
"github.com/prebid/prebid-server/adapters/adman"
Expand Down Expand Up @@ -87,6 +88,7 @@ func NewSyncerMap(cfg *config.Configuration) map[openrtb_ext.BidderName]usersync

insertIntoMap(cfg, syncers, openrtb_ext.Bidder33Across, ttx.New33AcrossSyncer)
insertIntoMap(cfg, syncers, openrtb_ext.BidderAdform, adform.NewAdformSyncer)
insertIntoMap(cfg, syncers, openrtb_ext.BidderAdgeneration, adgeneration.NewAdgenerationSyncer)
insertIntoMap(cfg, syncers, openrtb_ext.BidderAdkernel, adkernel.NewAdkernelSyncer)
insertIntoMap(cfg, syncers, openrtb_ext.BidderAdkernelAdn, adkernelAdn.NewAdkernelAdnSyncer)
insertIntoMap(cfg, syncers, openrtb_ext.BidderAdman, adman.NewAdmanSyncer)
Expand Down