From af408b0a7e8869f57a9ad553ffdc6edd4c6a8a7c Mon Sep 17 00:00:00 2001 From: myerkovich Date: Mon, 21 Sep 2020 20:19:38 +0300 Subject: [PATCH] type changes --- modules/pubProvidedSystem.js | 11 +++++++- modules/rubiconBidAdapter.js | 5 ++-- test/spec/modules/eids_spec.js | 22 ++++++++++------ test/spec/modules/rubiconBidAdapter_spec.js | 28 +++++++++++++-------- test/spec/modules/userId_spec.js | 28 +++++++++++++-------- 5 files changed, 63 insertions(+), 31 deletions(-) diff --git a/modules/pubProvidedSystem.js b/modules/pubProvidedSystem.js index 3d86f42a281..41795b91707 100644 --- a/modules/pubProvidedSystem.js +++ b/modules/pubProvidedSystem.js @@ -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 = { /** @@ -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}; } }; diff --git a/modules/rubiconBidAdapter.js b/modules/rubiconBidAdapter.js index 70f6a3820df..c3b411c3bba 100644 --- a/modules/rubiconBidAdapter.js +++ b/modules/rubiconBidAdapter.js @@ -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'); @@ -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; diff --git a/test/spec/modules/eids_spec.js b/test/spec/modules/eids_spec.js index e2d4e55e745..37f75f83d08 100644 --- a/test/spec/modules/eids_spec.js +++ b/test/spec/modules/eids_spec.js @@ -241,16 +241,19 @@ 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'] + } }] }] }; @@ -258,17 +261,20 @@ describe('eids array generation for known sub-modules', function() { 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'] + } }] }); }); diff --git a/test/spec/modules/rubiconBidAdapter_spec.js b/test/spec/modules/rubiconBidAdapter_spec.js index bee2ddd6f0e..d6b6854383f 100644 --- a/test/spec/modules/rubiconBidAdapter_spec.js +++ b/test/spec/modules/rubiconBidAdapter_spec.js @@ -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'] + } }] }] }; @@ -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'] + } }] }] }; @@ -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); diff --git a/test/spec/modules/userId_spec.js b/test/spec/modules/userId_spec.js index 53261c14ccc..b13e787b61a 100644 --- a/test/spec/modules/userId_spec.js +++ b/test/spec/modules/userId_spec.js @@ -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'] + } }] }); });