Skip to content

Commit

Permalink
Cadent Bid Adapter: rename emxdigital to cadent
Browse files Browse the repository at this point in the history
* rename files

* rename bidder_code

* rename adapter object

* rename remaining references

* add alias from emx_digital

---------

Co-authored-by: Michael Denton <mdenton@cadent.tv>
  • Loading branch information
EMXDigital and Michael Denton committed Jun 7, 2023
1 parent bdd56a7 commit 2cb62dc
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 78 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,21 @@ import {Renderer} from '../src/Renderer.js';
import {find, includes} from '../src/polyfill.js';
import {parseDomain} from '../src/refererDetection.js';

const BIDDER_CODE = 'emx_digital';
const BIDDER_CODE = 'cadent_aperture_mx';
const ENDPOINT = 'hb.emxdgt.com';
const RENDERER_URL = 'https://js.brealtime.com/outstream/1.30.0/bundle.js';
const ADAPTER_VERSION = '1.5.1';
const DEFAULT_CUR = 'USD';
const ALIASES = [
{ code: 'emx_digital', gvlid: 183 },
];

const EIDS_SUPPORTED = [
{ key: 'idl_env', source: 'liveramp.com', rtiPartner: 'idl', queryParam: 'idl' },
{ key: 'uid2.id', source: 'uidapi.com', rtiPartner: 'UID2', queryParam: 'uid2' }
];

export const emxAdapter = {
export const cadentAdapter = {
validateSizes: (sizes) => {
if (!isArray(sizes) || typeof sizes[0] === 'undefined') {
logWarn(BIDDER_CODE + ': Sizes should be an array');
Expand All @@ -40,7 +43,7 @@ export const emxAdapter = {
buildBanner: (bid) => {
let sizes = [];
bid.mediaTypes && bid.mediaTypes.banner && bid.mediaTypes.banner.sizes ? sizes = bid.mediaTypes.banner.sizes : sizes = bid.sizes;
if (!emxAdapter.validateSizes(sizes)) {
if (!cadentAdapter.validateSizes(sizes)) {
logWarn(BIDDER_CODE + ': could not detect mediaType banner sizes. Assigning to bid sizes instead');
sizes = bid.sizes
}
Expand All @@ -55,13 +58,13 @@ export const emxAdapter = {
h: sizes[0][1]
};
},
formatVideoResponse: (bidResponse, emxBid, bidRequest) => {
bidResponse.vastXml = emxBid.adm;
formatVideoResponse: (bidResponse, cadentBid, bidRequest) => {
bidResponse.vastXml = cadentBid.adm;
if (bidRequest.bidderRequest && bidRequest.bidderRequest.bids && bidRequest.bidderRequest.bids.length > 0) {
const matchingBid = find(bidRequest.bidderRequest.bids, bid => bidResponse.requestId && bid.bidId && bidResponse.requestId === bid.bidId && bid.mediaTypes && bid.mediaTypes.video && bid.mediaTypes.video.context === 'outstream');
if (matchingBid) {
bidResponse.renderer = emxAdapter.createRenderer(bidResponse, {
id: emxBid.id,
bidResponse.renderer = cadentAdapter.createRenderer(bidResponse, {
id: cadentBid.id,
url: RENDERER_URL
});
}
Expand All @@ -81,7 +84,7 @@ export const emxAdapter = {
dnt: (navigator.doNotTrack === 'yes' || navigator.doNotTrack === '1' || navigator.msDoNotTrack === '1') ? 1 : 0,
h: screen.height,
w: screen.width,
devicetype: emxAdapter.isMobile() ? 1 : emxAdapter.isConnectedTV() ? 3 : 2,
devicetype: cadentAdapter.isMobile() ? 1 : cadentAdapter.isConnectedTV() ? 3 : 2,
language: (navigator.language || navigator.browserLanguage || navigator.userLanguage || navigator.systemLanguage),
};
},
Expand Down Expand Up @@ -114,7 +117,7 @@ export const emxAdapter = {
loaded: false
});
try {
renderer.setRender(emxAdapter.outstreamRender);
renderer.setRender(cadentAdapter.outstreamRender);
} catch (err) {
logWarn('Prebid Error calling setRender on renderer', err);
}
Expand All @@ -131,13 +134,13 @@ export const emxAdapter = {
videoObj['w'] = bid.mediaTypes.video.playerSize[0];
videoObj['h'] = bid.mediaTypes.video.playerSize[1];
}
return emxAdapter.cleanProtocols(videoObj);
return cadentAdapter.cleanProtocols(videoObj);
},
parseResponse: (bidResponseAdm) => {
try {
return decodeURIComponent(bidResponseAdm.replace(/%(?![0-9][0-9a-fA-F]+)/g, '%25'));
} catch (err) {
logError('emx_digitalBidAdapter', 'error', err);
logError('cadent_aperture_mxBidAdapter', 'error', err);
}
},
getSite: (refInfo) => {
Expand All @@ -148,45 +151,45 @@ export const emxAdapter = {
ref: refInfo.ref || window.document.referrer
}
},
getGdpr: (bidRequests, emxData) => {
getGdpr: (bidRequests, cadentData) => {
if (bidRequests.gdprConsent) {
emxData.regs = {
cadentData.regs = {
ext: {
gdpr: bidRequests.gdprConsent.gdprApplies === true ? 1 : 0
}
};
}
if (bidRequests.gdprConsent && bidRequests.gdprConsent.gdprApplies) {
emxData.user = {
cadentData.user = {
ext: {
consent: bidRequests.gdprConsent.consentString
}
};
}

return emxData;
return cadentData;
},
getSupplyChain: (bidderRequest, emxData) => {
getSupplyChain: (bidderRequest, cadentData) => {
if (bidderRequest.bids[0] && bidderRequest.bids[0].schain) {
emxData.source = {
cadentData.source = {
ext: {
schain: bidderRequest.bids[0].schain
}
};
}

return emxData;
return cadentData;
},
// supporting eids
getEids(bidRequests) {
return EIDS_SUPPORTED
.map(emxAdapter.getUserId(bidRequests))
.map(cadentAdapter.getUserId(bidRequests))
.filter(x => x);
},
getUserId(bidRequests) {
return ({ key, source, rtiPartner }) => {
let id = deepAccess(bidRequests, `userId.${key}`);
return id ? emxAdapter.formatEid(id, source, rtiPartner) : null;
return id ? cadentAdapter.formatEid(id, source, rtiPartner) : null;
};
},
formatEid(id, source, rtiPartner) {
Expand All @@ -203,6 +206,7 @@ export const emxAdapter = {
export const spec = {
code: BIDDER_CODE,
gvlid: 183,
alias: ALIASES,
supportedMediaTypes: [BANNER, VIDEO],
isBidRequestValid: function (bid) {
if (!bid || !bid.params) {
Expand All @@ -211,7 +215,7 @@ export const spec = {
}

if (bid.bidder !== BIDDER_CODE) {
logWarn(BIDDER_CODE + ': Must use "emx_digital" as bidder code.');
logWarn(BIDDER_CODE + ': Must use "cadent_aperture_mx" as bidder code.');
return false;
}

Expand All @@ -223,12 +227,12 @@ export const spec = {
if (bid.mediaTypes && bid.mediaTypes.banner) {
let sizes;
bid.mediaTypes.banner.sizes ? sizes = bid.mediaTypes.banner.sizes : sizes = bid.sizes;
if (!emxAdapter.validateSizes(sizes)) {
if (!cadentAdapter.validateSizes(sizes)) {
logWarn(BIDDER_CODE + ': Missing sizes in bid');
return false;
}
} else if (bid.mediaTypes && bid.mediaTypes.video) {
if (!emxAdapter.checkVideoContext(bid)) {
if (!cadentAdapter.checkVideoContext(bid)) {
logWarn(BIDDER_CODE + ': Missing video context: instream or outstream');
return false;
}
Expand All @@ -242,13 +246,13 @@ export const spec = {
return true;
},
buildRequests: function (validBidRequests, bidderRequest) {
const emxImps = [];
const cadentImps = [];
const timeout = bidderRequest.timeout || '';
const timestamp = Date.now();
const url = 'https://' + ENDPOINT + ('?t=' + timeout + '&ts=' + timestamp + '&src=pbjs');
const secure = location.protocol.indexOf('https') > -1 ? 1 : 0;
const device = emxAdapter.getDevice();
const site = emxAdapter.getSite(bidderRequest.refererInfo);
const device = cadentAdapter.getDevice();
const site = cadentAdapter.getSite(bidderRequest.refererInfo);

_each(validBidRequests, function (bid) {
let tagid = getBidIdParameter('tagid', bid.params);
Expand All @@ -269,35 +273,35 @@ export const spec = {
if (gpid) {
data.ext = {gpid: gpid.toString()};
}
let typeSpecifics = isVideo ? { video: emxAdapter.buildVideo(bid) } : { banner: emxAdapter.buildBanner(bid) };
let typeSpecifics = isVideo ? { video: cadentAdapter.buildVideo(bid) } : { banner: cadentAdapter.buildBanner(bid) };
let bidfloorObj = bidfloor > 0 ? { bidfloor, bidfloorcur: DEFAULT_CUR } : {};
let emxBid = Object.assign(data, typeSpecifics, bidfloorObj);
emxImps.push(emxBid);
let cadentBid = Object.assign(data, typeSpecifics, bidfloorObj);
cadentImps.push(cadentBid);
});

let emxData = {
let cadentData = {
id: bidderRequest.auctionId,
imp: emxImps,
imp: cadentImps,
device,
site,
cur: DEFAULT_CUR,
version: ADAPTER_VERSION
};

emxData = emxAdapter.getGdpr(bidderRequest, Object.assign({}, emxData));
emxData = emxAdapter.getSupplyChain(bidderRequest, Object.assign({}, emxData));
cadentData = cadentAdapter.getGdpr(bidderRequest, Object.assign({}, cadentData));
cadentData = cadentAdapter.getSupplyChain(bidderRequest, Object.assign({}, cadentData));
if (bidderRequest && bidderRequest.uspConsent) {
emxData.us_privacy = bidderRequest.uspConsent;
cadentData.us_privacy = bidderRequest.uspConsent;
}

// adding eid support
if (bidderRequest.userId) {
let eids = emxAdapter.getEids(bidderRequest);
let eids = cadentAdapter.getEids(bidderRequest);
if (eids.length > 0) {
if (emxData.user && emxData.user.ext) {
emxData.user.ext.eids = eids;
if (cadentData.user && cadentData.user.ext) {
cadentData.user.ext.eids = eids;
} else {
emxData.user = {
cadentData.user = {
ext: {eids}
};
}
Expand All @@ -307,50 +311,50 @@ export const spec = {
return {
method: 'POST',
url,
data: JSON.stringify(emxData),
data: JSON.stringify(cadentData),
options: {
withCredentials: true
},
bidderRequest
};
},
interpretResponse: function (serverResponse, bidRequest) {
let emxBidResponses = [];
let cadentBidResponses = [];
let response = serverResponse.body || {};
if (response.seatbid && response.seatbid.length > 0 && response.seatbid[0].bid) {
response.seatbid.forEach(function (emxBid) {
emxBid = emxBid.bid[0];
response.seatbid.forEach(function (cadentBid) {
cadentBid = cadentBid.bid[0];
let isVideo = false;
let adm = emxAdapter.parseResponse(emxBid.adm) || '';
let adm = cadentAdapter.parseResponse(cadentBid.adm) || '';
let bidResponse = {
requestId: emxBid.id,
cpm: emxBid.price,
width: emxBid.w,
height: emxBid.h,
creativeId: emxBid.crid || emxBid.id,
dealId: emxBid.dealid || null,
requestId: cadentBid.id,
cpm: cadentBid.price,
width: cadentBid.w,
height: cadentBid.h,
creativeId: cadentBid.crid || cadentBid.id,
dealId: cadentBid.dealid || null,
currency: 'USD',
netRevenue: true,
ttl: emxBid.ttl,
ttl: cadentBid.ttl,
ad: adm
};
if (emxBid.adm && emxBid.adm.indexOf('<?xml version=') > -1) {
if (cadentBid.adm && cadentBid.adm.indexOf('<?xml version=') > -1) {
isVideo = true;
bidResponse = emxAdapter.formatVideoResponse(bidResponse, Object.assign({}, emxBid), bidRequest);
bidResponse = cadentAdapter.formatVideoResponse(bidResponse, Object.assign({}, cadentBid), bidRequest);
}
bidResponse.mediaType = (isVideo ? VIDEO : BANNER);

// support for adomain in prebid 5.0
if (emxBid.adomain && emxBid.adomain.length) {
if (cadentBid.adomain && cadentBid.adomain.length) {
bidResponse.meta = {
advertiserDomains: emxBid.adomain
advertiserDomains: cadentBid.adomain
};
}

emxBidResponses.push(bidResponse);
cadentBidResponses.push(bidResponse);
});
}
return emxBidResponses;
return cadentBidResponses;
},
getUserSyncs: function (syncOptions, responses, gdprConsent, uspConsent) {
const syncs = [];
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
# Overview

```
Module Name: EMX Digital Adapter
Module Name: Cadent Aperture MX Adapter
Module Type: Bidder Adapter
Maintainer: git@emxdigital.com
```

# Description

The EMX Digital adapter provides publishers with access to the EMX Marketplace. The adapter is GDPR compliant. Please note that the adapter supports Banner and Video (Instream & Outstream) media types.
The Cadent Aperture MX adapter provides publishers with access to the Cadent Aperture MX SSP. The adapter is GDPR compliant. Please note that the adapter supports Banner and Video (Instream & Outstream) media types.

Note: The EMX Digital adapter requires approval and implementation guidelines from the EMX team, including existing publishers that work with EMX Digital. Please reach out to your account manager or prebid@emxdigital.com for more information.
Note: The Cadent Aperture MX adapter requires approval and implementation guidelines from the Cadent team, including existing publishers that work with Cadent. Please reach out to your account manager or prebid@emxdigital.com for more information.

The bidder code should be ```emx_digital```
The bidder code should be ```cadent_aperture_mx```
The params used by the bidder are :
```tagid``` - string (mandatory)
```bidfloor``` - string (optional)
Expand All @@ -29,7 +29,7 @@ var adUnits = [{
},
bids: [
{
bidder: 'emx_digital',
bidder: 'cadent_aperture_mx',
params: {
tagid: '25251',
}
Expand All @@ -49,7 +49,7 @@ var adUnits = [{
},
bids: [
{
bidder: 'emx_digital',
bidder: 'cadent_aperture_mx',
params: {
tagid: '25251',
video: {
Expand Down
Loading

0 comments on commit 2cb62dc

Please sign in to comment.