Skip to content

Conversation

bruno-siira
Copy link
Contributor

This PR adds a new adapter for Reset Digital to the Prebid Server (Go version). The adapter enables Prebid Server to communicate with Reset Digital for real-time advertising auctions.

Changes:

Added the Reset Digital adapter in adapters/resetdigital/.
Implemented necessary methods for the adapter.
Added unit tests for the adapter in adapters/resetdigital/resetdigital_test.go.
Updated the documentation to include the configuration for the Reset Digital adapter.
Testing:

Unit tests have been written and verified to ensure the adapter works correctly.
Manual testing has been performed to verify the integration with Reset Digital.

Notes:

This system is based on single bid, so it's based on that premise.

Related Issues:

}

func getBidType(imp openrtb2.Imp) (openrtb_ext.BidType, error) {
if imp.Banner != nil {

Choose a reason for hiding this comment

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

Consider this as a suggestion. The current implementation follows an anti-pattern, assumes that if there is a multi-format request, the media type defaults to openrtb_ext.BidTypeBanner, nil. Prebid server expects the media type to be explicitly set in the adapter response. Therefore, we strongly recommend implementing a pattern where the adapter server sets the MType field in the response to accurately determine the media type for the impression.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Implemented as suggested

Copy link
Contributor

Choose a reason for hiding this comment

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

Implemented as suggested

could you point out or link where MType changes are implemented?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry, it was addressed on the point that we support only single format bids, so we could assume the anti pattern. Anyway, it would be more advisable to change to the normal pattern?

Copy link
Contributor

Choose a reason for hiding this comment

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

Anyway, it would be more advisable to change to the normal pattern?

Prebid team recommends using MType field. But if it's not doable then current change suffices single format bid. @bruno-siira should mention in Bidder docs that adapter expects only single format bids in the incoming request

Copy link
Contributor Author

Choose a reason for hiding this comment

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

When we're talking about the Bidder Docs what is this file exacly @onkarvhanumante

Copy link
Contributor

Choose a reason for hiding this comment

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

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, 3762676

resetdigital

Refer here for heat map coverage report

github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:57:	Builder			0.0%
github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:69:	getHeaders		100.0%
github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:86:	addNonEmptyHeaders	100.0%
github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:94:	getReferer		66.7%
github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:102:	getCurrency		66.7%
github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:110:	MakeRequests		72.2%
github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:151:	processDataFromRequest	94.4%
github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:186:	MakeBids		72.2%
github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:222:	getBidFromResponse	93.3%
github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:257:	getBidPrice		66.7%
github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:264:	getBidType		28.6%
total:										(statements)		74.2%

Implementation of suggestions
Copy link

github-actions bot commented Jul 3, 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, 989c565

resetdigital

Refer here for heat map coverage report

github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:57:	Builder			0.0%
github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:69:	getHeaders		100.0%
github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:86:	addNonEmptyHeaders	100.0%
github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:94:	getReferer		66.7%
github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:102:	getCurrency		66.7%
github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:110:	MakeRequests		72.2%
github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:151:	processDataFromRequest	94.4%
github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:186:	MakeBids		78.9%
github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:222:	getBidFromResponse	92.3%
github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:255:	getBidPrice		66.7%
github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:262:	getBidType		28.6%
github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:274:	getBidTypes		70.0%
total:										(statements)		74.5%

Copy link
Contributor Author

@bruno-siira bruno-siira left a comment

Choose a reason for hiding this comment

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

We have now a Builder

Copy link
Contributor Author

@bruno-siira bruno-siira left a comment

Choose a reason for hiding this comment

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

There is a schema now

Copy link

github-actions bot commented Jul 5, 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, 4482bc9

resetdigital

Refer here for heat map coverage report

github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:55:	Builder			0.0%
github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:67:	getHeaders		100.0%
github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:84:	addNonEmptyHeaders	100.0%
github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:92:	getReferer		66.7%
github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:100:	getCurrency		66.7%
github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:108:	MakeRequests		72.2%
github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:149:	processDataFromRequest	94.4%
github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:184:	MakeBids		78.9%
github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:220:	getBidFromResponse	92.3%
github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:253:	getBidPrice		66.7%
github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:260:	getBidType		28.6%
github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:272:	getBidTypes		70.0%
total:										(statements)		74.5%

@onkarvhanumante onkarvhanumante self-assigned this Jul 9, 2024
}
if reqImp.Audio != nil {
return openrtb_ext.BidTypeAudio
}

Choose a reason for hiding this comment

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

Consider this as a suggestion. The current implementation follows an anti-pattern, assumes that if there is a multi-format request, the media type defaults to openrtb_ext.BidTypeAudio. Prebid server expects the media type to be explicitly set in the adapter response. Therefore, we strongly recommend implementing a pattern where the adapter server sets the MType field in the response to accurately determine the media type for the impression.

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, 0623316

resetdigital

Refer here for heat map coverage report

github.com/prebid/prebid-server/v3/adapters/resetdigital/resetdigital.go:67:	Builder			80.0%
github.com/prebid/prebid-server/v3/adapters/resetdigital/resetdigital.go:78:	getHeaders		100.0%
github.com/prebid/prebid-server/v3/adapters/resetdigital/resetdigital.go:103:	addNonEmptyHeaders	100.0%
github.com/prebid/prebid-server/v3/adapters/resetdigital/resetdigital.go:111:	MakeRequests		87.5%
github.com/prebid/prebid-server/v3/adapters/resetdigital/resetdigital.go:149:	processDataFromRequest	97.1%
github.com/prebid/prebid-server/v3/adapters/resetdigital/resetdigital.go:209:	MakeBids		95.8%
github.com/prebid/prebid-server/v3/adapters/resetdigital/resetdigital.go:257:	getBidFromResponse	100.0%
github.com/prebid/prebid-server/v3/adapters/resetdigital/resetdigital.go:282:	getBidType		100.0%
github.com/prebid/prebid-server/v3/adapters/resetdigital/resetdigital.go:294:	GetMediaTypeForImp	100.0%
total:										(statements)		95.5%

@dirk-rd
Copy link
Contributor

dirk-rd commented Dec 22, 2024

@bsardo, this PR is once again ready for review.

@bsardo bsardo added the adapter label Jan 6, 2025
}

func getBidType(imp openrtb2.Imp) (openrtb_ext.BidType, error) {
if imp.Banner != nil {

Choose a reason for hiding this comment

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

Consider this as a suggestion. The current implementation follows an anti-pattern, assumes that if there is a multi-format request, the media type defaults to openrtb_ext.BidTypeBanner, nil. Prebid server expects the media type to be explicitly set in the adapter response. Therefore, we strongly recommend implementing a pattern where the adapter server sets the MType field in the response to accurately determine the media type for the impression.

return openrtb_ext.BidTypeVideo, nil
} else if imp.Audio != nil {
return openrtb_ext.BidTypeAudio, nil
}

Choose a reason for hiding this comment

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

Consider this as a suggestion. The current implementation follows an anti-pattern, assumes that if there is a multi-format request, the media type defaults to openrtb_ext.BidTypeVideo, nil. Prebid server expects the media type to be explicitly set in the adapter response. Therefore, we strongly recommend implementing a pattern where the adapter server sets the MType field in the response to accurately determine the media type for the impression.

return openrtb_ext.BidTypeBanner, nil
} else if imp.Video != nil {
return openrtb_ext.BidTypeVideo, nil
} else if imp.Audio != nil {

Choose a reason for hiding this comment

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

Consider this as a suggestion. The current implementation follows an anti-pattern, assumes that if there is a multi-format request, the media type defaults to openrtb_ext.BidTypeAudio, nil. Prebid server expects the media type to be explicitly set in the adapter response. Therefore, we strongly recommend implementing a pattern where the adapter server sets the MType field in the response to accurately determine the media type for the impression.

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, 8ed4059

resetdigital

Refer here for heat map coverage report

github.com/prebid/prebid-server/v3/adapters/resetdigital/resetdigital.go:67:	Builder			80.0%
github.com/prebid/prebid-server/v3/adapters/resetdigital/resetdigital.go:78:	getHeaders		100.0%
github.com/prebid/prebid-server/v3/adapters/resetdigital/resetdigital.go:103:	addNonEmptyHeaders	100.0%
github.com/prebid/prebid-server/v3/adapters/resetdigital/resetdigital.go:111:	MakeRequests		87.5%
github.com/prebid/prebid-server/v3/adapters/resetdigital/resetdigital.go:149:	processDataFromRequest	97.1%
github.com/prebid/prebid-server/v3/adapters/resetdigital/resetdigital.go:209:	MakeBids		85.7%
github.com/prebid/prebid-server/v3/adapters/resetdigital/resetdigital.go:262:	findRequestImpByID	75.0%
github.com/prebid/prebid-server/v3/adapters/resetdigital/resetdigital.go:271:	getBidFromResponse	100.0%
github.com/prebid/prebid-server/v3/adapters/resetdigital/resetdigital.go:296:	getBidType		100.0%
github.com/prebid/prebid-server/v3/adapters/resetdigital/resetdigital.go:308:	GetMediaTypeForImp	100.0%
total:										(statements)		92.9%

bidResponse := adapters.NewBidderResponseWithBidsCapacity(len(request.Imp))
// Ensure there is exactly one bid in the response
if len(response.Bids) != 1 {
return nil, []error{fmt.Errorf("expected exactly one bid in the response, but got %d", len(response.Bids))}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please achieve code coverage of this error case by adding a supplemental JSON test (e.g. multiple-bids.json) that contains more than one bid.

Copy link
Contributor

Choose a reason for hiding this comment

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

Done.

// Map the incoming impression to its ID for media type determination
requestImp, found := findRequestImpByID(request.Imp, resetDigitalBid.ImpID)
if !found {
return nil, []error{fmt.Errorf("no matching impression found for ImpID %s", resetDigitalBid.ImpID)}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please achieve code coverage of this error case by adding a supplemental JSON test (e.g. imp-id-mismatch.json) with a bid response imp id that does not match the bid request imp id.

Copy link
Contributor

Choose a reason for hiding this comment

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

Done.

@@ -207,51 +207,65 @@ func processDataFromRequest(requestData *openrtb2.BidRequest, imp openrtb2.Imp,
}

func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.RequestData, responseData *adapters.ResponseData) (*adapters.BidderResponse, []error) {
// Return early if the response contains no content
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nitpick: I suggest removing all of the comments in this function to tighten this up. IMO your code is self explanatory now. You can leave it of course if you think it will benefit your developers.

Copy link
Contributor

Choose a reason for hiding this comment

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

Done.

if err := adapters.CheckResponseStatusCodeForErrors(responseData); err != nil {
return nil, []error{err}
}

// Parse the response body into a single bid response
var response resetDigitalBidResponse
if err := json.Unmarshal(responseData.Body, &response); err != nil {
return nil, []error{err}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please achieve code coverage of this error case by adding a supplemental JSON test (e.g. malformed-response.json) that contains a malformed response body. This can be achieved by simply setting your mock response body to a string instead of an object.

Copy link
Contributor

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, fe2c572

resetdigital

Refer here for heat map coverage report

github.com/prebid/prebid-server/v3/adapters/resetdigital/resetdigital.go:67:	Builder			80.0%
github.com/prebid/prebid-server/v3/adapters/resetdigital/resetdigital.go:78:	getHeaders		100.0%
github.com/prebid/prebid-server/v3/adapters/resetdigital/resetdigital.go:103:	addNonEmptyHeaders	100.0%
github.com/prebid/prebid-server/v3/adapters/resetdigital/resetdigital.go:111:	MakeRequests		87.5%
github.com/prebid/prebid-server/v3/adapters/resetdigital/resetdigital.go:149:	processDataFromRequest	97.1%
github.com/prebid/prebid-server/v3/adapters/resetdigital/resetdigital.go:209:	MakeBids		100.0%
github.com/prebid/prebid-server/v3/adapters/resetdigital/resetdigital.go:253:	findRequestImpByID	100.0%
github.com/prebid/prebid-server/v3/adapters/resetdigital/resetdigital.go:262:	getBidFromResponse	100.0%
github.com/prebid/prebid-server/v3/adapters/resetdigital/resetdigital.go:287:	getBidType		100.0%
github.com/prebid/prebid-server/v3/adapters/resetdigital/resetdigital.go:299:	GetMediaTypeForImp	100.0%
total:										(statements)		96.4%

return openrtb_ext.BidTypeVideo, nil
} else if imp.Audio != nil {
return openrtb_ext.BidTypeAudio, nil
}

Choose a reason for hiding this comment

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

Consider this as a suggestion. The current implementation follows an anti-pattern, assumes that if there is a multi-format request, the media type defaults to openrtb_ext.BidTypeBanner, nil. Prebid server expects the media type to be explicitly set in the adapter response. Therefore, we strongly recommend implementing a pattern where the adapter server sets the MType field in the response to accurately determine the media type for the impression.

return openrtb_ext.BidTypeVideo, nil
} else if imp.Audio != nil {
return openrtb_ext.BidTypeAudio, nil
}

Choose a reason for hiding this comment

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

Consider this as a suggestion. The current implementation follows an anti-pattern, assumes that if there is a multi-format request, the media type defaults to openrtb_ext.BidTypeVideo, nil. Prebid server expects the media type to be explicitly set in the adapter response. Therefore, we strongly recommend implementing a pattern where the adapter server sets the MType field in the response to accurately determine the media type for the impression.

return openrtb_ext.BidTypeVideo, nil
} else if imp.Audio != nil {
return openrtb_ext.BidTypeAudio, nil
}

Choose a reason for hiding this comment

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

Consider this as a suggestion. The current implementation follows an anti-pattern, assumes that if there is a multi-format request, the media type defaults to openrtb_ext.BidTypeAudio, nil. Prebid server expects the media type to be explicitly set in the adapter response. Therefore, we strongly recommend implementing a pattern where the adapter server sets the MType field in the response to accurately determine the media type for the impression.


func GetMediaTypeForImp(reqImp openrtb2.Imp) openrtb_ext.BidType {

if reqImp.Video != nil {

Choose a reason for hiding this comment

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

Consider this as a suggestion. The current implementation follows an anti-pattern, assumes that if there is a multi-format request, the media type defaults to openrtb_ext.BidTypeVideo. Prebid server expects the media type to be explicitly set in the adapter response. Therefore, we strongly recommend implementing a pattern where the adapter server sets the MType field in the response to accurately determine the media type for the impression.

if reqImp.Video != nil {
return openrtb_ext.BidTypeVideo
}
if reqImp.Audio != nil {

Choose a reason for hiding this comment

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

Consider this as a suggestion. The current implementation follows an anti-pattern, assumes that if there is a multi-format request, the media type defaults to openrtb_ext.BidTypeAudio. Prebid server expects the media type to be explicitly set in the adapter response. Therefore, we strongly recommend implementing a pattern where the adapter server sets the MType field in the response to accurately determine the media type for the impression.

@dirk-rd
Copy link
Contributor

dirk-rd commented Jan 25, 2025

Ready for review again, @bsardo, please!

Copy link
Collaborator

@hhhjort hhhjort left a comment

Choose a reason for hiding this comment

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

LGTM

@bsardo bsardo merged commit 0c90e46 into prebid:master Jan 28, 2025
5 of 6 checks passed
@bretg
Copy link
Contributor

bretg commented Jan 30, 2025

@bruno-siira - are there any differences between this and the PBS-Java version of your adapter or is this a direct port?

scr-oath pushed a commit to scr-oath/prebid-server that referenced this pull request Mar 24, 2025
Co-authored-by: Bruno Jacinto <b.jacinto@gmail.com>
Co-authored-by: Emmanuel <eogbonna097@gmail.com>
Co-authored-by: dirk-rd <dirk@resetdigital.co>
shunj-nb pushed a commit to ParticleMedia/prebid-server that referenced this pull request Jun 13, 2025
Co-authored-by: Bruno Jacinto <b.jacinto@gmail.com>
Co-authored-by: Emmanuel <eogbonna097@gmail.com>
Co-authored-by: dirk-rd <dirk@resetdigital.co>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants