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

expose full user id config (including storage) to user id modules #5803

Merged
Show file tree
Hide file tree
Changes from 1 commit
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
5 changes: 3 additions & 2 deletions modules/britepoolIdSystem.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,12 @@ export const britepoolIdSubmodule = {
/**
* Performs action to obtain id and return a value in the callback's response argument
* @function
* @param {SubmoduleParams} [submoduleConfigParams]
* @param {SubmoduleParams} [submoduleConfig]
* @param {ConsentData|undefined} consentData
* @returns {function(callback:function)}
*/
getId(submoduleConfigParams, consentData) {
getId(submoduleConfig, consentData) {
const submoduleConfigParams = (submoduleConfig && submoduleConfig.params) || {};
const { params, headers, url, getter, errors } = britepoolIdSubmodule.createParams(submoduleConfigParams, consentData);
let getterResponse = null;
if (typeof getter === 'function') {
Expand Down
4 changes: 2 additions & 2 deletions modules/criteoIdSystem.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,11 @@ export const criteoIdSubmodule = {
/**
* get the Criteo Id from local storages and initiate a new user sync
* @function
* @param {SubmoduleParams} [configParams]
* @param {SubmoduleParams} [config]
* @param {ConsentData} [consentData]
* @returns {{id: {criteoId: string} | undefined}}}
*/
getId(configParams, consentData) {
getId(config, consentData) {
const hasGdprData = consentData && typeof consentData.gdprApplies === 'boolean' && consentData.gdprApplies;
const gdprConsentString = hasGdprData ? consentData.consentString : undefined;

Expand Down
4 changes: 2 additions & 2 deletions modules/haloIdSystem.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ export const haloIdSubmodule = {
/**
* performs action to obtain id and return a value in the callback's response argument
* @function
* @param {SubmoduleParams} [configParams]
* @param {SubmoduleParams} [config]
* @returns {IdResponse|undefined}
*/
getId(configParams) {
getId(config) {
const url = `https://id.halo.ad.gt/api/v1/pbhid`;

const resp = function (callback) {
Expand Down
10 changes: 6 additions & 4 deletions modules/id5IdSystem.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,13 @@ export const id5IdSubmodule = {
/**
* performs action to obtain id and return a value in the callback's response argument
* @function getId
* @param {SubmoduleParams} [configParams]
* @param {SubmoduleParams} [config]
* @param {ConsentData} [consentData]
* @param {(Object|undefined)} cacheIdObj
* @returns {IdResponse|undefined}
*/
getId(configParams, consentData, cacheIdObj) {
getId(config, consentData, cacheIdObj) {
const configParams = (config && config.params) || {};
if (!hasRequiredParams(configParams)) {
return undefined;
}
Expand Down Expand Up @@ -123,11 +124,12 @@ export const id5IdSubmodule = {
* If IdResponse#callback is defined, then it'll called at the end of auction.
* It's permissible to return neither, one, or both fields.
* @function extendId
* @param {SubmoduleParams} configParams
* @param {SubmoduleParams} config
* @param {Object} cacheIdObj - existing id, if any
* @return {(IdResponse|function(callback:function))} A response object that contains id and/or callback.
*/
extendId(configParams, cacheIdObj) {
extendId(config, cacheIdObj) {
const configParams = (config && config.params) || {};
incrementNb(configParams);
return cacheIdObj;
}
Expand Down
5 changes: 3 additions & 2 deletions modules/identityLinkIdSystem.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,11 @@ export const identityLinkSubmodule = {
* performs action to obtain id and return a value in the callback's response argument
* @function
* @param {ConsentData} [consentData]
* @param {SubmoduleParams} [configParams]
* @param {SubmoduleParams} [config]
* @returns {IdResponse|undefined}
*/
getId(configParams, consentData) {
getId(config, consentData) {
const configParams = (config && config.params) || {};
if (!configParams || typeof configParams.pid !== 'string') {
utils.logError('identityLink submodule requires partner id to be defined');
return;
Expand Down
5 changes: 3 additions & 2 deletions modules/intentIqIdSystem.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,11 @@ export const intentIqIdSubmodule = {
/**
* performs action to obtain id and return a value in the callback's response argument
* @function
* @param {SubmoduleParams} [configParams]
* @param {SubmoduleParams} [config]
* @returns {IdResponse|undefined}
*/
getId(configParams) {
getId(config) {
const configParams = (config && config.params) || {};
if (!configParams || typeof configParams.partner !== 'number') {
utils.logError('User ID - intentIqId submodule requires a valid partner to be defined');
return;
Expand Down
10 changes: 6 additions & 4 deletions modules/liveIntentIdSystem.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,11 @@ export const liveIntentIdSubmodule = {
* `publisherId` params.
* @function
* @param {{unifiedId:string}} value
* @param {SubmoduleParams|undefined} [configParams]
* @param {SubmoduleParams|undefined} [config]
smenzer marked this conversation as resolved.
Show resolved Hide resolved
* @returns {{lipb:Object}}
*/
decode(value, configParams) {
decode(value, config) {
const configParams = (config && config.params) || {};
function composeIdObject(value) {
const base = { 'lipbid': value['unifiedId'] };
delete value.unifiedId;
Expand All @@ -121,10 +122,11 @@ export const liveIntentIdSubmodule = {
/**
* performs action to obtain id and return a value in the callback's response argument
* @function
* @param {SubmoduleParams} [configParams]
* @param {SubmoduleParams} [config]
* @returns {IdResponse|undefined}
*/
getId(configParams) {
getId(config) {
const configParams = (config && config.params) || {};
const liveConnect = initializeLiveConnect(configParams);
if (!liveConnect) {
return;
Expand Down
6 changes: 3 additions & 3 deletions modules/lotamePanoramaIdSystem.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,19 +154,19 @@ export const lotamePanoramaIdSubmodule = {
* @param {(Object|string)} value
* @returns {(Object|undefined)}
*/
decode(value, configParams) {
decode(value, config) {
return utils.isStr(value) ? { 'lotamePanoramaId': value } : undefined;
},

/**
* Retrieve the Lotame Panorama Id
* @function
* @param {SubmoduleParams} [configParams]
* @param {SubmoduleParams} [config]
* @param {ConsentData} [consentData]
* @param {(Object|undefined)} cacheIdObj
* @returns {IdResponse|undefined}
*/
getId(configParams, consentData, cacheIdObj) {
getId(config, consentData, cacheIdObj) {
let localCache = getLotameLocalCache();

let refreshNeeded = Date.now() > localCache.expiryTimestampMs;
Expand Down
5 changes: 3 additions & 2 deletions modules/merkleIdSystem.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,12 @@ export const merkleIdSubmodule = {
/**
* performs action to obtain id and return a value in the callback's response argument
* @function
* @param {SubmoduleParams} [configParams]
* @param {SubmoduleParams} [config]
* @param {ConsentData} [consentData]
* @returns {IdResponse|undefined}
*/
getId(configParams, consentData) {
getId(config, consentData) {
const configParams = (config && config.params) || {};
if (!configParams || typeof configParams.pubid !== 'string') {
utils.logError('User ID - merkleId submodule requires a valid pubid to be defined');
return;
Expand Down
4 changes: 2 additions & 2 deletions modules/netIdSystem.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ export const netIdSubmodule = {
/**
* performs action to obtain id and return a value in the callback's response argument
* @function
* @param {SubmoduleParams} [configParams]
* @param {SubmoduleParams} [config]
* @param {ConsentData} [consentData]
* @param {(Object|undefined)} cacheIdObj
* @returns {IdResponse|undefined}
*/
getId(configParams) {
getId(config) {
/* currently not possible */
return {};
}
Expand Down
5 changes: 3 additions & 2 deletions modules/parrableIdSystem.js
Original file line number Diff line number Diff line change
Expand Up @@ -261,11 +261,12 @@ export const parrableIdSubmodule = {
/**
* performs action to obtain id and return a value in the callback's response argument
* @function
* @param {SubmoduleParams} [configParams]
* @param {SubmoduleParams} [config]
* @param {ConsentData} [consentData]
* @returns {function(callback:function), id:ParrableId}
*/
getId(configParams, gdprConsentData, currentStoredId) {
getId(config, gdprConsentData, currentStoredId) {
const configParams = (config && config.params) || {};
return fetchId(configParams);
}
};
Expand Down
8 changes: 4 additions & 4 deletions modules/pubCommonIdSystem.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ export const pubCommonIdSubmodule = {
/**
* performs action to obtain id
* @function
* @param {SubmoduleParams} [configParams]
* @param {SubmoduleParams} [config]
* @returns {IdResponse}
*/
getId: function ({create = true, pixelUrl} = {}) {
getId: function ({params: {create = true, pixelUrl} = {}} = {}) {
try {
if (typeof window[PUB_COMMON_ID] === 'object') {
// If the page includes its own pubcid module, then save a copy of id.
Expand All @@ -75,11 +75,11 @@ export const pubCommonIdSubmodule = {
/**
* performs action to extend an id
* @function
* @param {SubmoduleParams} [configParams]
* @param {SubmoduleParams} [config]
* @param {Object} storedId existing id
* @returns {IdResponse|undefined}
*/
extendId: function({extend = false, pixelUrl} = {}, storedId) {
extendId: function({params: {extend = false, pixelUrl} = {}} = {}, storedId) {
try {
if (typeof window[PUB_COMMON_ID] === 'object') {
// If the page includes its onw pubcid module, then there is nothing to do.
Expand Down
5 changes: 3 additions & 2 deletions modules/pubProvidedSystem.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,11 @@ export const pubProvidedIdSubmodule = {
/**
* performs action to obtain id and return a value.
* @function
* @param {SubmoduleParams} [configParams]
* @param {SubmoduleParams} [config]
* @returns {{id: array}}
*/
getId(configParams) {
getId(config) {
const configParams = (config && config.params) || {};
let res = [];
if (utils.isArray(configParams.eids)) {
res = res.concat(configParams.eids);
Expand Down
9 changes: 5 additions & 4 deletions modules/sharedIdSystem.js
Original file line number Diff line number Diff line change
Expand Up @@ -296,10 +296,10 @@ export const sharedIdSubmodule = {
/**
* performs action to obtain id and return a value.
* @function
* @param {SubmoduleParams} [configParams]
* @param {SubmoduleParams} [config]
* @returns {sharedId}
*/
getId(configParams) {
getId(config) {
const resp = function (callback) {
utils.logInfo('SharedId: Sharedid doesnt exists, new cookie creation');
ajax(ID_SVC, idGenerationCallback(callback), undefined, {method: 'GET', withCredentials: true});
Expand All @@ -309,11 +309,12 @@ export const sharedIdSubmodule = {

/**
* performs actions even if the id exists and returns a value
* @param configParams
* @param config
* @param storedId
* @returns {{callback: *}}
*/
extendId(configParams, storedId) {
extendId(config, storedId) {
const configParams = (config && config.params) || {};
utils.logInfo('SharedId: Existing shared id ' + storedId.id);
const resp = function (callback) {
const needSync = isIdSynced(configParams, storedId);
Expand Down
5 changes: 3 additions & 2 deletions modules/unifiedIdSystem.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,11 @@ export const unifiedIdSubmodule = {
/**
* performs action to obtain id and return a value in the callback's response argument
* @function
* @param {SubmoduleParams} [configParams]
* @param {SubmoduleParams} [config]
* @returns {IdResponse|undefined}
*/
getId(configParams) {
getId(config) {
const configParams = (config && config.params) || {};
if (!configParams || (typeof configParams.partner !== 'string' && typeof configParams.url !== 'string')) {
utils.logError('User ID - unifiedId submodule requires either partner or url to be defined');
return;
Expand Down
18 changes: 9 additions & 9 deletions modules/userId/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* If IdResponse#callback is defined, then it'll called at the end of auction.
* It's permissible to return neither, one, or both fields.
* @name Submodule#getId
* @param {SubmoduleParams} configParams
* @param {SubmoduleParams} config
* @param {ConsentData|undefined} consentData
* @param {(Object|undefined)} cacheIdObj
* @return {(IdResponse|undefined)} A response object that contains id and/or callback.
Expand All @@ -27,7 +27,7 @@
* If IdResponse#callback is defined, then it'll called at the end of auction.
* It's permissible to return neither, one, or both fields.
* @name Submodule#extendId
* @param {SubmoduleParams} configParams
* @param {SubmoduleParams} config
smenzer marked this conversation as resolved.
Show resolved Hide resolved
* @param {Object} storedId - existing id, if any
* @return {(IdResponse|function(callback:function))} A response object that contains id and/or callback.
*/
Expand All @@ -37,7 +37,7 @@
* @summary decode a stored value for passing to bid requests
* @name Submodule#decode
* @param {Object|string} value
* @param {SubmoduleParams|undefined} configParams
* @param {SubmoduleParams|undefined} config
smenzer marked this conversation as resolved.
Show resolved Hide resolved
* @return {(Object|undefined)}
*/

Expand Down Expand Up @@ -322,7 +322,7 @@ function processSubmoduleCallbacks(submodules, cb) {
setStoredValue(submodule, idObj);
}
// cache decoded value (this is copied to every adUnit bid)
submodule.idObj = submodule.submodule.decode(idObj);
submodule.idObj = submodule.submodule.decode(idObj, submodule.config);
} else {
utils.logInfo(`${MODULE_NAME}: ${submodule.submodule.name} - request id responded with an empty value`);
}
Expand Down Expand Up @@ -505,10 +505,10 @@ function initSubmodules(submodules, consentData) {

if (!storedId || refreshNeeded || !storedConsentDataMatchesConsentData(storedConsentData, consentData)) {
// No id previously saved, or a refresh is needed, or consent has changed. Request a new id from the submodule.
response = submodule.submodule.getId(submodule.config.params, consentData, storedId);
response = submodule.submodule.getId(submodule.config, consentData, storedId);
} else if (typeof submodule.submodule.extendId === 'function') {
// If the id exists already, give submodule a chance to decide additional actions that need to be taken
response = submodule.submodule.extendId(submodule.config.params, storedId);
response = submodule.submodule.extendId(submodule.config, storedId);
}

if (utils.isPlainObject(response)) {
Expand All @@ -526,16 +526,16 @@ function initSubmodules(submodules, consentData) {

if (storedId) {
// cache decoded value (this is copied to every adUnit bid)
submodule.idObj = submodule.submodule.decode(storedId, submodule.config.params);
submodule.idObj = submodule.submodule.decode(storedId, submodule.config);
}
} else if (submodule.config.value) {
// cache decoded value (this is copied to every adUnit bid)
submodule.idObj = submodule.config.value;
} else {
const response = submodule.submodule.getId(submodule.config.params, consentData, undefined);
const response = submodule.submodule.getId(submodule.config, consentData, undefined);
if (utils.isPlainObject(response)) {
if (typeof response.callback === 'function') { submodule.callback = response.callback; }
if (response.id) { submodule.idObj = submodule.submodule.decode(response.id, submodule.config.params); }
if (response.id) { submodule.idObj = submodule.submodule.decode(response.id, submodule.config); }
}
}
carry.push(submodule);
Expand Down
2 changes: 1 addition & 1 deletion modules/zeotapIdPlusIdSystem.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export const zeotapIdPlusSubmodule = {
/**
* performs action to obtain id and return a value in the callback's response argument
* @function
* @param {SubmoduleParams} configParams
* @param {SubmoduleParams} config
* @return {{id: string | undefined} | undefined}
*/
getId() {
Expand Down
10 changes: 5 additions & 5 deletions test/spec/modules/britepoolIdSystem_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,17 @@ describe('BritePool Submodule', () => {
});

it('trigger id resolution pixel when no identifiers set', () => {
britepoolIdSubmodule.getId({});
britepoolIdSubmodule.getId({ params: {} });
expect(triggerPixelStub.called).to.be.true;
});

it('trigger id resolution pixel when no identifiers set with api_key param', () => {
britepoolIdSubmodule.getId({ api_key });
britepoolIdSubmodule.getId({ params: { api_key } });
expect(triggerPixelStub.called).to.be.true;
});

it('does not trigger id resolution pixel when identifiers set', () => {
britepoolIdSubmodule.getId({ api_key, aaid });
britepoolIdSubmodule.getId({ params: { api_key, aaid } });
expect(triggerPixelStub.called).to.be.false;
});

Expand Down Expand Up @@ -110,7 +110,7 @@ describe('BritePool Submodule', () => {
expect(getter).to.equal(getter_override);
// Making sure it did not become part of params
expect(params.getter).to.be.undefined;
const response = britepoolIdSubmodule.getId({ api_key, aaid, url: url_override, getter: getter_override });
const response = britepoolIdSubmodule.getId({ params: { api_key, aaid, url: url_override, getter: getter_override } });
assert.deepEqual(response, { id: { 'primaryBPID': bpid } });
});

Expand All @@ -119,7 +119,7 @@ describe('BritePool Submodule', () => {
expect(getter).to.equal(getter_callback_override);
// Making sure it did not become part of params
expect(params.getter).to.be.undefined;
const response = britepoolIdSubmodule.getId({ api_key, aaid, url: url_override, getter: getter_callback_override });
const response = britepoolIdSubmodule.getId({ params: { api_key, aaid, url: url_override, getter: getter_callback_override } });
expect(response.callback).to.not.be.undefined;
response.callback(result => {
assert.deepEqual(result, { 'primaryBPID': bpid });
Expand Down
Loading