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

AkamaiDAP Id System: update submodule with x1 APIs #7137

Merged
merged 1 commit into from
Jul 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
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 integrationExamples/gpt/akamaidap_email_example.html
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
5 changes: 3 additions & 2 deletions integrationExamples/gpt/akamaidap_signature_example.html
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
119 changes: 119 additions & 0 deletions integrationExamples/gpt/akamaidap_x1_example.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@

<!--
This page calls a single bidder for a single ad slot. It can be considered a "hello world" example for using
Prebid with the Google Publisher Tag.
It also makes a good test page for new adapter PR submissions. Simply set your server's Bid Params object in the
bids array inside the adUnits, and it will use your adapter to load an ad.
NOTE that many ad servers won't send back an ad if the URL is localhost... so you might need to
set an alias in your /etc/hosts file so that you can load this page from a different domain.
-->

<html>
<head>
<script async src="../../build/dev/prebid.js"></script>
<script async src="https://www.googletagservices.com/tag/js/gpt.js"></script>
<script>
var FAILSAFE_TIMEOUT = 3300;
var PREBID_TIMEOUT = 2000;

var adUnits = [{
code: 'div-gpt-ad-1460505748561-0',
mediaTypes: {
banner: {
sizes: [[300, 250], [300,600]],
}
},
// Replace this object to test a new Adapter!
bids: [{
bidder: 'grid',
params: {
uid: 1
}
}]

}];

var pbjs = pbjs || {};
pbjs.que = pbjs.que || [];

</script>

<script>
var googletag = googletag || {};
googletag.cmd = googletag.cmd || [];
googletag.cmd.push(function() {
googletag.pubads().disableInitialLoad();
});

pbjs.que.push(function() {
pbjs.setConfig({

debugging: {
enabled: true
},

userSync: {
userIds: [
{
name: 'akamaiDAPId',
params: {
apiHostname: 'prebid.dap.akadns.net',
domain: 'prebid.org',
type: 'email',
identity: 'aaryn@query.com',
apiVersion: 'x1',
attributes: '{ "cohorts": [ "3:14400", "5:14400", "7:0" ],"first_name": "Ace","last_name": "McCool" }'
},
},
],
syncDelay: 5000,
auctionDelay: 2000,
segments: [ 1, 2, 3 ],
}
});
pbjs.addAdUnits(adUnits);
pbjs.requestBids({
bidsBackHandler: sendAdserverRequest,
timeout: PREBID_TIMEOUT
});
document.getElementById( "user-ids" ).innerHTML = JSON.stringify( pbjs.getUserIds() );
});

function sendAdserverRequest() {
if (pbjs.adserverRequestSent) return;
pbjs.adserverRequestSent = true;
googletag.cmd.push(function() {
pbjs.que.push(function() {
pbjs.setTargetingForGPTAsync();
googletag.pubads().refresh();
});
});
}

setTimeout(function() {
sendAdserverRequest();
}, FAILSAFE_TIMEOUT);

</script>

<script>
googletag.cmd.push(function () {
googletag.defineSlot('/19968336/header-bid-tag-0', [[300, 250], [300, 600]], 'div-gpt-ad-1460505748561-0').addService(googletag.pubads());
googletag.pubads().enableSingleRequest();
googletag.enableServices();
});
</script>
</head>

<body>
<h2>Prebid.js Test</h2>
<h5>Div-1</h5>
<div id='div-gpt-ad-1460505748561-0'>
<script type='text/javascript'>
googletag.cmd.push(function() { googletag.display('div-gpt-ad-1460505748561-0'); });
</script>
</div>
<h5>User IDs Sent to Bidding Adapter</h5>
<div id="user-ids"></div>
</body>
</html>
37 changes: 24 additions & 13 deletions modules/akamaiDAPIdSystem.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
11 changes: 9 additions & 2 deletions modules/akamaiDAPIdSystem.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -29,13 +29,20 @@ pbjs.setConfig({
apiHostname: '<see your Akamai account rep>',
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
4 changes: 3 additions & 1 deletion modules/userId/userId.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ pbjs.setConfig({
apiHostname: '<see your Akamai account rep>',
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',
Expand Down
25 changes: 21 additions & 4 deletions test/spec/modules/akamaiDAPIdSystem_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -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');
});
});
});