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

[RPO-2922] - Add Prebid Unified Token #5

Merged
merged 1 commit into from
Oct 17, 2022
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
29 changes: 29 additions & 0 deletions modules/concertBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ export const spec = {
buildRequests: function(validBidRequests, bidderRequest) {
logMessage(validBidRequests);
logMessage(bidderRequest);

const eids = [];

let payload = {
meta: {
prebidVersion: '$prebid.version$',
Expand All @@ -49,6 +52,8 @@ export const spec = {
};

payload.slots = validBidRequests.map(bidRequest => {
collectEid(eids, bidRequest);

let slot = {
name: bidRequest.adUnitCode,
bidId: bidRequest.bidId,
Expand All @@ -65,6 +70,8 @@ export const spec = {
return slot;
});

payload.meta.eids = eids.filter(Boolean);

logMessage(payload);

return {
Expand Down Expand Up @@ -216,3 +223,25 @@ function consentAllowsPpid(bidderRequest) {

return (uspConsent || gdprConsent);
}

function collectEid(eids, bid) {
if (bid.userId) {
const eid = getUserId(bid.userId.uid2 && bid.userId.uid2.id, 'uidapi.com', undefined, 3)
eids.push(eid)
}
}

function getUserId(id, source, uidExt, atype) {
if (id) {
const uid = { id, atype };

if (uidExt) {
uid.ext = uidExt;
}

return {
source,
uids: [ uid ]
};
}
}
21 changes: 21 additions & 0 deletions test/spec/modules/concertBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,27 @@ describe('ConcertAdapter', function () {

expect(payload.meta.uid).to.equal('foo');
});

it('should add uid2 to eids list if available', function() {
bidRequests[0].userId = { uid2: { id: 'uid123' } }

const request = spec.buildRequests(bidRequests, bidRequest);
const payload = JSON.parse(request.data);
const meta = payload.meta

expect(meta.eids.length).to.equal(1);
expect(meta.eids[0].uids[0].id).to.equal('uid123')
expect(meta.eids[0].uids[0].atype).to.equal(3)
})

it('should return empty eids list if none are available', function() {
bidRequests[0].userId = { testId: { id: 'uid123' } }
const request = spec.buildRequests(bidRequests, bidRequest);
const payload = JSON.parse(request.data);
const meta = payload.meta

expect(meta.eids.length).to.equal(0);
})
});

describe('spec.interpretResponse', function() {
Expand Down