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

WIP: feat: add ADGeneration Cookie sync #4

Open
wants to merge 2 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
3 changes: 3 additions & 0 deletions adapters/adgeneration/adgeneration.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,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)
NaoOishi marked this conversation as resolved.
Show resolved Hide resolved
}
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: 2 additions & 1 deletion 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://d.socdm.com/cookie?redirect_url="+url.QueryEscape(externalURL)+"%2Fsetuid%3Fgdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%24UID")
NaoOishi marked this conversation as resolved.
Show resolved Hide resolved
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
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