-
Notifications
You must be signed in to change notification settings - Fork 768
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
Syncer Level ExternalURL Override #2072
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
usersync/syncer.go
Outdated
redirectTemplate := syncerEndpoint.RedirectURL | ||
if redirectTemplate == "" { | ||
redirectTemplate = hostConfig.RedirectURL | ||
} | ||
|
||
externalURL := syncerEndpoint.ExternalURL | ||
if externalURL == "" { | ||
externalURL = syncerExternalURL | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I find the consecutive if externalURL == ""
a little confusing. Can we be more explicit? Maybe even with a comment to make it extra clear?
156 - externalURL := syncerEndpoint.ExternalURL
157 - if externalURL == "" {
158 - externalURL = syncerExternalURL
159 - }
160 - if externalURL == "" {
161 - externalURL = hostConfig.ExternalURL
162 - }
+ // Find an externalURL value either of the following: syncerEndpoint.ExternalURL, or syncerExternalURL or hostConfig.ExternalURL
+ // they take precedence in that exact order
+ var externalURL string
+ if syncerEndpoint.ExternalURL != "" {
+ externalURL = syncerEndpoint.ExternalURL
+ } else if syncerExternalURL != "" {
+ externalURL = syncerExternalURL
+ } else {
+ externalURL = hostConfig.ExternalURL
+ }
usersync/syncer.go
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I gotcha. Refactored.
@@ -1102,6 +1102,7 @@ func setBidderDefaults(v *viper.Viper, bidder string) { | |||
v.BindEnv(adapterCfgPrefix + ".usersync.redirect.redirect_url") | |||
v.BindEnv(adapterCfgPrefix + ".usersync.redirect.external_url") | |||
v.BindEnv(adapterCfgPrefix + ".usersync.redirect.user_macro") | |||
v.BindEnv(adapterCfgPrefix + ".usersync.external_url") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add an assertion in config/config_test.go
? Maybe in TestFullConfig
or even in the TestUnmarshalAdapterExtraInfo
test?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you really think we need to? There's nothing special with this config value. Adding it to TestFullConfig
is really just testing Viper and not so much this specific value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, I can live with that.
@@ -109,6 +112,10 @@ func (s *Syncer) Override(original *Syncer) *Syncer { | |||
copy.Redirect = s.Redirect.Override(original.Redirect) | |||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I realize this isn't part of your PR but, should we use this opportunity to merge the repetitive if
statements above into one?
103 if original == nil {
104 copy.IFrame = s.IFrame.Override(nil)
+ copy.Redirect = s.Redirect.Override(nil)
105 } else {
106 copy.IFrame = s.IFrame.Override(original.IFrame)
+ copy.Redirect = s.Redirect.Override(original.Redirect)
107 }
108
109 - if original == nil {
110 - copy.Redirect = s.Redirect.Override(nil)
111 - } else {
112 - copy.Redirect = s.Redirect.Override(original.Redirect)
113 - }
config/bidderinfo.go
Or maybe we could correct it in a separate PR and properly test the change there. I'm good either way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure. I didn't notice the repetition. Collapsed. This section of code has 100% test coverage. I'm confident it's a safe change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
return syncerURL | ||
} | ||
|
||
return hostConfigURL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Beautiful
givenSyncerEndpointURL: "", | ||
givenSyncerURL: "", | ||
givenHostConfigURL: "c", | ||
expected: "c", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome
@@ -1102,6 +1102,7 @@ func setBidderDefaults(v *viper.Viper, bidder string) { | |||
v.BindEnv(adapterCfgPrefix + ".usersync.redirect.redirect_url") | |||
v.BindEnv(adapterCfgPrefix + ".usersync.redirect.external_url") | |||
v.BindEnv(adapterCfgPrefix + ".usersync.redirect.user_macro") | |||
v.BindEnv(adapterCfgPrefix + ".usersync.external_url") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, I can live with that.
// ExternalURL is available as a macro to the RedirectURL template. If not specified, the host configuration | ||
// value is used. | ||
// ExternalURL is available as a macro to the RedirectURL template. If not specified, either the syncer configuration | ||
// value or the host configuration value is used. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great wording
* 'master' of https://github.com/wwwyyy/prebid-server: (23 commits) Add GPID Reserved Bidder Name (prebid#2107) Marsmedia adapter - param zoneId can get string and int (prebid#2105) Algorix: add Server Region Support (prebid#2096) New Adapter: Bizzclick (prebid#2056) Collect Prometheus Go process metrics (prebid#2101) Added channel support (prebid#2037) Rubicon: update fpd fields resolving (prebid#2091) Beachfront - Currency conversion (prebid#2078) New Adapter: Groupm (Alias Of PubMatic) (prebid#2042) Adform adapter lacked gross/net parameter support (prebid#2084) add iframe sync for openx (prebid#2094) changes to the correct user sync url (prebid#2092) Smaato: Add instl to tests (prebid#2089) Correct MakeRequests() output assertion in adapter JSON tests (prebid#2087) Adview: adapter currency fix. (prebid#2060) New Adapter: Coinzilla (prebid#2074) Syncer Level ExternalURL Override (prebid#2072) 33Across: Enable Support for SRA requests (prebid#2079) Currency conversion on adapter JSON tests (prebid#2071) New Adapter: VideoByte (prebid#2058) ...
Allows a host to override the external url at the syncer level in addition to the existing syncer endpoint level. This will make it easier for the host to configure an override since the endpoint type is no longer required, but is still available if different endpoints require different values.