Skip to content
98 changes: 98 additions & 0 deletions modules/aceexBidAdapter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
import { registerBidder } from '../src/adapters/bidderFactory.js';
import { BANNER, NATIVE, VIDEO } from '../src/mediaTypes.js';
import {
buildRequestsBase,
buildPlacementProcessingFunction,
} from '../libraries/teqblazeUtils/bidderUtils.js';

import { deepAccess } from '../src/utils.js';

const BIDDER_CODE = 'aceex';
const GVLID = 1387;
const AD_REQUEST_URL = 'http://bl-us.aceex.io/?secret_key=prebidjs';

const addCustomFieldsToPlacement = (bid, bidderRequest, placement) => {
placement.trafficType = placement.adFormat;
placement.publisherId = bid.params.publisherId;
placement.internalKey = bid.params.internalKey;
placement.bidfloor = bid.params.bidfloor;
};

const placementProcessingFunction = buildPlacementProcessingFunction({ addCustomFieldsToPlacement });

export const spec = {
code: BIDDER_CODE,
gvlid: GVLID,
supportedMediaTypes: [BANNER, VIDEO, NATIVE],

isBidRequestValid: (bid) => {
return !!(bid.bidId && bid.params?.publisherId && bid.params?.trafficType);
},

buildRequests: (validBidRequests = [], bidderRequest) => {
const base = buildRequestsBase({ adUrl: AD_REQUEST_URL, validBidRequests, bidderRequest, placementProcessingFunction });

base.data.cat = deepAccess(bidderRequest, 'ortb2.cat');
base.data.keywords = deepAccess(bidderRequest, 'ortb2.keywords');
base.data.badv = deepAccess(bidderRequest, 'ortb2.badv');
base.data.wseat = deepAccess(bidderRequest, 'ortb2.wseat');
base.data.bseat = deepAccess(bidderRequest, 'ortb2.bseat');

return base;
},

interpretResponse: (serverResponse, bidRequest) => {
if (!serverResponse || !serverResponse.body || !Array.isArray(serverResponse.body.seatbid)) return [];

const repackedBids = [];

serverResponse.body.seatbid.forEach(seatbidItem => {
seatbidItem.bid.forEach((bid) => {
const originalPlacement = bidRequest.data.placements?.find(pl => pl.bidId === bid.id);

const repackedBid = {
cpm: bid.price,
creativeId: bid.crid,
currency: 'USD',
dealId: bid.dealid,
height: bid.h,
width: bid.w,
mediaType: originalPlacement.adFormat,
netRevenue: true,
requestId: bid.id,
ttl: 1200,
meta: {
advertiserDomains: bid.adomain
},
Comment on lines 63 to 66

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Populate advertiserDomains from bid response

The adapter hard-codes meta.advertiserDomains to ['aaa.com'] for every bid. This mislabels the advertiser for all responses, which can bypass publisher blocklists or incorrectly block legitimate ads, and it also violates the expectation that this field reflects adomain/advertiser domains from the exchange. Use the response-provided domain list (e.g., bid.adomain) or leave it empty when it’s missing.

Useful? React with 👍 / 👎.

};

switch (originalPlacement.adFormat) {
case 'video':
repackedBid.vastXml = bid.adm;
break;

case 'banner':
repackedBid.ad = bid.adm;
break;

case 'native':
const nativeResponse = JSON.parse(bid.adm).native;

const { assets, imptrackers, link } = nativeResponse;
repackedBid.native = {
ortb: { assets, imptrackers, link },
};
break;

default: break;
};

repackedBids.push(repackedBid);
})
});

return repackedBids;
},
};

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

```
Module Name: Aceex Bidder Adapter
Module Type: Bidder Adapter
Maintainer: tech@aceex.io
```

# Description

Module that connects Prebid.JS publishers to Aceex ad-exchange

# Parameters

| Name | Scope | Description | Example |
| :------------ | :------- | :------------------------ | :------------------- |
| `publisherId` | required | Publisher ID on platform | 219 |
| `trafficType` | required | Configures the mediaType that should be used. Values can be banner, native or video | "banner" |
| `internalKey` | required | Publisher hash on platform | "j1opp02hsma8119" |
| `bidfloor` | required | Bidfloor | 0.1 |

# Test Parameters
```
var adUnits = [
// Will return static test banner
{
code: 'placementId_0',
mediaTypes: {
banner: {
sizes: [[300, 250]],
}
},
bids: [
{
bidder: 'aceex',
params: {
publisherId: 219,
internalKey: 'j1opp02hsma8119',
trafficType: 'banner',
bidfloor: 0.2
}
}
]
},
// Will return test vast video
{
code: 'placementId_0',
mediaTypes: {
video: {
playerSize: [640, 480],
context: 'instream'
}
},
bids: [
{
bidder: 'aceex',
params: {
publisherId: 219,
internalKey: 'j1opp02hsma8119',
trafficType: 'video',
bidfloor: 1.1
}
}
]
}
];
```
Loading
Loading