This repository has been archived by the owner on Dec 22, 2022. It is now read-only.
forked from prebid/prebid-server
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Added a config property for base usersync url. Updated the syncers to use it. * Added tests for the new config. * Made sync URLs fully configurable. * Updated the gumgum syncer, and fixed some broken tests. * Handled the errors. * Cleaned up a test. * Polished the grid syncer test a bit. * Fixed a bug related to bidder ID string cases.
- Loading branch information
Showing
53 changed files
with
433 additions
and
538 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,12 @@ | ||
package ttx | ||
|
||
import ( | ||
"net/url" | ||
"strings" | ||
"text/template" | ||
|
||
"github.com/prebid/prebid-server/adapters" | ||
"github.com/prebid/prebid-server/config" | ||
"github.com/prebid/prebid-server/openrtb_ext" | ||
"github.com/prebid/prebid-server/usersync" | ||
) | ||
|
||
func New33AcrossSyncer(cfg *config.Configuration) usersync.Usersyncer { | ||
externalURL := strings.TrimRight(cfg.ExternalURL, "/") | ||
adapterConfig := cfg.Adapters[string(openrtb_ext.Bidder33Across)] | ||
redirectURL := url.QueryEscape(externalURL) + "%2Fsetuid%3Fbidder%3Dttx%26uid%3D33XUSERID33X" | ||
syncerURL := adapterConfig.UserSyncURL + "/?ri=" + adapterConfig.PartnerId + "&ru=" + redirectURL | ||
|
||
if adapterConfig.PartnerId == "" { | ||
syncerURL = "/" | ||
} | ||
|
||
return adapters.NewSyncer("ttx", 58, adapters.ResolveMacros(syncerURL), adapters.SyncTypeRedirect) | ||
func New33AcrossSyncer(temp *template.Template) usersync.Usersyncer { | ||
return adapters.NewSyncer("ttx", 58, temp, adapters.SyncTypeRedirect) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,12 @@ | ||
package adform | ||
|
||
import ( | ||
"net/url" | ||
"text/template" | ||
|
||
"github.com/prebid/prebid-server/adapters" | ||
"github.com/prebid/prebid-server/config" | ||
"github.com/prebid/prebid-server/openrtb_ext" | ||
"github.com/prebid/prebid-server/usersync" | ||
) | ||
|
||
func NewAdformSyncer(cfg *config.Configuration) usersync.Usersyncer { | ||
usersyncURL := cfg.Adapters[string(openrtb_ext.BidderAdform)].UserSyncURL | ||
redirectURI := url.QueryEscape(cfg.ExternalURL) + "%2Fsetuid%3Fbidder%3Dadform%26gdpr%3D{{gdpr}}%26gdpr_consent%3D{{gdpr_consent}}%26uid%3D%24UID" | ||
return adapters.NewSyncer("adform", 50, adapters.ResolveMacros(usersyncURL+redirectURI), adapters.SyncTypeRedirect) | ||
func NewAdformSyncer(temp *template.Template) usersync.Usersyncer { | ||
return adapters.NewSyncer("adform", 50, temp, adapters.SyncTypeRedirect) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,14 @@ | ||
package adkernelAdn | ||
|
||
import ( | ||
"net/url" | ||
"strings" | ||
"text/template" | ||
|
||
"github.com/prebid/prebid-server/adapters" | ||
"github.com/prebid/prebid-server/config" | ||
"github.com/prebid/prebid-server/openrtb_ext" | ||
"github.com/prebid/prebid-server/usersync" | ||
) | ||
|
||
const adkernelGDPRVendorID = uint16(14) | ||
|
||
func NewAdkernelAdnSyncer(cfg *config.Configuration) usersync.Usersyncer { | ||
// Fixes #736 | ||
usersyncURL := cfg.Adapters[strings.ToLower(string(openrtb_ext.BidderAdkernelAdn))].UserSyncURL | ||
externalURL := strings.TrimRight(cfg.ExternalURL, "/") + "/setuid?bidder=adkernelAdn&uid={UID}" | ||
return adapters.NewSyncer("adkernelAdn", adkernelGDPRVendorID, adapters.ResolveMacros(usersyncURL+url.QueryEscape(externalURL)), adapters.SyncTypeRedirect) | ||
func NewAdkernelAdnSyncer(temp *template.Template) usersync.Usersyncer { | ||
return adapters.NewSyncer("adkernelAdn", 14, temp, adapters.SyncTypeRedirect) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,19 @@ | ||
package adkernelAdn | ||
|
||
import ( | ||
"strings" | ||
"testing" | ||
"text/template" | ||
|
||
"github.com/prebid/prebid-server/config" | ||
"github.com/prebid/prebid-server/openrtb_ext" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestAdkernelAdnSyncer(t *testing.T) { | ||
syncer := NewAdkernelAdnSyncer(&config.Configuration{ExternalURL: "https://localhost:8888", Adapters: map[string]config.Adapter{ | ||
// Prevents #736 | ||
strings.ToLower(string(openrtb_ext.BidderAdkernelAdn)): { | ||
UserSyncURL: "https://tag.adkernel.com/syncr?gdpr={{gdpr}}&gdpr_consent={{gdpr_consent}}&r=", | ||
}, | ||
}}) | ||
u := syncer.GetUsersyncInfo("1", "BONciguONcjGKADACHENAOLS1rAHDAFAAEAASABQAMwAeACEAFw") | ||
assert.Equal(t, "https://tag.adkernel.com/syncr?gdpr=1&gdpr_consent=BONciguONcjGKADACHENAOLS1rAHDAFAAEAASABQAMwAeACEAFw&r=https%3A%2F%2Flocalhost%3A8888%2Fsetuid%3Fbidder%3DadkernelAdn%26uid%3D%7BUID%7D", u.URL) | ||
assert.Equal(t, "redirect", u.Type) | ||
assert.Equal(t, adkernelGDPRVendorID, syncer.GDPRVendorID()) | ||
assert.Equal(t, false, u.SupportCORS) | ||
temp := template.Must(template.New("sync-template").Parse("https://tag.adkernel.com/syncr?gdpr={{.GDPR}}&gdpr_consent={{.GDPRConsent}}&r=https%3A%2F%2Flocalhost%3A8888%2Fsetuid%3Fbidder%3DadkernelAdn%26uid%3D%7BUID%7D")) | ||
syncer := NewAdkernelAdnSyncer(temp) | ||
syncInfo, err := syncer.GetUsersyncInfo("1", "BONciguONcjGKADACHENAOLS1rAHDAFAAEAASABQAMwAeACEAFw") | ||
assert.NoError(t, err) | ||
assert.Equal(t, "https://tag.adkernel.com/syncr?gdpr=1&gdpr_consent=BONciguONcjGKADACHENAOLS1rAHDAFAAEAASABQAMwAeACEAFw&r=https%3A%2F%2Flocalhost%3A8888%2Fsetuid%3Fbidder%3DadkernelAdn%26uid%3D%7BUID%7D", syncInfo.URL) | ||
assert.Equal(t, "redirect", syncInfo.Type) | ||
assert.EqualValues(t, adkernelGDPRVendorID, syncer.GDPRVendorID()) | ||
assert.Equal(t, false, syncInfo.SupportCORS) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,12 @@ | ||
package adtelligent | ||
|
||
import ( | ||
"net/url" | ||
"text/template" | ||
|
||
"github.com/prebid/prebid-server/adapters" | ||
"github.com/prebid/prebid-server/config" | ||
"github.com/prebid/prebid-server/usersync" | ||
) | ||
|
||
func NewAdtelligentSyncer(cfg *config.Configuration) usersync.Usersyncer { | ||
redirectURI := url.QueryEscape(cfg.ExternalURL) + "%2Fsetuid%3Fbidder%3Dadtelligent%26gdpr%3D{{gdpr}}%26gdpr_consent%3D{{gdpr_consent}}%26uid%3D%7Buid%7D" | ||
usersyncURL := "//sync.adtelligent.com/csync?t=p&ep=0&redir=" | ||
return adapters.NewSyncer("adtelligent", 0, adapters.ResolveMacros(usersyncURL+redirectURI), adapters.SyncTypeRedirect) | ||
func NewAdtelligentSyncer(temp *template.Template) usersync.Usersyncer { | ||
return adapters.NewSyncer("adtelligent", 0, temp, adapters.SyncTypeRedirect) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,12 @@ | ||
package appnexus | ||
|
||
import ( | ||
"net/url" | ||
"text/template" | ||
|
||
"github.com/prebid/prebid-server/adapters" | ||
"github.com/prebid/prebid-server/config" | ||
"github.com/prebid/prebid-server/usersync" | ||
) | ||
|
||
func NewAppnexusSyncer(cfg *config.Configuration) usersync.Usersyncer { | ||
redirectURI := url.QueryEscape(cfg.ExternalURL) + "%2Fsetuid%3Fbidder%3Dadnxs%26gdpr%3D{{gdpr}}%26gdpr_consent%3D{{gdpr_consent}}%26uid%3D%24UID" | ||
usersyncURL := "//ib.adnxs.com/getuid?" | ||
return adapters.NewSyncer("adnxs", 32, adapters.ResolveMacros(usersyncURL+redirectURI), adapters.SyncTypeRedirect) | ||
func NewAppnexusSyncer(temp *template.Template) usersync.Usersyncer { | ||
return adapters.NewSyncer("adnxs", 32, temp, adapters.SyncTypeRedirect) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,12 @@ | ||
package audienceNetwork | ||
|
||
import ( | ||
"strings" | ||
"text/template" | ||
|
||
"github.com/prebid/prebid-server/adapters" | ||
"github.com/prebid/prebid-server/config" | ||
"github.com/prebid/prebid-server/openrtb_ext" | ||
"github.com/prebid/prebid-server/usersync" | ||
) | ||
|
||
func NewFacebookSyncer(cfg *config.Configuration) usersync.Usersyncer { | ||
syncURL := cfg.Adapters[strings.ToLower(string(openrtb_ext.BidderFacebook))].UserSyncURL | ||
return adapters.NewSyncer("audienceNetwork", 0, adapters.ResolveMacros(syncURL), adapters.SyncTypeRedirect) | ||
func NewFacebookSyncer(temp *template.Template) usersync.Usersyncer { | ||
return adapters.NewSyncer("audienceNetwork", 0, temp, adapters.SyncTypeRedirect) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,19 @@ | ||
package audienceNetwork | ||
|
||
import ( | ||
"strings" | ||
"testing" | ||
|
||
"github.com/prebid/prebid-server/config" | ||
"github.com/prebid/prebid-server/openrtb_ext" | ||
"text/template" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestFacebookSyncer(t *testing.T) { | ||
syncer := NewFacebookSyncer(&config.Configuration{Adapters: map[string]config.Adapter{ | ||
strings.ToLower(string(openrtb_ext.BidderFacebook)): { | ||
UserSyncURL: "https://www.facebook.com/audiencenetwork/idsync/?partner=partnerId&callback=localhost%2Fsetuid%3Fbidder%3DaudienceNetwork%26gdpr%3D{{gdpr}}%26gdpr_consent%3D{{gdpr_consent}}%26uid%3D%24UID", | ||
}, | ||
}}) | ||
u := syncer.GetUsersyncInfo("", "") | ||
assert.Equal(t, "https://www.facebook.com/audiencenetwork/idsync/?partner=partnerId&callback=localhost%2Fsetuid%3Fbidder%3DaudienceNetwork%26gdpr%3D%26gdpr_consent%3D%26uid%3D%24UID", u.URL) | ||
assert.Equal(t, "redirect", u.Type) | ||
assert.Equal(t, uint16(0), syncer.GDPRVendorID()) | ||
assert.Equal(t, false, u.SupportCORS) | ||
temp := template.Must(template.New("sync-template").Parse("https://www.facebook.com/audiencenetwork/idsync/?partner=partnerId&callback=localhost%2Fsetuid%3Fbidder%3DaudienceNetwork%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%24UID")) | ||
syncer := NewFacebookSyncer(temp) | ||
syncInfo, err := syncer.GetUsersyncInfo("", "") | ||
assert.NoError(t, err) | ||
assert.Equal(t, "https://www.facebook.com/audiencenetwork/idsync/?partner=partnerId&callback=localhost%2Fsetuid%3Fbidder%3DaudienceNetwork%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) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,12 @@ | ||
package beachfront | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/prebid/prebid-server/openrtb_ext" | ||
"text/template" | ||
|
||
"github.com/prebid/prebid-server/adapters" | ||
"github.com/prebid/prebid-server/config" | ||
"github.com/prebid/prebid-server/usersync" | ||
) | ||
|
||
func NewBeachfrontSyncer(cfg *config.Configuration) usersync.Usersyncer { | ||
b := string(openrtb_ext.BidderBeachfront) | ||
usersyncURL := cfg.Adapters[b].UserSyncURL | ||
platformID := cfg.Adapters[b].PlatformID | ||
|
||
url := "" | ||
if len(usersyncURL) > 0 { | ||
url = fmt.Sprintf("%s%s", usersyncURL, platformID) | ||
} | ||
return adapters.NewSyncer("beachfront", 0, adapters.ResolveMacros(url), adapters.SyncTypeIframe) | ||
func NewBeachfrontSyncer(temp *template.Template) usersync.Usersyncer { | ||
return adapters.NewSyncer("beachfront", 0, temp, adapters.SyncTypeIframe) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.