Skip to content

Commit

Permalink
Sonobi Adapter - Support UnifiedId/tradedesk from user id module (#3743)
Browse files Browse the repository at this point in the history
* Sonobi Adapter added support for UnifiedId/tdid

* fixed unit test

* added semi colons

* removed fallback tdid on crumbs
  • Loading branch information
JonGoSonobi authored and jsnellbaker committed Apr 19, 2019
1 parent 3e97e59 commit 542b990
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 11 deletions.
4 changes: 4 additions & 0 deletions modules/sonobiBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ export const spec = {
payload.hfa = `PRE-${validBidRequests[0].crumbs.pubcid}`;
}

if (deepAccess(validBidRequests[0], 'userId.tdid')) {
payload.tdid = validBidRequests[0].userId.tdid;
}

if (validBidRequests[0].params.referrer) {
payload.ref = validBidRequests[0].params.referrer;
}
Expand Down
35 changes: 24 additions & 11 deletions test/spec/modules/sonobiBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -290,29 +290,42 @@ describe('SonobiBidAdapter', function () {
delete bidRequest[1].params.hfa;
bidRequest[0].crumbs = {'pubcid': 'abcd-efg-0101'};
bidRequest[1].crumbs = {'pubcid': 'abcd-efg-0101'};
const bidRequests = spec.buildRequests(bidRequest, bidderRequests)
expect(bidRequests.url).to.equal('https://apex.go.sonobi.com/trinity.json')
expect(bidRequests.method).to.equal('GET')
expect(bidRequests.data.ref).not.to.be.empty
expect(bidRequests.data.s).not.to.be.empty
const bidRequests = spec.buildRequests(bidRequest, bidderRequests);
expect(bidRequests.url).to.equal('https://apex.go.sonobi.com/trinity.json');
expect(bidRequests.method).to.equal('GET');
expect(bidRequests.data.ref).not.to.be.empty;
expect(bidRequests.data.s).not.to.be.empty;
expect(bidRequests.data.hfa).to.equal('PRE-abcd-efg-0101');
})
});

it('should return a properly formatted request with commonid from User ID as hfa', function () {
delete bidRequest[0].params.hfa;
delete bidRequest[1].params.hfa;
bidRequest[0].userId = {'pubcid': 'abcd-efg-0101'};
bidRequest[1].userId = {'pubcid': 'abcd-efg-0101'};
const bidRequests = spec.buildRequests(bidRequest, bidderRequests)
expect(bidRequests.url).to.equal('https://apex.go.sonobi.com/trinity.json')
expect(bidRequests.method).to.equal('GET')
expect(bidRequests.data.ref).not.to.be.empty
expect(bidRequests.data.s).not.to.be.empty
const bidRequests = spec.buildRequests(bidRequest, bidderRequests);
expect(bidRequests.url).to.equal('https://apex.go.sonobi.com/trinity.json');
expect(bidRequests.method).to.equal('GET');
expect(bidRequests.data.ref).not.to.be.empty;
expect(bidRequests.data.s).not.to.be.empty;
expect(bidRequests.data.hfa).to.equal('PRE-abcd-efg-0101');
delete bidRequest[0].userId;
delete bidRequest[1].userId;
})

it('should return a properly formatted request with unified id from User ID as tdid', function () {
delete bidRequest[0].params.tdid;
delete bidRequest[1].params.tdid;
bidRequest[0].userId = {'tdid': 'td-abcd-efg-0101'};
bidRequest[1].userId = {'tdid': 'td-abcd-efg-0101'};
const bidRequests = spec.buildRequests(bidRequest, bidderRequests);
expect(bidRequests.url).to.equal('https://apex.go.sonobi.com/trinity.json');
expect(bidRequests.method).to.equal('GET');
expect(bidRequests.data.ref).not.to.be.empty;
expect(bidRequests.data.s).not.to.be.empty;
expect(bidRequests.data.tdid).to.equal('td-abcd-efg-0101');
})

it('should return a properly formatted request with hfa preferred over commonid', function () {
bidRequest[0].params.hfa = 'hfakey';
bidRequest[1].params.hfa = 'hfakey';
Expand Down

0 comments on commit 542b990

Please sign in to comment.