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

Added basic support for ID Module #24

Closed
wants to merge 1 commit into from
Closed
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
37 changes: 21 additions & 16 deletions modules/sovrnBidAdapter.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import * as utils from '../src/utils.js'
import { registerBidder } from '../src/adapters/bidderFactory.js'
import { BANNER } from '../src/mediaTypes.js'
import { createEidsArray } from './userId/eids.js';

export const spec = {
code: 'sovrn',
supportedMediaTypes: [BANNER],
gvlid: 13,

/**
* Check if the bid is a valid zone ID in either number or string form
Expand All @@ -25,11 +27,21 @@ export const spec = {
let sovrnImps = [];
let iv;
let schain;
let unifiedID;
let eids;
let tpid = []
let criteoId;

utils._each(bidReqs, function (bid) {
if (!unifiedID) {
unifiedID = utils.deepAccess(bid, 'userId.tdid');
if (!eids && bid.userId) {
eids = createEidsArray(bid.userId)
eids.forEach(function (id) {
if (id.uids && id.uids[0]) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

id.uids is only ever an array with a max of one item in it? Or that's all we care about for now?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So in a great moment for standards, I am unsure what to do with a second Id value if it is in the tpid object. Everyone should be using the eids array but we saw some documentation that indicated that for some ids the tpid was used as well. My guess is that eventually, everyone will move off of tpid (if anyone is using it now) and we will stop sending it. Along with the weird, criteo id entry.

if (id.source === 'criteo.com') {
criteoId = id.uids[0].id
}
tpid.push({source: id.source, uid: id.uids[0].id})
}
})
}

if (bid.schain) {
Expand Down Expand Up @@ -84,19 +96,12 @@ export const spec = {
utils.deepSetValue(sovrnBidReq, 'regs.ext.us_privacy', bidderRequest.uspConsent);
}

if (unifiedID) {
const idArray = [{
source: 'adserver.org',
uids: [
{
id: unifiedID,
ext: {
rtiPartner: 'TDID'
}
}
]
}]
utils.deepSetValue(sovrnBidReq, 'user.ext.eids', idArray)
if (eids) {
utils.deepSetValue(sovrnBidReq, 'user.ext.eids', eids)
utils.deepSetValue(sovrnBidReq, 'user.ext.tpid', tpid)
if (criteoId) {
utils.deepSetValue(sovrnBidReq, 'user.ext.prebid_criteoid', criteoId)
}
}

let url = `https://ap.lijit.com/rtb/bid?src=$$REPO_AND_VERSION$$`;
Expand Down
23 changes: 16 additions & 7 deletions test/spec/modules/sovrnBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -239,8 +239,8 @@ describe('sovrnBidAdapter', function() {
expect(data.source.ext.schain.nodes.length).to.equal(1)
});

it('should add the unifiedID if present', function() {
const digitrustRequests = [{
it('should add ids to the bid request', function() {
const criteoIdRequest = [{
'bidder': 'sovrn',
'params': {
'tagid': 403370
Expand All @@ -254,6 +254,7 @@ describe('sovrnBidAdapter', function() {
'bidderRequestId': '22edbae2733bf6',
'auctionId': '1d1a030790a475',
'userId': {
'criteoId': 'A_CRITEO_ID',
'tdid': 'SOMESORTOFID',
}
}].concat(bidRequests);
Expand All @@ -263,12 +264,20 @@ describe('sovrnBidAdapter', function() {
}
};

const data = JSON.parse(spec.buildRequests(digitrustRequests, bidderRequest).data);
expect(data.user.ext.eids[0].source).to.equal('adserver.org')
expect(data.user.ext.eids[0].uids[0].id).to.equal('SOMESORTOFID')
expect(data.user.ext.eids[0].uids[0].ext.rtiPartner).to.equal('TDID')
})
const data = JSON.parse(spec.buildRequests(criteoIdRequest, bidderRequest).data);
expect(data.user.ext.eids[0].source).to.equal('criteo.com')
expect(data.user.ext.eids[0].uids[0].id).to.equal('A_CRITEO_ID')
expect(data.user.ext.eids[0].uids[0].atype).to.equal(1)
expect(data.user.ext.eids[1].source).to.equal('adserver.org')
expect(data.user.ext.eids[1].uids[0].id).to.equal('SOMESORTOFID')
expect(data.user.ext.eids[1].uids[0].ext.rtiPartner).to.equal('TDID')
expect(data.user.ext.eids[1].uids[0].atype).to.equal(1)
expect(data.user.ext.tpid[0].source).to.equal('criteo.com')
expect(data.user.ext.tpid[0].uid).to.equal('A_CRITEO_ID')
expect(data.user.ext.prebid_criteoid).to.equal('A_CRITEO_ID')
});
});

describe('interpretResponse', function () {
let response;
beforeEach(function () {
Expand Down