Skip to content

Commit

Permalink
Added static consentData to consentManagement config
Browse files Browse the repository at this point in the history
  • Loading branch information
ptomasroos committed May 29, 2018
1 parent 3e8beb2 commit 25e1560
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion modules/consentManagement.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,26 @@ const DEFAULT_ALLOW_AUCTION_WO_CONSENT = true;
export let userCMP;
export let consentTimeout;
export let allowAuction;
export let staticConsentData;

let consentData;

// add new CMPs here, with their dedicated lookup function
const cmpCallMap = {
'iab': lookupIabConsent
'iab': lookupIabConsent,
'static': lookupStaticConsentData
};

/**
* This function reads the consent string from the config to obtain the consent information of the user.
* @param {function(string)} cmpSuccess acts as a success callback when the value is read from config; pass along consentObject (string) from CMP
* @param {function(string)} cmpError acts as an error callback while interacting with the config string; pass along an error message (string)
* @param {object} hookConfig contains module related variables (see comment in requestBidsHook function)
*/
function lookupStaticConsentData(cmpSuccess, cmpError, hookConfig) {
cmpSuccess(staticConsentData, hookConfig);
}

/**
* This function handles interacting with an IAB compliant CMP to obtain the consent information of the user.
* Given the async nature of the CMP's API, we pass in acting success/error callback functions to exit this function
Expand Down Expand Up @@ -337,6 +349,15 @@ export function setConfig(config) {
utils.logInfo(`consentManagement config did not specify allowAuctionWithoutConsent. Using system default setting (${DEFAULT_ALLOW_AUCTION_WO_CONSENT}).`);
}

if (userCMP === 'static') {
if (utils.isPlainObject(config.consentData)) {
staticConsentData = config.consentData;
consentTimeout = 0;
} else {
utils.logInfo(`consentManagement config with cmpApi: 'static' did not specify consentData. No consents will be available to adapters.`);
}
}

$$PREBID_GLOBAL$$.requestBids.addHook(requestBidsHook, 50);
}
config.getConfig('consentManagement', config => setConfig(config.consentManagement));

0 comments on commit 25e1560

Please sign in to comment.