From db0ea310970dd665a030051fe4cf85ea4936ef38 Mon Sep 17 00:00:00 2001 From: OneTagDevOps <38786435+OneTagDevOps@users.noreply.github.com> Date: Wed, 31 Jul 2019 10:44:15 +0200 Subject: [PATCH 1/5] Minor bug fixing in onetagBidAdapter.js Fixed a minor bug. Updated TTL in response to align the correct specifications. --- modules/onetagBidAdapter.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/onetagBidAdapter.js b/modules/onetagBidAdapter.js index 96a85a6070d..7d1e4f5fd87 100644 --- a/modules/onetagBidAdapter.js +++ b/modules/onetagBidAdapter.js @@ -24,7 +24,7 @@ function isBidRequestValid(bid) { return false; } - if (typeof bid.params.pubId !== 'string' || bid.sizes === 'undefined' || bid.sizes.length === 0) { + if (typeof bid.params.pubId !== 'string' || typeof bid.sizes === 'undefined' || bid.sizes.length === 0) { return false; } @@ -82,7 +82,7 @@ function interpretResponse(serverResponse, request) { netRevenue: false, mediaType: bids.type ? bids.type : BANNER, ad: bid.ad, - ttl: bid.ttl || 6000 + ttl: bid.ttl || 300 }); }); } From 0a498dfc24743c3ac0763fece7e359f90ea92309 Mon Sep 17 00:00:00 2001 From: OneTagDevOps <38786435+OneTagDevOps@users.noreply.github.com> Date: Tue, 22 Oct 2019 11:01:08 +0200 Subject: [PATCH 2/5] Update onetagBidAdapter Added additional page info and user sync function. --- modules/onetagBidAdapter.js | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/modules/onetagBidAdapter.js b/modules/onetagBidAdapter.js index ce671772dad..3dad4af8bbe 100644 --- a/modules/onetagBidAdapter.js +++ b/modules/onetagBidAdapter.js @@ -3,6 +3,7 @@ const { registerBidder } = require('../src/adapters/bidderFactory'); const ENDPOINT = 'https://onetag-sys.com/prebid-request'; +const USER_SYNC_ENDPOINT = 'https://onetag-sys.com/usync/'; const BIDDER_CODE = 'onetag'; const BANNER = 'banner'; @@ -120,8 +121,15 @@ function getPageInfo() { masked: m, wWidth: w.innerWidth, wHeight: w.innerHeight, + oWidth: w.outerWidth, + oHeight: w.outerHeight, sWidth: s.width, sHeight: s.height, + aWidth: s.availWidth, + aHeight: s.availHeight, + sLeft: 'screenLeft' in w ? w.screenLeft : w.screenX, + sTop: 'screenTop' in w ? w.screenTop : w.screenY, + hLength: history.length, date: t.toUTCString(), timeOffset: t.getTimezoneOffset() }; @@ -162,6 +170,25 @@ function requestsToBids(bid) { return toRet; } +function getUserSyncs(syncOptions, serverResponses, gdprConsent) { + if (syncOptions.iframeEnabled) { + const rnd = new Date().getTime(); + let params = '?cb=' + rnd; + + if (gdprConsent && typeof gdprConsent.consentString === 'string') { + params += '&gdpr_consent=' + gdprConsent.consentString; + if (typeof gdprConsent.gdprApplies === 'boolean') { + params += '&gdpr=' + (gdprConsent.gdprApplies ? 1 : 0); + } + } + + return [{ + type: 'iframe', + url: USER_SYNC_ENDPOINT + params + }]; + } +} + export const spec = { code: BIDDER_CODE, @@ -170,6 +197,7 @@ export const spec = { isBidRequestValid: isBidRequestValid, buildRequests: buildRequests, interpretResponse: interpretResponse, + getUserSyncs: getUserSyncs }; From acf60aca33ac4ab8a1fdf987a0a8ac6c07bc15e6 Mon Sep 17 00:00:00 2001 From: OneTagDevOps <38786435+OneTagDevOps@users.noreply.github.com> Date: Tue, 22 Oct 2019 11:03:27 +0200 Subject: [PATCH 3/5] Update onetagBidAdapter_spec.js Added the test for getUserSyncs function. --- test/spec/modules/onetagBidAdapter_spec.js | 23 +++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/test/spec/modules/onetagBidAdapter_spec.js b/test/spec/modules/onetagBidAdapter_spec.js index d56ad9e6dc5..66b31658f6c 100644 --- a/test/spec/modules/onetagBidAdapter_spec.js +++ b/test/spec/modules/onetagBidAdapter_spec.js @@ -53,7 +53,7 @@ describe('onetag', function () { const data = JSON.parse(d); it('Should contains all keys', function () { expect(data).to.be.an('object'); - expect(data).to.have.all.keys('location', 'masked', 'referrer', 'sHeight', 'sWidth', 'timeOffset', 'date', 'wHeight', 'wWidth', 'bids'); + expect(data).to.have.all.keys('location', 'masked', 'referrer', 'sHeight', 'sWidth', 'timeOffset', 'date', 'wHeight', 'wWidth', 'oHeight', 'oWidth', 'aWidth', 'aHeight', 'sLeft', 'sTop', 'hLength', 'bids'); expect(data.location).to.be.a('string'); expect(data.masked).to.be.a('number'); expect(data.referrer).to.be.a('string'); @@ -61,6 +61,13 @@ describe('onetag', function () { expect(data.sWidth).to.be.a('number'); expect(data.wWidth).to.be.a('number'); expect(data.wHeight).to.be.a('number'); + expect(data.oHeight).to.be.a('number'); + expect(data.oWidth).to.be.a('number'); + expect(data.aWidth).to.be.a('number'); + expect(data.aHeight).to.be.a('number'); + expect(data.sLeft).to.be.a('number'); + expect(data.sTop).to.be.a('number'); + expect(data.hLength).to.be.a('number'); expect(data.timeOffset).to.be.a('number'); expect(data.date).to.be.a('string'); expect(data.bids).to.be.an('array'); @@ -146,4 +153,18 @@ describe('onetag', function () { }); }); }); + describe('getUserSyncs', function () { + const sync_endpoint = 'https://onetag-sys.com/usync/'; + it('Returns an iframe if iframeEnabled is true', function () { + const syncs = spec.getUserSyncs({iframeEnabled: true}); + expect(syncs).to.be.an('array'); + expect(syncs.length).to.equal(1); + expect(syncs[0].type).to.equal('iframe'); + expect(syncs[0].url).to.include(sync_endpoint); + }); + it('Returns an empty array if iframeEnabled is false', function () { + const syncs = spec.getUserSyncs({ iframeEnabled: false }); + expect(syncs).to.equal(undefined); + }); + }); }); From dc6867c3ea3b5f2bcf663141b1371db751670142 Mon Sep 17 00:00:00 2001 From: valentino Date: Tue, 22 Oct 2019 16:07:38 +0200 Subject: [PATCH 4/5] Fix about userSync --- modules/onetagBidAdapter.js | 6 ++++-- test/spec/modules/onetagBidAdapter_spec.js | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/modules/onetagBidAdapter.js b/modules/onetagBidAdapter.js index 3dad4af8bbe..77c257fd7fb 100644 --- a/modules/onetagBidAdapter.js +++ b/modules/onetagBidAdapter.js @@ -171,6 +171,7 @@ function requestsToBids(bid) { } function getUserSyncs(syncOptions, serverResponses, gdprConsent) { + const syncs = []; if (syncOptions.iframeEnabled) { const rnd = new Date().getTime(); let params = '?cb=' + rnd; @@ -182,11 +183,12 @@ function getUserSyncs(syncOptions, serverResponses, gdprConsent) { } } - return [{ + syncs.push({ type: 'iframe', url: USER_SYNC_ENDPOINT + params - }]; + }); } + return syncs; } export const spec = { diff --git a/test/spec/modules/onetagBidAdapter_spec.js b/test/spec/modules/onetagBidAdapter_spec.js index 66b31658f6c..fafcf03f96f 100644 --- a/test/spec/modules/onetagBidAdapter_spec.js +++ b/test/spec/modules/onetagBidAdapter_spec.js @@ -164,7 +164,7 @@ describe('onetag', function () { }); it('Returns an empty array if iframeEnabled is false', function () { const syncs = spec.getUserSyncs({ iframeEnabled: false }); - expect(syncs).to.equal(undefined); + expect(syncs).to.be.an('array').that.is.empty; }); }); }); From 4b4411568d992deae35d354dec4690802912dedc Mon Sep 17 00:00:00 2001 From: valentino Date: Wed, 23 Oct 2019 19:33:37 +0200 Subject: [PATCH 5/5] getUserSyncs: test update with gdpr params --- test/spec/modules/onetagBidAdapter_spec.js | 38 ++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/test/spec/modules/onetagBidAdapter_spec.js b/test/spec/modules/onetagBidAdapter_spec.js index fafcf03f96f..93284566069 100644 --- a/test/spec/modules/onetagBidAdapter_spec.js +++ b/test/spec/modules/onetagBidAdapter_spec.js @@ -166,5 +166,43 @@ describe('onetag', function () { const syncs = spec.getUserSyncs({ iframeEnabled: false }); expect(syncs).to.be.an('array').that.is.empty; }); + it('Must pass gdpr params when gdprApplies is true', function () { + const syncs = spec.getUserSyncs({ iframeEnabled: true }, {}, { + gdprApplies: true, consentString: 'foo' + }); + expect(syncs[0].type).to.equal('iframe'); + expect(syncs[0].url).to.include(sync_endpoint); + expect(syncs[0].url).to.match(/(?:[?&](?:gdpr_consent=foo([^&]*)|gdpr=1([^&]*)|[^&]*))+$/); + }); + it('Must pass gdpr params when gdprApplies is false', function () { + const syncs = spec.getUserSyncs({ iframeEnabled: true }, {}, { + gdprApplies: false, consentString: 'foo' + }); + expect(syncs[0].type).to.equal('iframe'); + expect(syncs[0].url).to.include(sync_endpoint); + expect(syncs[0].url).to.match(/(?:[?&](?:gdpr_consent=foo([^&]*)|gdpr=0([^&]*)))+$/); + }); + it('Must pass gdpr consent string param when gdprApplies is undefined', function () { + const syncs = spec.getUserSyncs({ iframeEnabled: true }, {}, { + consentString: 'foo' + }); + expect(syncs[0].type).to.equal('iframe'); + expect(syncs[0].url).to.include(sync_endpoint); + expect(syncs[0].url).to.match(/(?:[?&](?:gdpr_consent=foo([^&]*)))+$/); + }); + it('Must pass no gdpr params when consentString is null', function () { + const syncs = spec.getUserSyncs({ iframeEnabled: true }, {}, { + consentString: null + }); + expect(syncs[0].type).to.equal('iframe'); + expect(syncs[0].url).to.include(sync_endpoint); + expect(syncs[0].url).to.not.match(/(?:[?&](?:gdpr_consent=([^&]*)|gdpr=([^&]*)))+$/); + }); + it('Must pass no gdpr param when gdprConsent is empty', function () { + const syncs = spec.getUserSyncs({ iframeEnabled: true }, {}, {}); + expect(syncs[0].type).to.equal('iframe'); + expect(syncs[0].url).to.include(sync_endpoint); + expect(syncs[0].url).to.not.match(/(?:[?&](?:gdpr_consent=([^&]*)|gdpr=([^&]*)))+$/); + }); }); });