-
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
Akcelo bid adapter : initial release #12583
Merged
patmmccann
merged 2 commits into
prebid:master
from
spacefoot:feature/add-akcelo-bidder
Dec 27, 2024
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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,148 @@ | ||
import { registerBidder } from '../src/adapters/bidderFactory.js'; | ||
import { BANNER, NATIVE, VIDEO } from '../src/mediaTypes.js'; | ||
import { deepSetValue, getParameterByName, logError } from '../src/utils.js'; | ||
import { ortbConverter } from '../libraries/ortbConverter/converter.js'; | ||
import { ORTB_MTYPES } from '../libraries/ortbConverter/processors/mediaType.js'; | ||
|
||
/** | ||
* @typedef {import('../src/adapters/bidderFactory.js').BidRequest} BidRequest | ||
* @typedef {import('../src/adapters/bidderFactory.js').BidderRequest} BidderRequest | ||
* @typedef {import('../src/adapters/bidderFactory.js').Bid} Bid | ||
* @typedef {import('../src/adapters/bidderFactory.js').ServerResponse} ServerResponse | ||
* @typedef {import('../src/adapters/bidderFactory.js').SyncOptions} SyncOptions | ||
* @typedef {import('../src/adapters/bidderFactory.js').UserSync} UserSync | ||
*/ | ||
|
||
const BIDDER_CODE = 'akcelo'; | ||
const COOKIE_SYNC_ENDPOINT = 'akcelo'; | ||
|
||
const AUCTION_URL = 'https://s2s.sportslocalmedia.com/openrtb2/auction'; | ||
const IFRAME_SYNC_URL = 'https://ads.sportslocalmedia.com/load-cookie.html'; | ||
|
||
const DEFAULT_TTL = 300; | ||
|
||
const akceloDemoIsOn = () => getParameterByName('akcelo_demo') === 'true'; | ||
|
||
export const converter = ortbConverter({ | ||
context: { | ||
netRevenue: true, | ||
ttl: DEFAULT_TTL, | ||
}, | ||
imp(buildImp, bidRequest, context) { | ||
const imp = buildImp(bidRequest, context); | ||
|
||
if (bidRequest.params.siteId) { | ||
deepSetValue(imp, 'ext.akcelo.siteId', bidRequest.params.siteId); | ||
} else { | ||
logError('Missing parameter : siteId'); | ||
} | ||
|
||
if (bidRequest.params.adUnitId) { | ||
deepSetValue(imp, 'ext.akcelo.adUnitId', bidRequest.params.adUnitId); | ||
} else { | ||
logError('Missing parameter : adUnitId'); | ||
} | ||
|
||
if (akceloDemoIsOn()) { | ||
deepSetValue(imp, 'ext.akcelo.test', 1); | ||
} | ||
|
||
return imp; | ||
}, | ||
request(buildRequest, imps, bidderRequest, context) { | ||
const request = buildRequest(imps, bidderRequest, context); | ||
|
||
deepSetValue(request, 'test', akceloDemoIsOn() ? 1 : 0); | ||
|
||
const siteId = bidderRequest.bids.map((bid) => bid.params.siteId).find(Boolean); | ||
deepSetValue(request, 'site.publisher.ext.prebid.parentAccount', siteId); | ||
|
||
return request; | ||
}, | ||
bidResponse(buildBidResponse, bid, context) { | ||
// In ORTB 2.5, bid responses do not specify their mediatype, which is something Prebid.js requires | ||
context.mediaType = bid.mtype && ORTB_MTYPES[bid.mtype] | ||
? ORTB_MTYPES[bid.mtype] | ||
: bid.ext?.prebid?.type; | ||
|
||
return buildBidResponse(bid, context); | ||
}, | ||
}); | ||
|
||
export const spec = { | ||
code: BIDDER_CODE, | ||
supportedMediaTypes: [BANNER, NATIVE, VIDEO], | ||
|
||
/** | ||
* Determines whether the given bid request is valid. | ||
* | ||
* @param {Bid} bid The bid to validate. | ||
* @return boolean True if this is a valid bid, and false otherwise. | ||
*/ | ||
isBidRequestValid(bid) { | ||
if (!bid?.params?.adUnitId) { | ||
logError("Missing required parameter 'adUnitId'"); | ||
return false; | ||
} | ||
if (!bid?.params?.siteId) { | ||
logError("Missing required parameter 'siteId'"); | ||
return false; | ||
} | ||
return true; | ||
}, | ||
/** | ||
* Make a server request from the list of BidRequests. | ||
* | ||
* @param {BidRequest[]} bidRequests A non-empty list of bid requests which should be sent to the Server. | ||
* @param {BidderRequest} bidderRequest bidder request object. | ||
* @return ServerRequest Info describing the request to the server. | ||
*/ | ||
buildRequests(bidRequests, bidderRequest) { | ||
const data = converter.toORTB({ bidRequests, bidderRequest }); | ||
|
||
return [{ method: 'POST', url: AUCTION_URL, data }]; | ||
}, | ||
|
||
/** | ||
* Unpack the response from the server into a list of bids. | ||
* | ||
* @param {ServerResponse} serverResponse A successful response from the server. | ||
* @param {BidRequest} bidRequest The bid request sent to the server. | ||
* @return {Bid[]} An array of bids which were nested inside the server. | ||
*/ | ||
interpretResponse(serverResponse, bidRequest) { | ||
const { bids } = converter.fromORTB({ | ||
response: serverResponse.body, | ||
request: bidRequest.data, | ||
}); | ||
|
||
return bids; | ||
}, | ||
|
||
/** | ||
* Register the user sync pixels which should be dropped after the auction. | ||
* | ||
* @param {SyncOptions} syncOptions Which user syncs are allowed? | ||
* @param {ServerResponse[]} serverResponses List of server's responses. | ||
* @param {*} gdprConsent | ||
* @param {*} uspConsent | ||
* @return {UserSync[]} The user syncs which should be dropped. | ||
*/ | ||
getUserSyncs(syncOptions, serverResponses, gdprConsent, uspConsent) { | ||
if (syncOptions.iframeEnabled) { | ||
let syncParams = `?endpoint=${COOKIE_SYNC_ENDPOINT}`; | ||
if (gdprConsent) { | ||
syncParams += `&gdpr=${gdprConsent.gdprApplies ? 1 : 0}`; | ||
syncParams += `&gdpr_consent=${encodeURIComponent(gdprConsent.consentString || '')}`; | ||
} | ||
if (uspConsent) { | ||
syncParams += `&us_privacy=${encodeURIComponent(uspConsent)}`; | ||
} | ||
|
||
return [{ type: 'iframe', url: IFRAME_SYNC_URL + syncParams }]; | ||
} | ||
return []; | ||
}, | ||
}; | ||
|
||
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,57 @@ | ||
# Overview | ||
|
||
**Module Name**: Akcelo Bidder Adapter | ||
**Module Type**: Bidder Adapter | ||
**Maintainer**: [email protected] | ||
|
||
# Description | ||
|
||
A module that connects to the Akcelo network for bids | ||
|
||
## AdUnits configuration example | ||
|
||
```javascript | ||
const adUnits = [ | ||
{ | ||
code: 'div-123', | ||
mediaTypes: { | ||
banner: { | ||
sizes: [ | ||
[300, 250], | ||
[300, 600], | ||
], | ||
}, | ||
video: { | ||
context: "outstream", | ||
playerSize: [[640, 480]], | ||
mimes: ['video/mp4'], | ||
protocols: [1, 2, 3, 4, 5, 6, 7, 8], | ||
playbackmethod: [1], | ||
skip: 1, | ||
api: [2], | ||
minbitrate: 1000, | ||
maxbitrate: 3000, | ||
minduration: 3, | ||
maxduration: 10, | ||
startdelay: 2, | ||
placement: 4, | ||
linearity: 1 | ||
}, | ||
}, | ||
bids: [ | ||
{ | ||
bidder: 'akcelo', | ||
params: { | ||
siteId: 763, // required | ||
adUnitId: 7965, // required | ||
test: 1, // optional, use 0 to disable test creatives | ||
}, | ||
}, | ||
], | ||
}, | ||
]; | ||
|
||
pbjs.que.push(function () { | ||
pbjs.addAdUnits(adUnits); | ||
}); | ||
``` |
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.
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 probably want gpp strings as well