-
Notifications
You must be signed in to change notification settings - Fork 0
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
PE-87: Implement Prebid Adapter #1
PE-87: Implement Prebid Adapter #1
Conversation
modules/BTBidAdapter.js
Outdated
return []; | ||
} | ||
|
||
const seatBids = serverResponse?.body.seatbid || []; |
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 we already check for serverResponse
on line 37, I don't think we need the conditional operator after serverResponse
- maybe serverResponse.body?.seatbid
though?
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.
or we can combine this 2 checks:
const seatBids = serverResponse?.body?.seatbid || [];
if (!seatBids.length) {
return [];
}
btw, why the server responses with seatbid
while it seems to be an array?
modules/BTBidAdapter.js
Outdated
const newBids = seatBids.flatMap((seat) => { | ||
return seat.bid.map((bid) => { | ||
const bidResponse = getNewBidResponse(bid); | ||
bidResponse.btBidderCode = seat.seat; |
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.
Would it make sense to pass in seat
into getNewBidResponse
and have bidResponse.btBidderCode = seat.seat
be done inside the function instead?
Then I think you could do:
const newBids = seatBids.flatMap(seat =>
seat.bid.map(bid => getNewBidResponse(bid, seat))
);
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'm not super familiar with this, so feel free to leave it as is if you think it makes more sense to keep them separate
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.
bidResponse.btBidderCode = seat.seat;
was done this way, due to Relay implementation specific. so, if we can adjust this and probably rename (not to do seat.seat
), it would be great! I guess it requires BE change as well.
modules/BTBidAdapter.js
Outdated
const { ab, siteId, ...bidderParams } = params; | ||
const imps = []; | ||
|
||
for (const mediaType in mediaTypes) { |
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.
Personally I'm more of a fan of:
const imps = Object.entries(mediaTypes).map(([mediaType, currentType]) => ...)
Not really a huge deal either way; if you keep the for ... in
I wonder if you'd need to add a hasOwnProperty
check for safety
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.
do we expect mediaType
to be anything other than a banner
?
I mean, you specified supportedMediaTypes: [BANNER]
, but here if we get VIDEO
, we won't error. am I missing something?
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.
Rn we only support banner, but in future we plan to support other types. Might be worth adding check for supported media types
expect(requests[0].bids).to.equal(validBidRequests); | ||
}); | ||
|
||
it('should build post request ortb2 fields are not present', () => { |
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 this be something like: "should build post request even when ortb2 fields are not present"?
expect(bids.length).to.equal(0); | ||
}); | ||
|
||
it('should return bids array', () => { |
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.
Would it better to have this say something like: "should return bids array when serverResponse is defined and seatbid array is not empty"? Feel free to leave it as-is, I'm not really sure what the convention should be.
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.
did you skip logging on purpose?
why do we use this repo? are we going to merge it to our Prebid instance?
modules/BTBidAdapter.js
Outdated
isStr(bid.params.siteId) && | ||
!!bid.params?.ab && | ||
isBoolean(bid.params.ab) | ||
); |
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.
do you think we can add a log in case of invalid bidRequests
and specify what is missing/wrong?
also, we can move out bid.params
check to not repeat it:
bid.params && bid.params.siteId && ...
or even something like:
const { siteId, ab } = bid.params || {};
if (!siteId || !isStr(bid.params.siteId)) {
logError('BT Bid Adapter: siteId must be string type.');
return false;
}
modules/BTBidAdapter.js
Outdated
code: BIDDER_CODE, | ||
gvlid: GVLID, | ||
supportedMediaTypes: [BANNER], | ||
isBidRequestValid: (bid) => { |
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.
might be worth adding JSDoc, e.g.:
it's up to you, however I prefer to declare methods separately to make export spec
clearer:
function isBidRequestValid() { ... }
function buildRequests() { ... }
export const spec = {
code: BIDDER_CODE,
gvlid: GVLID,
supportedMediaTypes: [BANNER],
isBidRequestValid,
buildRequests,
...
}
modules/BTBidAdapter.md
Outdated
# Params | ||
|
||
- `ab` required, whether AdBlock is enabled. | ||
- `siteId` required, site 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.
modules/BTBidAdapter.md
Outdated
|
||
The BT service accepts industry standard OpenRTB 2.5 as its payload. The BT Bidder Adapter converts Prebid.js parameters into an OpenRTB 2.5 request. | ||
|
||
# Params |
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 this be Bid Params
?
modules/BTBidAdapter.md
Outdated
The BT Bidder Adapter provides an interface to the BT Service. The BT Bidder Adapter sends one request to the BT Service per ad unit, but the BT Service will then send one request to each configured exchange. This is functionally similar to Prebid Server. One client side request, bids from many exchanges. | ||
|
||
The BT service accepts industry standard OpenRTB 2.5 as its payload. The BT Bidder Adapter converts Prebid.js parameters into an OpenRTB 2.5 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.
so, this is just copy-pasted from Relay docs, we might be more creative, unless this is approved by Product
modules/BTBidAdapter.js
Outdated
const newBids = seatBids.flatMap((seat) => { | ||
return seat.bid.map((bid) => { | ||
const bidResponse = getNewBidResponse(bid); | ||
bidResponse.btBidderCode = seat.seat; |
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.
bidResponse.btBidderCode = seat.seat;
was done this way, due to Relay implementation specific. so, if we can adjust this and probably rename (not to do seat.seat
), it would be great! I guess it requires BE change as well.
modules/BTBidAdapter.js
Outdated
if (!seatBids.length) { | ||
return []; | ||
} | ||
const newBids = seatBids.flatMap((seat) => { |
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.
newBids
is redundant, we can just return seatBids.flatMap((seat) ...
modules/BTBidAdapter.js
Outdated
} | ||
|
||
function getBTRequest(validBidRequest, bidderRequest) { | ||
let 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.
could be const
modules/BTBidAdapter.js
Outdated
const imps = []; | ||
|
||
for (const mediaType in mediaTypes) { | ||
let bidImp = { |
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 be const
modules/BTBidAdapter.js
Outdated
const { ab, siteId, ...bidderParams } = params; | ||
const imps = []; | ||
|
||
for (const mediaType in mediaTypes) { |
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.
do we expect mediaType
to be anything other than a banner
?
I mean, you specified supportedMediaTypes: [BANNER]
, but here if we get VIDEO
, we won't error. am I missing something?
Yes, I didn't log anything as it isn't a part of acceptance criteria. But I could add some logs. We use this forked repo to contribute to Prebid.js in the future. I think we will merge this into up-prebid.js once they are merged to the Prebid.js |
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 wonder if the file name should start with a lowercase letter? I did not check the convention, but I don't see any files in Prebid that start with a capital letter.
* PE-87: Implement Prebid Adapter (#1) * PE-87: implement BT Bid Adapter * PE-87: rework adapter to use ortbConverter lib, make requested changes * PE-87: update imports * PE-110: Add user sync logic to the Prebid Adapter (#3) * PE-110: add user sync logic * PE-110: update userSync url * PE-110: check if iframe is enabled before setting params * PE-111: BT Prebid Adapter can request AA ads or regular ads (#2) * PE-120: Send Prebid Bidder info to BT Server (#4) * PE-120: add btBidderCode to the bid object * PE-120: use single quotes for logs string * PE-123: Add More Metadata in site.ext.blockthrough (#5) * PE-123: send additional meta data * PE-123: send auctionID under imp.ext.prebid.blockthrough * PE-123: use ortb2 config to set site.ext params * PE-123: sent auctionId in ext.prebid.blockthrough.auctionID * PE-123: update logs for bidderConfig setup * PE-000: check if blockthrough is defined (#6) * PE-87: remove BT specific logic (#7) * Implement Blockthrough Prebid Adapter * PE-87: Implement Prebid Adapter - misc fixes (#9) * PE-87: rename test file, add bidder config * PE-87: increase ttl * PE-000: fix test * BP-74: Change the way we enable debug (#10) * BP-79: Send GPID as a part of `imp[].ext` (#11) * BP-79: send gpid in imp.ext * BP-79: add optional operator * BP-90: Update Cookie Sync Logic (#12) * BP-90: pass bidder to cookie sync * BP-90: update sync logic, fix typo * BP-90: use const for syncs variable * BP-55: Re-add endpoint URLs (#13) * BP-91: Add prebid JS version to auction request (#14)
Story
PE-87
Implement BT Bid Adapter that send one request for each configured ad unit to the our prebid server
Testing
What tests did you perform to ensure that this code functions as expected?