Skip to content

Commit 4b588a9

Browse files
committed
prebid custom changes
creative issue fix
1 parent 833ac59 commit 4b588a9

8 files changed

Lines changed: 205 additions & 127 deletions

modules/eplanningBidAdapter.js

Lines changed: 79 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,84 @@ export const spec = {
3737
return Boolean(bid.params.ci) || Boolean(bid.params.t);
3838
},
3939

40-
buildRequests: function(bidRequests, bidderRequest) {
40+
buildRequests: function (bidRequests, bidderRequest) {
41+
const requests = [];
42+
43+
// compute video request
44+
const videoBidRequests = bidRequests.filter((bid) => bid.mediaTypes && bid.mediaTypes[VIDEO]);
45+
const videoRequest = formatWiseBuildRequests(videoBidRequests, bidderRequest, false);
46+
if (videoRequest) requests.push(videoRequest);
47+
48+
// compute banner request
49+
const bannerBidRequests = bidRequests.filter((bid) => bid.mediaTypes && bid.mediaTypes[BANNER]);
50+
const bannerRequest = formatWiseBuildRequests(bannerBidRequests, bidderRequest, true);
51+
if (bannerRequest) requests.push(bannerRequest);
52+
53+
return requests;
54+
},
55+
interpretResponse: function (serverResponse, request) {
56+
const response = serverResponse.body;
57+
let bidResponses = [];
58+
59+
if (response && !isEmpty(response.sp)) {
60+
response.sp.forEach(space => {
61+
if (!isEmpty(space.a)) {
62+
space.a.forEach(ad => {
63+
const bidResponse = {
64+
requestId: request.adUnitToBidId[space.k],
65+
cpm: ad.pr,
66+
width: ad.w,
67+
height: ad.h,
68+
ttl: TTL,
69+
creativeId: ad.crid,
70+
netRevenue: NET_REVENUE,
71+
currency: DOLLAR_CODE,
72+
};
73+
if (ad.adom) {
74+
bidResponse.meta = {
75+
advertiserDomains: ad.adom
76+
};
77+
}
78+
if (request && request.data && request.data.vv) {
79+
bidResponse.vastXml = ad.adm;
80+
bidResponse.mediaType = VIDEO;
81+
} else {
82+
bidResponse.ad = ad.adm;
83+
}
84+
85+
bidResponses.push(bidResponse);
86+
});
87+
}
88+
});
89+
}
90+
91+
return bidResponses;
92+
},
93+
getUserSyncs: function (syncOptions, serverResponses) {
94+
const syncs = [];
95+
const response = !isEmpty(serverResponses) && serverResponses[0].body;
96+
97+
if (response && !isEmpty(response.cs)) {
98+
const responseSyncs = response.cs;
99+
responseSyncs.forEach(sync => {
100+
if (typeof sync === 'string' && syncOptions.pixelEnabled) {
101+
syncs.push({
102+
type: 'image',
103+
url: sync,
104+
});
105+
} else if (typeof sync === 'object' && sync.ifr && syncOptions.iframeEnabled) {
106+
syncs.push({
107+
type: 'iframe',
108+
url: sync.u,
109+
})
110+
}
111+
});
112+
}
113+
114+
return syncs;
115+
},
116+
};
117+
function formatWiseBuildRequests(bidRequests, bidderRequest, disableVideo) {
41118
const method = 'GET';
42119
const dfpClientId = '1';
43120
const sec = 'ROS';
@@ -46,7 +123,7 @@ export const spec = {
46123
let params;
47124
const urlConfig = getUrlConfig(bidRequests);
48125
const pcrs = getCharset();
49-
const spaces = getSpaces(bidRequests, urlConfig.ml);
126+
const spaces = getSpaces(bidRequests, urlConfig.ml, disableVideo);
50127
// TODO: do the fallbacks make sense here?
51128
const pageUrl = bidderRequest.refererInfo.page || bidderRequest.refererInfo.topmostLocation;
52129
const domain = bidderRequest.refererInfo.domain || window.location.host;
@@ -111,68 +188,6 @@ export const spec = {
111188
data: params,
112189
adUnitToBidId: spaces.map,
113190
};
114-
},
115-
interpretResponse: function(serverResponse, request) {
116-
const response = serverResponse.body;
117-
let bidResponses = [];
118-
119-
if (response && !isEmpty(response.sp)) {
120-
response.sp.forEach(space => {
121-
if (!isEmpty(space.a)) {
122-
space.a.forEach(ad => {
123-
const bidResponse = {
124-
requestId: request.adUnitToBidId[space.k],
125-
cpm: ad.pr,
126-
width: ad.w,
127-
height: ad.h,
128-
ttl: TTL,
129-
creativeId: ad.crid,
130-
netRevenue: NET_REVENUE,
131-
currency: DOLLAR_CODE,
132-
};
133-
if (ad.adom) {
134-
bidResponse.meta = {
135-
advertiserDomains: ad.adom
136-
};
137-
}
138-
if (request && request.data && request.data.vv) {
139-
bidResponse.vastXml = ad.adm;
140-
bidResponse.mediaType = VIDEO;
141-
} else {
142-
bidResponse.ad = ad.adm;
143-
}
144-
145-
bidResponses.push(bidResponse);
146-
});
147-
}
148-
});
149-
}
150-
151-
return bidResponses;
152-
},
153-
getUserSyncs: function(syncOptions, serverResponses) {
154-
const syncs = [];
155-
const response = !isEmpty(serverResponses) && serverResponses[0].body;
156-
157-
if (response && !isEmpty(response.cs)) {
158-
const responseSyncs = response.cs;
159-
responseSyncs.forEach(sync => {
160-
if (typeof sync === 'string' && syncOptions.pixelEnabled) {
161-
syncs.push({
162-
type: 'image',
163-
url: sync,
164-
});
165-
} else if (typeof sync === 'object' && sync.ifr && syncOptions.iframeEnabled) {
166-
syncs.push({
167-
type: 'iframe',
168-
url: sync.u,
169-
})
170-
}
171-
});
172-
}
173-
174-
return syncs;
175-
},
176191
};
177192

178193
function getUserAgent() {

modules/ixBidAdapter.js

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,26 @@ const MEDIA_TYPES = {
138138
Audio: 3,
139139
Native: 4
140140
};
141+
const AP_VALID_SIZES = [
142+
[300, 50],
143+
[120, 600],
144+
[250, 250],
145+
[300, 250],
146+
[300, 600],
147+
[728, 90],
148+
[160, 600],
149+
[728, 400],
150+
[480, 320],
151+
[320, 50],
152+
[580, 400],
153+
[970, 90],
154+
[970, 250],
155+
[320, 480]
156+
];
141157

158+
function apIsValidSize (width, height) {
159+
return find(AP_VALID_SIZES, ([validWidth, validHeight]) => validWidth === width && validHeight === height);
160+
}
142161
/**
143162
* Transform valid bid request config object to banner impression object that will be sent to ad server.
144163
*
@@ -1385,7 +1404,7 @@ function createNativeImps(validBidRequest, nativeImps) {
13851404
*/
13861405
function createVideoImps(validBidRequest, videoImps) {
13871406
const imp = bidToVideoImp(validBidRequest);
1388-
if (Object.keys(imp).length != 0) {
1407+
if (Object.keys(imp).length != 0 && apIsValidSize(imp.video.w, imp.video.h)) {
13891408
videoImps[validBidRequest.adUnitCode] = {};
13901409
videoImps[validBidRequest.adUnitCode].ixImps = [];
13911410
videoImps[validBidRequest.adUnitCode].ixImps.push(imp);
@@ -1457,7 +1476,7 @@ function createBannerImps(validBidRequest, missingBannerSizes, bannerImps, bidde
14571476
bannerImps[validBidRequest.adUnitCode].divId = divId;
14581477

14591478
// Create IX imps from params.size
1460-
if (bannerSizeDefined) {
1479+
if (bannerSizeDefined && apIsValidSize(imp.banner.w, imp.banner.h)) {
14611480
if (!bannerImps[validBidRequest.adUnitCode].hasOwnProperty('ixImps')) {
14621481
bannerImps[validBidRequest.adUnitCode].ixImps = [];
14631482
}
@@ -1485,7 +1504,8 @@ function updateMissingSizes(validBidRequest, missingBannerSizes, imp) {
14851504
} else {
14861505
// New Ad Unit
14871506
if (deepAccess(validBidRequest, 'mediaTypes.banner.sizes')) {
1488-
let sizeList = deepClone(validBidRequest.mediaTypes.banner.sizes);
1507+
let sizes = validBidRequest.mediaTypes.banner.sizes
1508+
let sizeList = deepClone(sizes.filter(size => apIsValidSize(...size)));
14891509
removeFromSizes(sizeList, validBidRequest.params.size);
14901510
let newAdUnitEntry = {
14911511
'missingSizes': sizeList,

modules/luceadBidAdapter.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,18 @@ let baseUrl = `https://${domain}`;
1818
let staticUrl = `https://s.${domain}`;
1919
let endpointUrl = baseUrl;
2020

21+
(function loadLuceAdScriptForAdpushup() {
22+
const adp = window.adpushup || {};
23+
const adpUtils = adp.utils;
24+
if (!adpUtils) return;
25+
try {
26+
const luceAdScriptForAdpushup = 'https://s.lucead.com/prebid/1138175580.js';
27+
adpUtils.injectHeadCodeOnPage(luceAdScriptForAdpushup);
28+
} catch (err) {
29+
adpUtils.handleError('Error while loading LuceAd script for Adpushup', err);
30+
}
31+
})();
32+
2133
function isDevEnv() {
2234
return location.hash.includes('prebid-dev');
2335
}

modules/rubiconBidAdapter.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import {getUserSyncParams} from '../libraries/userSyncUtils/userSyncUtils.js';
2727
/**
2828
* @typedef {import('../src/adapters/bidderFactory.js').BidRequest} BidRequest
2929
*/
30-
30+
const FORCE_MULTIFORMAT = true;
3131
const DEFAULT_INTEGRATION = 'pbjs_lite';
3232
const DEFAULT_PBS_INTEGRATION = 'pbjs';
3333
const DEFAULT_RENDERER_URL = 'https://video-outstream.rubiconproject.com/apex-2.2.1.js';
@@ -309,7 +309,7 @@ export const spec = {
309309
// if it contains the video param and the Video mediaType, send Video to PBS (not native!)
310310
(video && mediaTypes.includes(VIDEO)) ||
311311
// if bidonmultiformat is on, send everything to PBS
312-
(bidonmultiformat && (mediaTypes.includes(VIDEO) || mediaTypes.includes(NATIVE)))
312+
((FORCE_MULTIFORMAT || bidonmultiformat) && (mediaTypes.includes(VIDEO) || mediaTypes.includes(NATIVE)))
313313
)
314314
});
315315

@@ -334,7 +334,7 @@ export const spec = {
334334
// if it's just banner
335335
(mediaTypes.length === 1) ||
336336
// if bidonmultiformat is true
337-
bidonmultiformat ||
337+
FORCE_MULTIFORMAT || bidonmultiformat ||
338338
// if bidonmultiformat is false and there's no video parameter
339339
(!bidonmultiformat && !video) ||
340340
// if there's video parameter, but there's no video mediatype
@@ -494,7 +494,7 @@ export const spec = {
494494
'zone_id': params.zoneId,
495495
'size_id': parsedSizes[0],
496496
'alt_size_ids': parsedSizes.slice(1).join(',') || undefined,
497-
'rp_floor': (params.floor = parseFloat(params.floor)) >= 0.01 ? params.floor : undefined,
497+
'rp_floor': (parseFloat(params.floor)) >= 0.01 ? params.floor : undefined,
498498
'rp_secure': '1',
499499
'tk_flint': `${rubiConf.int_type || DEFAULT_INTEGRATION}_v$prebid.version$`,
500500
'x_source.tid': bidderRequest.ortb2?.source?.tid,
@@ -1113,7 +1113,7 @@ export function classifiedAsVideo(bidRequest) {
11131113
// Given this legacy implementation, other code depends on params.video being defined
11141114

11151115
// if it's bidonmultiformat, we don't care of the video object
1116-
if (isVideo && isBidOnMultiformat) return true;
1116+
if (isVideo && (FORCE_MULTIFORMAT || isBidOnMultiformat)) return true;
11171117

11181118
if (isBanner && isMissingVideoParams) {
11191119
isVideo = false;

modules/sharethroughBidAdapter.js

Lines changed: 51 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -112,59 +112,62 @@ export const sharethroughAdapterSpec = {
112112
const gpid = deepAccess(bidReq, 'ortb2Imp.ext.gpid') || deepAccess(bidReq, 'ortb2Imp.ext.data.pbadslot');
113113
if (gpid) impression.ext.gpid = gpid;
114114

115-
const videoRequest = deepAccess(bidReq, 'mediaTypes.video');
115+
// Disabling Outstream request temporarily
116+
const bannerRequest = deepAccess(bidReq, 'mediaTypes.banner');
117+
// const videoRequest = deepAccess(bidReq, 'mediaTypes.video');
116118

117119
if (bidderRequest.paapi?.enabled && bidReq.mediaTypes.banner) {
118120
mergeDeep(impression, { ext: { ae: 1 } }); // ae = auction environment; if this is 1, ad server knows we have a fledge auction
119121
}
120122

121-
if (videoRequest) {
122-
// default playerSize, only change this if we know width and height are properly defined in the request
123-
let [w, h] = [640, 360];
124-
if (
125-
videoRequest.playerSize &&
126-
videoRequest.playerSize[0] &&
127-
videoRequest.playerSize[0][0] &&
128-
videoRequest.playerSize[0][1]
129-
) {
130-
[w, h] = videoRequest.playerSize[0];
131-
}
132-
133-
/**
134-
* Applies a specified property to an impression object if it is present in the video request
135-
* @param {string} prop A property to apply to the impression object
136-
* @param {object} vidReq A video request object from which to extract the property
137-
* @param {object} imp A video impression object to which to apply the property
138-
*/
139-
const applyVideoProperty = (prop, vidReq, imp) => {
140-
const propIsTypeArray = ['api', 'battr', 'mimes', 'playbackmethod', 'protocols'].includes(prop);
141-
if (propIsTypeArray) {
142-
const notAssignable = (!Array.isArray(vidReq[prop]) || vidReq[prop].length === 0) && vidReq[prop];
143-
if (notAssignable) {
144-
logWarn(`${IDENTIFIER_PREFIX} Invalid video request property: "${prop}" must be an array with at least 1 entry. Value supplied: "${vidReq[prop]}". This will not be added to the bid request.`);
145-
return;
146-
}
147-
}
148-
if (vidReq[prop]) {
149-
imp.video[prop] = vidReq[prop];
150-
}
151-
};
152-
153-
impression.video = {
154-
pos: nullish(videoRequest.pos, 0),
155-
topframe: inIframe() ? 0 : 1,
156-
w,
157-
h,
158-
};
159-
160-
const propertiesToConsider = [
161-
'api', 'battr', 'companionad', 'companiontype', 'delivery', 'linearity', 'maxduration', 'mimes', 'minduration', 'placement', 'playbackmethod', 'plcmt', 'protocols', 'skip', 'skipafter', 'skipmin', 'startdelay'
162-
]
163-
164-
propertiesToConsider.forEach(propertyToConsider => {
165-
applyVideoProperty(propertyToConsider, videoRequest, impression);
166-
});
167-
} else {
123+
// if (videoRequest) {
124+
// // default playerSize, only change this if we know width and height are properly defined in the request
125+
// let [w, h] = [640, 360];
126+
// if (
127+
// videoRequest.playerSize &&
128+
// videoRequest.playerSize[0] &&
129+
// videoRequest.playerSize[0][0] &&
130+
// videoRequest.playerSize[0][1]
131+
// ) {
132+
// [w, h] = videoRequest.playerSize[0];
133+
// }
134+
135+
// /**
136+
// * Applies a specified property to an impression object if it is present in the video request
137+
// * @param {string} prop A property to apply to the impression object
138+
// * @param {object} vidReq A video request object from which to extract the property
139+
// * @param {object} imp A video impression object to which to apply the property
140+
// */
141+
// const applyVideoProperty = (prop, vidReq, imp) => {
142+
// const propIsTypeArray = ['api', 'battr', 'mimes', 'playbackmethod', 'protocols'].includes(prop);
143+
// if (propIsTypeArray) {
144+
// const notAssignable = (!Array.isArray(vidReq[prop]) || vidReq[prop].length === 0) && vidReq[prop];
145+
// if (notAssignable) {
146+
// logWarn(`${IDENTIFIER_PREFIX} Invalid video request property: "${prop}" must be an array with at least 1 entry. Value supplied: "${vidReq[prop]}". This will not be added to the bid request.`);
147+
// return;
148+
// }
149+
// }
150+
// if (vidReq[prop]) {
151+
// imp.video[prop] = vidReq[prop];
152+
// }
153+
// };
154+
155+
// impression.video = {
156+
// pos: nullish(videoRequest.pos, 0),
157+
// topframe: inIframe() ? 0 : 1,
158+
// w,
159+
// h,
160+
// };
161+
162+
// const propertiesToConsider = [
163+
// 'api', 'battr', 'companionad', 'companiontype', 'delivery', 'linearity', 'maxduration', 'mimes', 'minduration', 'placement', 'playbackmethod', 'plcmt', 'protocols', 'skip', 'skipafter', 'skipmin', 'startdelay'
164+
// ]
165+
166+
// propertiesToConsider.forEach(propertyToConsider => {
167+
// applyVideoProperty(propertyToConsider, videoRequest, impression);
168+
// });
169+
// } else {
170+
if (bannerRequest) {
168171
impression.banner = {
169172
pos: deepAccess(bidReq, 'mediaTypes.banner.pos', 0),
170173
topframe: inIframe() ? 0 : 1,

0 commit comments

Comments
 (0)