Skip to content

Commit

Permalink
Various Adapters: Use Vidazoo utils lib to remove code duplications (p…
Browse files Browse the repository at this point in the history
…rebid#11888)

* vidazooUtils - single request configurations

* fix: shines rtb adapter use vidazoo bidder utils

* fix: added vidazoo utils to illimin adapter

* fix: illumin bid adapter using vidazooUtils

* fix: twistDigital adapter use vidazooUtils

* fix: tagoras adapter use vidazooUtils

* fix: kueezRtb adapter use vidazooUtils

* fix: removed parrable and digitrust id systems
  • Loading branch information
uditalias authored Jun 30, 2024
1 parent 0c560a3 commit d236eb1
Show file tree
Hide file tree
Showing 12 changed files with 191 additions and 1,748 deletions.
19 changes: 9 additions & 10 deletions libraries/vidazooUtils/bidderUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ export function appendUserIdsToRequestPayload(payloadRef, userIds) {
let key;
_each(userIds, (userId, idSystemProviderName) => {
key = `uid.${idSystemProviderName}`;

switch (idSystemProviderName) {
case 'lipb':
payloadRef[key] = userId.lipbid;
Expand All @@ -217,7 +218,7 @@ export function getVidazooSessionId(storage) {
return getStorageItem(storage, SESSION_ID_KEY) || '';
}

export function buildRequestData(bid, topWindowUrl, sizes, bidderRequest, bidderTimeout, webSessionId, storage, bidderVersion, bidderCode, getUniqueRequestData) {
export function buildRequestData(bid, topWindowUrl, sizes, bidderRequest, bidderTimeout, storage, bidderVersion, bidderCode, getUniqueRequestData) {
const {
params,
bidId,
Expand All @@ -234,7 +235,7 @@ export function buildRequestData(bid, topWindowUrl, sizes, bidderRequest, bidder
const {ext} = params;
let {bidFloor} = params;
const hashUrl = hashCode(topWindowUrl);
const uniqueRequestData = isFn(getUniqueRequestData) ? getUniqueRequestData(hashUrl) : {};
const uniqueRequestData = isFn(getUniqueRequestData) ? getUniqueRequestData(hashUrl, bid) : {};
const uniqueDealId = getUniqueDealId(storage, hashUrl);
const pId = extractPID(params);
const isStorageAllowed = bidderSettings.get(bidderCode, 'storageAllowed');
Expand Down Expand Up @@ -285,7 +286,6 @@ export function buildRequestData(bid, topWindowUrl, sizes, bidderRequest, bidder
bidderRequestsCount: bidderRequestsCount,
bidderWinsCount: bidderWinsCount,
bidderTimeout: bidderTimeout,
webSessionId: webSessionId,
...uniqueRequestData
};

Expand Down Expand Up @@ -331,13 +331,13 @@ export function buildRequestData(bid, topWindowUrl, sizes, bidderRequest, bidder
return data;
}

export function createInterpretResponseFn(bidderCode) {
export function createInterpretResponseFn(bidderCode, allowSingleRequest) {
return function interpretResponse(serverResponse, request) {
if (!serverResponse || !serverResponse.body) {
return [];
}

const singleRequestMode = config.getConfig(`${bidderCode}.singleRequest`);
const singleRequestMode = allowSingleRequest && config.getConfig(`${bidderCode}.singleRequest`);
const reqBidId = deepAccess(request, 'data.bidId');
const {results} = serverResponse.body;

Expand Down Expand Up @@ -410,12 +410,12 @@ export function createInterpretResponseFn(bidderCode) {
}
}

export function createBuildRequestsFn(createRequestDomain, createUniqueRequestData, webSessionId, storage, bidderCode, bidderVersion) {
export function createBuildRequestsFn(createRequestDomain, createUniqueRequestData, storage, bidderCode, bidderVersion, allowSingleRequest) {
function buildRequest(bid, topWindowUrl, sizes, bidderRequest, bidderTimeout) {
const {params} = bid;
const cId = extractCID(params);
const subDomain = extractSubDomain(params);
const data = buildRequestData(bid, topWindowUrl, sizes, bidderRequest, bidderTimeout, webSessionId, storage, bidderVersion, bidderCode, createUniqueRequestData);
const data = buildRequestData(bid, topWindowUrl, sizes, bidderRequest, bidderTimeout, storage, bidderVersion, bidderCode, createUniqueRequestData);
const dto = {
method: 'POST', url: `${createRequestDomain(subDomain)}/prebid/multi/${cId}`, data: data
};
Expand All @@ -428,7 +428,7 @@ export function createBuildRequestsFn(createRequestDomain, createUniqueRequestDa
const subDomain = extractSubDomain(params);
const data = bidRequests.map(bid => {
const sizes = parseSizesInput(bid.sizes);
return buildRequestData(bid, topWindowUrl, sizes, bidderRequest, bidderTimeout, webSessionId, storage, bidderVersion, bidderCode, createUniqueRequestData)
return buildRequestData(bid, topWindowUrl, sizes, bidderRequest, bidderTimeout, storage, bidderVersion, bidderCode, createUniqueRequestData)
});
const chunkSize = Math.min(20, config.getConfig(`${bidderCode}.chunkSize`) || 10);

Expand All @@ -445,11 +445,10 @@ export function createBuildRequestsFn(createRequestDomain, createUniqueRequestDa
}

return function buildRequests(validBidRequests, bidderRequest) {
// TODO: does the fallback make sense here?
const topWindowUrl = bidderRequest.refererInfo.page || bidderRequest.refererInfo.topmostLocation;
const bidderTimeout = config.getConfig('bidderTimeout');

const singleRequestMode = config.getConfig('vidazoo.singleRequest');
const singleRequestMode = allowSingleRequest && config.getConfig(`${bidderCode}.singleRequest`);

const requests = [];

Expand Down
Loading

0 comments on commit d236eb1

Please sign in to comment.