-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Blockthrough Bid Adapter: initial release #10870
Merged
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
79a0a94
PE-87: Implement Prebid Adapter (#1)
PavloMalashnyak 610b6c2
PE-110: Add user sync logic to the Prebid Adapter (#3)
PavloMalashnyak 6139fa7
PE-111: BT Prebid Adapter can request AA ads or regular ads (#2)
PavloMalashnyak df77fa8
PE-120: Send Prebid Bidder info to BT Server (#4)
PavloMalashnyak 80d2b59
PE-123: Add More Metadata in site.ext.blockthrough (#5)
PavloMalashnyak 0edb357
PE-000: check if blockthrough is defined (#6)
PavloMalashnyak b28a062
PE-87: remove BT specific logic (#7)
PavloMalashnyak 648153b
Implement Blockthrough Prebid Adapter
PavloMalashnyak 4712e10
Merge branch 'bt-master' of https://github.com/blockthrough/Prebid.js…
PavloMalashnyak 590d614
PE-87: Implement Prebid Adapter - misc fixes (#9)
PavloMalashnyak 3ce864c
PE-000: fix test
PavloMalashnyak f7b3c92
BP-74: Change the way we enable debug (#10)
PavloMalashnyak 66b939a
BP-79: Send GPID as a part of `imp[].ext` (#11)
PavloMalashnyak ac2d753
BP-90: Update Cookie Sync Logic (#12)
PavloMalashnyak 3c44cdf
BP-55: Re-add endpoint URLs (#13)
PavloMalashnyak 1a67387
BP-91: Add prebid JS version to auction request (#14)
PavloMalashnyak 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,204 @@ | ||
import { registerBidder } from '../src/adapters/bidderFactory.js'; | ||
import { deepSetValue, isPlainObject, logWarn } from '../src/utils.js'; | ||
import { BANNER } from '../src/mediaTypes.js'; | ||
import { ortbConverter } from '../libraries/ortbConverter/converter.js'; | ||
|
||
const BIDDER_CODE = 'blockthrough'; | ||
const GVLID = 815; | ||
const ENDPOINT_URL = 'https://pbs.btloader.com/openrtb2/auction'; | ||
const SYNC_URL = 'https://cdn.btloader.com/user_sync.html'; | ||
|
||
const CONVERTER = ortbConverter({ | ||
context: { | ||
netRevenue: true, | ||
ttl: 60, | ||
}, | ||
imp, | ||
request, | ||
bidResponse, | ||
}); | ||
|
||
/** | ||
* Builds an impression object for the ORTB 2.5 request. | ||
* | ||
* @param {function} buildImp - The function for building an imp object. | ||
* @param {Object} bidRequest - The bid request object. | ||
* @param {Object} context - The context object. | ||
* @returns {Object} The ORTB 2.5 imp object. | ||
*/ | ||
function imp(buildImp, bidRequest, context) { | ||
const imp = buildImp(bidRequest, context); | ||
const { params, ortb2Imp } = bidRequest; | ||
|
||
if (params) { | ||
deepSetValue(imp, 'ext', params); | ||
} | ||
if (ortb2Imp?.ext?.gpid) { | ||
deepSetValue(imp, 'ext.gpid', ortb2Imp.ext.gpid); | ||
} | ||
|
||
return imp; | ||
} | ||
|
||
/** | ||
* Builds a request object for the ORTB 2.5 request. | ||
* | ||
* @param {function} buildRequest - The function for building a request object. | ||
* @param {Array} imps - An array of ORTB 2.5 impression objects. | ||
* @param {Object} bidderRequest - The bidder request object. | ||
* @param {Object} context - The context object. | ||
* @returns {Object} The ORTB 2.5 request object. | ||
*/ | ||
function request(buildRequest, imps, bidderRequest, context) { | ||
const request = buildRequest(imps, bidderRequest, context); | ||
deepSetValue(request, 'ext.prebid.channel', { | ||
name: 'pbjs', | ||
version: '$prebid.version$', | ||
}); | ||
|
||
if (window.location.href.includes('btServerTest=true')) { | ||
request.test = 1; | ||
} | ||
|
||
return request; | ||
} | ||
|
||
/** | ||
* Processes a bid response using the provided build function, bid, and context. | ||
* | ||
* @param {Function} buildBidResponse - The function to build the bid response. | ||
* @param {Object} bid - The bid object to include in the bid response. | ||
* @param {Object} context - The context object containing additional information. | ||
* @returns {Object} - The processed bid response. | ||
*/ | ||
function bidResponse(buildBidResponse, bid, context) { | ||
const bidResponse = buildBidResponse(bid, context); | ||
const { seat } = context.seatbid || {}; | ||
bidResponse.btBidderCode = seat; | ||
|
||
return bidResponse; | ||
} | ||
|
||
/** | ||
* Checks if a bid request is valid. | ||
* | ||
* @param {Object} bid - The bid request object. | ||
* @returns {boolean} True if the bid request is valid, false otherwise. | ||
*/ | ||
function isBidRequestValid(bid) { | ||
if (!isPlainObject(bid.params) || !Object.keys(bid.params).length) { | ||
logWarn('BT Bid Adapter: bid params must be provided.'); | ||
return false; | ||
} | ||
|
||
return true; | ||
} | ||
|
||
/** | ||
* Builds the bid requests for the BT Service. | ||
* | ||
* @param {Array} validBidRequests - An array of valid bid request objects. | ||
* @param {Object} bidderRequest - The bidder request object. | ||
* @returns {Array} An array of BT Service bid requests. | ||
*/ | ||
function buildRequests(validBidRequests, bidderRequest) { | ||
const data = CONVERTER.toORTB({ | ||
bidRequests: validBidRequests, | ||
bidderRequest, | ||
}); | ||
|
||
return [ | ||
{ | ||
method: 'POST', | ||
url: ENDPOINT_URL, | ||
data, | ||
bids: validBidRequests, | ||
}, | ||
]; | ||
} | ||
|
||
/** | ||
* Interprets the server response and maps it to bids. | ||
* | ||
* @param {Object} serverResponse - The server response object. | ||
* @param {Object} request - The request object. | ||
* @returns {Array} An array of bid objects. | ||
*/ | ||
function interpretResponse(serverResponse, request) { | ||
if (!serverResponse || !request) { | ||
return []; | ||
} | ||
|
||
return CONVERTER.fromORTB({ | ||
response: serverResponse.body, | ||
request: request.data, | ||
}).bids; | ||
} | ||
|
||
/** | ||
* Generates user synchronization data based on provided options and consents. | ||
* | ||
* @param {Object} syncOptions - Synchronization options. | ||
* @param {Object[]} serverResponses - An array of server responses. | ||
* @param {Object} gdprConsent - GDPR consent information. | ||
* @param {string} uspConsent - US Privacy consent string. | ||
* @param {Object} gppConsent - Google Publisher Policies (GPP) consent information. | ||
* @returns {Object[]} An array of user synchronization objects. | ||
*/ | ||
function getUserSyncs( | ||
syncOptions, | ||
serverResponses, | ||
gdprConsent, | ||
uspConsent, | ||
gppConsent | ||
) { | ||
if (!syncOptions.iframeEnabled || !serverResponses?.length) { | ||
return []; | ||
} | ||
|
||
const bidderCodes = new Set(); | ||
serverResponses.forEach((serverResponse) => { | ||
if (serverResponse?.body?.ext?.responsetimemillis) { | ||
Object.keys(serverResponse.body.ext.responsetimemillis).forEach( | ||
bidderCodes.add, | ||
bidderCodes | ||
); | ||
} | ||
}); | ||
|
||
if (!bidderCodes.size) { | ||
return []; | ||
} | ||
|
||
const syncs = []; | ||
const syncUrl = new URL(SYNC_URL); | ||
syncUrl.searchParams.set('bidders', [...bidderCodes].join(',')); | ||
|
||
if (gdprConsent) { | ||
syncUrl.searchParams.set('gdpr', Number(gdprConsent.gdprApplies)); | ||
syncUrl.searchParams.set('gdpr_consent', gdprConsent.consentString); | ||
} | ||
if (gppConsent) { | ||
syncUrl.searchParams.set('gpp', gppConsent.gppString); | ||
syncUrl.searchParams.set('gpp_sid', gppConsent.applicableSections); | ||
} | ||
if (uspConsent) { | ||
syncUrl.searchParams.set('us_privacy', uspConsent); | ||
} | ||
|
||
syncs.push({ type: 'iframe', url: syncUrl.href }); | ||
|
||
return syncs; | ||
} | ||
|
||
export const spec = { | ||
code: BIDDER_CODE, | ||
gvlid: GVLID, | ||
supportedMediaTypes: [BANNER], | ||
isBidRequestValid, | ||
buildRequests, | ||
interpretResponse, | ||
getUserSyncs, | ||
}; | ||
|
||
registerBidder(spec); |
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 |
---|---|---|
@@ -0,0 +1,70 @@ | ||
# Overview | ||
|
||
**Module Name**: BT Bidder Adapter | ||
**Module Type**: Bidder Adapter | ||
**Maintainer**: engsupport@blockthrough.com | ||
|
||
# Description | ||
|
||
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. Behind the scenes, the BT Service further disperses requests to various configured exchanges. This operational model closely resembles that of Prebid Server, where a single request is made from the client side, and responses are gathered from multiple exchanges. | ||
|
||
The BT adapter requires setup and approval from the Blockthrough team. Please reach out to marketing@blockthrough.com for more information. | ||
|
||
# Bid Params | ||
|
||
| Key | Scope | Type | Description | | ||
| ------ | -------- | ------ | -------------------------------------------------------------- | | ||
| bidder | Required | Object | Bidder configuration. Could configure several bidders this way | | ||
|
||
# Bidder Config | ||
|
||
Make sure to set required ab, orgID, websiteID values received after approval using `pbjs.setBidderConfig`. | ||
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. we should include an example of this |
||
|
||
## Example | ||
|
||
```javascript | ||
pbjs.setBidderConfig({ | ||
bidders: ['blockthrough'], | ||
config: { | ||
ortb2: { | ||
site: { | ||
ext: { | ||
blockthrough: { | ||
ab: false, | ||
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 define these values |
||
orgID: '4829301576428910', | ||
websiteID: '5654012389765432', | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}); | ||
``` | ||
|
||
## AdUnits configuration example | ||
|
||
```javascript | ||
var adUnits = [ | ||
{ | ||
code: 'banner-div-1', | ||
mediaTypes: { | ||
banner: { | ||
sizes: [[728, 90]], | ||
}, | ||
}, | ||
bids: [ | ||
{ | ||
bidder: 'blockthrough', | ||
params: { | ||
bidderA: { | ||
publisherId: 55555, | ||
}, | ||
bidderB: { | ||
zoneId: 12, | ||
}, | ||
}, | ||
}, | ||
], | ||
}, | ||
]; | ||
``` |
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.
you need a real url
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.
is that a requirement? I think we wanted to gate it behind approval.
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.
this doesnt appear to fall back to config; can you have a sensible default and fallback?