Skip to content

Commit

Permalink
New Adapter: TrustX (prebid#1726)
Browse files Browse the repository at this point in the history
  • Loading branch information
TheMediaGrid authored and Dan Barnett committed May 11, 2021
1 parent d96f2b2 commit 957884d
Show file tree
Hide file tree
Showing 9 changed files with 74 additions and 0 deletions.
12 changes: 12 additions & 0 deletions adapters/trustx/usersync.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package trustx

import (
"text/template"

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

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

import (
"testing"
"text/template"

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

func TestTrustXSyncer(t *testing.T) {
syncURL := "//not_localhost/synclocalhost%2Fsetuid%3Fbidder%3Dgrid%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%24UID"
syncURLTemplate := template.Must(
template.New("sync-template").Parse(syncURL),
)

syncer := NewTrustXSyncer(syncURLTemplate)
syncInfo, err := syncer.GetUsersyncInfo(privacy.Policies{
GDPR: gdpr.Policy{
Signal: "0",
},
})

assert.NoError(t, err)
assert.Equal(t, "//not_localhost/synclocalhost%2Fsetuid%3Fbidder%3Dgrid%26gdpr%3D0%26gdpr_consent%3D%26uid%3D%24UID", syncInfo.URL)
assert.Equal(t, "redirect", syncInfo.Type)
assert.EqualValues(t, 686, syncer.GDPRVendorID())
assert.Equal(t, false, syncInfo.SupportCORS)
}
2 changes: 2 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -636,6 +636,7 @@ func (cfg *Configuration) setDerivedDefaults() {
setDefaultUsersync(cfg.Adapters, openrtb_ext.BidderTelaria, "https://pbs.publishers.tremorhub.com/pubsync?gdpr={{.GDPR}}&gdpr_consent={{.GDPRConsent}}&redir="+url.QueryEscape(externalURL)+"%2Fsetuid%3Fbidder%3Dtelaria%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%5Btvid%5D")
setDefaultUsersync(cfg.Adapters, openrtb_ext.BidderTriplelift, "https://eb2.3lift.com/getuid?gdpr={{.GDPR}}&cmp_cs={{.GDPRConsent}}&us_privacy={{.USPrivacy}}&redir="+url.QueryEscape(externalURL)+"%2Fsetuid%3Fbidder%3Dtriplelift%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%24UID")
setDefaultUsersync(cfg.Adapters, openrtb_ext.BidderTripleliftNative, "https://eb2.3lift.com/getuid?gdpr={{.GDPR}}&cmp_cs={{.GDPRConsent}}&us_privacy={{.USPrivacy}}&redir="+url.QueryEscape(externalURL)+"%2Fsetuid%3Fbidder%3Dtriplelift_native%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%24UID")
setDefaultUsersync(cfg.Adapters, openrtb_ext.BidderTrustX, "https://x.bidswitch.net/check_uuid/"+url.QueryEscape(externalURL)+"%2Fsetuid%3Fbidder%3Dtrustx%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%24%7BBSW_UUID%7D?gdpr={{.GDPR}}&gdpr_consent={{.GDPRConsent}}&us_privacy={{.USPrivacy}}")
setDefaultUsersync(cfg.Adapters, openrtb_ext.BidderUcfunnel, "https://sync.aralego.com/idsync?gdpr={{.GDPR}}&gdpr_consent={{.GDPRConsent}}&usprivacy={{.USPrivacy}}&redirect="+url.QueryEscape(externalURL)+"%2Fsetuid%3Fbidder%3Ducfunnel%26uid%3DSspCookieUserId")
setDefaultUsersync(cfg.Adapters, openrtb_ext.BidderUnruly, "https://usermatch.targeting.unrulymedia.com/pbsync?gdpr={{.GDPR}}&consent={{.GDPRConsent}}&us_privacy={{.USPrivacy}}&rurl="+url.QueryEscape(externalURL)+"%2Fsetuid%3Fbidder%3Dunruly%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%24UID")
setDefaultUsersync(cfg.Adapters, openrtb_ext.BidderValueImpression, "https://rtb.valueimpression.com/usersync?gdpr={{.GDPR}}&consent={{.GDPRConsent}}&us_privacy={{.USPrivacy}}&redirect="+url.QueryEscape(externalURL)+"%2Fsetuid%3Fbidder%3Dvalueimpression%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%24UID")
Expand Down Expand Up @@ -892,6 +893,7 @@ func SetupViper(v *viper.Viper, filename string) {
v.SetDefault("adapters.triplelift_native.disabled", true)
v.SetDefault("adapters.triplelift_native.extra_info", "{\"publisher_whitelist\":[]}")
v.SetDefault("adapters.triplelift.endpoint", "https://tlx.3lift.com/s2s/auction?sra=1&supplier_id=20")
v.SetDefault("adapters.trustx.endpoint", "https://grid.bidswitch.net/sp_bid?sp=trustx")
v.SetDefault("adapters.ucfunnel.endpoint", "https://pbs.aralego.com/prebid")
v.SetDefault("adapters.unruly.endpoint", "http://targeting.unrulymedia.com/openrtb/2.2")
v.SetDefault("adapters.valueimpression.endpoint", "https://rtb.valueimpression.com/endpoint")
Expand Down
1 change: 1 addition & 0 deletions exchange/adapter_builders.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ func newAdapterBuilders() map[openrtb_ext.BidderName]adapters.Builder {
openrtb_ext.BidderTelaria: telaria.Builder,
openrtb_ext.BidderTriplelift: triplelift.Builder,
openrtb_ext.BidderTripleliftNative: triplelift_native.Builder,
openrtb_ext.BidderTrustX: grid.Builder,
openrtb_ext.BidderUcfunnel: ucfunnel.Builder,
openrtb_ext.BidderUnruly: unruly.Builder,
openrtb_ext.BidderValueImpression: valueimpression.Builder,
Expand Down
2 changes: 2 additions & 0 deletions openrtb_ext/bidders.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ const (
BidderTelaria BidderName = "telaria"
BidderTriplelift BidderName = "triplelift"
BidderTripleliftNative BidderName = "triplelift_native"
BidderTrustX BidderName = "trustx"
BidderUcfunnel BidderName = "ucfunnel"
BidderUnruly BidderName = "unruly"
BidderValueImpression BidderName = "valueimpression"
Expand Down Expand Up @@ -267,6 +268,7 @@ func CoreBidderNames() []BidderName {
BidderTelaria,
BidderTriplelift,
BidderTripleliftNative,
BidderTrustX,
BidderUcfunnel,
BidderUnruly,
BidderValueImpression,
Expand Down
11 changes: 11 additions & 0 deletions static/bidder-info/trustx.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
maintainer:
email: "grid-tech@themediagrid.com"
capabilities:
app:
mediaTypes:
- banner
- video
site:
mediaTypes:
- banner
- video
13 changes: 13 additions & 0 deletions static/bidder-params/trustx.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "TrustX Adapter Params",
"description": "A schema which validates params accepted by TrustX adapter",
"type": "object",
"properties": {
"uid": {
"type": "integer",
"description": "An ID which identifies this placement of the impression"
}
},
"required": []
}
2 changes: 2 additions & 0 deletions usersync/usersyncers/syncer.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ import (
"github.com/prebid/prebid-server/adapters/telaria"
"github.com/prebid/prebid-server/adapters/triplelift"
"github.com/prebid/prebid-server/adapters/triplelift_native"
"github.com/prebid/prebid-server/adapters/trustx"
"github.com/prebid/prebid-server/adapters/ucfunnel"
"github.com/prebid/prebid-server/adapters/unruly"
"github.com/prebid/prebid-server/adapters/valueimpression"
Expand Down Expand Up @@ -165,6 +166,7 @@ func NewSyncerMap(cfg *config.Configuration) map[openrtb_ext.BidderName]usersync
insertIntoMap(cfg, syncers, openrtb_ext.BidderTelaria, telaria.NewTelariaSyncer)
insertIntoMap(cfg, syncers, openrtb_ext.BidderTriplelift, triplelift.NewTripleliftSyncer)
insertIntoMap(cfg, syncers, openrtb_ext.BidderTripleliftNative, triplelift_native.NewTripleliftSyncer)
insertIntoMap(cfg, syncers, openrtb_ext.BidderTrustX, trustx.NewTrustXSyncer)
insertIntoMap(cfg, syncers, openrtb_ext.BidderUcfunnel, ucfunnel.NewUcfunnelSyncer)
insertIntoMap(cfg, syncers, openrtb_ext.BidderUnruly, unruly.NewUnrulySyncer)
insertIntoMap(cfg, syncers, openrtb_ext.BidderValueImpression, valueimpression.NewValueImpressionSyncer)
Expand Down
1 change: 1 addition & 0 deletions usersync/usersyncers/syncer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ func TestNewSyncerMap(t *testing.T) {
string(openrtb_ext.BidderTelaria): syncConfig,
string(openrtb_ext.BidderTriplelift): syncConfig,
string(openrtb_ext.BidderTripleliftNative): syncConfig,
string(openrtb_ext.BidderTrustX): syncConfig,
string(openrtb_ext.BidderUcfunnel): syncConfig,
string(openrtb_ext.BidderUnruly): syncConfig,
string(openrtb_ext.BidderValueImpression): syncConfig,
Expand Down

0 comments on commit 957884d

Please sign in to comment.