Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VidoomyBidAdapter: fix video mediatype sizes format #7716

Merged
merged 16 commits into from
Nov 23, 2021
Merged
Changes from 15 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 15 additions & 10 deletions modules/vidoomyBidAdapter.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { logError, deepAccess } from '../src/utils.js';
import { logError, deepAccess, parseSizesInput } from '../src/utils.js';
import {registerBidder} from '../src/adapters/bidderFactory.js';
import {BANNER, VIDEO} from '../src/mediaTypes.js';
import {config} from '../src/config.js';
Expand Down Expand Up @@ -53,7 +53,7 @@ const isBidResponseValid = bid => {
case BANNER:
return Boolean(bid.width && bid.height && bid.ad);
case VIDEO:
return Boolean(bid.vastUrl);
return Boolean(bid.vastUrl || bid.vastXml);
default:
return false;
}
Expand All @@ -62,14 +62,15 @@ const isBidResponseValid = bid => {
const buildRequests = (validBidRequests, bidderRequest) => {
const serverRequests = validBidRequests.map(bid => {
let adType = BANNER;
let w, h;
let sizes;
if (bid.mediaTypes && bid.mediaTypes[BANNER] && bid.mediaTypes[BANNER].sizes) {
[w, h] = bid.mediaTypes[BANNER].sizes[0];
sizes = bid.mediaTypes[BANNER].sizes;
adType = BANNER;
} else if (bid.mediaTypes && bid.mediaTypes[VIDEO] && bid.mediaTypes[VIDEO].playerSize) {
[w, h] = bid.mediaTypes[VIDEO].playerSize;
sizes = bid.mediaTypes[VIDEO].playerSize;
adType = VIDEO;
}
const [w, h] = (parseSizesInput(sizes)[0] || '0x0').split('x');

const aElement = document.createElement('a');
aElement.href = (bidderRequest.refererInfo && bidderRequest.refererInfo.referer) || top.location.href;
Expand All @@ -88,7 +89,7 @@ const buildRequests = (validBidRequests, bidderRequest) => {
dt: /Mobi/.test(navigator.userAgent) ? 2 : 1,
pid: bid.params.pid,
requestId: bid.bidId,
d: getDomainWithoutSubdomain(hostname),
d: getDomainWithoutSubdomain(hostname), // 'vidoomy.com',
sp: encodeURIComponent(aElement.href),
usp: bidderRequest.uspConsent || '',
coppa: !!config.getConfig('coppa'),
Expand Down Expand Up @@ -127,7 +128,7 @@ const interpretResponse = (serverResponse, bidRequest) => {
let responseBody = serverResponse.body;
if (!responseBody) return;
if (responseBody.mediaType === 'video') {
responseBody.ad = responseBody.vastUrl;
responseBody.ad = responseBody.vastUrl || responseBody.vastXml;
const videoContext = bidRequest.data.videoContext;

if (videoContext === OUTSTREAM) {
Expand All @@ -143,13 +144,12 @@ const interpretResponse = (serverResponse, bidRequest) => {

responseBody.renderer = renderer;
} catch (e) {
responseBody.ad = responseBody.vastUrl;
responseBody.ad = responseBody.vastUrl || responseBody.vastXml;
logError(BIDDER_CODE + ': error while installing renderer to show outstream ad');
}
}
}
const bid = {
vastUrl: responseBody.vastUrl,
ad: responseBody.ad,
renderer: responseBody.renderer,
mediaType: responseBody.mediaType,
Expand Down Expand Up @@ -178,6 +178,11 @@ const interpretResponse = (serverResponse, bidRequest) => {
secondaryCatIds: responseBody.meta.secondaryCatIds
}
};
if (responseBody.vastUrl) {
bid.vastUrl = responseBody.vastUrl;
} else if (responseBody.vastXml) {
bid.vastXml = responseBody.vastXml;
}

const bids = [];

Expand All @@ -202,7 +207,7 @@ function getUserSyncs (syncOptions, responses, gdprConsent, uspConsent) {
return [].concat(urls).map(url => ({
type: pixelType,
url: url
.replace('{{GDPR}}', gdprConsent ? gdprConsent.gdprApplies : '0')
.replace('{{GDPR}}', gdprConsent ? (gdprConsent.gdprApplies ? '1' : '0') : '0')
.replace('{{GDPR_CONSENT}}', gdprConsent ? encodeURIComponent(gdprConsent.consentString) : '')
.replace('{{USP_CONSENT}}', uspConsent ? encodeURIComponent(uspConsent) : '')
}));
Expand Down