Skip to content

Commit

Permalink
Digitrust removal, broader identity support, floor-module support (#5599
Browse files Browse the repository at this point in the history
)

* Digitrust remove, broader identity support, floor-module support

* Digitrust removal, broader identity support, floor-module support
  • Loading branch information
rtuschkany authored Aug 17, 2020
1 parent 84e2361 commit 952e0fb
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 74 deletions.
95 changes: 25 additions & 70 deletions modules/connectadBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import * as utils from '../src/utils.js';
import { registerBidder } from '../src/adapters/bidderFactory.js';
import { BANNER } from '../src/mediaTypes.js'
import {config} from '../src/config.js';
import {createEidsArray} from './userId/eids.js';

const BIDDER_CODE = 'connectad';
const BIDDER_CODE_ALIAS = 'connectadrealtime';
Expand All @@ -18,8 +19,6 @@ export const spec = {
},

buildRequests: function(validBidRequests, bidderRequest) {
let digitrust;

let ret = {
method: 'POST',
url: '',
Expand All @@ -41,7 +40,8 @@ export const spec = {
screensize: getScreenSize(),
dnt: (navigator.doNotTrack == 'yes' || navigator.doNotTrack == '1' || navigator.msDoNotTrack == '1') ? 1 : 0,
language: navigator.language,
ua: navigator.userAgent
ua: navigator.userAgent,
pversion: '$prebid.version$'
});

// coppa compliance
Expand Down Expand Up @@ -69,80 +69,19 @@ export const spec = {
utils.deepSetValue(data, 'user.ext.us_privacy', bidderRequest.uspConsent);
}

// Digitrust Support
const bidRequestDigitrust = utils.deepAccess(validBidRequests[0], 'userId.digitrustid.data');
if (bidRequestDigitrust && (!bidRequestDigitrust.privacy || !bidRequestDigitrust.privacy.optout)) {
digitrust = {
id: bidRequestDigitrust.id,
keyv: bidRequestDigitrust.keyv
}
}

if (digitrust) {
utils.deepSetValue(data, 'user.ext.digitrust', {
id: digitrust.id,
keyv: digitrust.keyv
})
}

if (validBidRequests[0].userId && typeof validBidRequests[0].userId === 'object' && (validBidRequests[0].userId.tdid || validBidRequests[0].userId.pubcid || validBidRequests[0].userId.lipb || validBidRequests[0].userId.id5id || validBidRequests[0].userId.parrableId)) {
utils.deepSetValue(data, 'user.ext.eids', []);

if (validBidRequests[0].userId.tdid) {
data.user.ext.eids.push({
source: 'adserver.org',
uids: [{
id: validBidRequests[0].userId.tdid,
ext: {
rtiPartner: 'TDID'
}
}]
});
}

if (validBidRequests[0].userId.pubcid) {
data.user.ext.eids.push({
source: 'pubcommon',
uids: [{
id: validBidRequests[0].userId.pubcid,
}]
});
}

if (validBidRequests[0].userId.id5id) {
data.user.ext.eids.push({
source: 'id5-sync.com',
uids: [{
id: validBidRequests[0].userId.id5id,
}]
});
}

if (validBidRequests[0].userId.parrableId) {
data.user.ext.eids.push({
source: 'parrable.com',
uids: [{
id: validBidRequests[0].userId.parrableId.eid,
}]
});
}

if (validBidRequests[0].userId.lipb && validBidRequests[0].userId.lipb.lipbid) {
data.user.ext.eids.push({
source: 'liveintent.com',
uids: [{
id: validBidRequests[0].userId.lipb.lipbid
}]
});
}
// EIDS Support
if (validBidRequests[0].userId) {
data.user.ext.eids = createEidsArray(validBidRequests[0].userId);
}

validBidRequests.map(bid => {
const placement = Object.assign({
id: bid.transactionId,
divName: bid.bidId,
pisze: bid.mediaTypes.banner.sizes[0] || bid.sizes[0],
sizes: bid.mediaTypes.banner.sizes,
adTypes: getSize(bid.mediaTypes.banner.sizes || bid.sizes)
adTypes: getSize(bid.mediaTypes.banner.sizes || bid.sizes),
floor: getBidFloor(bid)
}, bid.params);

if (placement.networkId && placement.siteId) {
Expand Down Expand Up @@ -277,6 +216,22 @@ sizeMap[331] = '320x250';
sizeMap[3301] = '320x267';
sizeMap[2730] = '728x250';

function getBidFloor(bidRequest) {
let floorInfo = {};

if (typeof bidRequest.getFloor === 'function') {
floorInfo = bidRequest.getFloor({
currency: 'USD',
mediaType: 'banner',
size: '*'
});
}

let floor = floorInfo.floor || 0;

return floor;
}

function getSize(sizes) {
const result = [];
sizes.forEach(function(size) {
Expand Down
24 changes: 20 additions & 4 deletions test/spec/modules/connectadBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ describe('ConnectAd Adapter', function () {
bidder: 'conntectad',
params: {
siteId: 123456,
networkId: 123456
networkId: 123456,
bidfloor: 0.50
},
adUnitCode: '/19968336/header-bid-tag-1',
mediaTypes: {
Expand Down Expand Up @@ -46,8 +47,7 @@ describe('ConnectAd Adapter', function () {
bidderRequestId: '1c56ad30b9b8ca8',
transactionId: 'e76cbb58-f3e1-4ad9-9f4c-718c1919d0df',
userId: {
tdid: '123456',
digitrustid: {data: {id: 'DTID', keyv: 4, privacy: {optout: false}, producer: 'ABC', version: 2}}
tdid: '123456'
}
}];

Expand Down Expand Up @@ -154,6 +154,23 @@ describe('ConnectAd Adapter', function () {
expect(requestparse.placements[0].networkId).to.equal(123456);
});

it('should process floors module if available', function() {
const floorInfo = {
currency: 'USD',
floor: 5.20
};
bidRequests[0].getFloor = () => floorInfo;
const request = spec.buildRequests(bidRequests, bidderRequest);
const requestparse = JSON.parse(request.data);
expect(requestparse.placements[0].floor).to.equal(5.20);
});

it('should be 0 if no floormodule is available', function() {
const request = spec.buildRequests(bidRequests, bidderRequest);
const requestparse = JSON.parse(request.data);
expect(requestparse.placements[0].floor).to.equal(0);
});

it('should contain gdpr info', function () {
const request = spec.buildRequests(bidRequests, bidderRequest);
const requestparse = JSON.parse(request.data);
Expand Down Expand Up @@ -227,7 +244,6 @@ describe('ConnectAd Adapter', function () {
const requestparse = JSON.parse(request.data);
expect(requestparse.user.ext.eids).to.be.an('array');
expect(requestparse.user.ext.eids[0].uids[0].id).to.equal('123456');
expect(requestparse.user.ext.digitrust.id).to.equal('DTID');
});

it('should add referer info', function () {
Expand Down

0 comments on commit 952e0fb

Please sign in to comment.