Skip to content

Commit

Permalink
Adagio Bid Adapter: support UserId's (#5938)
Browse files Browse the repository at this point in the history
  • Loading branch information
osazos authored Nov 10, 2020
1 parent 7070b1f commit 9676ce0
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 1 deletion.
13 changes: 12 additions & 1 deletion modules/adagioBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ import JSEncrypt from 'jsencrypt/bin/jsencrypt.js';
import sha256 from 'crypto-js/sha256.js';
import { getStorageManager } from '../src/storageManager.js';
import { getRefererInfo } from '../src/refererDetection.js';
import { createEidsArray } from './userId/eids.js';

export const BIDDER_CODE = 'adagio';
export const LOG_PREFIX = 'Adagio:';
export const VERSION = '2.4.0';
export const VERSION = '2.5.0';
export const FEATURES_VERSION = '1';
export const ENDPOINT = 'https://mp.4dex.io/prebid';
export const SUPPORTED_MEDIA_TYPES = ['banner'];
Expand Down Expand Up @@ -572,6 +573,12 @@ function _getSchain(bidRequest) {
}
}

function _getEids(bidRequest) {
if (utils.deepAccess(bidRequest, 'userId')) {
return createEidsArray(bidRequest.userId)
}
}

export const spec = {
code: BIDDER_CODE,
gvlid: GVLID,
Expand Down Expand Up @@ -657,6 +664,7 @@ export const spec = {
const uspConsent = _getUspConsent(bidderRequest) || {};
const coppa = _getCoppa();
const schain = _getSchain(validBidRequests[0]);
const eids = _getEids(validBidRequests[0]) || [];
const adUnits = utils._map(validBidRequests, (bidRequest) => {
bidRequest.features = internal.getFeatures(bidRequest, bidderRequest);
return bidRequest;
Expand Down Expand Up @@ -691,6 +699,9 @@ export const spec = {
ccpa: uspConsent
},
schain: schain,
user: {
eids: eids
},
prebidVersion: '$prebid.version$',
adapterVersion: VERSION,
featuresVersion: FEATURES_VERSION
Expand Down
48 changes: 48 additions & 0 deletions test/spec/modules/adagioBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,7 @@ describe('Adagio bid adapter', () => {
'pageviewId',
'adUnits',
'regs',
'user',
'schain',
'prebidVersion',
'adapterVersion',
Expand Down Expand Up @@ -573,6 +574,53 @@ describe('Adagio bid adapter', () => {
expect(requests[0].data.regs.ccpa).to.be.empty;
});
});

describe('with userID modules', function() {
const userId = {
sharedid: {id: '01EAJWWNEPN3CYMM5N8M5VXY22', third: '01EAJWWNEPN3CYMM5N8M5VXY22'},
unsuported: '666'
}

it('should send "user.eids" in the request for Prebid.js supported modules only', function() {
const bid01 = new BidRequestBuilder({
userId
}).withParams().build();

const bidderRequest = new BidderRequestBuilder().build();

const requests = spec.buildRequests([bid01], bidderRequest);

const expected = [{
source: 'sharedid.org',
uids: [
{
atype: 1,
ext: {
third: '01EAJWWNEPN3CYMM5N8M5VXY22'
},
id: '01EAJWWNEPN3CYMM5N8M5VXY22'
}
]
}]

expect(requests[0].data.user.eids).to.have.lengthOf(1)
expect(requests[0].data.user.eids).to.deep.equal(expected)
})

it('should send an empty "user.eids" array in the request if userId module is unsupported', function() {
const bid01 = new BidRequestBuilder({
userId: {
unsuported: '666'
}
}).withParams().build();

const bidderRequest = new BidderRequestBuilder().build();

const requests = spec.buildRequests([bid01], bidderRequest);

expect(requests[0].data.user.eids).to.be.empty
})
})
});

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

0 comments on commit 9676ce0

Please sign in to comment.