-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Extract GDPRApplies in userId.js to make it available to cookie-sync requiring it * Adding id5 userId submodule, tests and documentation * Fixed typo in test name for unifiedid * Adding test to userId for ID5 * Follow correct naming convention for GDPRApplies: renamed to isGDPRApplicable * Refactoring of id5 module following refactoring of userId module. * Moved init of id5 user module at the end of the id5 module itself * regroup import to avoid a CircleCI Bug
- Loading branch information
Showing
5 changed files
with
175 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/** | ||
* This module adds ID5 to the User ID module | ||
* The {@link module:modules/userId} module is required | ||
* @module modules/unifiedIdSystem | ||
* @requires module:modules/userId | ||
*/ | ||
|
||
import * as utils from '../src/utils.js' | ||
import {ajax} from '../src/ajax.js'; | ||
import {isGDPRApplicable, attachIdSystem} from './userId.js'; | ||
|
||
/** @type {Submodule} */ | ||
export const id5IdSubmodule = { | ||
/** | ||
* used to link submodule with config | ||
* @type {string} | ||
*/ | ||
name: 'id5Id', | ||
/** | ||
* decode the stored id value for passing to bid requests | ||
* @function | ||
* @param {{ID5ID:Object}} value | ||
* @returns {{id5id:String}} | ||
*/ | ||
decode(value) { | ||
return (value && typeof value['ID5ID'] === 'string') ? { 'id5id': value['ID5ID'] } : undefined; | ||
}, | ||
/** | ||
* performs action to obtain id and return a value in the callback's response argument | ||
* @function | ||
* @param {SubmoduleParams} [configParams] | ||
* @param {ConsentData} [consentData] | ||
* @returns {function(callback:function)} | ||
*/ | ||
getId(configParams, consentData) { | ||
if (!configParams || typeof configParams.partner !== 'number') { | ||
utils.logError(`User ID - ID5 submodule requires partner to be defined as a number`); | ||
return; | ||
} | ||
const hasGdpr = isGDPRApplicable(consentData) ? 1 : 0; | ||
const gdprConsentString = hasGdpr ? consentData.consentString : ''; | ||
const url = `https://id5-sync.com/g/v1/${configParams.partner}.json?gdpr=${hasGdpr}&gdpr_consent=${gdprConsentString}`; | ||
|
||
return function (callback) { | ||
ajax(url, response => { | ||
let responseObj; | ||
if (response) { | ||
try { | ||
responseObj = JSON.parse(response); | ||
} catch (error) { | ||
utils.logError(error); | ||
} | ||
} | ||
callback(responseObj); | ||
}, undefined, { method: 'GET' }); | ||
} | ||
} | ||
}; | ||
|
||
attachIdSystem(id5IdSubmodule); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.