-
Notifications
You must be signed in to change notification settings - Fork 748
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
Added integration type support for host company #2082
Conversation
config/config.go
Outdated
@@ -84,6 +84,9 @@ type Configuration struct { | |||
GenerateBidID bool `mapstructure:"generate_bid_id"` | |||
// GenerateRequestID overrides the bidrequest.id in an AMP Request or an App Stored Request with a generated UUID if set to true. The default is false. | |||
GenerateRequestID bool `mapstructure:"generate_request_id"` | |||
// IntegrationTypes will hold the integration type values that the host will allow. | |||
// Map structure isn't included here because the integration type feature is still being worked on, but once complete, this variable will be updated | |||
IntegrationTypes map[string]bool |
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.
If I understand correctly, this config variable will only contain the integration type values that are allowed by the host, is that correct?
If so, in that case, map[string]struct{}
might make more sense since the map values are insignificant and the empty struct is a typical go construct used for this purpose. It does not appear as though the Java version has this configuration setting but we could still add it so we can detect invalid values and notify the publisher.
I also understand that a future PR will handle populating this map from what I imagine will be a slice called IntegrationTypes
on the Configuration
object so you might want to call this one you've defined here IntegrationTypesMap
instead.
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.
Thank you for this comment, I'll update this maps value accordingly!
openrtb_ext/request.go
Outdated
@@ -33,6 +33,7 @@ type ExtRequestPrebid struct { | |||
Data *ExtRequestPrebidData `json:"data,omitempty"` | |||
Debug bool `json:"debug,omitempty"` | |||
Events json.RawMessage `json:"events,omitempty"` | |||
IntegrationType string `json:"integration,omitempty"` |
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 think we might want to call this Integration
instead. Our struct field names typically match the json.
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.
Will update!
openrtb_ext/request.go
Outdated
@@ -33,6 +33,7 @@ type ExtRequestPrebid struct { | |||
Data *ExtRequestPrebidData `json:"data,omitempty"` | |||
Debug bool `json:"debug,omitempty"` | |||
Events json.RawMessage `json:"events,omitempty"` | |||
IntegrationType string `json:"integration,omitempty"` |
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 assume you'll also convert this from a string to some integration-specific custom string type in a future PR, is that right?
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.
Actually maybe I have that wrong. Can the integration values be whatever the host wants? In that case string makes sense.
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.
Yeah the integration values allowed are set by the host to be whatever they want!
endpoints/openrtb2/auction.go
Outdated
return "", err | ||
} | ||
reqPrebid := reqExt.GetPrebid() | ||
return reqPrebid.IntegrationType, nil |
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.
reqPrebid
could be nil so you'll want to check for that before you try to access .IntegrationType
.
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.
Will update!
endpoints/openrtb2/auction.go
Outdated
if _, ok := integrationTypes[integrationType]; ok { | ||
return nil | ||
} |
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.
If the integration has not been specified in the request, I believe that's valid according to the corresponding issue, is that correct? It looks like the integration would be set to some default value specified in the config in this case. If I have that right, you'll want to handle that case here as I don't imagine specifying an empty string or nil value in the slice of valid integration values in the config.
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.
You're right in bringing up this point! However, I'll handle this Default Integration in a future PR, since we're breaking up my implementation of Integration Type and Channel into multiple smaller PRs.
endpoints/openrtb2/auction.go
Outdated
return reqPrebid.IntegrationType, nil | ||
} | ||
|
||
func validateIntegrationType(req *openrtb_ext.RequestWrapper, integrationTypes map[string]bool) error { |
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.
Are you planning to add test coverage for these functions in this PR or a future related PR?
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.
Yeah I'll add more test coverage in this PR for the getIntegrationTypeFromRequest
function, the validateIntegrationType
function has a test that I wrote already in this PR!
@@ -84,6 +84,9 @@ type Configuration struct { | |||
GenerateBidID bool `mapstructure:"generate_bid_id"` | |||
// GenerateRequestID overrides the bidrequest.id in an AMP Request or an App Stored Request with a generated UUID if set to true. The default is false. | |||
GenerateRequestID bool `mapstructure:"generate_request_id"` | |||
// IntegrationTypesMap will hold the integration type values that the host will allow. | |||
// Map structure isn't included here because the integration type feature is still being worked on, but once complete, this variable will be updated | |||
IntegrationTypesMap map[string]struct{} |
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.
Two questions. First is how do you plan on populating IntegrationTypesMap
? For the above Blacklist maps, we have two entries, one a slice of strings, and the second is the actual map. In your configuration you would provide the list of values, and then config code builds the map from the list.
The second question is how do we default to integration types not being required? We don't want to break every install of PBS that is not currently requiring integration types to be sent in requests.
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.
To your first question, I like the idea of copying how the Blacklist maps work, so I could have one variable IntegrationTypes
that is just a slice of strings indicating what IntegrationTypes the host company allows, and this slice can be filled with another SetDefault
of that SetupViper
function. And then that slice can be apart of the IntegrationTypesMap
. And then we can continue to utilize the fast lookup the map allows us.
To your second question, integration types are not being required in this PR since we never actually call any of the validate/get functions set up for integration types, so the flow of current PBS instances won't be broken. But in the future, we could create a simple boolean (i.e. AllowIntegrationTypes
), that if false, avoids any evaluation of integration type information. Or host company's could choose to not populate the IntegrationTypes
slice, and then we could add a check that makes it if IntegrationTypes
slice is empty, we just continue evaluating the request ignoring IntegrationType
related validation.
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.
Oh, yes, you don't actually call these new functions. Seems like a small enough addition, was there a reason that the actual activation was left to another PR?
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.
Since we still have to implement the integration type features for accounts (i.e. Default Integration), we can leave the activation for that PR!
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.
Looks good, even if it just adds code but doesn't activate it. Will need a followup PR to activate this functionality, but will go ahead and set my approval now.
This PR partially addresses the Integration Type and Channel issue #1428
There will be a series of smaller PRs to address this issue, another PR is currently out for adding channel support here #2037
This PR is the first one dedicated towards the Integration part of the issue. What this PR does is it adds the functions that allow us to get the integration type (
getIntegrationTypeFromRequest()
) value found in a openRTB request, and to validate that the integration value in the request is allowed by the host company (validateIntegrationType()
).Future integration type focused PRs will add support for publishers to define a
defaultIntegration
value, and if that value can be overridden.