Skip to content

Commit

Permalink
Merge pull request #367 from PubMatic-OpenWrap/prebid_upgrade_2_44_2_…
Browse files Browse the repository at this point in the history
…20200115105543

Prebid upgrade 2 44 2 20200115105543
  • Loading branch information
pm-shashank-jain authored Jan 21, 2020
2 parents 3d75e1b + 586f16c commit a1ed465
Show file tree
Hide file tree
Showing 24 changed files with 855 additions and 139 deletions.
45 changes: 28 additions & 17 deletions modules/aniviewBidAdapter.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { VIDEO } from '../src/mediaTypes';
import * as utils from '../src/utils';
import { registerBidder } from '../src/adapters/bidderFactory';
import { Renderer } from '../src/Renderer';

Expand Down Expand Up @@ -50,19 +49,21 @@ function buildRequests(validBidRequests, bidderRequest) {

for (let i = 0; i < validBidRequests.length; i++) {
let bidRequest = validBidRequests[i];
var sizes = [[640, 480]];

if (!bidRequest.sizes || !bidRequest.sizes.length) {
bidRequest.sizes = [[640, 480]];
if (bidRequest.mediaTypes && bidRequest.mediaTypes.video && bidRequest.mediaTypes.video.playerSize) {
sizes = bidRequest.mediaTypes.video.playerSize;
} else {
if (bidRequest.sizes) {
sizes = bidRequest.sizes;
}
}

if (bidRequest.sizes.length === 2 && typeof bidRequest.sizes[0] === 'number' && typeof bidRequest.sizes[1] === 'number') {
let adWidth = bidRequest.sizes[0];
let adHeight = bidRequest.sizes[1];
bidRequest.sizes = [[adWidth, adHeight]];
if (sizes.length === 2 && typeof sizes[0] === 'number') {
sizes = [[sizes[0], sizes[1]]];
}

for (let j = 0; j < bidRequest.sizes.length; j++) {
let size = bidRequest.sizes[j];
for (let j = 0; j < sizes.length; j++) {
let size = sizes[j];
let playerWidth;
let playerHeight;
if (size && size.length == 2) {
Expand All @@ -82,32 +83,42 @@ function buildRequests(validBidRequests, bidderRequest) {
};

if (s2sParams.AV_APPPKGNAME && !s2sParams.AV_URL) { s2sParams.AV_URL = s2sParams.AV_APPPKGNAME; }
if (!s2sParams.AV_IDFA && !s2sParams.AV_URL) { s2sParams.AV_URL = utils.getTopWindowUrl(); }
if (!s2sParams.AV_IDFA && !s2sParams.AV_URL) {
if (bidderRequest && bidderRequest.refererInfo && bidderRequest.refererInfo.referer) {
s2sParams.AV_URL = bidderRequest.refererInfo.referer;
} else {
s2sParams.AV_URL = window.location.href;
}
}
if (s2sParams.AV_IDFA && !s2sParams.AV_AID) { s2sParams.AV_AID = s2sParams.AV_IDFA; }
if (s2sParams.AV_AID && !s2sParams.AV_IDFA) { s2sParams.AV_IDFA = s2sParams.AV_AID; }

s2sParams.pbjs = 1;
s2sParams.cb = Math.floor(Math.random() * 999999999);
s2sParams.AV_WIDTH = playerWidth;
s2sParams.AV_HEIGHT = playerHeight;
s2sParams.s2s = '1';
s2sParams.bidId = bidRequest.bidId;
s2sParams.bidWidth = playerWidth;
s2sParams.bidHeight = playerHeight;
s2sParams.bidId = bidRequest.bidId;
s2sParams.pbjs = 1;
s2sParams.tgt = 10;
s2sParams.s2s = '1';

if (bidderRequest && bidderRequest.gdprConsent) {
if (bidderRequest.gdprConsent.gdprApplies) {
s2sParams.AV_GDPR = 1;
s2sParams.AV_CONSENT = bidderRequest.gdprConsent.consentString
s2sParams.AV_CONSENT = bidderRequest.gdprConsent.consentString;
}
}
if (bidderRequest && bidderRequest.uspConsent) {
s2sParams.AV_CCPA = bidderRequest.uspConsent;
}

let serverDomain = bidRequest.params && bidRequest.params.serverDomain ? bidRequest.params.serverDomain : 'gov.aniview.com';
let serverUrl = 'https://' + serverDomain + '/api/adserver/vast3/';
let servingUrl = 'https://' + serverDomain + '/api/adserver/vast3/';

bidRequests.push({
method: 'GET',
url: serverUrl,
url: servingUrl,
data: s2sParams,
bidRequest
});
Expand Down
26 changes: 14 additions & 12 deletions modules/aniviewBidAdapter.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,20 @@ For more information about [Aniview](http://www.aniview.com), please contact [su
```javascript
var videoAdUnit = [
{
code: 'video1',
sizes: [
[300, 250],
[640, 480]
],
bids: [{
bidder: 'aniview',
params: {
AV_PUBLISHERID: '55b78633181f4603178b4568',
AV_CHANNELID: '55b7904d181f46410f8b4568'
}
}]
code: 'video1',
mediaTypes: {
video: {
playerSize: [[640, 480]],
context: 'instream'
},
},
bids: [{
bidder: 'aniview',
params: {
AV_PUBLISHERID: '55b78633181f4603178b4568',
AV_CHANNELID: '5d19dfca4b6236688c0a2fc4'
}
}]
}];
```

Expand Down
41 changes: 12 additions & 29 deletions modules/cedatoBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@ import { registerBidder } from '../src/adapters/bidderFactory';
import { BANNER, VIDEO } from '../src/mediaTypes';

const BIDDER_CODE = 'cedato';
const BID_URL = '//h.cedatoplayer.com/hb';
const SYNC_URL = '//h.cedatoplayer.com/hb_usync?uid={UUID}';
const COOKIE_NAME = 'hb-cedato-id';
const UUID_LEN = 36;
const BID_URL = 'https://h.cedatoplayer.com/hb';
const SYNC_URL = 'https://h.cedatoplayer.com/hb_usync';
const TTL = 10000;
const CURRENCY = 'USD';
const FIRST_PRICE = 1;
Expand All @@ -32,7 +30,6 @@ export const spec = {
const at = FIRST_PRICE;
const site = { id: params.player_id, domain: document.domain };
const device = { ua: navigator.userAgent };
const user = { id: getUserID() }
const currency = CURRENCY;
const tmax = bidderRequest.timeout;
const auctionId = bidderRequest.auctionId;
Expand All @@ -46,6 +43,7 @@ export const spec = {
const bidId = req.bidId;
const adUnitCode = req.adUnitCode;
const bidRequestsCount = req.bidRequestsCount;
const bidderWinsCount = req.bidderWinsCount;
const transactionId = req.transactionId;

return {
Expand All @@ -55,6 +53,7 @@ export const spec = {
adUnitCode,
bidfloor,
bidRequestsCount,
bidderWinsCount,
transactionId
};
});
Expand All @@ -64,7 +63,6 @@ export const spec = {
at,
site,
device,
user,
imp,
currency,
tmax,
Expand All @@ -75,6 +73,8 @@ export const spec = {

if (bidderRequest) {
payload.referer_info = bidderRequest.refererInfo;
payload.us_privacy = bidderRequest.uspConsent;

if (bidderRequest.gdprConsent) {
payload.gdpr_consent = {
consent_string: bidderRequest.gdprConsent.consentString,
Expand Down Expand Up @@ -108,12 +108,12 @@ export const spec = {
return bids;
},

getUserSyncs: function(syncOptions, resps, gdprConsent) {
getUserSyncs: function(syncOptions, resps, gdprConsent, uspConsent) {
const syncs = [];
if (syncOptions.iframeEnabled) {
syncs.push(getSync('iframe', gdprConsent));
syncs.push(getSync('iframe', gdprConsent, uspConsent));
} else if (syncOptions.pixelEnabled) {
syncs.push(getSync('image', gdprConsent));
syncs.push(getSync('image', gdprConsent, uspConsent));
}
return syncs;
}
Expand Down Expand Up @@ -186,10 +186,9 @@ function newBid(serverBid, bidderRequest) {
return bid;
}

const getSync = (type, gdprConsent) => {
const uuid = getUserID();
const getSync = (type, gdprConsent, uspConsent = '') => {
const syncUrl = SYNC_URL;
let params = '&type=' + type;
let params = '&type=' + type + '&us_privacy=' + uspConsent;
if (gdprConsent && typeof gdprConsent.consentString === 'string') {
if (typeof gdprConsent.gdprApplies === 'boolean') {
params += `&gdpr=${Number(gdprConsent.gdprApplies)}&gdpr_consent=${gdprConsent.consentString}`;
Expand All @@ -199,26 +198,10 @@ const getSync = (type, gdprConsent) => {
}
return {
type: type,
url: syncUrl.replace('{UUID}', uuid) + params,
url: syncUrl + params,
};
}

const getUserID = () => {
const cookieName = COOKIE_NAME;
const uuidLen = UUID_LEN;

const i = document.cookie.indexOf(cookieName);

if (i === -1) {
const uuid = utils.generateUUID();
document.cookie = `${cookieName}=${uuid}; path=/`;
return uuid;
}

const j = i + cookieName.length + 1;
return document.cookie.substring(j, j + uuidLen);
};

const getFormats = arr => arr.map((s) => {
return { w: s[0], h: s[1] };
});
Expand Down
Loading

0 comments on commit a1ed465

Please sign in to comment.