From d21fab3e5a8b98fba5c19289fc30ad8f28b40ef5 Mon Sep 17 00:00:00 2001 From: Jonathan Go Date: Thu, 11 Apr 2019 15:42:51 -0400 Subject: [PATCH 1/4] Sonobi Adapter added support for UnifiedId/tdid --- modules/sonobiBidAdapter.js | 6 +++++ test/spec/modules/sonobiBidAdapter_spec.js | 28 +++++++++++++++++++++- 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/modules/sonobiBidAdapter.js b/modules/sonobiBidAdapter.js index a82d19a485c..b4e5a8830c3 100644 --- a/modules/sonobiBidAdapter.js +++ b/modules/sonobiBidAdapter.js @@ -78,6 +78,12 @@ export const spec = { payload.hfa = `PRE-${validBidRequests[0].crumbs.pubcid}`; } + if (deepAccess(validBidRequests[0], 'userId.tdid')) { + payload.tdid = validBidRequests[0].userId.tdid + } else if (deepAccess(validBidRequests[0], 'crumbs.tdid')) { + payload.tdid = validBidRequests[0].crumbs.tdid + } + if (validBidRequests[0].params.referrer) { payload.ref = validBidRequests[0].params.referrer; } diff --git a/test/spec/modules/sonobiBidAdapter_spec.js b/test/spec/modules/sonobiBidAdapter_spec.js index 6a0729649fc..4eb404c2a45 100644 --- a/test/spec/modules/sonobiBidAdapter_spec.js +++ b/test/spec/modules/sonobiBidAdapter_spec.js @@ -296,7 +296,7 @@ describe('SonobiBidAdapter', function () { 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; @@ -313,6 +313,32 @@ describe('SonobiBidAdapter', function () { delete bidRequest[1].userId; }) + it('should return a properly formatted request with unified id as tdid', function () { + delete bidRequest[0].params.hfa; + delete bidRequest[1].params.hfa; + bidRequest[0].crumbs = {'tdid': 'td-abcd-efg-0101'}; + bidRequest[1].crumbs = {'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 unified id from User ID as tdid', function () { + delete bidRequest[0].params.hfa; + delete bidRequest[1].params.hfa; + 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'; From 98ab809fc5b4673c61350f77981ac494231ca6d5 Mon Sep 17 00:00:00 2001 From: Jonathan Go Date: Thu, 11 Apr 2019 15:44:25 -0400 Subject: [PATCH 2/4] fixed unit test --- test/spec/modules/sonobiBidAdapter_spec.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/spec/modules/sonobiBidAdapter_spec.js b/test/spec/modules/sonobiBidAdapter_spec.js index 4eb404c2a45..971b7204263 100644 --- a/test/spec/modules/sonobiBidAdapter_spec.js +++ b/test/spec/modules/sonobiBidAdapter_spec.js @@ -314,8 +314,8 @@ describe('SonobiBidAdapter', function () { }) it('should return a properly formatted request with unified id as tdid', function () { - delete bidRequest[0].params.hfa; - delete bidRequest[1].params.hfa; + delete bidRequest[0].params.tdid; + delete bidRequest[1].params.tdid; bidRequest[0].crumbs = {'tdid': 'td-abcd-efg-0101'}; bidRequest[1].crumbs = {'tdid': 'td-abcd-efg-0101'}; const bidRequests = spec.buildRequests(bidRequest, bidderRequests) @@ -327,8 +327,8 @@ describe('SonobiBidAdapter', function () { }); it('should return a properly formatted request with unified id from User ID as tdid', function () { - delete bidRequest[0].params.hfa; - delete bidRequest[1].params.hfa; + 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) From 34ffa06aa75cc30894505619403046903719c5c4 Mon Sep 17 00:00:00 2001 From: Jonathan Go Date: Thu, 11 Apr 2019 16:43:36 -0400 Subject: [PATCH 3/4] added semi colons --- modules/sonobiBidAdapter.js | 4 +-- test/spec/modules/sonobiBidAdapter_spec.js | 40 +++++++++++----------- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/modules/sonobiBidAdapter.js b/modules/sonobiBidAdapter.js index b4e5a8830c3..5592c5f978a 100644 --- a/modules/sonobiBidAdapter.js +++ b/modules/sonobiBidAdapter.js @@ -79,9 +79,9 @@ export const spec = { } if (deepAccess(validBidRequests[0], 'userId.tdid')) { - payload.tdid = validBidRequests[0].userId.tdid + payload.tdid = validBidRequests[0].userId.tdid; } else if (deepAccess(validBidRequests[0], 'crumbs.tdid')) { - payload.tdid = validBidRequests[0].crumbs.tdid + payload.tdid = validBidRequests[0].crumbs.tdid; } if (validBidRequests[0].params.referrer) { diff --git a/test/spec/modules/sonobiBidAdapter_spec.js b/test/spec/modules/sonobiBidAdapter_spec.js index 971b7204263..47d479189ad 100644 --- a/test/spec/modules/sonobiBidAdapter_spec.js +++ b/test/spec/modules/sonobiBidAdapter_spec.js @@ -290,11 +290,11 @@ 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'); }); @@ -303,11 +303,11 @@ describe('SonobiBidAdapter', function () { 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; @@ -318,11 +318,11 @@ describe('SonobiBidAdapter', function () { delete bidRequest[1].params.tdid; bidRequest[0].crumbs = {'tdid': 'td-abcd-efg-0101'}; bidRequest[1].crumbs = {'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 + 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'); }); @@ -331,11 +331,11 @@ describe('SonobiBidAdapter', function () { 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 + 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'); }) From 03dc6c18ff98796a1d2b568b2b34673cc8517f8b Mon Sep 17 00:00:00 2001 From: Jonathan Go Date: Fri, 19 Apr 2019 09:10:38 -0400 Subject: [PATCH 4/4] removed fallback tdid on crumbs --- modules/sonobiBidAdapter.js | 2 -- test/spec/modules/sonobiBidAdapter_spec.js | 13 ------------- 2 files changed, 15 deletions(-) diff --git a/modules/sonobiBidAdapter.js b/modules/sonobiBidAdapter.js index 5592c5f978a..1d83f532eae 100644 --- a/modules/sonobiBidAdapter.js +++ b/modules/sonobiBidAdapter.js @@ -80,8 +80,6 @@ export const spec = { if (deepAccess(validBidRequests[0], 'userId.tdid')) { payload.tdid = validBidRequests[0].userId.tdid; - } else if (deepAccess(validBidRequests[0], 'crumbs.tdid')) { - payload.tdid = validBidRequests[0].crumbs.tdid; } if (validBidRequests[0].params.referrer) { diff --git a/test/spec/modules/sonobiBidAdapter_spec.js b/test/spec/modules/sonobiBidAdapter_spec.js index 47d479189ad..a8443b9cad6 100644 --- a/test/spec/modules/sonobiBidAdapter_spec.js +++ b/test/spec/modules/sonobiBidAdapter_spec.js @@ -313,19 +313,6 @@ describe('SonobiBidAdapter', function () { delete bidRequest[1].userId; }) - it('should return a properly formatted request with unified id as tdid', function () { - delete bidRequest[0].params.tdid; - delete bidRequest[1].params.tdid; - bidRequest[0].crumbs = {'tdid': 'td-abcd-efg-0101'}; - bidRequest[1].crumbs = {'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 unified id from User ID as tdid', function () { delete bidRequest[0].params.tdid; delete bidRequest[1].params.tdid;