-
Notifications
You must be signed in to change notification settings - Fork 766
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
Integration Type Implementation #2111
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
59b03c8
Integration Type Handling
AlexBVolcy 8c78d56
Merge branch 'prebid:master' into New_Integration_Type
AlexBVolcy 71f7ff5
Addressing comments, fixed tests
AlexBVolcy 1e62728
Updated vtrack URL integration, altered tests, refactoring
AlexBVolcy 5bbabae
Added integration type validation, minor refactoring
AlexBVolcy 75c980e
Updated JSON exchange tests, updated event URL to apply integration type
AlexBVolcy c12acb3
Added integration validation to event/vtrack URLs
AlexBVolcy 25b03fc
Merge branch 'master' into New_Integration_Type
AlexBVolcy f12d6f4
Added more tests for integration validation
AlexBVolcy afa43b1
Address minor feedback
AlexBVolcy a609124
Added test coverage for readIntegrationType error
AlexBVolcy e7f1c64
Minor feedback updates
AlexBVolcy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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 |
---|---|---|
|
@@ -8,6 +8,7 @@ import ( | |
"net/url" | ||
"strconv" | ||
"time" | ||
"unicode" | ||
|
||
"github.com/julienschmidt/httprouter" | ||
accountService "github.com/prebid/prebid-server/account" | ||
|
@@ -26,12 +27,15 @@ const ( | |
AccountIdParameter = "a" | ||
|
||
// Optional | ||
BidderParameter = "bidder" | ||
TimestampParameter = "ts" | ||
FormatParameter = "f" | ||
AnalyticsParameter = "x" | ||
BidderParameter = "bidder" | ||
TimestampParameter = "ts" | ||
FormatParameter = "f" | ||
AnalyticsParameter = "x" | ||
IntegrationTypeParameter = "int" | ||
) | ||
|
||
const integrationParamMaxLength = 64 | ||
|
||
type eventEndpoint struct { | ||
Accounts stored_requests.AccountFetcher | ||
Analytics analytics.PBSAnalyticsModule | ||
|
@@ -162,6 +166,10 @@ func ParseEventRequest(r *http.Request) (*analytics.EventRequest, []error) { | |
errs = append(errs, err) | ||
} | ||
|
||
if err := readIntegrationType(event, r); err != nil { | ||
errs = append(errs, err) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you add coverage for this line? You should be able to just add another test which is basically a copy of |
||
} | ||
|
||
// Bidder | ||
event.Bidder = r.URL.Query().Get(BidderParameter) | ||
|
||
|
@@ -225,6 +233,10 @@ func optionalParameters(request *analytics.EventRequest) string { | |
r.Add(AnalyticsParameter, string(analytics.Disabled)) | ||
} | ||
|
||
if request.Integration != "" { | ||
r.Add(IntegrationTypeParameter, request.Integration) | ||
} | ||
|
||
opt := r.Encode() | ||
|
||
if opt != "" { | ||
|
@@ -323,3 +335,25 @@ func checkRequiredParameter(httpRequest *http.Request, parameter string) (string | |
|
||
return t, nil | ||
} | ||
|
||
func readIntegrationType(er *analytics.EventRequest, httpRequest *http.Request) error { | ||
integrationType := httpRequest.URL.Query().Get(IntegrationParameter) | ||
err := validateIntegrationType(integrationType) | ||
if err != nil { | ||
return err | ||
} | ||
er.Integration = integrationType | ||
return nil | ||
} | ||
|
||
func validateIntegrationType(integrationType string) error { | ||
if len(integrationType) > integrationParamMaxLength { | ||
return errors.New("integration type length is too long") | ||
} | ||
for _, char := range integrationType { | ||
if !unicode.IsDigit(char) && !unicode.IsLetter(char) && char != '-' && char != '_' { | ||
return errors.New("integration type can only contain numbers, letters and these characters '-', '_'") | ||
} | ||
} | ||
return nil | ||
} |
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Just checking, is this a standardized query parameter agreed upon with the PBS committee?
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.
Yes I believe so, I'll double check with Mansi, but I believe this is correct
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 see that this is the name of the parameter in PBS-Java.