Skip to content

Commit

Permalink
type changes
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkoYerkovichRP committed Sep 21, 2020
1 parent f0a230c commit af408b0
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 31 deletions.
11 changes: 10 additions & 1 deletion modules/pubProvidedSystem.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,15 @@ import * as utils from '../src/utils.js';

const MODULE_NAME = 'pubProvided';

function addType(uid) {
if(!uid.ext.types){
uid.ext.types = [];
}
if(!uid.ext.types.includes('ppuid')){
uid.ext.types.push('ppuid')
}
}

/** @type {Submodule} */
export const pubProvidedSubmodule = {
/**
Expand Down Expand Up @@ -44,7 +53,7 @@ export const pubProvidedSubmodule = {
if (typeof configParams.eidsFunction === 'function') {
res = res.concat(configParams.eidsFunction());
}
res.forEach(id => id.type = 'pubProvided');
res.forEach(id => id.uids.forEach(uid => addType(uid)));
return {id: res};
}
};
Expand Down
5 changes: 3 additions & 2 deletions modules/rubiconBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,8 @@ export const spec = {
const eids = utils.deepAccess(bidderRequest, 'bids.0.userIdAsEids');
if (eids && eids.length) {
// filter out unsupported id systems
utils.deepSetValue(data, 'user.ext.eids', eids.filter(eid => ['adserver.org', 'pubcid.org', 'liveintent.com', 'liveramp.com', 'sharedid.org'].indexOf(eid.source) !== -1 || eid.type === 'pubProvided'));
utils.deepSetValue(data, 'user.ext.eids', eids.filter(eid => ['adserver.org', 'pubcid.org', 'liveintent.com', 'liveramp.com', 'sharedid.org'].indexOf(eid.source) !== -1 ||
eid.uids[0].ext.types.includes('ppuid')));

// liveintent requires additional props to be set
const liveIntentEid = find(data.user.ext.eids, eid => eid.source === 'liveintent.com');
Expand Down Expand Up @@ -538,7 +539,7 @@ export const spec = {
if (sharedId) {
data['eid_sharedid.org'] = `${sharedId.uids[0].id}^${sharedId.uids[0].atype}^${sharedId.uids[0].ext.third}`;
}
const pubProvidedIds = bidRequest.userIdAsEids.filter(eid => eid.type === 'pubProvided');
const pubProvidedIds = bidRequest.userIdAsEids.filter(eid => eid.uids[0].ext.types.includes('ppuid'));
if (pubProvidedIds) {
pubProvidedIds.forEach(pubProvidedId => {
data[`${pubProvidedId.source}_id`] = pubProvidedId.uids[0].id;
Expand Down
22 changes: 14 additions & 8 deletions test/spec/modules/eids_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -241,34 +241,40 @@ describe('eids array generation for known sub-modules', function() {
const userId = {
pubProvided: [{
source: 'example.com',
type: 'pubProvided',
uids: [{
id: 'value read from cookie or local storage',
ext: {}
ext: {
types: ['ppuid']
}
}]
}, {
source: 'id-partner.com',
type: 'pubProvided',
uids: [{
id: 'value read from cookie or local storage'
id: 'value read from cookie or local storage',
ext: {
types: ['ppuid']
}
}]
}]
};
const newEids = createEidsArray(userId);
expect(newEids.length).to.equal(2);
expect(newEids[0]).to.deep.equal({
source: 'example.com',
type: 'pubProvided',
uids: [{
id: 'value read from cookie or local storage',
ext: {}
ext: {
types: ['ppuid']
}
}]
});
expect(newEids[1]).to.deep.equal({
source: 'id-partner.com',
type: 'pubProvided',
uids: [{
id: 'value read from cookie or local storage'
id: 'value read from cookie or local storage',
ext: {
types: ['ppuid']
}
}]
});
});
Expand Down
28 changes: 18 additions & 10 deletions test/spec/modules/rubiconBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -234,16 +234,21 @@ describe('the rubicon adapter', function () {
pubcid: '4000',
pubProvided: [{
source: 'example.com',
type: 'pubProvided',
uids: [{
id: '333333',
ext: {}
ext: {
ext: {
types: ['ppuid']
}
}
}]
}, {
source: 'id-partner.com',
type: 'pubProvided',
uids: [{
id: '4444444'
id: '4444444',
ext: {
types: ['ppuid']
}
}]
}]
};
Expand Down Expand Up @@ -1418,16 +1423,19 @@ describe('the rubicon adapter', function () {
clonedBid.userId = {
pubProvided: [{
source: 'example.com',
type: 'pubProvided',
uids: [{
id: '11111',
ext: {}
ext: {
types: ['ppuid']
}
}]
}, {
source: 'id-partner.com',
type: 'pubProvided',
uids: [{
id: '222222'
id: '222222',
ext: {
types: ['ppuid']
}
}]
}]
};
Expand Down Expand Up @@ -1681,10 +1689,10 @@ describe('the rubicon adapter', function () {
expect(post.user.ext.eids[4].uids[0].id).to.equal('4000');
// PubProvided should exist
expect(post.user.ext.eids[5].source).to.equal('example.com');
expect(post.user.ext.eids[5].type).to.equal('pubProvided');
expect(post.user.ext.eids[5].uids[0].ext.types).to.equal(['ppuid']);
expect(post.user.ext.eids[5].uids[0].id).to.equal('333333');
expect(post.user.ext.eids[6].source).to.equal('id-partner.com');
expect(post.user.ext.eids[6].type).to.equal('pubProvided');
expect(post.user.ext.eids[6].uids[0].ext.types).to.equal(['ppuid']);
expect(post.user.ext.eids[6].uids[0].id).to.equal('4444444');

expect(post.regs.ext.gdpr).to.equal(1);
Expand Down
28 changes: 18 additions & 10 deletions test/spec/modules/userId_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1054,38 +1054,46 @@ describe('User ID', function () {
expect(bid).to.have.deep.nested.property('userId.pubProvided');
expect(bid.userId.pubProvided).to.deep.equal([{
source: 'example.com',
type: 'pubProvided',
uids: [{
id: 'value read from cookie or local storage',
ext: {}
ext: {
types: ['ppuid']
}
}]
}, {
source: 'id-partner.com',
type: 'pubProvided',
uids: [{
id: 'value read from cookie or local storage'
id: 'value read from cookie or local storage',
ext: {
types: ['ppuid']
}
}]
}, {
source: 'provider.com',
type: 'pubProvided',
uids: [{
id: 'value read from cookie or local storage'
id: 'value read from cookie or local storage',
ext: {
types: ['ppuid']
}
}]
}]);

expect(bid.userIdAsEids[0]).to.deep.equal({
source: 'example.com',
type: 'pubProvided',
uids: [{
id: 'value read from cookie or local storage',
ext: {}
ext: {
types: ['ppuid']
}
}]
});
expect(bid.userIdAsEids[2]).to.deep.equal({
source: 'provider.com',
type: 'pubProvided',
uids: [{
id: 'value read from cookie or local storage'
id: 'value read from cookie or local storage',
ext: {
types: ['ppuid']
}
}]
});
});
Expand Down

0 comments on commit af408b0

Please sign in to comment.