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

Sonobi Adapter - Support UnifiedId/tradedesk from user id module #3743

Merged
merged 4 commits into from
Apr 19, 2019
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
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