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

Admixer ID System: add userId submodule #6238

Merged
merged 26 commits into from
Apr 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
0b48ea9
Migrating to Prebid 1.0
Oct 24, 2017
6ec18f4
Migrating to Prebid 1.0
Dec 11, 2017
63928ed
Fix spec
Dec 11, 2017
1adaf95
Merge branch 'master1'
Dec 19, 2017
f24a281
Merge remote-tracking branch 'Prebid.js/master'
Galphimbl Apr 27, 2020
961c25f
add gdpr and usp
Galphimbl Apr 27, 2020
81b156e
remove changes in gdpr_hello_world.html
Galphimbl Apr 27, 2020
c5831c7
Merge remote-tracking branch 'Prebid.js/master'
Galphimbl Apr 28, 2020
3315d3c
Update gdpr_hello_world.html
Galphimbl May 5, 2020
020d732
Merge branch 'prebid.js-master'
Galphimbl Sep 7, 2020
9a99ceb
Merge branch 'prebid.js-master'
Galphimbl Nov 23, 2020
891faba
add user syncs
Galphimbl Nov 24, 2020
ee38d00
remove comments
Galphimbl Nov 24, 2020
dfd97f6
tests
Galphimbl Nov 25, 2020
b377bb0
Merge branch 'prebid.js-master'
Galphimbl Nov 27, 2020
50b7b8f
Merge branch 'prebid.js-master'
Galphimbl Dec 4, 2020
d27a7ed
Merge branch 'prebid.js-master'
Galphimbl Jan 14, 2021
0dd729c
admixer id system
Galphimbl Jan 28, 2021
4f02a79
Merge branch 'prebid.js-master'
Galphimbl Jan 28, 2021
c1932b6
Merge branch 'master' into id-system
Galphimbl Jan 28, 2021
713d23e
admixer id system
Galphimbl Jan 28, 2021
517a397
admixer id system eids.md userId.md
Galphimbl Jan 31, 2021
0387a68
admixer id system .submodules.json
Galphimbl Jan 31, 2021
cefe9d1
admixer id system
Galphimbl Apr 5, 2021
86ce4e5
Merge branch 'prebid.js-master' into id-system
Galphimbl Apr 5, 2021
f496e22
Merge branch 'prebid.js-master' into id-system
Galphimbl Apr 6, 2021
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
3 changes: 2 additions & 1 deletion modules/.submodules.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
"mwOpenLinkIdSystem",
"tapadIdSystem",
"novatiqIdSystem",
"uid2IdSystem"
"uid2IdSystem",
"admixerIdSystem"
],
"adpod": [
"freeWheelAdserverVideo",
Expand Down
92 changes: 92 additions & 0 deletions modules/admixerIdSystem.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
/**
* This module adds AdmixerId to the User ID module
* The {@link module:modules/userId} module is required
* @module modules/admixerIdSubmodule
* @requires module:modules/userId
*/

import * as utils from '../src/utils.js'
import { ajax } from '../src/ajax.js';
import { submodule } from '../src/hook.js';
import {getStorageManager} from '../src/storageManager.js';

export const storage = getStorageManager();

/** @type {Submodule} */
export const admixerIdSubmodule = {
/**
* used to link submodule with config
* @type {string}
*/
name: 'admixerId',
/**
* used to specify vendor id
* @type {number}
*/
gvlid: 511,
/**
* decode the stored id value for passing to bid requests
* @function
* @param {string} value
* @returns {{admixerId:string}}
*/
decode(value) {
return { 'admixerId': value }
},
/**
* performs action to obtain id and return a value in the callback's response argument
* @function
* @param {SubmoduleConfig} [config]
* @param {ConsentData} [consentData]
* @returns {IdResponse|undefined}
*/
getId(config, consentData) {
const {e, p, pid} = (config && config.params) || {};
if (!pid || typeof pid !== 'string') {
utils.logError('admixerId submodule requires partner id to be defined');
return;
}
const gdpr = (consentData && typeof consentData.gdprApplies === 'boolean' && consentData.gdprApplies) ? 1 : 0;
const consentString = gdpr ? consentData.consentString : '';
if (gdpr && !consentString) {
utils.logInfo('Consent string is required to call admixer id.');
return;
}
const url = `https://inv-nets.admixer.net/cntcm.aspx?ssp=${pid}${e ? `&e=${e}` : ''}${p ? `&p=${p}` : ''}${consentString ? `&cs=${consentString}` : ''}`;
const resp = function(callback) {
if (window.admixTMLoad && window.admixTMLoad.push) {
window.admixTMLoad.push(function() {
window.admixTM.retrieveVisitorId(function(visitorId) {
if (visitorId) {
callback(visitorId);
} else {
callback();
}
});
});
} else {
retrieveVisitorId(url, callback);
}
};

return { callback: resp };
}
};
function retrieveVisitorId(url, callback) {
ajax(url, {
success: response => {
const {setData: {visitorid} = {}} = JSON.parse(response || '{}');
if (visitorid) {
callback(visitorid);
} else {
callback();
}
},
error: error => {
utils.logInfo(`admixerId: fetch encountered an error`, error);
callback();
}
}, undefined, { method: 'GET', withCredentials: true });
}

submodule('userId', admixerIdSubmodule);
6 changes: 6 additions & 0 deletions modules/userId/eids.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,12 @@ const USER_IDS_CONFIG = {
getValue: function(data) {
return data.id;
}
},

// Admixer Id
'admixerId': {
source: 'admixer.net',
atype: 3
}
};

Expand Down
11 changes: 9 additions & 2 deletions modules/userId/eids.md
Original file line number Diff line number Diff line change
Expand Up @@ -171,12 +171,19 @@ userIdAsEids = [
atype: 1
}]
},
{
{
source: 'uidapi.com',
uids: [{
id: 'some-random-id-value',
atype: 3
}]
}
},
{
source: 'admixer.net',
uids: [{
id: 'some-random-id-value',
atype: 3
}]
}
]
```
38 changes: 31 additions & 7 deletions modules/userId/userId.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,18 @@ pbjs.setConfig({
},{
name: 'uid2'
}
}, {
name: 'admixerId',
params: {
pid: "4D393FAC-B6BB-4E19-8396-0A4813607316", // example id
e: "3d400b57e069c993babea0bd9efa79e5dc698e16c042686569faae20391fd7ea", // example hashed email (sha256)
p: "05de6c07eb3ea4bce45adca4e0182e771d80fbb99e12401416ca84ddf94c3eb9" //example hashed phone (sha256)
},
storage: {
type: 'cookie',
name: '__adm__admixer',
expires: 30
}
}],
syncDelay: 5000,
auctionDelay: 1000
Expand Down Expand Up @@ -171,18 +183,18 @@ pbjs.setConfig({
expires: 90, // Expiration in days
refreshInSeconds: 8*3600 // User Id cache lifetime in seconds, defaulting to 'expires'
},
}, {
name: 'nextrollId',
params: {
partnerId: "1009", // Set your real NextRoll partner ID here for production
}
}, {
}, {
name: 'nextrollId',
params: {
partnerId: "1009", // Set your real NextRoll partner ID here for production
}
}, {
name: 'criteo',
storage: { // It is best not to specify this parameter since the module needs to be called as many times as possible
type: 'html5',
name: '_criteoId',
expires: 1
}
}
},{
name: "merkleId",
params: {
Expand All @@ -196,6 +208,18 @@ pbjs.setConfig({
name: "merkleId",
expires: 30
}
}, {
name: 'admixerId',
params: {
pid: "4D393FAC-B6BB-4E19-8396-0A4813607316", // example id
e: "3d400b57e069c993babea0bd9efa79e5dc698e16c042686569faae20391fd7ea", // example hashed email (sha256)
p: "05de6c07eb3ea4bce45adca4e0182e771d80fbb99e12401416ca84ddf94c3eb9" //example hashed phone (sha256)
},
storage: {
type: 'html5',
name: 'admixerId',
expires: 30
}
}],
syncDelay: 5000
}
Expand Down
81 changes: 81 additions & 0 deletions test/spec/modules/admixerIdSystem_spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
import {admixerIdSubmodule} from 'modules/admixerIdSystem.js';
import * as utils from 'src/utils.js';
import {server} from 'test/mocks/xhr.js';
import {getStorageManager} from '../../../src/storageManager.js';

export const storage = getStorageManager();

const pid = '4D393FAC-B6BB-4E19-8396-0A4813607316';
const getIdParams = {params: {pid: pid}};
describe('admixerId tests', function () {
let logErrorStub;

beforeEach(function () {
logErrorStub = sinon.stub(utils, 'logError');
});

afterEach(function () {
logErrorStub.restore();
});

it('should log an error if pid configParam was not passed when getId', function () {
admixerIdSubmodule.getId();
expect(logErrorStub.callCount).to.be.equal(1);

admixerIdSubmodule.getId({});
expect(logErrorStub.callCount).to.be.equal(2);

admixerIdSubmodule.getId({params: {}});
expect(logErrorStub.callCount).to.be.equal(3);

admixerIdSubmodule.getId({params: {pid: 123}});
expect(logErrorStub.callCount).to.be.equal(4);
});

it('should NOT call the admixer id endpoint if gdpr applies but consent string is missing', function () {
let submoduleCallback = admixerIdSubmodule.getId(getIdParams, { gdprApplies: true });
expect(submoduleCallback).to.be.undefined;
});

it('should call the admixer id endpoint', function () {
let callBackSpy = sinon.spy();
let submoduleCallback = admixerIdSubmodule.getId(getIdParams).callback;
submoduleCallback(callBackSpy);
let request = server.requests[0];
expect(request.url).to.be.eq(`https://inv-nets.admixer.net/cntcm.aspx?ssp=${pid}`);
request.respond(
200,
{},
JSON.stringify({})
);
expect(callBackSpy.calledOnce).to.be.true;
});

it('should call callback with user id', function () {
let callBackSpy = sinon.spy();
let submoduleCallback = admixerIdSubmodule.getId(getIdParams).callback;
submoduleCallback(callBackSpy);
let request = server.requests[0];
expect(request.url).to.be.eq(`https://inv-nets.admixer.net/cntcm.aspx?ssp=${pid}`);
request.respond(
200,
{},
JSON.stringify({setData: {visitorid: '571058d70bce453b80e6d98b4f8a81e3'}})
);
expect(callBackSpy.calledOnce).to.be.true;
expect(callBackSpy.args[0][0]).to.be.eq('571058d70bce453b80e6d98b4f8a81e3');
});

it('should continue to callback if ajax response 204', function () {
let callBackSpy = sinon.spy();
let submoduleCallback = admixerIdSubmodule.getId(getIdParams).callback;
submoduleCallback(callBackSpy);
let request = server.requests[0];
expect(request.url).to.be.eq(`https://inv-nets.admixer.net/cntcm.aspx?ssp=${pid}`);
request.respond(
204
);
expect(callBackSpy.calledOnce).to.be.true;
expect(callBackSpy.args[0][0]).to.be.undefined;
});
});
Loading