From 8ae87a5e10cf7eb6bf452901727444ba07edb792 Mon Sep 17 00:00:00 2001 From: Patrick McCann Date: Thu, 25 Jun 2020 07:50:03 -0400 Subject: [PATCH 01/17] make default s2s ttl configurable --- modules/prebidServerBidAdapter/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/prebidServerBidAdapter/index.js b/modules/prebidServerBidAdapter/index.js index 96986ed185c..c8231480e22 100644 --- a/modules/prebidServerBidAdapter/index.js +++ b/modules/prebidServerBidAdapter/index.js @@ -17,7 +17,7 @@ const getConfig = config.getConfig; const TYPE = S2S.SRC; let _synced = false; -const DEFAULT_S2S_TTL = 60; +const DEFAULT_S2S_TTL = pbjs_config.getConfig('defaultS2STTL') || 60; const DEFAULT_S2S_CURRENCY = 'USD'; const DEFAULT_S2S_NETREVENUE = true; From 893d71834f1954e23f4320ba305e537bac2b332d Mon Sep 17 00:00:00 2001 From: Patrick McCann Date: Thu, 25 Jun 2020 08:03:28 -0400 Subject: [PATCH 02/17] Update prebidServerBidAdapter_spec.js add unit test to s2sconfigdefault_s2s_ttl --- test/spec/modules/prebidServerBidAdapter_spec.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/test/spec/modules/prebidServerBidAdapter_spec.js b/test/spec/modules/prebidServerBidAdapter_spec.js index b4544a2ec48..2c338167659 100644 --- a/test/spec/modules/prebidServerBidAdapter_spec.js +++ b/test/spec/modules/prebidServerBidAdapter_spec.js @@ -2155,6 +2155,16 @@ describe('S2S Adapter', function () { }) }); + it('should set default s2s ttl', function () { + config.setConfig({ + s2sConfig: { + default_s2s_ttl: 30 + } + } + }); + expect(config.getConfig('s2sConfig').default_s2s_ttl).to.deep.equal(30) + }); + it('should set syncUrlModifier', function () { config.setConfig({ s2sConfig: { From cb99d097990aae852daa22700e0db9c796633d5a Mon Sep 17 00:00:00 2001 From: Patrick McCann Date: Thu, 25 Jun 2020 08:10:47 -0400 Subject: [PATCH 03/17] Update index.js --- modules/prebidServerBidAdapter/index.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/prebidServerBidAdapter/index.js b/modules/prebidServerBidAdapter/index.js index c8231480e22..0b9b05d788a 100644 --- a/modules/prebidServerBidAdapter/index.js +++ b/modules/prebidServerBidAdapter/index.js @@ -17,7 +17,6 @@ const getConfig = config.getConfig; const TYPE = S2S.SRC; let _synced = false; -const DEFAULT_S2S_TTL = pbjs_config.getConfig('defaultS2STTL') || 60; const DEFAULT_S2S_CURRENCY = 'USD'; const DEFAULT_S2S_NETREVENUE = true; @@ -111,6 +110,8 @@ function setS2sConfig(options) { } getConfig('s2sConfig', ({s2sConfig}) => setS2sConfig(s2sConfig)); +let DEFAULT_S2S_TTL = _s2sConfig.default_s2s_ttl || 60; + /** * resets the _synced variable back to false, primiarily used for testing purposes */ From a35d8ef0c720d801cf58748dd7c4bac02a218e6e Mon Sep 17 00:00:00 2001 From: Patrick McCann Date: Thu, 25 Jun 2020 08:28:54 -0400 Subject: [PATCH 04/17] Update prebidServerBidAdapter_spec.js --- test/spec/modules/prebidServerBidAdapter_spec.js | 1 - 1 file changed, 1 deletion(-) diff --git a/test/spec/modules/prebidServerBidAdapter_spec.js b/test/spec/modules/prebidServerBidAdapter_spec.js index 2c338167659..a0726751de6 100644 --- a/test/spec/modules/prebidServerBidAdapter_spec.js +++ b/test/spec/modules/prebidServerBidAdapter_spec.js @@ -2160,7 +2160,6 @@ describe('S2S Adapter', function () { s2sConfig: { default_s2s_ttl: 30 } - } }); expect(config.getConfig('s2sConfig').default_s2s_ttl).to.deep.equal(30) }); From c8c5ed35ba2b7e4ec18031a9b432b2abe8ede709 Mon Sep 17 00:00:00 2001 From: Patrick McCann Date: Thu, 25 Jun 2020 08:38:41 -0400 Subject: [PATCH 05/17] Update prebidServerBidAdapter_spec.js --- test/spec/modules/prebidServerBidAdapter_spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/spec/modules/prebidServerBidAdapter_spec.js b/test/spec/modules/prebidServerBidAdapter_spec.js index a0726751de6..d1b8346e9ed 100644 --- a/test/spec/modules/prebidServerBidAdapter_spec.js +++ b/test/spec/modules/prebidServerBidAdapter_spec.js @@ -2159,7 +2159,7 @@ describe('S2S Adapter', function () { config.setConfig({ s2sConfig: { default_s2s_ttl: 30 - } + } }); expect(config.getConfig('s2sConfig').default_s2s_ttl).to.deep.equal(30) }); From a61a8da90ea2576fdce99342cfc755cc8484085a Mon Sep 17 00:00:00 2001 From: Patrick McCann Date: Thu, 25 Jun 2020 08:49:48 -0400 Subject: [PATCH 06/17] Update index.js --- modules/prebidServerBidAdapter/index.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/prebidServerBidAdapter/index.js b/modules/prebidServerBidAdapter/index.js index 0b9b05d788a..f88ccbc5ca9 100644 --- a/modules/prebidServerBidAdapter/index.js +++ b/modules/prebidServerBidAdapter/index.js @@ -18,6 +18,7 @@ const getConfig = config.getConfig; const TYPE = S2S.SRC; let _synced = false; const DEFAULT_S2S_CURRENCY = 'USD'; +const DEFAULT_S2S_TTL = 60; const DEFAULT_S2S_NETREVENUE = true; let _s2sConfig; @@ -110,8 +111,6 @@ function setS2sConfig(options) { } getConfig('s2sConfig', ({s2sConfig}) => setS2sConfig(s2sConfig)); -let DEFAULT_S2S_TTL = _s2sConfig.default_s2s_ttl || 60; - /** * resets the _synced variable back to false, primiarily used for testing purposes */ @@ -833,7 +832,8 @@ const OPEN_RTB_PROTOCOL = { bidObject.currency = (response.cur) ? response.cur : DEFAULT_S2S_CURRENCY; // TODO: Remove when prebid-server returns ttl and netRevenue - bidObject.ttl = (bid.ttl) ? bid.ttl : DEFAULT_S2S_TTL; + let config_ttl = _s2sConfig.default_s2s_ttl || DEFAULT_S2S_TTL; + bidObject.ttl = (bid.ttl) ? bid.ttl : config_ttl; bidObject.netRevenue = (bid.netRevenue) ? bid.netRevenue : DEFAULT_S2S_NETREVENUE; bids.push({ adUnit: bid.impid, bid: bidObject }); From 8bf1477c470a355637bde10523861732490ce932 Mon Sep 17 00:00:00 2001 From: Patrick McCann Date: Thu, 25 Jun 2020 08:53:34 -0400 Subject: [PATCH 07/17] Update index.js --- modules/prebidServerBidAdapter/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/prebidServerBidAdapter/index.js b/modules/prebidServerBidAdapter/index.js index f88ccbc5ca9..d573135c28f 100644 --- a/modules/prebidServerBidAdapter/index.js +++ b/modules/prebidServerBidAdapter/index.js @@ -17,8 +17,8 @@ const getConfig = config.getConfig; const TYPE = S2S.SRC; let _synced = false; -const DEFAULT_S2S_CURRENCY = 'USD'; const DEFAULT_S2S_TTL = 60; +const DEFAULT_S2S_CURRENCY = 'USD'; const DEFAULT_S2S_NETREVENUE = true; let _s2sConfig; @@ -832,7 +832,7 @@ const OPEN_RTB_PROTOCOL = { bidObject.currency = (response.cur) ? response.cur : DEFAULT_S2S_CURRENCY; // TODO: Remove when prebid-server returns ttl and netRevenue - let config_ttl = _s2sConfig.default_s2s_ttl || DEFAULT_S2S_TTL; + const config_ttl = _s2sConfig.default_s2s_ttl || DEFAULT_S2S_TTL; bidObject.ttl = (bid.ttl) ? bid.ttl : config_ttl; bidObject.netRevenue = (bid.netRevenue) ? bid.netRevenue : DEFAULT_S2S_NETREVENUE; From d0d4942569266b6822bcc2241d215d35bfac225d Mon Sep 17 00:00:00 2001 From: Patrick McCann Date: Thu, 25 Jun 2020 09:05:20 -0400 Subject: [PATCH 08/17] Update index.js change to camel case --- modules/prebidServerBidAdapter/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/prebidServerBidAdapter/index.js b/modules/prebidServerBidAdapter/index.js index d573135c28f..c28a006d772 100644 --- a/modules/prebidServerBidAdapter/index.js +++ b/modules/prebidServerBidAdapter/index.js @@ -832,7 +832,7 @@ const OPEN_RTB_PROTOCOL = { bidObject.currency = (response.cur) ? response.cur : DEFAULT_S2S_CURRENCY; // TODO: Remove when prebid-server returns ttl and netRevenue - const config_ttl = _s2sConfig.default_s2s_ttl || DEFAULT_S2S_TTL; + const config_ttl = _s2sConfig.defaultS2sTtl || DEFAULT_S2S_TTL; bidObject.ttl = (bid.ttl) ? bid.ttl : config_ttl; bidObject.netRevenue = (bid.netRevenue) ? bid.netRevenue : DEFAULT_S2S_NETREVENUE; From dca82f7f8d1955ce38f220b4137690907c00303e Mon Sep 17 00:00:00 2001 From: Patrick McCann Date: Thu, 25 Jun 2020 09:06:42 -0400 Subject: [PATCH 09/17] Update prebidServerBidAdapter_spec.js change to camel case --- test/spec/modules/prebidServerBidAdapter_spec.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/spec/modules/prebidServerBidAdapter_spec.js b/test/spec/modules/prebidServerBidAdapter_spec.js index d1b8346e9ed..3ff03f397f6 100644 --- a/test/spec/modules/prebidServerBidAdapter_spec.js +++ b/test/spec/modules/prebidServerBidAdapter_spec.js @@ -2158,10 +2158,10 @@ describe('S2S Adapter', function () { it('should set default s2s ttl', function () { config.setConfig({ s2sConfig: { - default_s2s_ttl: 30 + defaultS2sTtl: 30 } }); - expect(config.getConfig('s2sConfig').default_s2s_ttl).to.deep.equal(30) + expect(config.getConfig('s2sConfig').defaultS2sTtl).to.deep.equal(30) }); it('should set syncUrlModifier', function () { From 6e874ef4a007796a1ecc6986a48c87abe8df527e Mon Sep 17 00:00:00 2001 From: Patrick McCann Date: Thu, 25 Jun 2020 09:10:34 -0400 Subject: [PATCH 10/17] Update index.js camel case --- modules/prebidServerBidAdapter/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/prebidServerBidAdapter/index.js b/modules/prebidServerBidAdapter/index.js index c28a006d772..262ff52f99a 100644 --- a/modules/prebidServerBidAdapter/index.js +++ b/modules/prebidServerBidAdapter/index.js @@ -832,8 +832,8 @@ const OPEN_RTB_PROTOCOL = { bidObject.currency = (response.cur) ? response.cur : DEFAULT_S2S_CURRENCY; // TODO: Remove when prebid-server returns ttl and netRevenue - const config_ttl = _s2sConfig.defaultS2sTtl || DEFAULT_S2S_TTL; - bidObject.ttl = (bid.ttl) ? bid.ttl : config_ttl; + const configTtl = _s2sConfig.defaultS2sTtl || DEFAULT_S2S_TTL; + bidObject.ttl = (bid.ttl) ? bid.ttl : configTtl; bidObject.netRevenue = (bid.netRevenue) ? bid.netRevenue : DEFAULT_S2S_NETREVENUE; bids.push({ adUnit: bid.impid, bid: bidObject }); From efa52c96d8d083cfa3014b9d1990760d2b7a0179 Mon Sep 17 00:00:00 2001 From: Patrick McCann Date: Mon, 29 Jun 2020 13:34:02 -0400 Subject: [PATCH 11/17] Update prebidServerBidAdapter_spec.js --- .../modules/prebidServerBidAdapter_spec.js | 24 ++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/test/spec/modules/prebidServerBidAdapter_spec.js b/test/spec/modules/prebidServerBidAdapter_spec.js index 3ff03f397f6..eb2c0fc8036 100644 --- a/test/spec/modules/prebidServerBidAdapter_spec.js +++ b/test/spec/modules/prebidServerBidAdapter_spec.js @@ -1702,6 +1702,28 @@ describe('S2S Adapter', function () { expect(response).to.have.property('cpm', 0.5); expect(response).to.not.have.property('vastUrl'); expect(response).to.not.have.property('videoCacheKey'); + expect(response).to.have.property('ttl', '60'); + }); + + + it('respects defaultS2sTtl', function () { + const s2sConfig = Object.assign({}, CONFIG, { + endpoint: 'https://prebid.adnxs.com/pbs/v1/openrtb2/auction', + defaultS2sTtl: 30 + }); + config.setConfig({ s2sConfig }); + + adapter.callBids(REQUEST, BID_REQUESTS, addBidResponse, done, ajax); + server.requests[0].respond(200, {}, JSON.stringify(RESPONSE_OPENRTB)); + + sinon.assert.calledOnce(events.emit); + const event = events.emit.firstCall.args; + expect(event[0]).to.equal(CONSTANTS.EVENTS.BIDDER_DONE); + expect(event[1].bids[0]).to.have.property('serverResponseTimeMs', 8); + + sinon.assert.calledOnce(addBidResponse); + const response = addBidResponse.firstCall.args[1]; + expect(response).to.have.property('ttl', '30'); }); it('handles OpenRTB video responses', function () { @@ -2161,7 +2183,7 @@ describe('S2S Adapter', function () { defaultS2sTtl: 30 } }); - expect(config.getConfig('s2sConfig').defaultS2sTtl).to.deep.equal(30) + expect(config.getConfig('s2sConfig').defaultS2sTtl).to.deep.equal(30); }); it('should set syncUrlModifier', function () { From 5c4b7125ab46699b08038e3ef253dfe362105092 Mon Sep 17 00:00:00 2001 From: Patrick McCann Date: Mon, 29 Jun 2020 13:36:09 -0400 Subject: [PATCH 12/17] Update prebidServerBidAdapter_spec.js --- test/spec/modules/prebidServerBidAdapter_spec.js | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/test/spec/modules/prebidServerBidAdapter_spec.js b/test/spec/modules/prebidServerBidAdapter_spec.js index eb2c0fc8036..887b96014c6 100644 --- a/test/spec/modules/prebidServerBidAdapter_spec.js +++ b/test/spec/modules/prebidServerBidAdapter_spec.js @@ -1702,7 +1702,7 @@ describe('S2S Adapter', function () { expect(response).to.have.property('cpm', 0.5); expect(response).to.not.have.property('vastUrl'); expect(response).to.not.have.property('videoCacheKey'); - expect(response).to.have.property('ttl', '60'); + expect(response).to.have.property('ttl', 60); }); @@ -1718,12 +1718,9 @@ describe('S2S Adapter', function () { sinon.assert.calledOnce(events.emit); const event = events.emit.firstCall.args; - expect(event[0]).to.equal(CONSTANTS.EVENTS.BIDDER_DONE); - expect(event[1].bids[0]).to.have.property('serverResponseTimeMs', 8); - sinon.assert.calledOnce(addBidResponse); const response = addBidResponse.firstCall.args[1]; - expect(response).to.have.property('ttl', '30'); + expect(response).to.have.property('ttl', 30); }); it('handles OpenRTB video responses', function () { From de234fd79ed27304776f081059df209061092982 Mon Sep 17 00:00:00 2001 From: Patrick McCann Date: Mon, 29 Jun 2020 13:38:44 -0400 Subject: [PATCH 13/17] Update prebidServerBidAdapter_spec.js --- test/spec/modules/prebidServerBidAdapter_spec.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test/spec/modules/prebidServerBidAdapter_spec.js b/test/spec/modules/prebidServerBidAdapter_spec.js index 887b96014c6..4ef732837f2 100644 --- a/test/spec/modules/prebidServerBidAdapter_spec.js +++ b/test/spec/modules/prebidServerBidAdapter_spec.js @@ -1704,8 +1704,7 @@ describe('S2S Adapter', function () { expect(response).to.not.have.property('videoCacheKey'); expect(response).to.have.property('ttl', 60); }); - - + it('respects defaultS2sTtl', function () { const s2sConfig = Object.assign({}, CONFIG, { endpoint: 'https://prebid.adnxs.com/pbs/v1/openrtb2/auction', From 39dca11ca868df311b35516bf9d3aefb66cf7cda Mon Sep 17 00:00:00 2001 From: Patrick McCann Date: Thu, 2 Jul 2020 17:18:16 -0400 Subject: [PATCH 14/17] Update index.js --- modules/prebidServerBidAdapter/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/prebidServerBidAdapter/index.js b/modules/prebidServerBidAdapter/index.js index 262ff52f99a..0f2fb6eb067 100644 --- a/modules/prebidServerBidAdapter/index.js +++ b/modules/prebidServerBidAdapter/index.js @@ -832,7 +832,7 @@ const OPEN_RTB_PROTOCOL = { bidObject.currency = (response.cur) ? response.cur : DEFAULT_S2S_CURRENCY; // TODO: Remove when prebid-server returns ttl and netRevenue - const configTtl = _s2sConfig.defaultS2sTtl || DEFAULT_S2S_TTL; + const configTtl = _s2sConfig.defaultTtl || DEFAULT_S2S_TTL; bidObject.ttl = (bid.ttl) ? bid.ttl : configTtl; bidObject.netRevenue = (bid.netRevenue) ? bid.netRevenue : DEFAULT_S2S_NETREVENUE; From 05eec240882aa886461651345f5834da5ab80a13 Mon Sep 17 00:00:00 2001 From: Patrick McCann Date: Thu, 2 Jul 2020 17:19:16 -0400 Subject: [PATCH 15/17] Update prebidServerBidAdapter_spec.js --- test/spec/modules/prebidServerBidAdapter_spec.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/spec/modules/prebidServerBidAdapter_spec.js b/test/spec/modules/prebidServerBidAdapter_spec.js index 4ef732837f2..2a047832183 100644 --- a/test/spec/modules/prebidServerBidAdapter_spec.js +++ b/test/spec/modules/prebidServerBidAdapter_spec.js @@ -1705,10 +1705,10 @@ describe('S2S Adapter', function () { expect(response).to.have.property('ttl', 60); }); - it('respects defaultS2sTtl', function () { + it('respects defaultTtl', function () { const s2sConfig = Object.assign({}, CONFIG, { endpoint: 'https://prebid.adnxs.com/pbs/v1/openrtb2/auction', - defaultS2sTtl: 30 + defaultTtl: 30 }); config.setConfig({ s2sConfig }); @@ -2176,7 +2176,7 @@ describe('S2S Adapter', function () { it('should set default s2s ttl', function () { config.setConfig({ s2sConfig: { - defaultS2sTtl: 30 + defaultTtl: 30 } }); expect(config.getConfig('s2sConfig').defaultS2sTtl).to.deep.equal(30); From b095b981798a8764ee9b4e7629f65a0b83335506 Mon Sep 17 00:00:00 2001 From: Patrick McCann Date: Thu, 2 Jul 2020 17:19:48 -0400 Subject: [PATCH 16/17] Update prebidServerBidAdapter_spec.js --- test/spec/modules/prebidServerBidAdapter_spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/spec/modules/prebidServerBidAdapter_spec.js b/test/spec/modules/prebidServerBidAdapter_spec.js index 2a047832183..d99ec9d421d 100644 --- a/test/spec/modules/prebidServerBidAdapter_spec.js +++ b/test/spec/modules/prebidServerBidAdapter_spec.js @@ -2179,7 +2179,7 @@ describe('S2S Adapter', function () { defaultTtl: 30 } }); - expect(config.getConfig('s2sConfig').defaultS2sTtl).to.deep.equal(30); + expect(config.getConfig('s2sConfig').defaultTtl).to.deep.equal(30); }); it('should set syncUrlModifier', function () { From d55b8e343aa1947d6a73b1831f1939baa5e73169 Mon Sep 17 00:00:00 2001 From: Patrick McCann Date: Thu, 2 Jul 2020 17:21:14 -0400 Subject: [PATCH 17/17] Update index.js --- modules/prebidServerBidAdapter/index.js | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/prebidServerBidAdapter/index.js b/modules/prebidServerBidAdapter/index.js index 0f2fb6eb067..7536851f5e1 100644 --- a/modules/prebidServerBidAdapter/index.js +++ b/modules/prebidServerBidAdapter/index.js @@ -71,6 +71,7 @@ config.setDefaults({ * @property {string} endpoint endpoint to contact * === optional params below === * @property {number} [timeout] timeout for S2S bidders - should be lower than `pbjs.requestBids({timeout})` + * @property {number} [defaultTtl] ttl for S2S bidders when pbs does not return a ttl on the response - defaults to 60` * @property {boolean} [cacheMarkup] whether to cache the adm result * @property {string} [adapter] adapter code to use for S2S * @property {string} [syncEndpoint] endpoint URL for syncing cookies