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

Eskimi Bid Adapter : support string placementId and adjust user-sync logic #12286

Merged
merged 1 commit into from
Oct 9, 2024
Merged
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
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