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

adtelligent bid adapter: add new allias #12559

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
79 changes: 79 additions & 0 deletions libraries/adtelligentUtils/adtelligentUtils.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
import {deepAccess, isArray} from '../../src/utils.js';
import { config } from '../../src/config.js';
import {BANNER, VIDEO} from '../../src/mediaTypes.js';

export const supportedMediaTypes = [VIDEO, BANNER]

export function isBidRequestValid (bid) {
return !!deepAccess(bid, 'params.aid');
}

export function getUserSyncsFn (syncOptions, serverResponses, syncsCache = {}) {
const syncs = [];
function addSyncs(bid) {
const uris = bid.cookieURLs;
const types = bid.cookieURLSTypes || [];

if (Array.isArray(uris)) {
uris.forEach((uri, i) => {
const type = types[i] || 'image';

if ((!syncOptions.pixelEnabled && type === 'image') ||
(!syncOptions.iframeEnabled && type === 'iframe') ||
syncsCache[uri]) {
return;
}

syncsCache[uri] = true;
syncs.push({
type: type,
url: uri
})
})
}
}

if (syncOptions.pixelEnabled || syncOptions.iframeEnabled) {
isArray(serverResponses) && serverResponses.forEach((response) => {
if (response.body) {
if (isArray(response.body)) {
response.body.forEach(b => {
addSyncs(b);
})
} else {
addSyncs(response.body)
}
}
})
}
return syncs;
}

export function createTag(bidRequests, adapterRequest) {
const tag = {
// TODO: is 'page' the right value here?
Domain: deepAccess(adapterRequest, 'refererInfo.page'),
};

if (config.getConfig('coppa') === true) {
tag.Coppa = 1;
}
if (deepAccess(adapterRequest, 'gdprConsent.gdprApplies')) {
tag.GDPR = 1;
tag.GDPRConsent = deepAccess(adapterRequest, 'gdprConsent.consentString');
}
if (deepAccess(adapterRequest, 'uspConsent')) {
tag.USP = deepAccess(adapterRequest, 'uspConsent');
}
if (deepAccess(bidRequests[0], 'schain')) {
tag.Schain = deepAccess(bidRequests[0], 'schain');
}
if (deepAccess(bidRequests[0], 'userId')) {
tag.UserIds = deepAccess(bidRequests[0], 'userId');
}
if (deepAccess(bidRequests[0], 'userIdAsEids')) {
tag.UserEids = deepAccess(bidRequests[0], 'userIdAsEids');
}

return tag;
}
72 changes: 9 additions & 63 deletions modules/adtargetBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ import {BANNER, VIDEO} from '../src/mediaTypes.js';
import {config} from '../src/config.js';
import {find} from '../src/polyfill.js';
import {chunk} from '../libraries/chunk/chunk.js';
import {
createTag, getUserSyncsFn,
isBidRequestValid,
supportedMediaTypes
} from '../libraries/adtelligentUtils/adtelligentUtils.js';

const ENDPOINT = 'https://ghb.console.adtarget.com.tr/v2/auction/';
const BIDDER_CODE = 'adtarget';
Expand All @@ -13,50 +18,10 @@ const syncsCache = {};
export const spec = {
code: BIDDER_CODE,
gvlid: 779,
supportedMediaTypes: [VIDEO, BANNER],
isBidRequestValid: function (bid) {
return !!deepAccess(bid, 'params.aid');
},
supportedMediaTypes,
isBidRequestValid,
getUserSyncs: function (syncOptions, serverResponses) {
const syncs = [];

function addSyncs(bid) {
const uris = bid.cookieURLs;
const types = bid.cookieURLSTypes || [];

if (Array.isArray(uris)) {
uris.forEach((uri, i) => {
const type = types[i] || 'image';

if ((!syncOptions.pixelEnabled && type === 'image') ||
(!syncOptions.iframeEnabled && type === 'iframe') ||
syncsCache[uri]) {
return;
}

syncsCache[uri] = true;
syncs.push({
type: type,
url: uri
})
})
}
}

if (syncOptions.pixelEnabled || syncOptions.iframeEnabled) {
isArray(serverResponses) && serverResponses.forEach((response) => {
if (response.body) {
if (isArray(response.body)) {
response.body.forEach(b => {
addSyncs(b);
})
} else {
addSyncs(response.body)
}
}
})
}
return syncs;
return getUserSyncsFn(syncOptions, serverResponses, syncsCache)
},

buildRequests: function (bidRequests, adapterRequest) {
Expand Down Expand Up @@ -118,26 +83,7 @@ function parseResponse(serverResponse, adapterRequest) {
}

function bidToTag(bidRequests, adapterRequest) {
const tag = {
// TODO: is 'page' the right value here?
Domain: deepAccess(adapterRequest, 'refererInfo.page')
};
if (config.getConfig('coppa') === true) {
tag.Coppa = 1;
}
if (deepAccess(adapterRequest, 'gdprConsent.gdprApplies')) {
tag.GDPR = 1;
tag.GDPRConsent = deepAccess(adapterRequest, 'gdprConsent.consentString');
}
if (deepAccess(adapterRequest, 'uspConsent')) {
tag.USP = deepAccess(adapterRequest, 'uspConsent');
}
if (deepAccess(bidRequests[0], 'schain')) {
tag.Schain = deepAccess(bidRequests[0], 'schain');
}
if (deepAccess(bidRequests[0], 'userId')) {
tag.UserIds = deepAccess(bidRequests[0], 'userId');
}
const tag = createTag(bidRequests, adapterRequest);

const bids = [];

Expand Down
78 changes: 12 additions & 66 deletions modules/adtelligentBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ import {config} from '../src/config.js';
import {Renderer} from '../src/Renderer.js';
import {find} from '../src/polyfill.js';
import {chunk} from '../libraries/chunk/chunk.js';
import {
createTag, getUserSyncsFn,
isBidRequestValid,
supportedMediaTypes
} from '../libraries/adtelligentUtils/adtelligentUtils.js';

/**
* @typedef {import('../src/adapters/bidderFactory.js').Bid} Bid
Expand All @@ -26,6 +31,7 @@ const HOST_GETTERS = {
ocm: () => 'ghb.cenarius.orangeclickmedia.com',
'9dotsmedia': () => 'ghb.platform.audiodots.com',
indicue: () => 'ghb.console.indicue.com',
stellormedia: () => 'ghb.ads.stellormedia.com',
}
const getUri = function (bidderCode) {
let bidderWithoutSuffix = bidderCode.split('_')[0];
Expand All @@ -48,51 +54,12 @@ export const spec = {
{ code: 'ocm', gvlid: 1148 },
'9dotsmedia',
'indicue',
'stellormedia'
],
supportedMediaTypes: [VIDEO, BANNER],
isBidRequestValid: function (bid) {
return !!deepAccess(bid, 'params.aid');
},
supportedMediaTypes,
isBidRequestValid,
getUserSyncs: function (syncOptions, serverResponses) {
const syncs = [];

function addSyncs(bid) {
const uris = bid.cookieURLs;
const types = bid.cookieURLSTypes || [];

if (Array.isArray(uris)) {
uris.forEach((uri, i) => {
const type = types[i] || 'image';

if ((!syncOptions.pixelEnabled && type === 'image') ||
(!syncOptions.iframeEnabled && type === 'iframe') ||
syncsCache[uri]) {
return;
}

syncsCache[uri] = true;
syncs.push({
type: type,
url: uri
})
})
}
}

if (syncOptions.pixelEnabled || syncOptions.iframeEnabled) {
isArray(serverResponses) && serverResponses.forEach((response) => {
if (response.body) {
if (isArray(response.body)) {
response.body.forEach(b => {
addSyncs(b);
})
} else {
addSyncs(response.body)
}
}
})
}
return syncs;
return getUserSyncsFn(syncOptions, serverResponses, syncsCache)
},
/**
* Make a server request from the list of BidRequests
Expand Down Expand Up @@ -162,29 +129,7 @@ function parseRTBResponse(serverResponse, adapterRequest) {

function bidToTag(bidRequests, adapterRequest) {
// start publisher env
const tag = {
// TODO: is 'page' the right value here?
Domain: deepAccess(adapterRequest, 'refererInfo.page')
};
if (config.getConfig('coppa') === true) {
tag.Coppa = 1;
}
if (deepAccess(adapterRequest, 'gdprConsent.gdprApplies')) {
tag.GDPR = 1;
tag.GDPRConsent = deepAccess(adapterRequest, 'gdprConsent.consentString');
}
if (deepAccess(adapterRequest, 'uspConsent')) {
tag.USP = deepAccess(adapterRequest, 'uspConsent');
}
if (deepAccess(bidRequests[0], 'schain')) {
tag.Schain = deepAccess(bidRequests[0], 'schain');
}
if (deepAccess(bidRequests[0], 'userId')) {
tag.UserIds = deepAccess(bidRequests[0], 'userId');
}
if (deepAccess(bidRequests[0], 'userIdAsEids')) {
tag.UserEids = deepAccess(bidRequests[0], 'userIdAsEids');
}
const tag = createTag(bidRequests, adapterRequest);
if (window.adtDmp && window.adtDmp.ready) {
tag.DMPId = window.adtDmp.getUID();
}
Expand Down Expand Up @@ -307,6 +252,7 @@ function createBid(bidResponse, bidRequest) {
/**
* Create Adtelligent renderer
* @param requestId
* @param bidderParams
* @returns {*}
*/
function newRenderer(requestId, bidderParams) {
Expand Down
53 changes: 11 additions & 42 deletions modules/viewdeosDXBidAdapter.js
Original file line number Diff line number Diff line change
@@ -1,61 +1,29 @@
import {deepAccess, flatten, isArray, logError, parseSizesInput} from '../src/utils.js';
import {registerBidder} from '../src/adapters/bidderFactory.js';
import {BANNER, VIDEO} from '../src/mediaTypes.js';
import {VIDEO} from '../src/mediaTypes.js';
import {Renderer} from '../src/Renderer.js';
import {findIndex} from '../src/polyfill.js';
import {
getUserSyncsFn,
isBidRequestValid,
supportedMediaTypes
} from '../libraries/adtelligentUtils/adtelligentUtils.js';

const URL = 'https://ghb.sync.viewdeos.com/auction/';
const OUTSTREAM_SRC = 'https://player.sync.viewdeos.com/outstream-unit/2.01/outstream.min.js';
const BIDDER_CODE = 'viewdeosDX';
const OUTSTREAM = 'outstream';
const DISPLAY = 'display';
const syncsCache = {};

export const spec = {
code: BIDDER_CODE,
aliases: ['viewdeos'],
gvlid: 924,
supportedMediaTypes: [VIDEO, BANNER],
isBidRequestValid: function (bid) {
return !!deepAccess(bid, 'params.aid');
},
supportedMediaTypes,
isBidRequestValid,
getUserSyncs: function (syncOptions, serverResponses) {
const syncs = [];

function addSyncs(bid) {
const uris = bid.cookieURLs;
const types = bid.cookieURLSTypes || [];

if (Array.isArray(uris)) {
uris.forEach((uri, i) => {
const type = types[i] || 'image';

if ((!syncOptions.pixelEnabled && type === 'image') ||
(!syncOptions.iframeEnabled && type === 'iframe')) {
return;
}

syncs.push({
type: type,
url: uri
})
})
}
}

if (syncOptions.pixelEnabled || syncOptions.iframeEnabled) {
isArray(serverResponses) && serverResponses.forEach((response) => {
if (response.body) {
if (isArray(response.body)) {
response.body.forEach(b => {
addSyncs(b);
})
} else {
addSyncs(response.body)
}
}
})
}
return syncs;
return getUserSyncsFn(syncOptions, serverResponses, syncsCache)
},
/**
* Make a server request from the list of BidRequests
Expand Down Expand Up @@ -221,6 +189,7 @@ function createBid(bidResponse, mediaType, bidderParams) {
/**
* Create renderer
* @param requestId
* @param bidderParams
* @returns {*}
*/
function newRenderer(requestId, bidderParams) {
Expand Down
1 change: 1 addition & 0 deletions test/spec/modules/adtelligentBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const aliasEP = {
'ocm': 'https://ghb.cenarius.orangeclickmedia.com/v2/auction/',
'9dotsmedia': 'https://ghb.platform.audiodots.com/v2/auction/',
'indicue': 'https://ghb.console.indicue.com/v2/auction/',
'stellormedia': 'https://ghb.ads.stellormedia.com/v2/auction/',
};

const DEFAULT_ADATPER_REQ = { bidderCode: 'adtelligent' };
Expand Down
Loading
Loading