Skip to content

Commit

Permalink
Eskimi Bid Adapter: support string placementId, adjust user-sync proc…
Browse files Browse the repository at this point in the history
…essing logic (#12286)

Co-authored-by: Andrius Versockas <[email protected]>
  • Loading branch information
myDisconnect and Andrius Versockas authored Oct 9, 2024
1 parent 317235d commit 5e6f716
Showing 1 changed file with 7 additions and 24 deletions.
31 changes: 7 additions & 24 deletions modules/eskimiBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import {registerBidder} from '../src/adapters/bidderFactory.js';
import {BANNER, VIDEO} from '../src/mediaTypes.js';
import * as utils from '../src/utils.js';
import {getBidIdParameter, logInfo, mergeDeep} from '../src/utils.js';
import {hasPurpose1Consent} from '../src/utils/gdpr.js';

/**
* @typedef {import('../src/adapters/bidderFactory.js').BidRequest} BidRequest
Expand Down Expand Up @@ -47,7 +46,6 @@ const REGION_SUBDOMAIN_SUFFIX = {

export const spec = {
code: BIDDER_CODE,
aliases: ['eskimi'],
gvlid: GVLID,
supportedMediaTypes: [BANNER, VIDEO],
isBidRequestValid,
Expand Down Expand Up @@ -120,7 +118,7 @@ function isBidRequestValid(bidRequest) {
}

function isPlacementIdValid(bidRequest) {
return utils.isNumber(bidRequest.params.placementId);
return !!parseInt(bidRequest.params.placementId);
}

function isValidBannerRequest(bidRequest) {
Expand Down Expand Up @@ -215,7 +213,7 @@ function createRequest(bidRequests, bidderRequest, mediaType) {

const bid = bidRequests.find((b) => b.params.placementId)
if (!data.site) data.site = {}
data.site.ext = {placementId: bid.params.placementId}
data.site.ext = {placementId: parseInt(bid.params.placementId)}

if (bidderRequest.gdprConsent) {
if (!data.user) data.user = {};
Expand Down Expand Up @@ -255,46 +253,31 @@ function isBannerBid(bid) {
* @return {{type: (string), url: (*|string)}[]}
*/
function getUserSyncs(syncOptions, responses, gdprConsent, uspConsent, gppConsent) {
if ((syncOptions.iframeEnabled || syncOptions.pixelEnabled) && hasSyncConsent(gdprConsent, uspConsent, gppConsent)) {
if ((syncOptions.iframeEnabled || syncOptions.pixelEnabled)) {
let pixelType = syncOptions.iframeEnabled ? 'iframe' : 'image';
let query = [];
let syncUrl = getUserSyncUrlByRegion();
// Attaching GDPR Consent Params in UserSync url
// GDPR Consent Params in UserSync url
if (gdprConsent) {
query.push('gdpr=' + (gdprConsent.gdprApplies & 1));
query.push('gdpr_consent=' + encodeURIComponent(gdprConsent.consentString || ''));
}
// CCPA
// US Privacy Consent
if (uspConsent) {
query.push('us_privacy=' + encodeURIComponent(uspConsent));
}
// GPP Consent
// Global Privacy Platform Consent
if (gppConsent?.gppString && gppConsent?.applicableSections?.length) {
query.push('gpp=' + encodeURIComponent(gppConsent.gppString));
query.push('gpp_sid=' + encodeURIComponent(gppConsent.applicableSections.join(',')));
}
return [{
type: pixelType,
url: `${syncUrl}${query.length > 0 ? '?' + query.join('&') : ''}`
url: `${syncUrl}${query.length > 0 ? '&' + query.join('&') : ''}`
}];
}
}

function hasSyncConsent(gdprConsent, uspConsent, gppConsent) {
return hasPurpose1Consent(gdprConsent) && hasUspConsent(uspConsent) && hasGppConsent(gppConsent);
}

function hasUspConsent(uspConsent) {
return typeof uspConsent !== 'string' || !(uspConsent[0] === '1' && uspConsent[2] === 'Y');
}

function hasGppConsent(gppConsent) {
return (
!(gppConsent && Array.isArray(gppConsent.applicableSections)) ||
gppConsent.applicableSections.every((section) => typeof section === 'number' && section <= 5)
);
}

/**
* Get Bid Request endpoint url by region
* @return {string}
Expand Down

0 comments on commit 5e6f716

Please sign in to comment.