Skip to content
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
merged 2 commits into from
Dec 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
148 changes: 148 additions & 0 deletions modules/akceloBidAdapter.js
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)}`;
Copy link
Collaborator

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

}

return [{ type: 'iframe', url: IFRAME_SYNC_URL + syncParams }];
}
return [];
},
};

registerBidder(spec);
57 changes: 57 additions & 0 deletions modules/akceloBidAdapter.md
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);
});
```
Loading
Loading