Skip to content

Commit

Permalink
Merge remote-tracking branch 'Prebid.js/prebid-8' into retailspot-bid…
Browse files Browse the repository at this point in the history
…deradapter
  • Loading branch information
rs-guian committed May 2, 2023
2 parents 2ad1241 + 486e2b8 commit a8f5bfc
Show file tree
Hide file tree
Showing 93 changed files with 1,907 additions and 7,881 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ name: "CodeQL"

on:
push:
branches: [ "master" ]
branches: [ "master", "prebid-8" ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ "master" ]
branches: [ "master", "prebid-8" ]
schedule:
- cron: '22 11 * * 0'

Expand Down
103 changes: 103 additions & 0 deletions integrationExamples/gpt/fledge_example.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
<html>
<head>
<!--
FLEDGE (Protected Audience API) configuration with GPT and FLEDGE-supporting adapter
gulp serve --modules=fledgeForGpt,openxBidAdapter
-->
<script async src="../../build/dev/prebid.js"></script>
<script async src="https://www.googletagservices.com/tag/js/gpt.js"></script>
<script>
var FAILSAFE_TIMEOUT = 3000;
var PREBID_TIMEOUT = 1500;

var pbjs = pbjs || {};
pbjs.que = pbjs.que || [];

var googletag = googletag || {};
googletag.cmd = googletag.cmd || [];

googletag.cmd.push(function() {
googletag.pubads().disableInitialLoad();
});

var adUnits = [{
code: 'div-gpt-ad-1460505748561-0',
mediaTypes: {
banner: {
sizes: [[300, 250]]
}
},
bids: [{
bidder: 'openx',
params: {
platform: '8869ec2c-9d3f-4f16-9d2f-49aaab8978fb',
unit: '111111'
}
}],
ortb2Imp: {
ext: {
ae: 1
}
}
}];

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

pbjs.setBidderConfig({
bidders: ['openx'],
config: {
fledgeEnabled: true
}
});

pbjs.addAdUnits(adUnits);

pbjs.requestBids({
bidsBackHandler: sendAdserverRequest,
timeout: PREBID_TIMEOUT
});

function sendAdserverRequest() {
if (pbjs.adserverRequestSent) return;
pbjs.adserverRequestSent = true;
googletag.cmd.push(function() {
pbjs.que.push(function() {
pbjs.setTargetingForGPTAsync();
googletag.pubads().refresh();
});
});
}

setTimeout(function() {
sendAdserverRequest();
}, FAILSAFE_TIMEOUT);
});

googletag.cmd.push(function() {
googletag
.defineSlot('/19968336/header-bid-tag-0', adUnits[0].mediaTypes.banner.sizes, 'div-gpt-ad-1460505748561-0')
.addService(googletag.pubads());

googletag.pubads().enableSingleRequest();
googletag.enableServices();
});
</script>
</head>

<body>
<h2>Prebid.js FLEDGE+GPT Example</h2>

<h5>Div-1</h5>
<div id='div-gpt-ad-1460505748561-0'>
<script type='text/javascript'>
googletag.cmd.push(function() { googletag.display('div-gpt-ad-1460505748561-0'); });
</script>
</div>
</body>
</html>
111 changes: 111 additions & 0 deletions integrationExamples/gpt/prebidServer_fledge_example.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
<html>
<head>
<!--
FLEDGE (Protected Audience API) configuration with GPT and Prebid-Server
gulp serve --modules=fledgeForGpt,prebidServerBidAdapter
-->
<script async src="../../build/dev/prebid.js"></script>
<script async src="https://www.googletagservices.com/tag/js/gpt.js"></script>
<script>
var FAILSAFE_TIMEOUT = 3000;
var PREBID_TIMEOUT = 1500;

var pbjs = pbjs || {};
pbjs.que = pbjs.que || [];

var googletag = googletag || {};
googletag.cmd = googletag.cmd || [];

googletag.cmd.push(function() {
googletag.pubads().disableInitialLoad();
});

var adUnits = [{
code: 'div-gpt-ad-1460505748561-0',
mediaTypes: {
banner: {
sizes: [[300, 250]]
}
},
bids: [{
bidder: 'openx',
params: {
platform: '8869ec2c-9d3f-4f16-9d2f-49aaab8978fb',
unit: '111111'
}
}],
ortb2Imp: {
ext: {
ae: 1
}
}
}];

pbjs.que.push(function() {
pbjs.setConfig({
fledgeForGpt: {
enabled: true
},
s2sConfig: [{
accountId : '1',
enabled : true,
defaultVendor: 'appnexus',
bidders : ['openx'],
timeout : 1500,
adapter : 'prebidServer'
}]
});

pbjs.setBidderConfig({
bidders: ['openx'],
config: {
fledgeEnabled: true
}
});

pbjs.addAdUnits(adUnits);

pbjs.requestBids({
bidsBackHandler: sendAdserverRequest,
timeout: PREBID_TIMEOUT
});

function sendAdserverRequest() {
if (pbjs.adserverRequestSent) return;
pbjs.adserverRequestSent = true;
googletag.cmd.push(function() {
pbjs.que.push(function() {
pbjs.setTargetingForGPTAsync();
googletag.pubads().refresh();
});
});
}

setTimeout(function() {
sendAdserverRequest();
}, FAILSAFE_TIMEOUT);
});

googletag.cmd.push(function() {
googletag
.defineSlot('/19968336/header-bid-tag-0', adUnits[0].mediaTypes.banner.sizes, 'div-gpt-ad-1460505748561-0')
.addService(googletag.pubads());

googletag.pubads().enableSingleRequest();
googletag.enableServices();
});
</script>
</head>

<body>
<h2>Prebid.js FLEDGE+GPT Example</h2>

<h5>Div-1</h5>
<div id='div-gpt-ad-1460505748561-0'>
<script type='text/javascript'>
googletag.cmd.push(function() { googletag.display('div-gpt-ad-1460505748561-0'); });
</script>
</div>
</body>
</html>
7 changes: 3 additions & 4 deletions libraries/ortbConverter/processors/default.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {deepSetValue, mergeDeep} from '../../../src/utils.js';
import {generateUUID, mergeDeep} from '../../../src/utils.js';
import {bannerResponseProcessor, fillBannerImp} from './banner.js';
import {fillVideoImp, fillVideoResponse} from './video.js';
import {setResponseMediaType} from './mediaType.js';
Expand All @@ -21,17 +21,16 @@ export const DEFAULT_PROCESSORS = {
fn: clientSectionChecker('ORTB request')
},
props: {
// sets request properties id, tmax, test, source.tid
// sets request properties id, tmax, test
fn(ortbRequest, bidderRequest) {
Object.assign(ortbRequest, {
id: ortbRequest.id || bidderRequest.auctionId,
id: ortbRequest.id || generateUUID(),
test: ortbRequest.test || 0
});
const timeout = parseInt(bidderRequest.timeout, 10);
if (!isNaN(timeout)) {
ortbRequest.tmax = timeout;
}
deepSetValue(ortbRequest, 'source.tid', ortbRequest.source?.tid || bidderRequest.auctionId);
}
}
},
Expand Down
1 change: 1 addition & 0 deletions libraries/ortbConverter/processors/video.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {sizesToFormat} from '../lib/sizes.js';
const ORTB_VIDEO_PARAMS = new Set([
'pos',
'placement',
'plcmt',
'api',
'mimes',
'protocols',
Expand Down
2 changes: 1 addition & 1 deletion modules/.submodules.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"tapadIdSystem",
"teadsIdSystem",
"tncIdSystem",
"trustpidSystem",
"utiqSystem",
"uid2IdSystem",
"unifiedIdSystem",
"verizonMediaIdSystem",
Expand Down
9 changes: 4 additions & 5 deletions modules/ablidaBidAdapter.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { triggerPixel } from '../src/utils.js';
import {config} from '../src/config.js';
import {triggerPixel} from '../src/utils.js';
import {registerBidder} from '../src/adapters/bidderFactory.js';
import { BANNER, NATIVE, VIDEO } from '../src/mediaTypes.js';
import { convertOrtbRequestToProprietaryNative } from '../src/native.js';
import {BANNER, NATIVE, VIDEO} from '../src/mediaTypes.js';
import {convertOrtbRequestToProprietaryNative} from '../src/native.js';

const BIDDER_CODE = 'ablida';
const ENDPOINT_URL = 'https://bidder.ablida.net/prebid';
Expand Down Expand Up @@ -77,7 +76,7 @@ export const spec = {
const response = serverResponse.body;

response.forEach(function(bid) {
bid.ttl = config.getConfig('_bidderTimeout');
bid.ttl = 60
bidResponses.push(bid);
});
return bidResponses;
Expand Down
37 changes: 32 additions & 5 deletions modules/admaticBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export const spec = {
*/
buildRequests: (validBidRequests, bidderRequest) => {
const bids = validBidRequests.map(buildRequestObject);
const blacklist = bidderRequest.ortb2 || {};
const blacklist = bidderRequest.ortb2;
const networkId = getValue(validBidRequests[0].params, 'networkId');
const host = getValue(validBidRequests[0].params, 'host');
const currency = config.getConfig('currency.adServerCurrency') || 'TRY';
Expand Down Expand Up @@ -93,7 +93,7 @@ export const spec = {
* @return {Bid[]}
*/
interpretResponse: (response, request) => {
const body = response.body || response;
const body = response.body;
const bidResponses = [];
if (body && body?.data && isArray(body.data)) {
body.data.forEach(bid => {
Expand All @@ -104,13 +104,23 @@ export const spec = {
height: bid.height,
currency: body.cur || 'TRY',
netRevenue: true,
ad: bid.party_tag,
creativeId: bid.creative_id,
meta: {
advertiserDomains: bid && bid.adomain ? bid.adomain : []
},
ttl: 360,
bidder: bid.bidder
bidder: bid.bidder,
mediaType: bid.type,
ttl: 60
};

if (resbid.mediaType === 'video' && isUrl(bid.party_tag)) {
resbid.vastUrl = bid.party_tag;
resbid.vastImpUrl = bid.iurl;
} else if (resbid.mediaType === 'video') {
resbid.vastXml = bid.party_tag;
resbid.vastImpUrl = bid.iurl;
} else if (resbid.mediaType === 'banner') {
resbid.ad = bid.party_tag;
};

bidResponses.push(resbid);
Expand All @@ -120,6 +130,15 @@ export const spec = {
}
};

function isUrl(str) {
try {
URL(str);
return true;
} catch (error) {
return false;
}
};

function enrichSlotWithFloors(slot, bidRequest) {
try {
const slotFloors = {};
Expand Down Expand Up @@ -168,6 +187,14 @@ function parseSize(size) {
function buildRequestObject(bid) {
const reqObj = {};
reqObj.size = getSizes(bid);
if (bid.mediaTypes?.banner) {
reqObj.type = 'banner';
reqObj.mediatype = {};
}
if (bid.mediaTypes?.video) {
reqObj.type = 'video';
reqObj.mediatype = bid.mediaTypes.video;
}
reqObj.id = getBidIdParameter('bidId', bid);

enrichSlotWithFloors(reqObj, bid);
Expand Down
Loading

0 comments on commit a8f5bfc

Please sign in to comment.