Skip to content
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: Trustedstack #3618

Merged

Conversation

product-trustedstack
Copy link
Contributor

@product-trustedstack product-trustedstack commented Apr 9, 2024

Copy link

github-actions bot commented Apr 9, 2024

Code coverage summary

Note:

  • Prebid team doesn't anticipate tests covering code paths that might result in marshal and unmarshal errors
  • Coverage summary encompasses all commits leading up to the latest one, b4a6ab3

trustedstack

Refer here for heat map coverage report

github.com/prebid/prebid-server/v2/adapters/trustedstack/trustedstack.go:20:	MakeRequests		75.0%
github.com/prebid/prebid-server/v2/adapters/trustedstack/trustedstack.go:40:	MakeBids		84.2%
github.com/prebid/prebid-server/v2/adapters/trustedstack/trustedstack.go:85:	Builder			100.0%
github.com/prebid/prebid-server/v2/adapters/trustedstack/trustedstack.go:92:	getMediaTypeForImp	85.7%
github.com/prebid/prebid-server/v2/adapters/trustedstack/trustedstack.go:108:	buildEndpoint		88.9%
total:										(statements)		84.4%


// Builder builds a new instance of the Trustedstack adapter for the given bidder with the given config.
func Builder(bidderName openrtb_ext.BidderName, config config.Adapter, server config.Server) (adapters.Bidder, error) {
url := buildEndpoint(config.Endpoint, config.ExtraAdapterInfo)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not use server.ExternalUrl instead of using the extra info field?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Copy link

Code coverage summary

Note:

  • Prebid team doesn't anticipate tests covering code paths that might result in marshal and unmarshal errors
  • Coverage summary encompasses all commits leading up to the latest one, a8844e6

trustedstack

Refer here for heat map coverage report

github.com/prebid/prebid-server/v2/adapters/trustedstack/trustedstack.go:20:	MakeRequests		75.0%
github.com/prebid/prebid-server/v2/adapters/trustedstack/trustedstack.go:40:	MakeBids		84.2%
github.com/prebid/prebid-server/v2/adapters/trustedstack/trustedstack.go:85:	Builder			100.0%
github.com/prebid/prebid-server/v2/adapters/trustedstack/trustedstack.go:92:	getMediaTypeForImp	85.7%
github.com/prebid/prebid-server/v2/adapters/trustedstack/trustedstack.go:108:	buildEndpoint		88.9%
total:										(statements)		84.4%

Copy link

Code coverage summary

Note:

  • Prebid team doesn't anticipate tests covering code paths that might result in marshal and unmarshal errors
  • Coverage summary encompasses all commits leading up to the latest one, 1400778

trustedstack

Refer here for heat map coverage report

github.com/prebid/prebid-server/v2/adapters/trustedstack/trustedstack.go:20:	MakeRequests		75.0%
github.com/prebid/prebid-server/v2/adapters/trustedstack/trustedstack.go:40:	MakeBids		84.2%
github.com/prebid/prebid-server/v2/adapters/trustedstack/trustedstack.go:85:	Builder			100.0%
github.com/prebid/prebid-server/v2/adapters/trustedstack/trustedstack.go:92:	getMediaTypeForImp	85.7%
github.com/prebid/prebid-server/v2/adapters/trustedstack/trustedstack.go:108:	buildEndpoint		77.8%
total:										(statements)		82.2%

Copy link

Code coverage summary

Note:

  • Prebid team doesn't anticipate tests covering code paths that might result in marshal and unmarshal errors
  • Coverage summary encompasses all commits leading up to the latest one, f34f503

trustedstack

Refer here for heat map coverage report

github.com/prebid/prebid-server/v2/adapters/trustedstack/trustedstack.go:20:	MakeRequests			75.0%
github.com/prebid/prebid-server/v2/adapters/trustedstack/trustedstack.go:40:	MakeBids			100.0%
github.com/prebid/prebid-server/v2/adapters/trustedstack/trustedstack.go:77:	Builder				100.0%
github.com/prebid/prebid-server/v2/adapters/trustedstack/trustedstack.go:84:	getMediaTypeForImp		100.0%
github.com/prebid/prebid-server/v2/adapters/trustedstack/trustedstack.go:109:	getBidMediaTypeFromMtype	100.0%
github.com/prebid/prebid-server/v2/adapters/trustedstack/trustedstack.go:124:	buildEndpoint			77.8%
total:										(statements)			92.6%

Copy link

Code coverage summary

Note:

  • Prebid team doesn't anticipate tests covering code paths that might result in marshal and unmarshal errors
  • Coverage summary encompasses all commits leading up to the latest one, 80470f2

trustedstack

Refer here for heat map coverage report

github.com/prebid/prebid-server/v2/adapters/trustedstack/trustedstack.go:20:	MakeRequests			75.0%
github.com/prebid/prebid-server/v2/adapters/trustedstack/trustedstack.go:41:	MakeBids			100.0%
github.com/prebid/prebid-server/v2/adapters/trustedstack/trustedstack.go:78:	Builder				100.0%
github.com/prebid/prebid-server/v2/adapters/trustedstack/trustedstack.go:85:	getMediaTypeForImp		100.0%
github.com/prebid/prebid-server/v2/adapters/trustedstack/trustedstack.go:110:	getBidMediaTypeFromMtype	100.0%
github.com/prebid/prebid-server/v2/adapters/trustedstack/trustedstack.go:125:	buildEndpoint			77.8%
total:										(statements)			92.6%

Comment on lines 86 to 93
mediaType, err := getBidMediaTypeFromMtype(bid)
if err == nil {
return mediaType, nil
}
mediaType = openrtb_ext.BidTypeBanner
for _, imp := range imps {
if imp.ID == bid.ImpID {
switch {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@product-trustedstack any particular reason to fall back to imp.ID comparission when getBidMediaTypeFromMtype

Additionally,

  • err != nil case is being ignored for getBidMediaTypeFromMtype
  • By default setting media type to banner on line 90 seems incorrect. Better to add a switch case for banner type as well. This ensures banner media type is used only when imp.Banner is not nil

Copy link
Contributor Author

@product-trustedstack product-trustedstack Apr 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fall back was for mtype not correctly present in the response. That is the case for if err != nil, if mtype is wrong in the response, then impID can be used to fetch the correct mediaType.

Removed the fallbak to Impression Id. Updated the changes for default handling to banner and added it to the switch case.

Comment on lines 111 to 121
switch bid.MType {
case openrtb2.MarkupBanner:
return openrtb_ext.BidTypeBanner, nil
case openrtb2.MarkupVideo:
return openrtb_ext.BidTypeVideo, nil
case openrtb2.MarkupAudio:
return openrtb_ext.BidTypeAudio, nil
case openrtb2.MarkupNative:
return openrtb_ext.BidTypeNative, nil
default:
return "", fmt.Errorf("unable to fetch mediaType for imp: %s", bid.ImpID)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

static/bidder-info/trustedstack.yaml doesnot define audio as supported media type.

Should make changes in adapter code to only support media types defined in bidder info yaml or update bidder info yaml to define audio as supported media type as well.

capabilities:
  app:
    mediaTypes:
      - banner
      - video
      - native
  site:
    mediaTypes:
      - banner
      - video
      - native

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to the implementation of request to adapter, mediaType which adapters are not supported, request is not made for that impression and thus not sent to the bidder.
Shall bidder response parsing however can support all the media types and that can be utilised when the capabilities are updated?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shall bidder response parsing however can support all the media types and that can be utilised when the capabilities are updated?

@product-trustedstack for now adapter code should only check for media types supported. Code can be updated when capabilities includes new media type

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Comment on lines 96 to 97
case imp.Banner == nil && imp.Video == nil && imp.Audio != nil && imp.Native == nil:
mediaType = openrtb_ext.BidTypeAudio
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

refer https://github.com/prebid/prebid-server/pull/3618/files#r1570529242

static/bidder-info/trustedstack.yaml doesnot define audio as supported media type.

Should make changes in adapter code to only support media types defined in bidder info yaml or update bidder info yaml to define audio as supported media type as well.

capabilities:
  app:
    mediaTypes:
      - banner
      - video
      - native
  site:
    mediaTypes:
      - banner
      - video
      - native

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to the implementation of request to adapter, mediaType which adapters are not supported, request is not made for that impression and thus not sent to the bidder.
Shall bidder response parsing however can support all the media types and that can be utilised when the capabilities are updated?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shall bidder response parsing however can support all the media types and that can be utilised when the capabilities are updated?

@product-trustedstack for now adapter code should only check for media types supported. Code can be updated when capabilities includes new media type

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was the fallback logic as discussed in the comment #3618 (comment).
This has been removed. The core logic to get the mtype from the field above has been updated to only support media types currently mentioned in the config.

@onkarvhanumante
Copy link
Contributor

@product-trustedstack requesting to merge Prebid:master changes into product-trustedstack:trustedstack-adapter and update MakeRequests to return ImpIDs as mentioned below

headers.Add("Content-Type", "application/json;charset=utf-8")
headers.Add("Accept", "application/json")
return []*adapters.RequestData{{
Method: "POST",
Uri: a.URI,
Body: reqJSON,
Headers: headers,
ImpIDs: openrtb_ext.GetImpIDs(request.Imp),

@product-trustedstack
Copy link
Contributor Author

@product-trustedstack requesting to merge Prebid:master changes into product-trustedstack:trustedstack-adapter and update MakeRequests to return ImpIDs as mentioned below

headers.Add("Content-Type", "application/json;charset=utf-8")
headers.Add("Accept", "application/json")
return []*adapters.RequestData{{
Method: "POST",
Uri: a.URI,
Body: reqJSON,
Headers: headers,
ImpIDs: openrtb_ext.GetImpIDs(request.Imp),

@onkarvhanumante this is done.

Copy link

Code coverage summary

Note:

  • Prebid team doesn't anticipate tests covering code paths that might result in marshal and unmarshal errors
  • Coverage summary encompasses all commits leading up to the latest one, 40c8bb8

trustedstack

Refer here for heat map coverage report

github.com/prebid/prebid-server/v2/adapters/trustedstack/trustedstack.go:20:	MakeRequests			83.3%
github.com/prebid/prebid-server/v2/adapters/trustedstack/trustedstack.go:39:	MakeBids			100.0%
github.com/prebid/prebid-server/v2/adapters/trustedstack/trustedstack.go:76:	Builder				100.0%
github.com/prebid/prebid-server/v2/adapters/trustedstack/trustedstack.go:83:	getMediaTypeForImp		100.0%
github.com/prebid/prebid-server/v2/adapters/trustedstack/trustedstack.go:112:	getBidMediaTypeFromMtype	100.0%
github.com/prebid/prebid-server/v2/adapters/trustedstack/trustedstack.go:127:	buildEndpoint			77.8%
total:										(statements)			94.3%

Copy link

Code coverage summary

Note:

  • Prebid team doesn't anticipate tests covering code paths that might result in marshal and unmarshal errors
  • Coverage summary encompasses all commits leading up to the latest one, 3ddde18

trustedstack

Refer here for heat map coverage report

github.com/prebid/prebid-server/v2/adapters/trustedstack/trustedstack.go:20:	MakeRequests			83.3%
github.com/prebid/prebid-server/v2/adapters/trustedstack/trustedstack.go:39:	MakeBids			100.0%
github.com/prebid/prebid-server/v2/adapters/trustedstack/trustedstack.go:76:	Builder				100.0%
github.com/prebid/prebid-server/v2/adapters/trustedstack/trustedstack.go:83:	getMediaTypeForImp		100.0%
github.com/prebid/prebid-server/v2/adapters/trustedstack/trustedstack.go:93:	getBidMediaTypeFromMtype	100.0%
github.com/prebid/prebid-server/v2/adapters/trustedstack/trustedstack.go:108:	buildEndpoint			77.8%
total:										(statements)			93.2%

Copy link

Code coverage summary

Note:

  • Prebid team doesn't anticipate tests covering code paths that might result in marshal and unmarshal errors
  • Coverage summary encompasses all commits leading up to the latest one, 542fc21

trustedstack

Refer here for heat map coverage report

github.com/prebid/prebid-server/v2/adapters/trustedstack/trustedstack.go:20:	MakeRequests			83.3%
github.com/prebid/prebid-server/v2/adapters/trustedstack/trustedstack.go:39:	MakeBids			100.0%
github.com/prebid/prebid-server/v2/adapters/trustedstack/trustedstack.go:76:	Builder				100.0%
github.com/prebid/prebid-server/v2/adapters/trustedstack/trustedstack.go:83:	getMediaTypeForImp		100.0%
github.com/prebid/prebid-server/v2/adapters/trustedstack/trustedstack.go:93:	getBidMediaTypeFromMtype	100.0%
github.com/prebid/prebid-server/v2/adapters/trustedstack/trustedstack.go:106:	buildEndpoint			77.8%
total:										(statements)			93.0%

}, nil
}

func getMediaTypeForImp(bid *openrtb2.Bid, imps []openrtb2.Imp) (openrtb_ext.BidType, error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

imps are not used in the function. We can keep the definition clean by removing the unused parameters.

Copy link
Contributor

@Sonali-More-Xandr Sonali-More-Xandr Apr 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, this function is not required. getBidMediaTypeFromMtype can be called directly from MakeBids function as follow:-

bidType, err := getBidMediaTypeFromMtype(&sb.Bid[i])

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Copy link

Code coverage summary

Note:

  • Prebid team doesn't anticipate tests covering code paths that might result in marshal and unmarshal errors
  • Coverage summary encompasses all commits leading up to the latest one, 42a6a00

trustedstack

Refer here for heat map coverage report

github.com/prebid/prebid-server/v2/adapters/trustedstack/trustedstack.go:19:	MakeRequests			83.3%
github.com/prebid/prebid-server/v2/adapters/trustedstack/trustedstack.go:38:	MakeBids			100.0%
github.com/prebid/prebid-server/v2/adapters/trustedstack/trustedstack.go:75:	Builder				100.0%
github.com/prebid/prebid-server/v2/adapters/trustedstack/trustedstack.go:82:	getBidMediaTypeFromMtype	100.0%
github.com/prebid/prebid-server/v2/adapters/trustedstack/trustedstack.go:95:	buildEndpoint			77.8%
total:										(statements)			92.3%

@onkarvhanumante onkarvhanumante merged commit bc89164 into prebid:master May 2, 2024
5 checks passed
mefjush pushed a commit to adhese/prebid-server that referenced this pull request Jul 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants