-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Synapse HX Bid Adapter : initial release #15331
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
Merged
patmmccann
merged 13 commits into
prebid:master
from
prebid-compas:implement-synapse-hx-adapter
Aug 6, 2026
+741
−0
Merged
Changes from 1 commit
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
e8a3686
Implementation of the Synapse HX adapter
prebid-compas c4cb58f
Adjustments according to review
prebid-compas c74bf96
Merge branch 'master' into implement-synapse-hx-adapter
prebid-compas 5fddad7
Adjustments according to review # 2
prebid-compas 02915df
Merge branch 'master' into implement-synapse-hx-adapter
prebid-compas 7f52687
Merge branch 'master' into implement-synapse-hx-adapter
prebid-compas 03601a4
Merge branch 'master' into implement-synapse-hx-adapter
prebid-compas 1ea3ace
Merge branch 'master' into implement-synapse-hx-adapter
prebid-compas 935f135
Migrate to TypeScript
prebid-compas 4c2a029
Merge branch 'master' into implement-synapse-hx-adapter
prebid-compas 3c0e1ab
Remove onBidWon
prebid-compas 97a7e37
Merge branch 'master' into implement-synapse-hx-adapter
prebid-compas bb03e4a
Merge branch 'master' into implement-synapse-hx-adapter
prebid-compas 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 hidden or 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,161 @@ | ||
| import { registerBidder } from '../src/adapters/bidderFactory.js'; | ||
| import { BANNER, VIDEO } from '../src/mediaTypes.js'; | ||
| import { logError, isFn, isPlainObject, formatQS } from '../src/utils.js'; | ||
| import { ortbConverter } from '../libraries/ortbConverter/converter.js'; | ||
| import { toOrtb26 } from '../libraries/ortb2.5Translator/translator.js'; | ||
| import { getUserSyncParams } from '../libraries/userSyncUtils/userSyncUtils.js'; | ||
|
|
||
| const BIDDER_CODE = 'synapsehx'; | ||
| const METHOD = 'POST'; | ||
| const ENDPOINT_URL = `https://rtb.hx.compasonline.com/pbjs`; | ||
|
|
||
| function getMediaType(bid) { | ||
| if (bid.mtype) { | ||
| const mtypeToMediaType = { 1: BANNER, 2: VIDEO }; | ||
| return mtypeToMediaType[bid.mtype]; | ||
| } | ||
| return bid?.ext?.prebid?.type; | ||
| } | ||
|
|
||
| const converter = ortbConverter({ | ||
| imp(buildImp, bidRequest, context) { | ||
| const imp = buildImp(bidRequest, context); | ||
|
|
||
| if (bidRequest?.params?.adUnitId) { | ||
| imp.tagid = bidRequest.params.adUnitId; | ||
| } | ||
|
|
||
| const floor = getBidFloor(bidRequest); | ||
| if (floor) { | ||
| imp.bidfloor = floor; | ||
| imp.bidfloorcur = 'USD'; | ||
| } | ||
|
|
||
| return imp; | ||
| }, | ||
| request(buildRequest, imps, bidderRequest, context) { | ||
| return buildRequest(imps, bidderRequest, context); | ||
| }, | ||
| bidResponse(buildBidResponse, bid, context) { | ||
| const isValidBidType = Object.keys(context.bidRequest.mediaTypes).includes(getMediaType(bid)); | ||
|
|
||
| if (isValidBidType) { | ||
| return buildBidResponse(bid, context); | ||
| } | ||
|
|
||
| logError('Incorrect bid type for bid: ', bid.id); | ||
| }, | ||
| context: { | ||
| netRevenue: true, | ||
| ttl: 30 | ||
| }, | ||
| translator: toOrtb26 | ||
| }); | ||
|
|
||
| function getBidFloor(bid) { | ||
| if (isFn(bid.getFloor)) { | ||
| const floor = bid.getFloor({ | ||
| currency: 'USD', | ||
| mediaType: '*', | ||
| size: '*' | ||
| }); | ||
| if (isPlainObject(floor) && !isNaN(floor.floor) && floor.currency === 'USD') { | ||
| return floor.floor; | ||
| } | ||
| } | ||
| return bid.params?.floor; | ||
| } | ||
|
|
||
| function isValidBidFloorCurrency(bid) { | ||
| return !bid.ortb2Imp?.bidfloorcur || bid.ortb2Imp.bidfloorcur === 'USD'; | ||
| } | ||
|
|
||
| function isValidParams(bid) { | ||
| const tenantId = bid?.params?.tenantId; | ||
| const adUnitId = bid?.params?.adUnitId; | ||
| return typeof tenantId === 'string' && tenantId.length > 0 && | ||
| (adUnitId == null || (typeof adUnitId === 'string' && adUnitId.length > 0)); | ||
| } | ||
|
|
||
| function makeUrl(bidRequests) { | ||
| return `${ENDPOINT_URL}?${formatQS({ pid: bidRequests[0].params.tenantId })}`; | ||
| } | ||
|
|
||
| export const spec = { | ||
| code: BIDDER_CODE, | ||
| supportedMediaTypes: [VIDEO, BANNER], | ||
| isBidRequestValid: (bid) => !!bid && isValidParams(bid) && isValidBidFloorCurrency(bid), | ||
|
|
||
| buildRequests: (bidRequests, bidderRequest) => { | ||
| const data = converter.toORTB({ bidRequests, bidderRequest }); | ||
|
|
||
| return [{ | ||
| method: METHOD, | ||
| url: makeUrl(bidRequests), | ||
| options: { | ||
| contentType: 'application/json', | ||
Check warningCode scanning / CodeQL Application/json request type in bidder Warning
application/json request type triggers preflight requests and may increase bidder timeouts
|
||
|
patmmccann marked this conversation as resolved.
Outdated
github-advanced-security[bot] marked this conversation as resolved.
Fixed
|
||
| withCredentials: true, | ||
| crossOrigin: true | ||
| }, | ||
| data: data, | ||
| }]; | ||
| }, | ||
|
|
||
| interpretResponse: ({ body }, req) => { | ||
| if (!body || !body.seatbid || body.seatbid.length === 0) { | ||
| return []; | ||
| } | ||
| return converter.fromORTB({ | ||
| response: body, | ||
| request: req.data | ||
| }); | ||
| }, | ||
|
|
||
| onTimeout: (data) => { }, | ||
|
|
||
| onBidWon: (bid) => { | ||
| if (bid.nurl) { | ||
| const url = new URL(bid.nurl); | ||
| url.searchParams.set('cpm', bid.cpm); | ||
| fetch(url.toString(), { method: 'GET', keepalive: true }).catch(err => | ||
| logError('Error triggering win notification', err) | ||
| ); | ||
| } | ||
| }, | ||
|
|
||
| onSetTargeting: (bid) => { }, | ||
|
|
||
| getUserSyncs: function(syncOptions, serverResponses, gdprConsent, uspConsent, gppConsent) { | ||
| const syncs = []; | ||
|
|
||
| if (serverResponses && (syncOptions.iframeEnabled || syncOptions.pixelEnabled)) { | ||
| const params = formatQS(getUserSyncParams(gdprConsent, uspConsent, gppConsent)); | ||
|
|
||
| if (syncOptions.iframeEnabled) { | ||
| serverResponses.forEach(response => { | ||
| const iframeUrl = response?.body?.ext?.[BIDDER_CODE]?.sync?.iframe; | ||
| if (iframeUrl) { | ||
| syncs.push({ | ||
| type: "iframe", | ||
| url: `${iframeUrl}${params ? `${iframeUrl.lastIndexOf('?') !== -1 ? '&' : '?'}${params}` : ''}`, | ||
| }); | ||
| } | ||
| }); | ||
| } else if (syncOptions.pixelEnabled) { | ||
| serverResponses.forEach(response => { | ||
| const images = response?.body?.ext?.[BIDDER_CODE]?.sync?.image || []; | ||
| images.forEach(image => { | ||
| syncs.push({ | ||
| type: "image", | ||
| url: `${image}${params ? `${image.lastIndexOf('?') !== -1 ? '&' : '?'}${params}` : ''}`, | ||
| }); | ||
| }); | ||
| }); | ||
| } | ||
| } | ||
|
|
||
| return syncs; | ||
| } | ||
| }; | ||
|
|
||
| registerBidder(spec); | ||
This file contains hidden or 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,76 @@ | ||
| # Overview | ||
|
|
||
| ``` | ||
| Module Name: Synapse HX Bidder Adapter | ||
| Module Type: Bidder Adapter | ||
| Maintainer: prebid@compas-inc.com | ||
| ``` | ||
|
|
||
| # Description | ||
|
|
||
| The Synapse HX Bidder Adapter enables publishers to integrate with Synapse HX exchange for banner and video ad formats. The adapter supports OpenRTB standards and processes bid requests efficiently using the Prebid.js framework. | ||
|
|
||
| # Test Parameters | ||
|
|
||
| ## Sample Banner Ad Unit | ||
| ``` | ||
| var adUnits = [ | ||
| { | ||
| code: 'test-div', | ||
| mediaTypes: { | ||
| banner: { | ||
| sizes: [[300,250]] | ||
| } | ||
| }, | ||
| bids: [ | ||
| { | ||
| bidder: 'synapsehx', | ||
| params: { | ||
| // REQUIRED - Synapse HX tenant identifier | ||
| tenantId: 'your-account-id', | ||
| // OPTIONAL - Synapse HX ad unit identifier | ||
| adUnitId: 'ad-unit-id' | ||
| } | ||
| } | ||
| ] | ||
| } | ||
| ]; | ||
| ``` | ||
|
|
||
| ## Sample Video Ad Unit | ||
| ``` | ||
| var videoAdUnits = [ | ||
| { | ||
| code: 'test-div-video', | ||
| mediaTypes: { | ||
| video: { | ||
| context: 'instream', | ||
| placement: 1, | ||
| playerSize: [640, 360], | ||
| mimes: ['video/mp4'], | ||
| protocols: [2, 3, 5, 6], | ||
| api: [2], | ||
| maxduration: 30, | ||
| linearity: 1, | ||
| playbackmethod: [2] | ||
| } | ||
| }, | ||
| bids: [ | ||
| { | ||
| bidder: 'synapsehx', | ||
| params: { | ||
| // REQUIRED - Synapse HX tenant identifier | ||
| tenantId: 'your-account-id', | ||
| // OPTIONAL - Synapse HX ad unit identifier | ||
| adUnitId: 'ad-unit-id' | ||
| } | ||
| } | ||
| ] | ||
| } | ||
| ]; | ||
| ``` | ||
|
|
||
| # Additional Notes | ||
| - The adapter processes requests via OpenRTB 2.6 standards. | ||
| - Ensure that the `tenantId` parameter is set correctly for your integration. | ||
| - The `adUnitId` parameter is optional. |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.