Skip to content

Commit

Permalink
Merge pull request #4 from rediads/master
Browse files Browse the repository at this point in the history
sync with master
  • Loading branch information
symplor-alpha authored Feb 21, 2025
2 parents 5488745 + 866b18e commit c065d54
Show file tree
Hide file tree
Showing 124 changed files with 5,428 additions and 846 deletions.
79 changes: 79 additions & 0 deletions integrationExamples/testBidder/testBidderBannerExample.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
<html>
<head>
<title>Prebid Test Bidder Example</title>
<script src="../../build/dev/prebid.js" async></script>
<script>
var pbjs = pbjs || {};
pbjs.que = pbjs.que || [];

const adUnitCode = 'adUnit-0000';

const adUnits = [{
mediaTypes: {
banner: {
sizes: [600, 500]
}
},
code: adUnitCode,
bids: [
{bidder: 'testBidder', params: {}}
]
}]

pbjs.que.push(function () {

/**
* BID RESPONSE SIMULATION SECTION START
*
* This section handles simulating a bidder
* that will always respond with bid responses.
*
* This part should not be present in production.
*/
pbjs.registerBidAdapter(null, 'testBidder', {
supportedMediaTypes: ['banner', 'video', 'native'],
isBidRequestValid: () => true
});

pbjs.setConfig({
debugging: {
enabled: true,
intercept: [
{
when: {
bidder: 'testBidder',
},
then: {
creativeId: 'testCreativeId',
}
}
]
}
});
/**
* BID RESPONSE SIMULATION SECTION END
*/

pbjs.addAdUnits(adUnits);
pbjs.requestBids({
adUnitCodes: [adUnitCode],
bidsBackHandler: function() {
const bids = pbjs.getHighestCpmBids(adUnitCode);
const winningBid = bids[0];
const div = document.getElementById('banner');
let iframe = document.createElement('iframe');
iframe.frameBorder = '0';
div.appendChild(iframe);
var iframeDoc = iframe.contentWindow.document;
pbjs.renderAd(iframeDoc, winningBid.adId);
}
});
});
</script>
</head>
<body>
<h2>Prebid Test Bidder Example</h2>
<h5>Banner ad</h5>
<div id="banner"></div>
</body>
</html>
151 changes: 151 additions & 0 deletions integrationExamples/testBidder/testBidderNativeExample.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
<html>
<head>
<title>Prebid Test Bidder Example</title>
<script src="../../build/dev/prebid.js" async></script>
<script>
var pbjs = pbjs || {};
pbjs.que = pbjs.que || [];

const adUnitCode = 'adUnit-0000';

const adUnits = [{
mediaTypes: {
native: {
ortb: {
assets: [
{
required: true,
id: 1,
img: {
type: 3,
wmin: 100,
hmin: 100,
}
},
{
required: true,
id: 2,
img: {
type: 3,
wmin: 200,
hmin: 200
}
},
{
required: true,
id: 3,
data: {
type: 3,
len: 20
}
},
{
required: true,
id: 4,
title: {
len: 20
}
}
]
}
}
},
code: adUnitCode,
bids: [
{bidder: 'testBidder', params: {}}
]
}]

pbjs.que.push(function () {

/**
* BID RESPONSE SIMULATION SECTION START
*
* This section handles simulating a bidder
* that will always respond with bid responses.
*
* This part should not be present in production.
*/
pbjs.registerBidAdapter(null, 'testBidder', {
supportedMediaTypes: ['banner', 'video', 'native'],
isBidRequestValid: () => true
});

pbjs.setConfig({
debugging: {
enabled: true,
intercept: [
{
when: {
bidder: 'testBidder',
},
then: {
creativeId: 'testCreativeId',
}
}
]
}
});
/**
* BID RESPONSE SIMULATION SECTION END
*/

pbjs.addAdUnits(adUnits);
pbjs.requestBids({
adUnitCodes: [adUnitCode],
bidsBackHandler: function() {
const bids = pbjs.getHighestCpmBids(adUnitCode);
const bid = bids[0];
const slot = document.getElementById('native');
const iframe = document.createElement('iframe');
Object.entries({
frameBorder: 0,
marginWidth: 0,
marginHeight: 0,
width: 600,
height: 500,
scrolling: 'no',
srcdoc: document.getElementById('native-template').innerHTML
}).forEach(([prop, val]) => iframe.setAttribute(prop, val));
slot.appendChild(iframe);
iframe.onload = () => pbjs.renderAd(iframe.contentDocument, bid.adId);
}
});
});
</script>
</head>
<body>
<template id="native-template">
<style>
body {
display: inline-block;
}

.container {
display: inline-block;
font-family: "Helvetica Neue",Helvetica,Arial,sans-serif;
font-size: 14px;
line-height: 1.42857143;
box-sizing: border-box;
border: 3px dashed red;
padding: 20px;
color: #333;
}

.img {
width: 300px;
height: 200px;
}

</style>
<div class="container">
<h1>##hb_native_asset_id_4##</h1>
<h3>Rating: ##hb_native_asset_id_3##</h3>
<img class="img" src="##hb_native_asset_id_1##" alt="bg" />
</div>
</template>
<h2>Prebid Test Bidder Example</h2>
<h5>Native ad</h5>
<div id="native"></div>
</body>
</html>
75 changes: 75 additions & 0 deletions integrationExamples/testBidder/testBidderVideoExample.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
<html>
<head>
<title>Prebid Test Bidder Example</title>
<script src="../../build/dev/prebid.js" async></script>
<script>
var pbjs = pbjs || {};
pbjs.que = pbjs.que || [];

const adUnitCode = 'adUnit-0000';

const adUnits = [{
mediaTypes: {
video: {
playerSize: [640, 360],
context: 'outstream'
}
},
code: adUnitCode,
bids: [
{bidder: 'testBidder', params: {}}
]
}]

pbjs.que.push(function () {

/**
* BID RESPONSE SIMULATION SECTION START
*
* This section handles simulating a bidder
* that will always respond with bid responses.
*
* This part should not be present in production.
*/
pbjs.registerBidAdapter(null, 'testBidder', {
supportedMediaTypes: ['banner', 'video', 'native'],
isBidRequestValid: () => true
});

pbjs.setConfig({
debugging: {
enabled: true,
intercept: [
{
when: {
bidder: 'testBidder',
},
then: {
creativeId: 'testCreativeId',
}
}
]
}
});
/**
* BID RESPONSE SIMULATION SECTION END
*/

pbjs.addAdUnits(adUnits);
pbjs.requestBids({
adUnitCodes: [adUnitCode],
bidsBackHandler: function() {
const bids = pbjs.getHighestCpmBids(adUnitCode);
const winningBid = bids[0];
pbjs.renderAd(document, winningBid.adId);
}
});
});
</script>
</head>
<body>
<h2>Prebid Test Bidder Example</h2>
<h5>Video ad</h5>
<div id="player"></div>
</body>
</html>
6 changes: 6 additions & 0 deletions libraries/audUtils/bidderUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ export const getBannerRequest = (bidRequests, bidderRequest, ENDPOINT) => {
deepSetValue(req, 'regs.ext.us_privacy', bidderRequest.uspConsent);
}
req.MediaType = getMediaType(bidReq);
// Adding eids if passed
if (bidReq.userIdAsEids) {
req.user.ext.eids = bidReq.userIdAsEids;
}
request.push(req);
});
// Return the array of request
Expand Down Expand Up @@ -167,11 +171,13 @@ const getUserDetails = (bidReq) => {
user.buyeruid = bidReq.ortb2.user.buyeruid ? bidReq.ortb2.user.buyeruid : '';
user.keywords = bidReq.ortb2.user.keywords ? bidReq.ortb2.user.keywords : '';
user.customdata = bidReq.ortb2.user.customdata ? bidReq.ortb2.user.customdata : '';
user.ext = bidReq.ortb2.user.ext ? bidReq.ortb2.user.ext : '';
} else {
user.id = '';
user.buyeruid = '';
user.keywords = '';
user.customdata = '';
user.ext = {};
}
return user;
}
Expand Down
2 changes: 1 addition & 1 deletion libraries/intentIqConstants/intentIqConstants.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ export const OPT_OUT = 'O';
export const BLACK_LIST = 'L';
export const CLIENT_HINTS_KEY = '_iiq_ch';
export const EMPTY = 'EMPTY'
export const VERSION = 0.25
export const VERSION = 0.26
2 changes: 1 addition & 1 deletion libraries/intentIqUtils/detectBrowserUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export function detectBrowserFromUserAgent(userAgent) {

/**
* Detects the browser from the NavigatorUAData object
* @param {NavigatorUAData} userAgentData - The user agent data object from the browser
* @param {Object} userAgentData - The user agent data object from the browser
* @return {string} The name of the detected browser or 'unknown' if unable to detect
*/
export function detectBrowserFromUserAgentData(userAgentData) {
Expand Down
3 changes: 3 additions & 0 deletions libraries/ortbConverter/processors/default.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@ export const DEFAULT_PROCESSORS = {
if (bid.attr) {
bidResponse.meta.attr = bid.attr;
}
if (bid.ext?.eventtrackers) {
bidResponse.eventtrackers = (bidResponse.eventtrackers ?? []).concat(bid.ext.eventtrackers);
}
}
}
}
Expand Down
18 changes: 18 additions & 0 deletions libraries/pbsExtensions/processors/eventTrackers.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import {EVENT_TYPE_IMPRESSION, EVENT_TYPE_WIN, TRACKER_METHOD_IMG} from '../../../src/eventTrackers.js';

export function addEventTrackers(bidResponse, bid) {
bidResponse.eventtrackers = bidResponse.eventtrackers || [];
[
[bid.burl, EVENT_TYPE_IMPRESSION], // core used to fire burl directly, but only for bids coming from PBS
[bid?.ext?.prebid?.events?.win, EVENT_TYPE_WIN]
].filter(([winUrl, type]) => winUrl && bidResponse.eventtrackers.find(
({method, event, url}) => event === type && method === TRACKER_METHOD_IMG && url === winUrl
) == null)
.forEach(([url, event]) => {
bidResponse.eventtrackers.push({
method: TRACKER_METHOD_IMG,
event,
url
})
})
}
Loading

0 comments on commit c065d54

Please sign in to comment.