From be32f6f94f12f3c175ebc5e9ecb2ff7bb154b2e5 Mon Sep 17 00:00:00 2001 From: Rowan Ledgerwood-Gee Date: Tue, 12 Dec 2023 10:26:01 +1300 Subject: [PATCH 1/5] add metatag version info to the payload --- modules/stroeerCoreBidAdapter.js | 8 +++-- .../modules/stroeerCoreBidAdapter_spec.js | 36 ++++++++++++++++--- 2 files changed, 36 insertions(+), 8 deletions(-) diff --git a/modules/stroeerCoreBidAdapter.js b/modules/stroeerCoreBidAdapter.js index 6bbdf8f636d..e9426ceea7a 100644 --- a/modules/stroeerCoreBidAdapter.js +++ b/modules/stroeerCoreBidAdapter.js @@ -4,8 +4,6 @@ import {BANNER, VIDEO} from '../src/mediaTypes.js' import * as utils from '../src/utils.js' import {getGlobal} from '../src/prebidGlobal.js' - - // Do not import POLYFILLS from core-js. Most likely until next major update (v4). // Prebid.js committers updated core-js to version 3 on v3.19.0 release (9/5/2020). // This broke imports. We need to be backwards compatible since this adapter is copied into @@ -155,10 +153,14 @@ function groupBy(array, keyFns) { function getVersionValues (win) { const pbjs = getGlobal(); - return { + var versionObject = { yl: win.YLHH?.bidder?.settings?.version, pb: pbjs.version }; + + versionObject.mt = win?.SDG?.version && win.SDG.version() + + return versionObject } function divideBidRequestsBySsat(bidRequests) { diff --git a/test/spec/modules/stroeerCoreBidAdapter_spec.js b/test/spec/modules/stroeerCoreBidAdapter_spec.js index 86e7a3d9e90..3d46356f8b9 100644 --- a/test/spec/modules/stroeerCoreBidAdapter_spec.js +++ b/test/spec/modules/stroeerCoreBidAdapter_spec.js @@ -870,40 +870,66 @@ describe('stroeerCore bid adapter', function () { describe('optional fields', () => { describe('version fields', () => { + let pbVerStub + let mtVerStub + beforeEach(() => { pbVerStub = sinon.stub(prebidGlobal, 'getGlobal') + win.SDG = {version: () => { + return "" + }} + mtVerStub = sinon.stub(win.SDG, 'version') }); afterEach(() => { pbVerStub.restore() + mtVerStub.restore() }); it('gets version variables', () => { pbVerStub.returns({version: '1.2'}); + mtVerStub.returns('1.8'); win.YLHH.bidder.settings = {version: '1.1'}; const bidReq = buildBidderRequest(); const serverRequestInfo = spec.buildRequests(bidReq.bids, bidReq)[0]; - assert.deepEqual(serverRequestInfo.data.ver, {'yl': '1.1', 'pb': '1.2'}) - }) + assert.deepEqual(serverRequestInfo.data.ver, {'yl': '1.1', 'pb': '1.2', 'mt': '1.8'}); + }); it('functions with no pb value', () => { pbVerStub.returns({version: undefined}); win.YLHH.bidder.settings = {version: '1.1'}; + mtVerStub.returns('1.8'); const bidReq = buildBidderRequest(); const serverRequestInfo = spec.buildRequests(bidReq.bids, bidReq)[0]; - assert.deepEqual(serverRequestInfo.data.ver, {'yl': '1.1', 'pb': undefined}) + assert.deepEqual(serverRequestInfo.data.ver, {'yl': '1.1', 'pb': undefined, 'mt': '1.8'}); }); it('functions with no yl value', () => { pbVerStub.returns({version: '2'}); + mtVerStub.returns('1.8'); + const bidReq = buildBidderRequest(); + const serverRequestInfo = spec.buildRequests(bidReq.bids, bidReq)[0]; + assert.deepEqual(serverRequestInfo.data.ver, {'pb': '2', 'yl': undefined, 'mt': '1.8'}); + }); + it('functions with no mt value', () => { + pbVerStub.returns({version: '1.2'}); + win.YLHH.bidder.settings = {version: '1.1'}; + mtVerStub.returns(undefined); + const bidReq = buildBidderRequest(); + const serverRequestInfo = spec.buildRequests(bidReq.bids, bidReq)[0]; + assert.deepEqual(serverRequestInfo.data.ver, {'yl': '1.1', 'pb': '1.2', 'mt': undefined}); + }); + it('functions with no mt version function', () => { + pbVerStub.returns({version: '1.2'}); + win.YLHH.bidder.settings = {version: '1.1'}; const bidReq = buildBidderRequest(); const serverRequestInfo = spec.buildRequests(bidReq.bids, bidReq)[0]; - assert.deepEqual(serverRequestInfo.data.ver, {'pb': '2', 'yl': undefined}) + assert.deepEqual(serverRequestInfo.data.ver, {'yl': '1.1', 'pb': '1.2', 'mt': undefined}); }); it('functions with no values', () => { pbVerStub.returns({version: undefined}); const bidReq = buildBidderRequest(); const serverRequestInfo = spec.buildRequests(bidReq.bids, bidReq)[0]; - assert.deepEqual(serverRequestInfo.data.ver, {'yl': undefined, 'pb': undefined}) + assert.deepEqual(serverRequestInfo.data.ver, {'yl': undefined, 'pb': undefined, 'mt': undefined}); }); }); it('should use ssat value from config', () => { From 0ffb863b7b4e891d31adcd8d91c6d4fe30c902f6 Mon Sep 17 00:00:00 2001 From: Rowan Ledgerwood-Gee Date: Tue, 12 Dec 2023 13:05:42 +1300 Subject: [PATCH 2/5] some changes to make the code look better meybe? --- test/spec/modules/stroeerCoreBidAdapter_spec.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/test/spec/modules/stroeerCoreBidAdapter_spec.js b/test/spec/modules/stroeerCoreBidAdapter_spec.js index 3d46356f8b9..f5f0cd80783 100644 --- a/test/spec/modules/stroeerCoreBidAdapter_spec.js +++ b/test/spec/modules/stroeerCoreBidAdapter_spec.js @@ -870,15 +870,14 @@ describe('stroeerCore bid adapter', function () { describe('optional fields', () => { describe('version fields', () => { - let pbVerStub let mtVerStub beforeEach(() => { pbVerStub = sinon.stub(prebidGlobal, 'getGlobal') - win.SDG = {version: () => { - return "" - }} + win.SDG = {version: () => { + return '' + }} mtVerStub = sinon.stub(win.SDG, 'version') }); From 0ef122d454956b049859aebf350c0ebfa70b188e Mon Sep 17 00:00:00 2001 From: Rowan Ledgerwood-Gee Date: Tue, 12 Dec 2023 15:34:05 +1300 Subject: [PATCH 3/5] change a variable to const and update some tests to no longer stub, also fixed a test that wasnt running properly --- modules/stroeerCoreBidAdapter.js | 2 +- .../modules/stroeerCoreBidAdapter_spec.js | 26 ++++++++++++------- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/modules/stroeerCoreBidAdapter.js b/modules/stroeerCoreBidAdapter.js index e9426ceea7a..e531b6ca2d8 100644 --- a/modules/stroeerCoreBidAdapter.js +++ b/modules/stroeerCoreBidAdapter.js @@ -153,7 +153,7 @@ function groupBy(array, keyFns) { function getVersionValues (win) { const pbjs = getGlobal(); - var versionObject = { + const versionObject = { yl: win.YLHH?.bidder?.settings?.version, pb: pbjs.version }; diff --git a/test/spec/modules/stroeerCoreBidAdapter_spec.js b/test/spec/modules/stroeerCoreBidAdapter_spec.js index f5f0cd80783..596b38f5e6c 100644 --- a/test/spec/modules/stroeerCoreBidAdapter_spec.js +++ b/test/spec/modules/stroeerCoreBidAdapter_spec.js @@ -871,53 +871,56 @@ describe('stroeerCore bid adapter', function () { describe('optional fields', () => { describe('version fields', () => { let pbVerStub - let mtVerStub beforeEach(() => { pbVerStub = sinon.stub(prebidGlobal, 'getGlobal') - win.SDG = {version: () => { - return '' - }} - mtVerStub = sinon.stub(win.SDG, 'version') }); afterEach(() => { pbVerStub.restore() - mtVerStub.restore() }); it('gets version variables', () => { + win.SDG = {version: () => { + return '1.8'; + }}; pbVerStub.returns({version: '1.2'}); - mtVerStub.returns('1.8'); win.YLHH.bidder.settings = {version: '1.1'}; const bidReq = buildBidderRequest(); const serverRequestInfo = spec.buildRequests(bidReq.bids, bidReq)[0]; assert.deepEqual(serverRequestInfo.data.ver, {'yl': '1.1', 'pb': '1.2', 'mt': '1.8'}); }); it('functions with no pb value', () => { + win.SDG = {version: () => { + return '1.8'; + }}; pbVerStub.returns({version: undefined}); win.YLHH.bidder.settings = {version: '1.1'}; - mtVerStub.returns('1.8'); const bidReq = buildBidderRequest(); const serverRequestInfo = spec.buildRequests(bidReq.bids, bidReq)[0]; assert.deepEqual(serverRequestInfo.data.ver, {'yl': '1.1', 'pb': undefined, 'mt': '1.8'}); }); it('functions with no yl value', () => { + win.SDG = {version: () => { + return '1.8'; + }}; pbVerStub.returns({version: '2'}); - mtVerStub.returns('1.8'); const bidReq = buildBidderRequest(); const serverRequestInfo = spec.buildRequests(bidReq.bids, bidReq)[0]; assert.deepEqual(serverRequestInfo.data.ver, {'pb': '2', 'yl': undefined, 'mt': '1.8'}); }); it('functions with no mt value', () => { + win.SDG = {version: () => { + return undefined; + }}; pbVerStub.returns({version: '1.2'}); win.YLHH.bidder.settings = {version: '1.1'}; - mtVerStub.returns(undefined); const bidReq = buildBidderRequest(); const serverRequestInfo = spec.buildRequests(bidReq.bids, bidReq)[0]; assert.deepEqual(serverRequestInfo.data.ver, {'yl': '1.1', 'pb': '1.2', 'mt': undefined}); }); it('functions with no mt version function', () => { + win.SDG = {}; pbVerStub.returns({version: '1.2'}); win.YLHH.bidder.settings = {version: '1.1'}; const bidReq = buildBidderRequest(); @@ -925,6 +928,9 @@ describe('stroeerCore bid adapter', function () { assert.deepEqual(serverRequestInfo.data.ver, {'yl': '1.1', 'pb': '1.2', 'mt': undefined}); }); it('functions with no values', () => { + win.SDG = {version: () => { + return undefined; + }}; pbVerStub.returns({version: undefined}); const bidReq = buildBidderRequest(); const serverRequestInfo = spec.buildRequests(bidReq.bids, bidReq)[0]; From a2ede0463f9a254dddfc3dbeaecdc4b8e7a8a3d2 Mon Sep 17 00:00:00 2001 From: Rowan Ledgerwood-Gee Date: Tue, 12 Dec 2023 15:55:48 +1300 Subject: [PATCH 4/5] make tests cleaner --- .../modules/stroeerCoreBidAdapter_spec.js | 22 ++++++------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/test/spec/modules/stroeerCoreBidAdapter_spec.js b/test/spec/modules/stroeerCoreBidAdapter_spec.js index 596b38f5e6c..6003c1bfb34 100644 --- a/test/spec/modules/stroeerCoreBidAdapter_spec.js +++ b/test/spec/modules/stroeerCoreBidAdapter_spec.js @@ -871,9 +871,11 @@ describe('stroeerCore bid adapter', function () { describe('optional fields', () => { describe('version fields', () => { let pbVerStub + let mtVersion beforeEach(() => { pbVerStub = sinon.stub(prebidGlobal, 'getGlobal') + win.SDG = {version: () => mtVersion}; }); afterEach(() => { @@ -881,9 +883,7 @@ describe('stroeerCore bid adapter', function () { }); it('gets version variables', () => { - win.SDG = {version: () => { - return '1.8'; - }}; + mtVersion = '1.8'; pbVerStub.returns({version: '1.2'}); win.YLHH.bidder.settings = {version: '1.1'}; const bidReq = buildBidderRequest(); @@ -891,9 +891,7 @@ describe('stroeerCore bid adapter', function () { assert.deepEqual(serverRequestInfo.data.ver, {'yl': '1.1', 'pb': '1.2', 'mt': '1.8'}); }); it('functions with no pb value', () => { - win.SDG = {version: () => { - return '1.8'; - }}; + mtVersion = '1.8'; pbVerStub.returns({version: undefined}); win.YLHH.bidder.settings = {version: '1.1'}; const bidReq = buildBidderRequest(); @@ -901,18 +899,14 @@ describe('stroeerCore bid adapter', function () { assert.deepEqual(serverRequestInfo.data.ver, {'yl': '1.1', 'pb': undefined, 'mt': '1.8'}); }); it('functions with no yl value', () => { - win.SDG = {version: () => { - return '1.8'; - }}; + mtVersion = '1.8'; pbVerStub.returns({version: '2'}); const bidReq = buildBidderRequest(); const serverRequestInfo = spec.buildRequests(bidReq.bids, bidReq)[0]; assert.deepEqual(serverRequestInfo.data.ver, {'pb': '2', 'yl': undefined, 'mt': '1.8'}); }); it('functions with no mt value', () => { - win.SDG = {version: () => { - return undefined; - }}; + mtVersion = undefined; pbVerStub.returns({version: '1.2'}); win.YLHH.bidder.settings = {version: '1.1'}; const bidReq = buildBidderRequest(); @@ -928,9 +922,7 @@ describe('stroeerCore bid adapter', function () { assert.deepEqual(serverRequestInfo.data.ver, {'yl': '1.1', 'pb': '1.2', 'mt': undefined}); }); it('functions with no values', () => { - win.SDG = {version: () => { - return undefined; - }}; + mtVersion = undefined; pbVerStub.returns({version: undefined}); const bidReq = buildBidderRequest(); const serverRequestInfo = spec.buildRequests(bidReq.bids, bidReq)[0]; From e0412f72890401158305b0e6ae56a1b722fb2313 Mon Sep 17 00:00:00 2001 From: Rowan Ledgerwood-Gee Date: Tue, 12 Dec 2023 16:04:34 +1300 Subject: [PATCH 5/5] change return behaviour of version getter --- modules/stroeerCoreBidAdapter.js | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/modules/stroeerCoreBidAdapter.js b/modules/stroeerCoreBidAdapter.js index e531b6ca2d8..62ff9d4d386 100644 --- a/modules/stroeerCoreBidAdapter.js +++ b/modules/stroeerCoreBidAdapter.js @@ -153,14 +153,11 @@ function groupBy(array, keyFns) { function getVersionValues (win) { const pbjs = getGlobal(); - const versionObject = { + return { yl: win.YLHH?.bidder?.settings?.version, - pb: pbjs.version + pb: pbjs.version, + mt: win?.SDG?.version && win.SDG.version() }; - - versionObject.mt = win?.SDG?.version && win.SDG.version() - - return versionObject } function divideBidRequestsBySsat(bidRequests) {