From a0cc67b97be09bc62a9021d5a52c8ac962de868d Mon Sep 17 00:00:00 2001 From: moroz Date: Fri, 7 Dec 2018 14:44:59 +0200 Subject: [PATCH 1/8] Add user sync pixel logic in Adtelligent adapter --- modules/adtelligentBidAdapter.js | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/modules/adtelligentBidAdapter.js b/modules/adtelligentBidAdapter.js index 65181c70ed9..1255550ab33 100644 --- a/modules/adtelligentBidAdapter.js +++ b/modules/adtelligentBidAdapter.js @@ -17,7 +17,35 @@ export const spec = { isBidRequestValid: function (bid) { return bid && bid.params && bid.params.aid; }, + getUserSyncs: function (syncOptions, serverResponses) { + var syncs = []; + + function addSyncs(_s) { + if (_s && _s.length) { + _s.forEach(s => { + syncs.push({ + type: 'image', + url: s + }) + }) + } + } + if (syncOptions.pixelEnabled) { + serverResponses && serverResponses.length && serverResponses.forEach((response) => { + if (response.body) { + if (utils.isArray(response.body)) { + response.body.forEach(b => { + addSyncs(b.cookieURLs); + }) + } else { + addSyncs(response.body.cookieURLs) + } + } + }) + } + return syncs; + }, /** * Make a server request from the list of BidRequests * @param bidRequests From 431edaf5015dc800cd2761b63533768fb6ebd71a Mon Sep 17 00:00:00 2001 From: moroz Date: Fri, 7 Dec 2018 21:26:23 +0200 Subject: [PATCH 2/8] Add gdpr support --- modules/adtelligentBidAdapter.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/modules/adtelligentBidAdapter.js b/modules/adtelligentBidAdapter.js index 1255550ab33..6477a80f71c 100644 --- a/modules/adtelligentBidAdapter.js +++ b/modules/adtelligentBidAdapter.js @@ -53,7 +53,7 @@ export const spec = { */ buildRequests: function (bidRequests, bidderRequest) { return { - data: bidToTag(bidRequests), + data: bidToTag(bidRequests, bidderRequest), bidderRequest, method: 'GET', url: URL @@ -111,11 +111,16 @@ function parseRTBResponse(serverResponse, bidderRequest) { return bids; } -function bidToTag(bidRequests) { +function bidToTag(bidRequests, bidderRequest) { let tag = { domain: utils.getTopWindowLocation().hostname }; + if(bidderRequest && bidderRequest.gdprConsent){ + tag.gdpr = 1; + tag.gdpr_consent = bidderRequest.gdprConsent.consentString; + } + for (let i = 0, length = bidRequests.length; i < length; i++) { Object.assign(tag, prepareRTBRequestParams(i, bidRequests[i])); } From 75d21a6066deabec3bf445426e439254ca12ad1a Mon Sep 17 00:00:00 2001 From: moroz Date: Fri, 7 Dec 2018 21:31:38 +0200 Subject: [PATCH 3/8] Add gdpr support --- modules/adtelligentBidAdapter.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/adtelligentBidAdapter.js b/modules/adtelligentBidAdapter.js index 6477a80f71c..95087b56f21 100644 --- a/modules/adtelligentBidAdapter.js +++ b/modules/adtelligentBidAdapter.js @@ -116,7 +116,7 @@ function bidToTag(bidRequests, bidderRequest) { domain: utils.getTopWindowLocation().hostname }; - if(bidderRequest && bidderRequest.gdprConsent){ + if (bidderRequest && bidderRequest.gdprConsent) { tag.gdpr = 1; tag.gdpr_consent = bidderRequest.gdprConsent.consentString; } From 6f40409fe168965ead401a2240d795b68be5435b Mon Sep 17 00:00:00 2001 From: moroz Date: Mon, 10 Dec 2018 15:40:36 +0200 Subject: [PATCH 4/8] Update tests --- .../modules/adtelligentBidAdapter_spec.js | 37 ++++++++++++++++++- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/test/spec/modules/adtelligentBidAdapter_spec.js b/test/spec/modules/adtelligentBidAdapter_spec.js index 6190f53fdc4..0ee2bb2726f 100644 --- a/test/spec/modules/adtelligentBidAdapter_spec.js +++ b/test/spec/modules/adtelligentBidAdapter_spec.js @@ -46,6 +46,7 @@ const SERVER_VIDEO_RESPONSE = { } ] }; + const SERVER_DISPLAY_RESPONSE = { 'source': {'aid': 12345, 'pubId': 54321}, 'bids': [{ @@ -57,7 +58,8 @@ const SERVER_DISPLAY_RESPONSE = { 'cur': 'USD', 'width': 300, 'cpm': 0.9 - }] + }], + 'cookieURLs': ['link1', 'link2'] }; const videoBidderRequest = { @@ -70,6 +72,14 @@ const displayBidderRequest = { bids: [{bidId: '2e41f65424c87c'}] }; +const displayBidderRequestWithGdpr = { + bidderCode: 'bidderCode', + bids: [{bidId: '2e41f65424c87c'}], + gdprConsent: { + consentString: 'test' + } +}; + const videoEqResponse = [{ vastUrl: 'http://rtb.adtelligent.com/vast/?adid=44F2AEB9BFC881B3', requestId: '2e41f65424c87c', @@ -96,9 +106,25 @@ const displayEqResponse = [{ cpm: 0.9 }]; -describe('adtelligentBidAdapter', function () { +describe('adtelligentBidAdapter', function () { // todo remove only const adapter = newBidder(spec); + describe('user syncs', function () { + it('should be returned if pixel enabled', function () { + const syncs = spec.getUserSyncs({pixelEnabled: true}, [{body: SERVER_DISPLAY_RESPONSE}]); + + expect(syncs.map(s => s.url)).to.deep.equal(SERVER_DISPLAY_RESPONSE.cookieURLs); + }) + }) + + describe('user syncs', function () { + it('should not be returned if pixel not set', function () { + const syncs = spec.getUserSyncs({}, [{body: SERVER_DISPLAY_RESPONSE}]); + + expect(syncs).to.be.empty; + }) + }) + describe('inherited functions', function () { it('exists and is a function', function () { expect(adapter.callBids).to.exist.and.to.be.a('function'); @@ -212,6 +238,13 @@ describe('adtelligentBidAdapter', function () { bidServerResponseCheck(); }); + it('should set gdpr data correctly', function () { + const builtRequestData = spec.buildRequests([DISPLAY_REQUEST], displayBidderRequestWithGdpr); + + expect(builtRequestData.data.gdpr).to.be.equal(1); + expect(builtRequestData.data.gdpr_consent).to.be.equal(displayBidderRequestWithGdpr.gdprConsent.consentString); + }); + function bidServerResponseCheck() { const result = spec.interpretResponse({body: serverResponse}, {bidderRequest}); From 5b4c9f1b44535b2c3fba03a0733ea4794ac2e281 Mon Sep 17 00:00:00 2001 From: moroz Date: Fri, 11 Jan 2019 14:33:45 +0200 Subject: [PATCH 5/8] Support both types of user syncs --- modules/adtelligentBidAdapter.js | 27 ++++++++---- .../modules/adtelligentBidAdapter_spec.js | 42 +++++++++++++++++-- 2 files changed, 57 insertions(+), 12 deletions(-) diff --git a/modules/adtelligentBidAdapter.js b/modules/adtelligentBidAdapter.js index 95087b56f21..7c02a193159 100644 --- a/modules/adtelligentBidAdapter.js +++ b/modules/adtelligentBidAdapter.js @@ -20,26 +20,37 @@ export const spec = { getUserSyncs: function (syncOptions, serverResponses) { var syncs = []; - function addSyncs(_s) { - if (_s && _s.length) { - _s.forEach(s => { + function addSyncs(bid) { + const uris = bid.cookieURLs; + const types = bid.cookieURLSTypes || []; + + if (uris && uris.length) { + uris.forEach((uri, i) => { + let type = types[i] || 'image'; + + if (syncOptions.pixelEnabled && !syncOptions.iframeEnabled) { + type = 'image'; + } else if (!syncOptions.pixelEnabled && syncOptions.iframeEnabled) { + type = 'iframe'; + } + syncs.push({ - type: 'image', - url: s + type: type, + url: uri }) }) } } - if (syncOptions.pixelEnabled) { + if (syncOptions.pixelEnabled || syncOptions.iframeEnabled) { serverResponses && serverResponses.length && serverResponses.forEach((response) => { if (response.body) { if (utils.isArray(response.body)) { response.body.forEach(b => { - addSyncs(b.cookieURLs); + addSyncs(b); }) } else { - addSyncs(response.body.cookieURLs) + addSyncs(response.body) } } }) diff --git a/test/spec/modules/adtelligentBidAdapter_spec.js b/test/spec/modules/adtelligentBidAdapter_spec.js index 0ee2bb2726f..e34a8e19b5c 100644 --- a/test/spec/modules/adtelligentBidAdapter_spec.js +++ b/test/spec/modules/adtelligentBidAdapter_spec.js @@ -61,6 +61,21 @@ const SERVER_DISPLAY_RESPONSE = { }], 'cookieURLs': ['link1', 'link2'] }; +const SERVER_DISPLAY_RESPONSE_WITH_MIXED_SYNCS = { + 'source': {'aid': 12345, 'pubId': 54321}, + 'bids': [{ + 'ad': '', + 'requestId': '2e41f65424c87c', + 'creative_id': 342516, + 'cmpId': 342516, + 'height': 250, + 'cur': 'USD', + 'width': 300, + 'cpm': 0.9 + }], + 'cookieURLs': ['link1', 'link2'], + 'cookieURLSTypes': ['image', 'iframe'] +}; const videoBidderRequest = { bidderCode: 'bidderCode', @@ -109,17 +124,36 @@ const displayEqResponse = [{ describe('adtelligentBidAdapter', function () { // todo remove only const adapter = newBidder(spec); - describe('user syncs', function () { + describe('user syncs as image', function () { + it('should be returned if pixel enabled', function () { + const syncs = spec.getUserSyncs({pixelEnabled: true}, [{body: SERVER_DISPLAY_RESPONSE_WITH_MIXED_SYNCS}]); + + expect(syncs.map(s => s.url)).to.deep.equal(SERVER_DISPLAY_RESPONSE_WITH_MIXED_SYNCS.cookieURLs); + expect(syncs.map(s => s.type)).to.deep.equal(['image', 'image']); + }) + }) + + describe('user syncs as iframe', function () { + it('should be returned if pixel enabled', function () { + const syncs = spec.getUserSyncs({iframeEnabled: true}, [{body: SERVER_DISPLAY_RESPONSE_WITH_MIXED_SYNCS}]); + + expect(syncs.map(s => s.url)).to.deep.equal(SERVER_DISPLAY_RESPONSE_WITH_MIXED_SYNCS.cookieURLs); + expect(syncs.map(s => s.type)).to.deep.equal(['iframe', 'iframe']); + }) + }) + + describe('user syncs with both types', function () { it('should be returned if pixel enabled', function () { - const syncs = spec.getUserSyncs({pixelEnabled: true}, [{body: SERVER_DISPLAY_RESPONSE}]); + const syncs = spec.getUserSyncs({iframeEnabled: true, pixelEnabled: true}, [{body: SERVER_DISPLAY_RESPONSE_WITH_MIXED_SYNCS}]); - expect(syncs.map(s => s.url)).to.deep.equal(SERVER_DISPLAY_RESPONSE.cookieURLs); + expect(syncs.map(s => s.url)).to.deep.equal(SERVER_DISPLAY_RESPONSE_WITH_MIXED_SYNCS.cookieURLs); + expect(syncs.map(s => s.type)).to.deep.equal(SERVER_DISPLAY_RESPONSE_WITH_MIXED_SYNCS.cookieURLSTypes); }) }) describe('user syncs', function () { it('should not be returned if pixel not set', function () { - const syncs = spec.getUserSyncs({}, [{body: SERVER_DISPLAY_RESPONSE}]); + const syncs = spec.getUserSyncs({}, [{body: SERVER_DISPLAY_RESPONSE_WITH_MIXED_SYNCS}]); expect(syncs).to.be.empty; }) From bc200c73d7b92ab0b85d0d63c2f36a169acf14fa Mon Sep 17 00:00:00 2001 From: moroz Date: Wed, 23 Jan 2019 22:45:32 +0200 Subject: [PATCH 6/8] More logical code with syncs --- modules/adtelligentBidAdapter.js | 7 +++---- test/spec/modules/adtelligentBidAdapter_spec.js | 15 +++++++++------ 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/modules/adtelligentBidAdapter.js b/modules/adtelligentBidAdapter.js index 7c02a193159..c23c818601b 100644 --- a/modules/adtelligentBidAdapter.js +++ b/modules/adtelligentBidAdapter.js @@ -28,10 +28,9 @@ export const spec = { uris.forEach((uri, i) => { let type = types[i] || 'image'; - if (syncOptions.pixelEnabled && !syncOptions.iframeEnabled) { - type = 'image'; - } else if (!syncOptions.pixelEnabled && syncOptions.iframeEnabled) { - type = 'iframe'; + if ((!syncOptions.pixelEnabled && type == 'image') || + (!syncOptions.iframeEnabled && type == 'iframe')) { + return; } syncs.push({ diff --git a/test/spec/modules/adtelligentBidAdapter_spec.js b/test/spec/modules/adtelligentBidAdapter_spec.js index e34a8e19b5c..9386d313e1f 100644 --- a/test/spec/modules/adtelligentBidAdapter_spec.js +++ b/test/spec/modules/adtelligentBidAdapter_spec.js @@ -121,15 +121,15 @@ const displayEqResponse = [{ cpm: 0.9 }]; -describe('adtelligentBidAdapter', function () { // todo remove only +describe.only('adtelligentBidAdapter', function () { // todo remove only const adapter = newBidder(spec); describe('user syncs as image', function () { it('should be returned if pixel enabled', function () { const syncs = spec.getUserSyncs({pixelEnabled: true}, [{body: SERVER_DISPLAY_RESPONSE_WITH_MIXED_SYNCS}]); - expect(syncs.map(s => s.url)).to.deep.equal(SERVER_DISPLAY_RESPONSE_WITH_MIXED_SYNCS.cookieURLs); - expect(syncs.map(s => s.type)).to.deep.equal(['image', 'image']); + expect(syncs.map(s => s.url)).to.deep.equal([SERVER_DISPLAY_RESPONSE_WITH_MIXED_SYNCS.cookieURLs[0]]); + expect(syncs.map(s => s.type)).to.deep.equal(['image']); }) }) @@ -137,14 +137,17 @@ describe('adtelligentBidAdapter', function () { // todo remove only it('should be returned if pixel enabled', function () { const syncs = spec.getUserSyncs({iframeEnabled: true}, [{body: SERVER_DISPLAY_RESPONSE_WITH_MIXED_SYNCS}]); - expect(syncs.map(s => s.url)).to.deep.equal(SERVER_DISPLAY_RESPONSE_WITH_MIXED_SYNCS.cookieURLs); - expect(syncs.map(s => s.type)).to.deep.equal(['iframe', 'iframe']); + expect(syncs.map(s => s.url)).to.deep.equal([SERVER_DISPLAY_RESPONSE_WITH_MIXED_SYNCS.cookieURLs[1]]); + expect(syncs.map(s => s.type)).to.deep.equal(['iframe']); }) }) describe('user syncs with both types', function () { it('should be returned if pixel enabled', function () { - const syncs = spec.getUserSyncs({iframeEnabled: true, pixelEnabled: true}, [{body: SERVER_DISPLAY_RESPONSE_WITH_MIXED_SYNCS}]); + const syncs = spec.getUserSyncs({ + iframeEnabled: true, + pixelEnabled: true + }, [{body: SERVER_DISPLAY_RESPONSE_WITH_MIXED_SYNCS}]); expect(syncs.map(s => s.url)).to.deep.equal(SERVER_DISPLAY_RESPONSE_WITH_MIXED_SYNCS.cookieURLs); expect(syncs.map(s => s.type)).to.deep.equal(SERVER_DISPLAY_RESPONSE_WITH_MIXED_SYNCS.cookieURLSTypes); From 82a4ad144bf83b1ce7a9b4dfd8e49261c93f254f Mon Sep 17 00:00:00 2001 From: moroz Date: Thu, 24 Jan 2019 13:54:54 +0200 Subject: [PATCH 7/8] Remove "only" from test --- test/spec/modules/adtelligentBidAdapter_spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/spec/modules/adtelligentBidAdapter_spec.js b/test/spec/modules/adtelligentBidAdapter_spec.js index 9386d313e1f..c586f846d27 100644 --- a/test/spec/modules/adtelligentBidAdapter_spec.js +++ b/test/spec/modules/adtelligentBidAdapter_spec.js @@ -121,7 +121,7 @@ const displayEqResponse = [{ cpm: 0.9 }]; -describe.only('adtelligentBidAdapter', function () { // todo remove only +describe('adtelligentBidAdapter', function () { // todo remove only const adapter = newBidder(spec); describe('user syncs as image', function () { From 604858b178e6f659d187630ab1afc625f60b948c Mon Sep 17 00:00:00 2001 From: moroz Date: Mon, 28 Jan 2019 23:17:24 +0200 Subject: [PATCH 8/8] Update test messages --- test/spec/modules/adtelligentBidAdapter_spec.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/spec/modules/adtelligentBidAdapter_spec.js b/test/spec/modules/adtelligentBidAdapter_spec.js index c586f846d27..9187d779145 100644 --- a/test/spec/modules/adtelligentBidAdapter_spec.js +++ b/test/spec/modules/adtelligentBidAdapter_spec.js @@ -134,7 +134,7 @@ describe('adtelligentBidAdapter', function () { // todo remove only }) describe('user syncs as iframe', function () { - it('should be returned if pixel enabled', function () { + it('should be returned if iframe enabled', function () { const syncs = spec.getUserSyncs({iframeEnabled: true}, [{body: SERVER_DISPLAY_RESPONSE_WITH_MIXED_SYNCS}]); expect(syncs.map(s => s.url)).to.deep.equal([SERVER_DISPLAY_RESPONSE_WITH_MIXED_SYNCS.cookieURLs[1]]); @@ -143,7 +143,7 @@ describe('adtelligentBidAdapter', function () { // todo remove only }) describe('user syncs with both types', function () { - it('should be returned if pixel enabled', function () { + it('should be returned if pixel and iframe enabled', function () { const syncs = spec.getUserSyncs({ iframeEnabled: true, pixelEnabled: true