Skip to content

Commit

Permalink
AdMatic Bid Adapter : consent management features added (#10813)
Browse files Browse the repository at this point in the history
* Admatic Bidder Adaptor

* Update admaticBidAdapter.md

* Update admaticBidAdapter.md

* remove floor parameter

* Update admaticBidAdapter.js

* Admatic Bid Adapter: alias and bid floor features activated

* Admatic adapter: host param control changed

* Alias name changed.

* Revert "Admatic adapter: host param control changed"

This reverts commit de7ac85.

* added alias feature and host param

* Revert "added alias feature and host param"

This reverts commit 6ec8f45.

* Revert "Alias name changed."

This reverts commit 661c54f.

* Revert "Admatic Bid Adapter: alias and bid floor features activated"

This reverts commit 7a2e0e2.

* Revert "Update admaticBidAdapter.js"

This reverts commit 7a845b7.

* Revert "remove floor parameter"

This reverts commit 7a23b05.

* Admatic adapter: host param control && Add new Bidder

* Revert "Admatic adapter: host param control && Add new Bidder"

This reverts commit 3c797b1.

* commit new features

* Update admaticBidAdapter.js

* updated for coverage

* sync updated

* Update adloader.js

* AdMatic Bidder: development of user sync url

* Update admaticBidAdapter.js

* Set currency for AdserverCurrency: bug fix

* Update admaticBidAdapter.js

* update

* admatic adapter video params update

* Update admaticBidAdapter.js

* update

* Update admaticBidAdapter.js

* update

* update

* Update admaticBidAdapter_spec.js

* Update admaticBidAdapter.js

* Update admaticBidAdapter.js

* Revert "Update admaticBidAdapter.js"

This reverts commit 1216892.

* Revert "Update admaticBidAdapter.js"

This reverts commit b1929ec.

* Revert "Update admaticBidAdapter_spec.js"

This reverts commit 1ca6597.

* Revert "update"

This reverts commit 689ce9d.

* Revert "update"

This reverts commit f381a45.

* Revert "Update admaticBidAdapter.js"

This reverts commit 38fd7ab.

* Revert "update"

This reverts commit a5316e7.

* Revert "Update admaticBidAdapter.js"

This reverts commit 60a28ca.

* Revert "admatic adapter video params update"

This reverts commit 31e69e8.

* update

* Update admaticBidAdapter.js

* Update admaticBidAdapter_spec.js

* mime_type add

* add native adapter

* AdMatic Adapter: Consent Management
  • Loading branch information
fatihkaya84 authored Dec 27, 2023
1 parent f625c1e commit ed48e34
Show file tree
Hide file tree
Showing 2 changed files with 818 additions and 370 deletions.
131 changes: 115 additions & 16 deletions modules/admaticBidAdapter.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {getValue, logError, isEmpty, deepAccess, isArray, getBidIdParameter} from '../src/utils.js';
import {getValue, formatQS, logError, deepAccess, isArray, getBidIdParameter} from '../src/utils.js';
import { registerBidder } from '../src/adapters/bidderFactory.js';
import { config } from '../src/config.js';
import { BANNER, VIDEO, NATIVE } from '../src/mediaTypes.js';
Expand Down Expand Up @@ -56,18 +56,16 @@ export const spec = {
* @return {ServerRequest}
*/
buildRequests: (validBidRequests, bidderRequest) => {
const tmax = bidderRequest.timeout;
const bids = validBidRequests.map(buildRequestObject);
const blacklist = bidderRequest.ortb2;
const ortb = bidderRequest.ortb2;
const networkId = getValue(validBidRequests[0].params, 'networkId');
const host = getValue(validBidRequests[0].params, 'host');
const currency = config.getConfig('currency.adServerCurrency') || 'TRY';
const bidderName = validBidRequests[0].bidder;

const payload = {
user: {
ua: navigator.userAgent
},
blacklist: [],
ortb,
site: {
page: bidderRequest.refererInfo.page,
ref: bidderRequest.refererInfo.page,
Expand All @@ -80,17 +78,59 @@ export const spec = {
ext: {
cur: currency,
bidder: bidderName
}
},
schain: {},
regs: {
ext: {
}
},
user: {
ext: {}
},
at: 1,
tmax: parseInt(tmax)
};

if (!isEmpty(blacklist.badv)) {
payload.blacklist = blacklist.badv;
};
if (bidderRequest && bidderRequest.gdprConsent && bidderRequest.gdprConsent.gdprApplies) {
const consentStr = (bidderRequest.gdprConsent.consentString)
? bidderRequest.gdprConsent.consentString.replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/, '') : '';
const gdpr = bidderRequest.gdprConsent.gdprApplies ? 1 : 0;
payload.regs.ext.gdpr = gdpr;
payload.regs.ext.consent = consentStr;
}

if (bidderRequest && bidderRequest.coppa) {
payload.regs.ext.coppa = bidderRequest.coppa === true ? 1 : (bidderRequest.coppa === false ? 0 : undefined);
}

if (bidderRequest && bidderRequest.ortb2?.regs?.gpp) {
payload.regs.ext.gpp = bidderRequest.ortb2?.regs?.gpp;
}

if (bidderRequest && bidderRequest.ortb2?.regs?.gpp_sid) {
payload.regs.ext.gpp_sid = bidderRequest.ortb2?.regs?.gpp_sid;
}

if (bidderRequest && bidderRequest.uspConsent) {
payload.regs.ext.uspIab = bidderRequest.uspConsent;
}

if (validBidRequests[0].schain) {
const schain = mapSchain(validBidRequests[0].schain);
if (schain) {
payload.schain = schain;
}
}

if (validBidRequests[0].userIdAsEids) {
const eids = { eids: validBidRequests[0].userIdAsEids };
payload.user.ext = { ...payload.user.ext, ...eids };
}

if (payload) {
switch (bidderName) {
case 'pixad':
SYNC_URL = 'https://static.pixad.com.tr/sync.html';
SYNC_URL = 'https://static.cdn.pixad.com.tr/sync.html';
break;
default:
SYNC_URL = 'https://cdn.serve.admatic.com.tr/showad/sync.html';
Expand All @@ -101,12 +141,36 @@ export const spec = {
}
},

getUserSyncs: function (syncOptions, responses) {
if (syncOptions.iframeEnabled) {
return [{
getUserSyncs: function (syncOptions, responses, gdprConsent, uspConsent, gppConsent) {
if (!hasSynced && syncOptions.iframeEnabled) {
// data is only assigned if params are available to pass to syncEndpoint
let params = {};

if (gdprConsent) {
if (typeof gdprConsent.gdprApplies === 'boolean') {
params['gdpr'] = Number(gdprConsent.gdprApplies);
}
if (typeof gdprConsent.consentString === 'string') {
params['gdpr_consent'] = gdprConsent.consentString;
}
}

if (uspConsent) {
params['us_privacy'] = encodeURIComponent(uspConsent);
}

if (gppConsent?.gppString) {
params['gpp'] = gppConsent.gppString;
params['gpp_sid'] = gppConsent.applicableSections?.toString();
}

params = Object.keys(params).length ? `?${formatQS(params)}` : '';

hasSynced = true;
return {
type: 'iframe',
url: SYNC_URL
}];
url: SYNC_URL + params
};
}
},

Expand Down Expand Up @@ -156,6 +220,41 @@ export const spec = {
}
};

var hasSynced = false;

export function resetUserSync() {
hasSynced = false;
}

/**
* @param {object} schain object set by Publisher
* @returns {object} OpenRTB SupplyChain object
*/
function mapSchain(schain) {
if (!schain) {
return null;
}
if (!validateSchain(schain)) {
logError('AdMatic: required schain params missing');
return null;
}
return schain;
}

/**
* @param {object} schain object set by Publisher
* @returns {object} bool
*/
function validateSchain(schain) {
if (!schain.nodes) {
return false;
}
const requiredFields = ['asi', 'sid', 'hp'];
return schain.nodes.every(node => {
return requiredFields.every(field => node[field]);
});
}

function isUrl(str) {
try {
URL(str);
Expand Down
Loading

0 comments on commit ed48e34

Please sign in to comment.