Skip to content

Commit

Permalink
Merge pull request #19 from prebid/master
Browse files Browse the repository at this point in the history
Sync with master
  • Loading branch information
pm-nitin-shirsat authored Nov 15, 2024
2 parents 83c3380 + ee12e82 commit 305ff62
Show file tree
Hide file tree
Showing 14 changed files with 1,253 additions and 218 deletions.
2 changes: 2 additions & 0 deletions libraries/targetVideoUtils/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const BIDDER_CODE = 'targetVideo';
const TIME_TO_LIVE = 300;
const BANNER_ENDPOINT_URL = 'https://ib.adnxs.com/ut/v3/prebid';
const VIDEO_ENDPOINT_URL = 'https://pbs.prebrid.tv/openrtb2/auction';
const SYNC_URL = 'https://bppb.link/static/';
const VIDEO_PARAMS = [
'api', 'linearity', 'maxduration', 'mimes', 'minduration',
'plcmt', 'playbackmethod', 'protocols', 'startdelay'
Expand All @@ -16,6 +17,7 @@ export {
GVLID,
MARGIN,
BIDDER_CODE,
SYNC_URL,
TIME_TO_LIVE,
BANNER_ENDPOINT_URL,
VIDEO_ENDPOINT_URL,
Expand Down
11 changes: 8 additions & 3 deletions modules/admaticBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ export const spec = {
{code: 'admaticde', gvlid: 1281},
{code: 'pixad', gvlid: 1281},
{code: 'monetixads', gvlid: 1281},
{code: 'netaddiction', gvlid: 1281}
{code: 'netaddiction', gvlid: 1281},
{code: 'adt', gvlid: 779}
],
supportedMediaTypes: [BANNER, VIDEO, NATIVE],
/**
Expand Down Expand Up @@ -54,7 +55,7 @@ export const spec = {
const bids = validBidRequests.map(buildRequestObject);
const ortb = bidderRequest.ortb2;
const networkId = getValue(validBidRequests[0].params, 'networkId');
const host = getValue(validBidRequests[0].params, 'host');
let host = getValue(validBidRequests[0].params, 'host');
const bidderName = validBidRequests[0].bidder;

const payload = {
Expand Down Expand Up @@ -137,11 +138,15 @@ export const spec = {
case 'admaticde':
SYNC_URL = 'https://static.cdn.admatic.de/admaticde/sync.html';
break;
case 'adt':
SYNC_URL = 'https://static.cdn.adtarget.org/adt/sync.html';
break;
default:
SYNC_URL = 'https://static.cdn.admatic.com.tr/sync.html';
break;
}

host = host?.replace('https://', '')?.replace('http://', '')?.replace('/', '');
return { method: 'POST', url: `https://${host}/pb`, data: payload, options: { contentType: 'application/json' } };
}
},
Expand All @@ -150,7 +155,7 @@ export const spec = {
if (!hasSynced && syncOptions.iframeEnabled) {
// data is only assigned if params are available to pass to syncEndpoint
let params = getUserSyncParams(gdprConsent, uspConsent, gppConsent);
params = Object.keys(params).length ? `?${formatQS(params)}` : '';
params = Object.keys(params).length ? `&${formatQS(params)}` : '';

hasSynced = true;
return {
Expand Down
175 changes: 81 additions & 94 deletions modules/bridBidAdapter.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,17 @@
import {_each, deepAccess, getDefinedParams, parseGPTSingleSizeArrayToRtbSize} from '../src/utils.js';
import {_each, deepAccess, formatQS, getDefinedParams, parseGPTSingleSizeArrayToRtbSize} from '../src/utils.js';
import {VIDEO} from '../src/mediaTypes.js';
import {registerBidder} from '../src/adapters/bidderFactory.js';
import {getAd, getSiteObj} from '../libraries/targetVideoUtils/bidderUtils.js'
import {GVLID, SOURCE, SYNC_URL, TIME_TO_LIVE, VIDEO_ENDPOINT_URL, VIDEO_PARAMS} from '../libraries/targetVideoUtils/constants.js';

/**
* @typedef {import('../src/adapters/bidderFactory.js').BidRequest} BidRequest
* @typedef {import('../src/adapters/bidderFactory.js').Bid} Bid
* @typedef {import('../src/adapters/bidderFactory.js').BidderRequest} BidderRequest
*/

const SOURCE = 'pbjs';
const BIDDER_CODE = 'brid';
const ENDPOINT_URL = 'https://pbs.prebrid.tv/openrtb2/auction';
const GVLID = 934;
const TIME_TO_LIVE = 300;
const VIDEO_PARAMS = [
'api', 'linearity', 'maxduration', 'mimes', 'minduration', 'plcmt',
'playbackmethod', 'protocols', 'startdelay'
];

export const spec = {

code: BIDDER_CODE,
code: 'brid',
gvlid: GVLID,
supportedMediaTypes: [VIDEO],

Expand Down Expand Up @@ -117,7 +107,7 @@ export const spec = {

requests.push({
method: 'POST',
url: ENDPOINT_URL,
url: VIDEO_ENDPOINT_URL,
data: JSON.stringify(postBody),
options: {
withCredentials: true
Expand All @@ -138,92 +128,89 @@ export const spec = {
*/
interpretResponse: function(serverResponse, bidRequest) {
const response = serverResponse.body;
const bidResponses = [];

_each(response.seatbid, (resp) => {
_each(resp.bid, (bid) => {
const requestId = bidRequest.bidId;
const params = bidRequest.params;

const {ad, adUrl, vastUrl, vastXml} = getAd(bid);

const bidResponse = {
requestId,
params,
cpm: bid.price,
width: bid.w,
height: bid.h,
creativeId: bid.adid,
currency: response.cur,
netRevenue: false,
ttl: TIME_TO_LIVE,
meta: {
advertiserDomains: bid.adomain || []
}
};
let highestBid = null;

if (response && response.seatbid && response.seatbid.length && response.seatbid[0].bid && response.seatbid[0].bid.length) {
_each(response.seatbid, (resp) => {
_each(resp.bid, (bid) => {
const requestId = bidRequest.bidId;
const params = bidRequest.params;

const {ad, adUrl, vastUrl, vastXml} = getAd(bid);

const bidResponse = {
requestId,
params,
cpm: bid.price,
width: bid.w,
height: bid.h,
creativeId: bid.crid || bid.adid,
currency: response.cur,
netRevenue: false,
ttl: TIME_TO_LIVE,
meta: {
advertiserDomains: bid.adomain || []
}
};

if (vastUrl || vastXml) {
bidResponse.mediaType = VIDEO;
if (vastUrl) bidResponse.vastUrl = vastUrl;
if (vastXml) bidResponse.vastXml = vastXml;
} else {
bidResponse.ad = ad;
bidResponse.adUrl = adUrl;
};
if (vastUrl || vastXml) {
bidResponse.mediaType = VIDEO;
if (vastUrl) bidResponse.vastUrl = vastUrl;
if (vastXml) bidResponse.vastXml = vastXml;
} else {
bidResponse.ad = ad;
bidResponse.adUrl = adUrl;
};

bidResponses.push(bidResponse);
if (!highestBid || highestBid.cpm < bidResponse.cpm) {
highestBid = bidResponse;
}
});
});
});
}

return bidResponses;
return highestBid ? [highestBid] : [];
},

}
/**
* Determine the user sync type (either 'iframe' or 'image') based on syncOptions.
* Construct the sync URL by appending required query parameters such as gdpr, ccpa, and coppa consents.
* Return an array containing an object with the sync type and the constructed URL.
*/
getUserSyncs: (syncOptions, serverResponses, gdprConsent, uspConsent, gppConsent) => {
const params = {
endpoint: 'brid'
};

// Attaching GDPR Consent Params in UserSync url
if (gdprConsent) {
params.gdpr = (gdprConsent.gdprApplies ? 1 : 0);
params.gdpr_consent = encodeURIComponent(gdprConsent.consentString || '');
}

// CCPA
if (uspConsent && typeof uspConsent === 'string') {
params.us_privacy = encodeURIComponent(uspConsent);
}

// GPP Consent
if (gppConsent?.gppString && gppConsent?.applicableSections?.length) {
params.gpp = encodeURIComponent(gppConsent.gppString);
params.gpp_sid = encodeURIComponent(gppConsent?.applicableSections?.join(','));
}

const queryParams = Object.keys(params).length > 0 ? formatQS(params) : '';
let response = [];
if (syncOptions.iframeEnabled) {
response = [{
type: 'iframe',
url: SYNC_URL + 'load-cookie.html?' + queryParams
}];
}

return response;
}

// /**
// * Helper function to get ad
// *
// * @param {object} bid The bid.
// * @return {object} ad object.
// */
// function getAd(bid) {
// let ad, adUrl, vastXml, vastUrl;

// switch (deepAccess(bid, 'ext.prebid.type')) {
// case VIDEO:
// if (bid.adm.substr(0, 4) === 'http') {
// vastUrl = bid.adm;
// } else {
// vastXml = bid.adm;
// };
// break;
// default:
// if (bid.adm && bid.nurl) {
// ad = bid.adm;
// ad += createTrackPixelHtml(decodeURIComponent(bid.nurl));
// } else if (bid.adm) {
// ad = bid.adm;
// } else if (bid.nurl) {
// adUrl = bid.nurl;
// };
// }

// return {ad, adUrl, vastXml, vastUrl};
// }

// /**
// * Helper function to get site object
// *
// * @return {object} siteObj.
// */
// function getSiteObj() {
// const refInfo = (getRefererInfo && getRefererInfo()) || {};

// return {
// page: refInfo.page,
// ref: refInfo.ref,
// domain: refInfo.domain
// };
// }
}

registerBidder(spec);
41 changes: 41 additions & 0 deletions modules/ehealthcaresolutionsBidAdapter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import {
BANNER,
NATIVE
} from '../src/mediaTypes.js';
import {
registerBidder
} from '../src/adapters/bidderFactory.js';
import {
getBannerRequest,
getBannerResponse,
getNativeResponse,
} from '../libraries/audUtils/bidderUtils.js';

const ENDPOINT_URL = 'https://rtb.ehealthcaresolutions.com/hb';
// Export const spec
export const spec = {
code: 'ehealthcaresolutions',
supportedMediaTypes: [BANNER, NATIVE],
// Determines whether or not the given bid request is valid
isBidRequestValid: (bParam) => {
return !!(bParam.params.placement_id);
},
// Make a server request from the list of BidRequests
buildRequests: (bidRequests, serverRequest) => {
// Get Requests based on media types
return getBannerRequest(bidRequests, serverRequest, ENDPOINT_URL);
},
// Unpack the response from the server into a list of bids.
interpretResponse: (bResponse, bRequest) => {
let Response = {};
const mediaType = JSON.parse(bRequest.data)[0].MediaType;
if (mediaType == BANNER) {
Response = getBannerResponse(bResponse, BANNER);
} else if (mediaType == NATIVE) {
Response = getNativeResponse(bResponse, bRequest, NATIVE);
}
return Response;
}
}

registerBidder(spec);
61 changes: 61 additions & 0 deletions modules/ehealthcaresolutionsBidAdapter.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Overview

```
Module Name: eHealthcareSolutions Bidder Adapter
Module Type: Bidder Adapter
Maintainer: [email protected]
```

# Description

eHealthcareSolutions currently supports the BANNER and NATIVE type ads through prebid js

Module that connects to eHealthcareSolutions's demand sources.

# Test Request
```
var adUnits = [
{
code: 'display-ad',
mediaTypes: {
banner: {
sizes: [[300, 250]],
}
}
bids: [
{
bidder: 'ehealthcaresolutions',
params: {
placement_id: 111519, // Required parameter
width: 300, // Optional parameter
height: 250, // Optional parameter
bid_floor: 0.5 // Optional parameter
}
}
]
},
{
code: 'native-ad-container',
mediaTypes: {
native: {
title: { required: true, len: 100 },
image: { required: true, sizes: [300, 250] },
sponsored: { required: false },
clickUrl: { required: true },
desc: { required: true },
icon: { required: false, sizes: [50, 50] },
cta: { required: false }
}
},
bids: [
{
bidder: 'eHealthcareSolutions',
params: {
placement_id: 111519, // Required parameter
bid_floor: 1 // Optional parameter
}
}
]
}
];
```
Loading

0 comments on commit 305ff62

Please sign in to comment.