From a2c68d3401491e9883fb105594de461fee0960eb Mon Sep 17 00:00:00 2001 From: amishra11j <86069270+amishra11j@users.noreply.github.com> Date: Thu, 8 Jul 2021 00:24:21 +0530 Subject: [PATCH] Updating the akamaiDAPIdSystem submodule with x1 APIs (#7137) --- .../gpt/akamaidap_email_example.html | 5 +- .../gpt/akamaidap_signature_example.html | 5 +- .../gpt/akamaidap_x1_example.html | 119 ++++++++++++++++++ modules/akamaiDAPIdSystem.js | 37 ++++-- modules/akamaiDAPIdSystem.md | 11 +- modules/userId/userId.md | 4 +- test/spec/modules/akamaiDAPIdSystem_spec.js | 25 +++- 7 files changed, 182 insertions(+), 24 deletions(-) create mode 100755 integrationExamples/gpt/akamaidap_x1_example.html diff --git a/integrationExamples/gpt/akamaidap_email_example.html b/integrationExamples/gpt/akamaidap_email_example.html index ef62876231e..828b2add787 100755 --- a/integrationExamples/gpt/akamaidap_email_example.html +++ b/integrationExamples/gpt/akamaidap_email_example.html @@ -60,8 +60,9 @@ apiHostname: 'prebid.dap.akadns.net', domain: 'prebid.org', type: 'email', - identity: 'aaryn@query.com' - } + identity: 'aaryn@query.com', + apiVersion: 'v1' + }, }, ], syncDelay: 5000, diff --git a/integrationExamples/gpt/akamaidap_signature_example.html b/integrationExamples/gpt/akamaidap_signature_example.html index 94940a659c1..e4c7c617653 100644 --- a/integrationExamples/gpt/akamaidap_signature_example.html +++ b/integrationExamples/gpt/akamaidap_signature_example.html @@ -59,8 +59,9 @@ params: { apiHostname: 'prebid.dap.akadns.net', domain: 'prebid.org', - type: 'dap-signature:1.0.0' - } + type: 'dap-signature:1.0.0', + apiVersion: 'v1' + }, }, ], syncDelay: 5000, diff --git a/integrationExamples/gpt/akamaidap_x1_example.html b/integrationExamples/gpt/akamaidap_x1_example.html new file mode 100755 index 00000000000..b1f16acc560 --- /dev/null +++ b/integrationExamples/gpt/akamaidap_x1_example.html @@ -0,0 +1,119 @@ + + + + + + + + + + + + + + + +

Prebid.js Test

+
Div-1
+
+ +
+
User IDs Sent to Bidding Adapter
+
+ + diff --git a/modules/akamaiDAPIdSystem.js b/modules/akamaiDAPIdSystem.js index 980fcfaa7f2..c64502a8c5a 100644 --- a/modules/akamaiDAPIdSystem.js +++ b/modules/akamaiDAPIdSystem.js @@ -66,27 +66,38 @@ export const akamaiDAPIdSubmodule = { let url = ''; let postData; let tokenName = ''; - if (configParams.type.indexOf('dap-signature:') == 0) { - let parts = configParams.type.split(':'); - let v = parts[1]; - url = `https://${configParams.apiHostname}/data-activation/v1/domain/${configParams.domain}/signature?v=${v}&gdpr=${hasGdpr}&gdpr_consent=${gdprConsentString}&us_privacy=${uspConsent}`; - tokenName = 'SigToken'; + if (configParams.apiVersion === 'v1') { + if (configParams.type.indexOf('dap-signature:') == 0) { + let parts = configParams.type.split(':'); + let v = parts[1]; + url = `https://${configParams.apiHostname}/data-activation/v1/domain/${configParams.domain}/signature?v=${v}&gdpr=${hasGdpr}&gdpr_consent=${gdprConsentString}&us_privacy=${uspConsent}`; + tokenName = 'SigToken'; + } else { + url = `https://${configParams.apiHostname}/data-activation/v1/identity/tokenize?gdpr=${hasGdpr}&gdpr_consent=${gdprConsentString}&us_privacy=${uspConsent}`; + postData = { + 'version': 1, + 'domain': configParams.domain, + 'identity': configParams.identity, + 'type': configParams.type + }; + tokenName = 'PubToken'; + } } else { - url = `https://${configParams.apiHostname}/data-activation/v1/identity/tokenize?gdpr=${hasGdpr}&gdpr_consent=${gdprConsentString}&us_privacy=${uspConsent}`; + url = `https://${configParams.apiHostname}/data-activation/x1/identity/tokenize?gdpr=${hasGdpr}&gdpr_consent=${gdprConsentString}&us_privacy=${uspConsent}`; postData = { - 'version': 1, + 'version': configParams.apiVersion, 'domain': configParams.domain, 'identity': configParams.identity, - 'type': configParams.type + 'type': configParams.type, + 'attributes': configParams.attributes }; - tokenName = 'PubToken'; + tokenName = 'x1Token'; } - utils.logInfo('akamaiDAPId[getId] making API call for ' + tokenName); - let cb = { - success: response => { - storage.setDataInLocalStorage(STORAGE_KEY, response); + success: (response, request) => { + var token = (response === '') ? request.getResponseHeader('Akamai-DAP-Token') : response; + storage.setDataInLocalStorage(STORAGE_KEY, token); }, error: error => { utils.logError('akamaiDAPId [getId:ajax.error] failed to retrieve ' + tokenName, error); diff --git a/modules/akamaiDAPIdSystem.md b/modules/akamaiDAPIdSystem.md index 888a409b7a8..9b35709c3f2 100644 --- a/modules/akamaiDAPIdSystem.md +++ b/modules/akamaiDAPIdSystem.md @@ -15,7 +15,7 @@ Please reach out to your Akamai account representative(Prebid@akamai.com) to get First, make sure to add the DAP submodule to your Prebid.js package with: ``` -gulp build --modules=akamaiDAPId,userId +gulp build --modules=akamaiDAPIdSystem,userId ``` The following configuration parameters are available: @@ -29,13 +29,20 @@ pbjs.setConfig({ apiHostname: '', domain: 'your-domain.com', type: 'email' | 'mobile' | ... | 'dap-signature:1.0.0', - identity: ‘your@email.com’ | ‘6175551234' | ... + identity: ‘your@email.com’ | ‘6175551234' | ...', + apiVersion: 'v1' | 'x1', + attributes: '{ "cohorts": [ "3:14400", "5:14400", "7:0" ],"first_name": "...","last_name": "..." }' }, }], auctionDelay: 50 // 50ms maximum auction delay, applies to all userId modules } }); ``` + +In order to make use of v1 APIs, "apiVersion" needs to explicitly mentioned as 'v1'. The "apiVersion" defaults to x1 if not specified. +"attributes" can be configured in x1 API only and not v1 APIs. Please ensure that the "attributes" value is in same format as shown above. + Refer to the sample integration example present at below location Prebid.js/integrationExamples/gpt/akamaidap_email_example.html Prebid.js/integrationExamples/gpt/akamaidap_signature_example.html +Prebid.js/integrationExamples/gpt/akamaidap_x1_example.html diff --git a/modules/userId/userId.md b/modules/userId/userId.md index 1dbdf7588ec..7d352505aa9 100644 --- a/modules/userId/userId.md +++ b/modules/userId/userId.md @@ -56,7 +56,9 @@ pbjs.setConfig({ apiHostname: '', domain: 'your-domain.com', type: 'email' | 'mobile' | ... | 'dap-signature:1.0.0', - identity: ‘your@email.com’ | ‘6175551234' | ... + identity: ‘your@email.com’ | ‘6175551234' | ..., + apiVersion: 'v1' | 'x1', + attributes: '{ "cohorts": [ "3:14400", "5:14400", "7:0" ],"first_name": "...","last_name": "..." }' } },{ name: 'identityLink', diff --git a/test/spec/modules/akamaiDAPIdSystem_spec.js b/test/spec/modules/akamaiDAPIdSystem_spec.js index afb5fdf043b..e44285eda34 100644 --- a/test/spec/modules/akamaiDAPIdSystem_spec.js +++ b/test/spec/modules/akamaiDAPIdSystem_spec.js @@ -8,14 +8,25 @@ export const storage = getStorageManager(); const signatureConfigParams = {params: { apiHostname: 'prebid.dap.akadns.net', domain: 'prebid.org', - type: 'dap-signature:1.0.0' + type: 'dap-signature:1.0.0', + apiVersion: 'v1' }}; const tokenizeConfigParams = {params: { apiHostname: 'prebid.dap.akadns.net', domain: 'prebid.org', type: 'email', - identity: 'amishra@xyz.com' + identity: 'amishra@xyz.com', + apiVersion: 'v1' +}}; + +const x1TokenizeConfigParams = {params: { + apiHostname: 'prebid.dap.akadns.net', + domain: 'prebid.org', + type: 'email', + identity: 'amishra@xyz.com', + apiVersion: 'x1', + attributes: '{ "cohorts": [ "3:14400", "5:14400", "7:0" ],"first_name": "Ace","last_name": "McCool" }' }}; const consentData = { @@ -85,16 +96,22 @@ describe('akamaiDAPId getId', function () { expect(submoduleCallback).to.be.undefined; }); - it('should call the signature API and store token in Local storage', function () { + it('should call the signature v1 API and store token in Local storage', function () { let submoduleCallback1 = akamaiDAPIdSubmodule.getId(signatureConfigParams, consentData).id; expect(submoduleCallback1).to.be.eq(storage.getDataFromLocalStorage('akamai_dap_token')) storage.removeDataFromLocalStorage('akamai_dap_token'); }); - it('should call the tokenize API and store token in Local storage', function () { + it('should call the tokenize v1 API and store token in Local storage', function () { let submoduleCallback = akamaiDAPIdSubmodule.getId(tokenizeConfigParams, consentData).id; expect(submoduleCallback).to.be.eq(storage.getDataFromLocalStorage('akamai_dap_token')) storage.removeDataFromLocalStorage('akamai_dap_token'); }); + + it('should call the tokenize x1 API and store token in Local storage', function () { + let submoduleCallback = akamaiDAPIdSubmodule.getId(x1TokenizeConfigParams, consentData).id; + expect(submoduleCallback).to.be.eq(storage.getDataFromLocalStorage('akamai_dap_token')) + storage.removeDataFromLocalStorage('akamai_dap_token'); + }); }); });