Skip to content

Commit

Permalink
Merge pull request #20 from prebid/master
Browse files Browse the repository at this point in the history
merge master
  • Loading branch information
pro-nsk authored Feb 20, 2024
2 parents 8c682ac + 67210fa commit 2e0a2fd
Show file tree
Hide file tree
Showing 44 changed files with 3,185 additions and 631 deletions.
2 changes: 1 addition & 1 deletion gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ function lint(done) {
'!plugins/**/node_modules/**',
'./*.js'
], { base: './' })
.pipe(eslint({ fix: !argv.nolintfix, quiet: !(argv.lintWarnings ?? true) }))
.pipe(eslint({ fix: !argv.nolintfix, quiet: !(typeof argv.lintWarnings === 'boolean' ? argv.lintWarnings : true) }))
.pipe(eslint.format('stylish'))
.pipe(eslint.failAfterError())
.pipe(gulpif(isFixed, gulp.dest('./')));
Expand Down
15 changes: 6 additions & 9 deletions integrationExamples/gpt/fledge_example.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,11 @@

pbjs.que.push(function() {
pbjs.setConfig({
fledgeForGpt: {
enabled: true
}
});

pbjs.setBidderConfig({
bidders: ['openx'],
config: {
fledgeEnabled: true
paapi: {
enabled: true,
gpt: {
autoconfig: false
}
}
});

Expand All @@ -69,6 +65,7 @@
googletag.cmd.push(function() {
pbjs.que.push(function() {
pbjs.setTargetingForGPTAsync();
pbjs.setPAAPIConfigForGPT();
googletag.pubads().refresh();
});
});
Expand Down
3 changes: 3 additions & 0 deletions modules/.submodules.json
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@
"videoModule": [
"jwplayerVideoProvider",
"videojsVideoProvider"
],
"paapi": [
"fledgeForGpt"
]
}
}
7 changes: 6 additions & 1 deletion modules/adagioBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -990,6 +990,9 @@ export const spec = {
const syncEnabled = deepAccess(config.getConfig('userSync'), 'syncEnabled')
const usIfr = syncEnabled && userSync.canBidderRegisterSync('iframe', 'adagio')

// We don't validate the dsa object in adapter and let our server do it.
const dsa = deepAccess(bidderRequest, 'ortb2.regs.ext.dsa');

const aucId = generateUUID()

const adUnits = validBidRequests.map(rawBidRequest => {
Expand Down Expand Up @@ -1179,7 +1182,8 @@ export const spec = {
coppa: coppa,
ccpa: uspConsent,
gpp: gppConsent.gpp,
gppSid: gppConsent.gppSid
gppSid: gppConsent.gppSid,
dsa: dsa // populated if exists
},
schain: schain,
user: {
Expand Down Expand Up @@ -1216,6 +1220,7 @@ export const spec = {
const bidReq = (find(bidRequest.data.adUnits, bid => bid.bidId === bidObj.requestId));

if (bidReq) {
// bidObj.meta is the `bidResponse.meta` object according to https://docs.prebid.org/dev-docs/bidder-adaptor.html#interpreting-the-response
bidObj.meta = deepAccess(bidObj, 'meta', {});
bidObj.meta.mediaType = bidObj.mediaType;
bidObj.meta.advertiserDomains = (Array.isArray(bidObj.aDomain) && bidObj.aDomain.length) ? bidObj.aDomain : [];
Expand Down
113 changes: 113 additions & 0 deletions modules/adbutlerBidAdapter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
import * as utils from '../src/utils.js';
import { registerBidder } from '../src/adapters/bidderFactory.js';
import { BANNER } from '../src/mediaTypes.js';

const BIDDER_CODE = 'adbutler';

function getTrackingPixelsMarkup(pixelURLs) {
return pixelURLs
.map(pixelURL => `<img height="0" width="0" border="0" style="display:none;" src="${pixelURL}"/>`)
.join();
}

export const spec = {
code: BIDDER_CODE,
pageID: Math.floor(Math.random() * 10e6),
aliases: ['divreach', 'doceree'],
supportedMediaTypes: [BANNER],

isBidRequestValid(bid) {
return !!(bid.params.accountID && bid.params.zoneID);
},

buildRequests(validBidRequests) {
const zoneCounters = {};

return utils._map(validBidRequests, function (bidRequest) {
const zoneID = bidRequest.params?.zoneID;

zoneCounters[zoneID] ??= 0;

const domain = bidRequest.params?.domain ?? 'servedbyadbutler.com';
const adserveBase = `https://${domain}/adserve`;
const params = {
...(bidRequest.params?.extra ?? {}),
ID: bidRequest.params?.accountID,
type: 'hbr',
setID: zoneID,
pid: spec.pageID,
place: zoneCounters[zoneID],
kw: bidRequest.params?.keyword,
};

const paramsString = Object.entries(params).map(([key, value]) => `${key}=${value}`).join(';');
const requestURI = `${adserveBase}/;${paramsString};`;

zoneCounters[zoneID]++;

return {
method: 'GET',
url: requestURI,
data: {},
bidRequest,
};
});
},

interpretResponse(serverResponse, serverRequest) {
const bidObj = serverRequest.bidRequest;
const response = serverResponse.body ?? {};

if (!bidObj || response.status !== 'SUCCESS') {
return [];
}

const width = parseInt(response.width);
const height = parseInt(response.height);

const sizeValid = (bidObj.mediaTypes?.banner?.sizes ?? []).some(([w, h]) => w === width && h === height);

if (!sizeValid) {
return [];
}

const cpm = response.cpm;
const minCPM = bidObj.params?.minCPM ?? null;
const maxCPM = bidObj.params?.maxCPM ?? null;

if (minCPM !== null && cpm < minCPM) {
return [];
}

if (maxCPM !== null && cpm > maxCPM) {
return [];
}

let advertiserDomains = [];

if (response.advertiser?.domain) {
advertiserDomains.push(response.advertiser.domain);
}

const bidResponse = {
requestId: bidObj.bidId,
cpm,
currency: 'USD',
width,
height,
ad: response.ad_code + getTrackingPixelsMarkup(response.tracking_pixels),
ttl: 360,
creativeId: response.placement_id,
netRevenue: true,
meta: {
advertiserId: response.advertiser?.id,
advertiserName: response.advertiser?.name,
advertiserDomains,
},
};

return [bidResponse];
},
};

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

**Module Name**: AdButler Bidder Adapter
**Module Type**: Bidder Adapter
**Maintainer**: trevor@sparklit.com

# Description

Bid Adapter for creating a bid from an AdButler zone.

# Test Parameters
```
var adUnits = [
{
code: 'display-div',
sizes: [[300, 250]], // a display size
bids: [
{
bidder: "adbutler",
params: {
accountID: '181556',
zoneID: '705374',
keyword: 'red', //optional
minCPM: '1.00', //optional
maxCPM: '5.00' //optional
}
}
]
}
];
```
11 changes: 8 additions & 3 deletions modules/adnuntiusBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,16 @@ const storageTool = (function () {
storage.setDataInLocalStorage(META_DATA_KEY, JSON.stringify(metaDataForSaving));
};

const getUsi = function (meta, ortb2) {
let usi = (meta && meta.usi) ? meta.usi : false;
const getUsi = function (meta, ortb2, bidderRequest) {
// Fetch user id from parameters.
const paramUsi = (bidderRequest.bids) ? bidderRequest.bids.find(bid => {
if (bid.params && bid.params.userId) return true
}).params.userId : false
let usi = (meta && meta.usi) ? meta.usi : false
if (ortb2 && ortb2.user && ortb2.user.id) {
usi = ortb2.user.id
}
if (paramUsi) usi = paramUsi
return usi;
}

Expand All @@ -131,7 +136,7 @@ const storageTool = (function () {
refreshStorage: function (bidderRequest) {
const ortb2 = bidderRequest.ortb2 || {};
metaInternal = getMetaInternal().reduce((a, entry) => ({ ...a, [entry.key]: entry.value }), {});
metaInternal.usi = getUsi(metaInternal, ortb2);
metaInternal.usi = getUsi(metaInternal, ortb2, bidderRequest);
if (!metaInternal.usi) {
delete metaInternal.usi;
}
Expand Down
4 changes: 1 addition & 3 deletions modules/criteoBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -298,9 +298,6 @@ export const spec = {
if (!sellerSignals.floor && bidRequest.params.bidFloor) {
sellerSignals.floor = bidRequest.params.bidFloor;
}
if (!sellerSignals.sellerCurrency && bidRequest.params.bidFloorCur) {
sellerSignals.sellerCurrency = bidRequest.params.bidFloorCur;
}
if (body?.ext?.sellerSignalsPerImp !== undefined) {
const sellerSignalsPerImp = body.ext.sellerSignalsPerImp[bidId];
if (sellerSignalsPerImp !== undefined) {
Expand All @@ -317,6 +314,7 @@ export const spec = {
auctionSignals: {},
decisionLogicUrl: FLEDGE_DECISION_LOGIC_URL,
interestGroupBuyers: Object.keys(perBuyerSignals),
sellerCurrency: sellerSignals.currency || '???',
},
});
});
Expand Down
Loading

0 comments on commit 2e0a2fd

Please sign in to comment.