-
Notifications
You must be signed in to change notification settings - Fork 737
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
New Adapter: Insticator #3806
base: master
Are you sure you want to change the base?
New Adapter: Insticator #3806
Conversation
* init insticator adaptor * update modules * add mediaType for bids * update insticator adaptor with tests * update insticator for test cases * fix test cases * update InstAdapter * update insticator adaptor * fix test cases for adUnitId * update insticator adapter type * Updates - add currency converter support - Add video validation support * remove default plcmt and placement * add more test cases * update for publisher ID * fix tests
* add multi-imps testJson * fix pubId parsing for request
Code coverage summaryNote:
insticatorRefer here for heat map coverage report
|
adapters/insticator/insticator.go
Outdated
// type adapter struct { | ||
// endpoint string | ||
// } | ||
|
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.
should remove this comment
adapters/insticator/insticator.go
Outdated
// CALLER Info used to track Prebid Server | ||
// as one of the hops in the request to exchange | ||
var CALLER = InsticatorCaller{"Prebid-Server", "n/a"} |
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.
Accessibility scope of CALLER
is public i.e can be accessed outside of insticator package. Should make it private as done below:
// caller Info used to track Prebid Server
// as one of the hops in the request to exchange
var caller = InsticatorCaller{"Prebid-Server", "n/a"}
@@ -0,0 +1,17 @@ | |||
endpoint: "https://ex.ingage.tech/v1/prebidserver" |
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.
endpoint is reachable.
% curl -i --location --request POST 'https://ex.ingage.tech/v1/prebidserver'
HTTP/2 403
date: Tue, 06 Aug 2024 09:27:09
@shubhamc-ins are there any geo location restriction for insticator adapter? Because received following error as curl response
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Access Restricted</title>
<style>
body { font-family: Arial, sans-serif; text-align: center; padding: 50px; }
h1 { color: #ff0000; }
</style>
</head>
<body>
<h1>Access Restricted</h1>
<p>We're sorry, but access to this service is restricted from your location. Error code: 1</p>
<p>If you believe this is an error, please contact our support team.</p>
<script>(function(){function c(){var b=a.contentDocument||a.contentWindow.document;if(b){var d=b.createElement('script');d.innerHTML="window.__CF$cv$params={r:'8aedfd4b2a2e3c5e',t:'MTcyMjkzNjQyOS4wMDAwMDA='};var a=document.createElement('script');a.nonce='';a.src='/cdn-cgi/challenge-platform/scripts/jsd/main.js';document.getElementsByTagName('head')[0].appendChild(a);";b.getElementsByTagName('head')[0].appendChild(d)}}if(document.body){var a=document.createElement('iframe');a.height=1;a.width=1;a.style.position='absolute';a.style.top=0;a.style.left=0;a.style.border='none';a.style.visibility='hidden';document.body.appendChild(a);if('loading'!==document.readyState)c();else if(window.addEventListener)document.addEventListener('DOMContentLoaded',c);else{var e=document.onreadystatechange||function(){};document.onreadystatechange=function(b){e(b);'loading'!==document.readyState&&(document.onreadystatechange=e,c())}}}})();</script></body>
</html>
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.
@onkarvhanumante yes, we do have geo restrictions on ingage.tech domain. You should be to access it via VPN using America/Canada region.
endpoint: "https://ex.ingage.tech/v1/prebidserver" | ||
maintainer: | ||
email: "predid@insticator.com" | ||
gvlVendorID: 910 |
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.
verified gvl id
% curl https://vendor-list.consensu.org/v2/vendor-list.json | jq '.vendors."910"'
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 430k 100 430k 0 0 2811k 0 --:--:-- --:--:-- --:--:-- 2830k
{
"id": 910,
"name": "Insticator, Inc.",
"purposes": [
1,
2,
3,
4,
5,
6,
7,
8,
10
],
"legIntPurposes": [],
"flexiblePurposes": [
2,
5,
6,
7,
8,
10
],
"specialPurposes": [
1,
2
],
"features": [
3
],
"specialFeatures": [],
"policyUrl": "https://www.insticator.com/privacy/",
"cookieMaxAgeSeconds": 25920000,
"usesCookies": true,
"cookieRefresh": false,
"usesNonCookieAccess": true,
"deviceStorageDisclosureUrl": "https://insticator.com/device-storage-disclosure.json"
}
static/bidder-info/insticator.yaml
Outdated
@@ -0,0 +1,17 @@ | |||
endpoint: "https://ex.ingage.tech/v1/prebidserver" | |||
maintainer: | |||
email: "predid@insticator.com" |
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.
Prebid team has sent email to verify above maintainers email. Requesting to responding back on email thread
adapters/insticator/insticator.go
Outdated
} | ||
|
||
// Placeholder for the actual openrtb2.Video struct | ||
type Video 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.
Video
struct is unused. Should remove it.
adapters/insticator/insticator.go
Outdated
// endpoint string | ||
// } | ||
|
||
type Ext 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.
should be private
type ext struct {
Insticator impInsticatorExt `json:"insticator"`
}
adapters/insticator/insticator.go
Outdated
Insticator impInsticatorExt `json:"insticator"` | ||
} | ||
|
||
type insticatorUserExt 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.
insticatorUserExt
struct is unused. Should remove it.
adapters/insticator/insticator.go
Outdated
type InsticatorCaller struct { | ||
Name string `json:"name,omitempty"` | ||
Version string `json:"version,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.
should be private
type insticatorCaller struct {
Name string `json:"name,omitempty"`
Version string `json:"version,omitempty"`
}
adapters/insticator/insticator.go
Outdated
type BadInput struct { | ||
Message string | ||
} | ||
|
||
func (e *BadInput) Error() string { | ||
return e.Message | ||
} | ||
|
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.
BadInput
is unused. Should remove it.
adapters/insticator/insticator.go
Outdated
func getBidType(ext bidExt) openrtb_ext.BidType { | ||
if ext.Insticator.MediaType == "video" { | ||
return openrtb_ext.BidTypeVideo | ||
} | ||
|
||
return openrtb_ext.BidTypeBanner | ||
} |
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.
function getBidType
is unused. Should remove this function.
adapters/insticator/insticator.go
Outdated
if imp.Banner == nil && imp.Video == nil { | ||
return openrtb2.Imp{}, &errortypes.BadInput{ | ||
Message: fmt.Sprintf("Imp ID %s must have at least one of [Banner, Video] defined", imp.ID), | ||
} | ||
} |
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.
static/bidder-info/insticator.yaml
mentions Banner and Video
as required media types params. Therefore, Prebid core framework will ensure incoming request has Banner and Video details for insticator bidder.
Therefore, can exclude this check from adapter
videoCopy, err := validateVideoParams(imp.Video) | ||
|
||
imp.Video = videoCopy | ||
|
||
if err != nil { | ||
return openrtb2.Imp{}, &errortypes.BadInput{ | ||
Message: err.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.
- should remove line space on line 381 and line 384
- error check should be done before assigning value to
imp.Video
- create copy of imp in
makeImps
and then make changes in imp copy
videoCopy, err := validateVideoParams(imp.Video)
if err != nil {
return openrtb2.Imp{}, &errortypes.BadInput{
Message: err.Error(),
}
}
imp.Video = videoCopy
adapters/insticator/insticator.go
Outdated
v := reflect.ValueOf(video).Elem() | ||
t := v.Type() | ||
|
||
for i := 0; i < t.NumField(); i++ { | ||
field := t.Field(i) | ||
fieldValue := v.Field(i) | ||
|
||
// Convert the field name to camelCase for matching in optionalVideoParams map |
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.
Usage of reflection should be avoided.
Also looks like validateOptionalVideoParams
is validating if correct values are parsed and assigned to the fields of *openrtb2.Video
struct. This step is not needed.
Because adapter code will receive parsed values. Here MakeRequests
receives request *openrtb2.BidRequest
. and request.Imp[$].Video
is already validated during parsing.
func (a *adapter) MakeRequests(request *openrtb2.BidRequest, requestInfo *adapters.ExtraRequestInfo)
Parsing done before MakeRequests
call ensures that incoming values are valid and parsable into struct.
For example, request.Imp[$].Video.MinDuration
has int64
type. Here parsing will fail if incoming request has value that cannot be parsed as int64
@shubhamc-ins you could simply use values and make sure it is suitable for your business logic.
var validLinearity = map[int]bool{1: true} |
prebid-server/adapters/insticator/insticator.go
Lines 144 to 149 in b751ff9
var validPlaybackEnd = map[int]bool{1: true, 2: true, 3: true} | |
var validPos = map[int]bool{0: true, 1: true, 2: true, 3: true, 4: true, 5: true, 6: true, 7: true} | |
// Map parameters to validation functions | |
var optionalVideoParams = map[string]func(interface{}) bool{ | |
"minduration": isInteger, |
For example, your adapter requires linearity
to be 1
. Here code can be restructured as below:
func validateOptionalVideoParams(video *openrtb2.Video) (*openrtb2.Video, error) {
if video.Linearity <some conditon> {
<some logic>
}
....
Similarly other business logic can be validated into validateOptionalVideoParams
adapters/insticator/insticator.go
Outdated
func toCamelCase(s string) string { | ||
if s == "" { | ||
return s | ||
} | ||
return strings.ToLower(string(s[0])) + s[1:] | ||
} | ||
|
||
// Helper function to check if a value is zero or nil | ||
func isZeroOrNil(value reflect.Value) bool { | ||
switch value.Kind() { |
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.
based on https://github.com/prebid/prebid-server/pull/3806/files#r1705364786 comment these functions won't be needed
adapters/insticator/insticator.go
Outdated
func toInt(value interface{}) int { | ||
switch v := value.(type) { | ||
case int: | ||
return v | ||
case float64: | ||
return int(v) | ||
case string: | ||
if i, err := strconv.Atoi(v); err == nil { | ||
return i | ||
} | ||
} | ||
return 0 | ||
} |
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.
Based on https://github.com/prebid/prebid-server/pull/3806/files#r1705364786 comment this function is not required.
adapters/insticator/insticator.go
Outdated
func isInteger(value interface{}) bool { | ||
switch v := value.(type) { | ||
case int: | ||
return true | ||
case float64: | ||
return v == float64(int(v)) | ||
case string: | ||
_, err := strconv.Atoi(v) | ||
return err == nil | ||
default: | ||
return false | ||
} | ||
} | ||
|
||
func isArrayOfNums(value interface{}) bool { | ||
switch v := value.(type) { |
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.
Based on https://github.com/prebid/prebid-server/pull/3806/files#r1705364786 comment this function is not required.
adapters/insticator/insticator.go
Outdated
// Define valid values | ||
var validLinearity = map[int]bool{1: true} | ||
var validSkip = map[int]bool{0: true, 1: true} | ||
var validPlaybackEnd = map[int]bool{1: true, 2: true, 3: true} | ||
var validPos = map[int]bool{0: true, 1: true, 2: true, 3: true, 4: true, 5: true, 6: true, 7: true} | ||
|
||
// Map parameters to validation functions | ||
var optionalVideoParams = map[string]func(interface{}) bool{ | ||
"minduration": isInteger, |
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.
Based on https://github.com/prebid/prebid-server/pull/3806/files#r1705364786 comment this function is not required.
adapters/insticator/insticator.go
Outdated
if responseData.StatusCode == http.StatusNoContent { | ||
return nil, nil | ||
} | ||
|
||
if responseData.StatusCode == http.StatusBadRequest { | ||
err := &errortypes.BadInput{ | ||
Message: fmt.Sprintf("Unexpected status code: %d. Run with request.debug = 1 for more info.", responseData.StatusCode), | ||
} | ||
return nil, []error{err} | ||
} | ||
|
||
if responseData.StatusCode != http.StatusOK { | ||
err := &errortypes.BadServerResponse{ | ||
Message: fmt.Sprintf("Unexpected status code: %d. Run with request.debug = 1 for more info.", responseData.StatusCode), | ||
} | ||
return nil, []error{err} | ||
} |
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.
could make use of adapter response utils here
prebid-server/adapters/response.go
Lines 10 to 28 in ec729e6
func CheckResponseStatusCodeForErrors(response *ResponseData) error { | |
if response.StatusCode == http.StatusBadRequest { | |
return &errortypes.BadInput{ | |
Message: fmt.Sprintf("Unexpected status code: %d. Run with request.debug = 1 for more info", response.StatusCode), | |
} | |
} | |
if response.StatusCode != http.StatusOK { | |
return &errortypes.BadServerResponse{ | |
Message: fmt.Sprintf("Unexpected status code: %d. Run with request.debug = 1 for more info", response.StatusCode), | |
} | |
} | |
return nil | |
} | |
func IsResponseStatusCodeNoContent(response *ResponseData) bool { | |
return response.StatusCode == http.StatusNoContent | |
} |
adapters/insticator/insticator.go
Outdated
bidResponse := adapters.NewBidderResponseWithBidsCapacity(len(request.Imp)) | ||
bidResponse.Currency = response.Cur |
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.
adapters.NewBidderResponseWithBidsCapacity
initialises bidResponse.Currency
with USD
value
consider scenario where bidResponse.Currency
is empty, assigning response.Cur
directly may set bidResponse.Currency
to empty value
consider implementing following changes:
bidResponse := adapters.NewBidderResponseWithBidsCapacity(len(response.SeatBid[0].Bid))
if response.Cur != "" {
bidResponse.Currency = response.Cur
}
adapters/insticator/insticator.go
Outdated
if request.Site != nil && i == 0 { | ||
populatePublisherId(&impCopy, request) | ||
} else if request.App != nil && i == 0 { | ||
populatePublisherId(&impCopy, request) | ||
} |
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.
@shubhamc-ins any particular region to use only request.Imp[0]
for populating publisher id?
Is expected behaviour here is to pass same values in Imp.Ext
for all impressions part of request. If yes then this should be explicitly mentioned bidder docs. If doc PR doesn't not exist then create it in https://github.com/prebid/prebid.github.io repo
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 have updated it.
c3ab32b
to
24d9b39
Compare
Code coverage summaryNote:
insticatorRefer here for heat map coverage report
|
Code coverage summaryNote:
insticatorRefer here for heat map coverage report
|
Hi @onkarvhanumante , Hope you are doing great. Did you get time to re-visit this again? |
Hi @shubhamc-ins, I'll see if I can get you a re-review. For the future, please push new commits and merge with master to resolve conflicts instead of rebasing / force pushing. Force pushing requires a lot of extra work on behalf of the reviewers since we need to review everything again instead of just looking at what changed from the last review. All commits on the PR are squashed when merged. |
Thanks @bsardo , Got it! Let me know, if you need anything from my side or want me to create a new clean PR ( with new branch ). |
@bsardo Hope you're doing well, did you manage to get some time to get this reviewed again? In case you need a clean PR again, let me know. Thanks :) |
Code coverage summaryNote:
insticatorRefer here for heat map coverage report
|
Hey @bsardo @onkarvhanumante Please let us know if there is any update or if you got chance to review this again. I have updated the PR with all the requested changes. OR let me know if you guys want a fresh PR, I'll do that (quickly). I understand you guys must have your hands full but we'd really appreciate, if we can have an estimate since It has been quite a few months that this is opened. I hope you understand. Thanks a lot. |
Hi @shubhamc-ins, @przemkaczmarek and I will take this over and review it. Thanks for your patience. |
Code coverage summaryNote:
insticatorRefer here for heat map coverage report
|
Hi @shubhamc-ins, we recently released PBS 3.0, more specifically v3.1.0, which updates Prebid Server package import references throughout the project from
As a result, please merge with master (no rebase) and then ensure all Prebid Server package import references in the files you’ve changed are |
Code coverage summaryNote:
insticatorRefer here for heat map coverage report
|
Hi @bsardo, thanks for the reminder. I have updated the PR with v3 imports. Thanks :) |
DOCS PR: prebid/prebid.github.io#5571