From 33c780c16a970a9c5e6eab510e792d42e18f3ae4 Mon Sep 17 00:00:00 2001 From: Patrick Loughrey Date: Mon, 4 Apr 2022 22:24:02 -0400 Subject: [PATCH 01/25] TL-19850 Finished log error logic around floors functionality --- modules/tripleliftBidAdapter.js | 22 +++++++++++-------- .../spec/modules/tripleliftBidAdapter_spec.js | 22 +++++++++++++++++++ 2 files changed, 35 insertions(+), 9 deletions(-) diff --git a/modules/tripleliftBidAdapter.js b/modules/tripleliftBidAdapter.js index 215769e9812..934070e13a8 100644 --- a/modules/tripleliftBidAdapter.js +++ b/modules/tripleliftBidAdapter.js @@ -1,4 +1,4 @@ -import { tryAppendQueryString, logMessage, isEmpty, isStr, isPlainObject, isArray, logWarn } from '../src/utils.js'; +import { tryAppendQueryString, logMessage, logError, isEmpty, isStr, isPlainObject, isArray, logWarn } from '../src/utils.js'; import { BANNER, VIDEO } from '../src/mediaTypes.js'; import { registerBidder } from '../src/adapters/bidderFactory.js'; import { config } from '../src/config.js'; @@ -175,14 +175,18 @@ function _getORTBVideo(bidRequest) { function _getFloor (bid) { let floor = null; if (typeof bid.getFloor === 'function') { - const floorInfo = bid.getFloor({ - currency: 'USD', - mediaType: _isInstreamBidRequest(bid) ? 'video' : 'banner', - size: '*' - }); - if (typeof floorInfo === 'object' && - floorInfo.currency === 'USD' && !isNaN(parseFloat(floorInfo.floor))) { - floor = parseFloat(floorInfo.floor); + try { + const floorInfo = bid.getFloor({ + currency: 'USD', + mediaType: _isInstreamBidRequest(bid) ? 'video' : 'banner', + size: '*' + }); + if (typeof floorInfo === 'object' && + floorInfo.currency === 'USD' && !isNaN(parseFloat(floorInfo.floor))) { + floor = parseFloat(floorInfo.floor); + } + } catch (err) { + logError('Triplelift: getFloor threw an error: ', err); } } return floor !== null ? floor : bid.params.floor; diff --git a/test/spec/modules/tripleliftBidAdapter_spec.js b/test/spec/modules/tripleliftBidAdapter_spec.js index 6f2674dadc5..196a95349bf 100644 --- a/test/spec/modules/tripleliftBidAdapter_spec.js +++ b/test/spec/modules/tripleliftBidAdapter_spec.js @@ -787,6 +787,28 @@ describe('triplelift adapter', function () { size: '*' })).to.be.true; }); + it('should not set bid floor if currency is not USD', function() { + bidRequests.forEach(request => { + request.getFloor = () => {}; + sinon.spy(request, 'getFloor') + }); + + tripleliftAdapterSpec.buildRequests(bidRequests, bidderRequest); + + // banner request with non-USD currency + expect(bidRequests[0].getFloor.calledWith({ + currency: 'EUR', + mediaType: 'banner', + size: '*' + })).to.be.false; + + // banner request with non-USD currency + expect(bidRequests[1].getFloor.calledWith({ + currency: 'CAD', + mediaType: 'video', + size: '*' + })).to.be.false; + }); it('should send global config fpd if kvps are available', function() { const sens = null; const category = ['news', 'weather', 'hurricane']; From 905e884ca7d87344b27bfe890d5b795fa87f423b Mon Sep 17 00:00:00 2001 From: Nick Llerandi Date: Thu, 7 Apr 2022 16:41:33 -0400 Subject: [PATCH 02/25] deprecates getlegacyFpd --- modules/tripleliftBidAdapter.js | 4 ++-- test/spec/modules/tripleliftBidAdapter_spec.js | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/modules/tripleliftBidAdapter.js b/modules/tripleliftBidAdapter.js index 215769e9812..830d26eda61 100644 --- a/modules/tripleliftBidAdapter.js +++ b/modules/tripleliftBidAdapter.js @@ -192,9 +192,9 @@ function _getGlobalFpd() { const fpd = {}; const context = {} const user = {}; - const ortbData = config.getLegacyFpd(config.getConfig('ortb2')) || {}; + const ortbData = config.getConfig('ortb2') || {}; - const fpdContext = Object.assign({}, ortbData.context); + const fpdContext = Object.assign({}, ortbData.site); const fpdUser = Object.assign({}, ortbData.user); _addEntries(context, fpdContext); diff --git a/test/spec/modules/tripleliftBidAdapter_spec.js b/test/spec/modules/tripleliftBidAdapter_spec.js index 6f2674dadc5..1f17c67c99c 100644 --- a/test/spec/modules/tripleliftBidAdapter_spec.js +++ b/test/spec/modules/tripleliftBidAdapter_spec.js @@ -812,8 +812,9 @@ describe('triplelift adapter', function () { }); const request = tripleliftAdapterSpec.buildRequests(bidRequests, bidderRequest); const { data: payload } = request; + console.log(JSON.stringify(payload)) expect(payload.ext.fpd.user).to.not.exist; - expect(payload.ext.fpd.context.data).to.haveOwnProperty('category'); + expect(payload.ext.fpd.context.ext.data).to.haveOwnProperty('category'); expect(payload.ext.fpd.context).to.haveOwnProperty('pmp_elig'); }); it('should send ad unit fpd if kvps are available', function() { From c2650c2c4a526a416b04e7976ddf4cbce964710b Mon Sep 17 00:00:00 2001 From: Nick Llerandi Date: Thu, 7 Apr 2022 16:57:45 -0400 Subject: [PATCH 03/25] remove console log --- test/spec/modules/tripleliftBidAdapter_spec.js | 1 - 1 file changed, 1 deletion(-) diff --git a/test/spec/modules/tripleliftBidAdapter_spec.js b/test/spec/modules/tripleliftBidAdapter_spec.js index 1f17c67c99c..164188804a3 100644 --- a/test/spec/modules/tripleliftBidAdapter_spec.js +++ b/test/spec/modules/tripleliftBidAdapter_spec.js @@ -812,7 +812,6 @@ describe('triplelift adapter', function () { }); const request = tripleliftAdapterSpec.buildRequests(bidRequests, bidderRequest); const { data: payload } = request; - console.log(JSON.stringify(payload)) expect(payload.ext.fpd.user).to.not.exist; expect(payload.ext.fpd.context.ext.data).to.haveOwnProperty('category'); expect(payload.ext.fpd.context).to.haveOwnProperty('pmp_elig'); From 0ebf51ca012afc0c95e5c9278e4f8e39e665c644 Mon Sep 17 00:00:00 2001 From: Patrick Loughrey Date: Wed, 20 Apr 2022 10:28:57 -0400 Subject: [PATCH 04/25] TL-19850 Changed functionlity of tests --- .../spec/modules/tripleliftBidAdapter_spec.js | 25 ++++++------------- 1 file changed, 7 insertions(+), 18 deletions(-) diff --git a/test/spec/modules/tripleliftBidAdapter_spec.js b/test/spec/modules/tripleliftBidAdapter_spec.js index 196a95349bf..0d463912cc6 100644 --- a/test/spec/modules/tripleliftBidAdapter_spec.js +++ b/test/spec/modules/tripleliftBidAdapter_spec.js @@ -787,27 +787,16 @@ describe('triplelift adapter', function () { size: '*' })).to.be.true; }); - it('should not set bid floor if currency is not USD', function() { - bidRequests.forEach(request => { - request.getFloor = () => {}; - sinon.spy(request, 'getFloor') - }); + it('should catch error if getFloor throws error', function() { + let logErrorSpy = sinon.spy(utils, 'logError'); - tripleliftAdapterSpec.buildRequests(bidRequests, bidderRequest); + bidRequests[0].getFloor = () => { + throw new Error('An exception!'); + }; - // banner request with non-USD currency - expect(bidRequests[0].getFloor.calledWith({ - currency: 'EUR', - mediaType: 'banner', - size: '*' - })).to.be.false; + tripleliftAdapterSpec.buildRequests(bidRequests, bidderRequest); - // banner request with non-USD currency - expect(bidRequests[1].getFloor.calledWith({ - currency: 'CAD', - mediaType: 'video', - size: '*' - })).to.be.false; + expect(logErrorSpy.calledOnce).to.equal(true); }); it('should send global config fpd if kvps are available', function() { const sens = null; From 3b347240484c7399a969bfbd793e990ccad65f70 Mon Sep 17 00:00:00 2001 From: Nick Llerandi Date: Fri, 29 Apr 2022 12:22:58 -0400 Subject: [PATCH 05/25] restore logErrorSpy aftereach --- test/spec/modules/tripleliftBidAdapter_spec.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/test/spec/modules/tripleliftBidAdapter_spec.js b/test/spec/modules/tripleliftBidAdapter_spec.js index 2a326376532..fc33a7cd676 100644 --- a/test/spec/modules/tripleliftBidAdapter_spec.js +++ b/test/spec/modules/tripleliftBidAdapter_spec.js @@ -11,8 +11,7 @@ const GDPR_CONSENT_STR = 'BOONm0NOONm0NABABAENAa-AAAARh7______b9_3__7_9uz_Kv_K7V describe('triplelift adapter', function () { const adapter = newBidder(tripleliftAdapterSpec); - let bid, instreamBid; - let sandbox; + let bid, instreamBid, sandbox, logErrorSpy; this.beforeEach(() => { bid = { @@ -379,9 +378,11 @@ describe('triplelift adapter', function () { }, }; sandbox = sinon.sandbox.create(); + logErrorSpy = sinon.spy(utils, 'logError'); }); afterEach(() => { sandbox.restore(); + utils.logError.restore(); }); it('exists and is an object', function () { @@ -788,8 +789,6 @@ describe('triplelift adapter', function () { })).to.be.true; }); it('should catch error if getFloor throws error', function() { - let logErrorSpy = sinon.spy(utils, 'logError'); - bidRequests[0].getFloor = () => { throw new Error('An exception!'); }; From f98715f76d101f3a6187fcc185b41dce1ccdb4b4 Mon Sep 17 00:00:00 2001 From: Nick Llerandi Date: Tue, 3 May 2022 14:32:56 -0400 Subject: [PATCH 06/25] passes 1px segments --- modules/tripleliftBidAdapter.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/modules/tripleliftBidAdapter.js b/modules/tripleliftBidAdapter.js index 7e964661db6..453586b313d 100644 --- a/modules/tripleliftBidAdapter.js +++ b/modules/tripleliftBidAdapter.js @@ -2,6 +2,7 @@ import { tryAppendQueryString, logMessage, logError, isEmpty, isStr, isPlainObje import { BANNER, VIDEO } from '../src/mediaTypes.js'; import { registerBidder } from '../src/adapters/bidderFactory.js'; import { config } from '../src/config.js'; +import {getStorageManager} from '../src/storageManager.js'; const GVLID = 28; const BIDDER_CODE = 'triplelift'; @@ -10,6 +11,7 @@ const BANNER_TIME_TO_LIVE = 300; const INSTREAM_TIME_TO_LIVE = 3600; let gdprApplies = true; let consentString = null; +const storage = getStorageManager({gvlid: GVLID, bidderCode: BIDDER_CODE}); export const tripleliftAdapterSpec = { gvlid: GVLID, @@ -197,10 +199,19 @@ function _getGlobalFpd() { const context = {} const user = {}; const ortbData = config.getConfig('ortb2') || {}; + const oneplusx = storage.getDataFromLocalStorage('1plusx') const fpdContext = Object.assign({}, ortbData.site); const fpdUser = Object.assign({}, ortbData.user); + if (!isEmpty(oneplusx)) { + fpdUser.data = fpdUser.data || [] + fpdUser.data.push({ + name: '1PlusX', + segment: [JSON.parse(oneplusx)] + }) + } + _addEntries(context, fpdContext); _addEntries(user, fpdUser); From 20e40e2d4b58957704061899a2a63392d79034b4 Mon Sep 17 00:00:00 2001 From: Nick Llerandi Date: Tue, 3 May 2022 15:08:47 -0400 Subject: [PATCH 07/25] array and malformed json check --- modules/tripleliftBidAdapter.js | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/modules/tripleliftBidAdapter.js b/modules/tripleliftBidAdapter.js index 453586b313d..315134d614a 100644 --- a/modules/tripleliftBidAdapter.js +++ b/modules/tripleliftBidAdapter.js @@ -204,12 +204,19 @@ function _getGlobalFpd() { const fpdContext = Object.assign({}, ortbData.site); const fpdUser = Object.assign({}, ortbData.user); - if (!isEmpty(oneplusx)) { + // NEEDS TEST: check that oneplusx is parseable + if (oneplusx && _testJSONParse(oneplusx)) { fpdUser.data = fpdUser.data || [] - fpdUser.data.push({ - name: '1PlusX', - segment: [JSON.parse(oneplusx)] - }) + // NEEDS TEST: check that fpdUser.data is an array before pushing; + // publisher may accidentally make it an object + try { + fpdUser.data.push({ + name: "1PlusX", + segment: [oneplusx] + }) + } catch (err) { + logError('Triplelift: error adding 1PlusX segemnts: ', err); + } } _addEntries(context, fpdContext); @@ -224,6 +231,16 @@ function _getGlobalFpd() { return fpd; } +function _testJSONParse(input) { + if (input == null) return false + try { + const parsedJson = JSON.parse(input) + return parsedJson + } catch (err) { + logError('Triplelift: error parsing JSON', err) + } +} + function _getAdUnitFpd(adUnitFpd) { const fpd = {}; const context = {}; From 96c4020074d3c4bbec6f1833d8b8327350e54e3b Mon Sep 17 00:00:00 2001 From: Nick Llerandi Date: Tue, 3 May 2022 15:12:01 -0400 Subject: [PATCH 08/25] spell check --- modules/tripleliftBidAdapter.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/tripleliftBidAdapter.js b/modules/tripleliftBidAdapter.js index 315134d614a..123776b7e7b 100644 --- a/modules/tripleliftBidAdapter.js +++ b/modules/tripleliftBidAdapter.js @@ -215,7 +215,7 @@ function _getGlobalFpd() { segment: [oneplusx] }) } catch (err) { - logError('Triplelift: error adding 1PlusX segemnts: ', err); + logError('Triplelift: error adding 1PlusX segments: ', err); } } @@ -237,7 +237,7 @@ function _testJSONParse(input) { const parsedJson = JSON.parse(input) return parsedJson } catch (err) { - logError('Triplelift: error parsing JSON', err) + logError('Triplelift: error parsing JSON: ', err) } } From 3954ceafb0b7d323003321999524a8bcb90d9679 Mon Sep 17 00:00:00 2001 From: Nick Llerandi Date: Tue, 3 May 2022 15:19:56 -0400 Subject: [PATCH 09/25] single quotes --- modules/tripleliftBidAdapter.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/tripleliftBidAdapter.js b/modules/tripleliftBidAdapter.js index 123776b7e7b..9a427c2bf51 100644 --- a/modules/tripleliftBidAdapter.js +++ b/modules/tripleliftBidAdapter.js @@ -211,7 +211,7 @@ function _getGlobalFpd() { // publisher may accidentally make it an object try { fpdUser.data.push({ - name: "1PlusX", + name: '1PlusX', segment: [oneplusx] }) } catch (err) { From dd8cc271b0ab95547bbe404a51d371708dd7a47a Mon Sep 17 00:00:00 2001 From: Patrick Loughrey Date: Tue, 3 May 2022 22:09:00 -0400 Subject: [PATCH 10/25] TL-27574 Second draft of implementing 1plusx logic --- modules/tripleliftBidAdapter.js | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/modules/tripleliftBidAdapter.js b/modules/tripleliftBidAdapter.js index 9a427c2bf51..d5bb4e87fa6 100644 --- a/modules/tripleliftBidAdapter.js +++ b/modules/tripleliftBidAdapter.js @@ -199,23 +199,23 @@ function _getGlobalFpd() { const context = {} const user = {}; const ortbData = config.getConfig('ortb2') || {}; - const oneplusx = storage.getDataFromLocalStorage('1plusx') + const [oneplusx, isValid] = _testJSONParse(); const fpdContext = Object.assign({}, ortbData.site); const fpdUser = Object.assign({}, ortbData.user); // NEEDS TEST: check that oneplusx is parseable - if (oneplusx && _testJSONParse(oneplusx)) { + if (oneplusx && isValid) { fpdUser.data = fpdUser.data || [] // NEEDS TEST: check that fpdUser.data is an array before pushing; // publisher may accidentally make it an object try { fpdUser.data.push({ - name: '1PlusX', + name: '1plusX', segment: [oneplusx] }) } catch (err) { - logError('Triplelift: error adding 1PlusX segments: ', err); + logError('Triplelift: error adding 1plusX segments: ', err); } } @@ -231,13 +231,14 @@ function _getGlobalFpd() { return fpd; } -function _testJSONParse(input) { - if (input == null) return false +function _testJSONParse() { + const oneplusx = storage.getDataFromLocalStorage('1plusx'); + if (oneplusx == null) return [{}, false]; try { - const parsedJson = JSON.parse(input) - return parsedJson + const parsedJson = JSON.parse(oneplusx); + return [parsedJson, true]; } catch (err) { - logError('Triplelift: error parsing JSON: ', err) + logError('Triplelift: error parsing JSON: ', err); } } From 2c5d2435db96d9a634f92160e25cea181323a6fe Mon Sep 17 00:00:00 2001 From: Nick Llerandi Date: Wed, 4 May 2022 08:47:49 -0400 Subject: [PATCH 11/25] cleanup around fetchOnePlusX --- modules/tripleliftBidAdapter.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/modules/tripleliftBidAdapter.js b/modules/tripleliftBidAdapter.js index d5bb4e87fa6..daa8d981477 100644 --- a/modules/tripleliftBidAdapter.js +++ b/modules/tripleliftBidAdapter.js @@ -199,20 +199,20 @@ function _getGlobalFpd() { const context = {} const user = {}; const ortbData = config.getConfig('ortb2') || {}; - const [oneplusx, isValid] = _testJSONParse(); + const onePlusXStorage = _fetchOnePlusX(); const fpdContext = Object.assign({}, ortbData.site); const fpdUser = Object.assign({}, ortbData.user); - // NEEDS TEST: check that oneplusx is parseable - if (oneplusx && isValid) { + // NEEDS TEST: check that onePlusXStorage is parseable + if (onePlusXStorage) { fpdUser.data = fpdUser.data || [] // NEEDS TEST: check that fpdUser.data is an array before pushing; // publisher may accidentally make it an object try { fpdUser.data.push({ name: '1plusX', - segment: [oneplusx] + segment: [onePlusXStorage] }) } catch (err) { logError('Triplelift: error adding 1plusX segments: ', err); @@ -231,14 +231,15 @@ function _getGlobalFpd() { return fpd; } -function _testJSONParse() { +function _fetchOnePlusX() { const oneplusx = storage.getDataFromLocalStorage('1plusx'); - if (oneplusx == null) return [{}, false]; + if (oneplusx == null) return null; try { const parsedJson = JSON.parse(oneplusx); - return [parsedJson, true]; + return parsedJson } catch (err) { logError('Triplelift: error parsing JSON: ', err); + return null } } From 839a34cc8985f0d4f9131f7676096cfd6c12d187 Mon Sep 17 00:00:00 2001 From: Nick Llerandi Date: Fri, 6 May 2022 13:42:09 -0400 Subject: [PATCH 12/25] replaces segment for ext --- modules/tripleliftBidAdapter.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/tripleliftBidAdapter.js b/modules/tripleliftBidAdapter.js index daa8d981477..f2984b8636c 100644 --- a/modules/tripleliftBidAdapter.js +++ b/modules/tripleliftBidAdapter.js @@ -211,8 +211,8 @@ function _getGlobalFpd() { // publisher may accidentally make it an object try { fpdUser.data.push({ - name: '1plusX', - segment: [onePlusXStorage] + name: 'www.1plusx.com', + ext: [onePlusXStorage] }) } catch (err) { logError('Triplelift: error adding 1plusX segments: ', err); From dac52d9a3f3d1e2fb9b3eaa5289d846ef35ce8ea Mon Sep 17 00:00:00 2001 From: Nick Llerandi Date: Mon, 9 May 2022 16:25:52 -0400 Subject: [PATCH 13/25] ext should be object --- modules/tripleliftBidAdapter.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/tripleliftBidAdapter.js b/modules/tripleliftBidAdapter.js index f2984b8636c..9e5b41cd395 100644 --- a/modules/tripleliftBidAdapter.js +++ b/modules/tripleliftBidAdapter.js @@ -212,7 +212,7 @@ function _getGlobalFpd() { try { fpdUser.data.push({ name: 'www.1plusx.com', - ext: [onePlusXStorage] + ext: onePlusXStorage }) } catch (err) { logError('Triplelift: error adding 1plusX segments: ', err); From a8c43a16433ed7ab4fe3c3975aef59e2bd5b521c Mon Sep 17 00:00:00 2001 From: Nick Llerandi Date: Fri, 13 May 2022 10:41:32 -0400 Subject: [PATCH 14/25] tests --- modules/tripleliftBidAdapter.js | 2 +- .../spec/modules/tripleliftBidAdapter_spec.js | 52 ++++++++++++++++++- 2 files changed, 52 insertions(+), 2 deletions(-) diff --git a/modules/tripleliftBidAdapter.js b/modules/tripleliftBidAdapter.js index 9e5b41cd395..7a1787610a9 100644 --- a/modules/tripleliftBidAdapter.js +++ b/modules/tripleliftBidAdapter.js @@ -11,7 +11,7 @@ const BANNER_TIME_TO_LIVE = 300; const INSTREAM_TIME_TO_LIVE = 3600; let gdprApplies = true; let consentString = null; -const storage = getStorageManager({gvlid: GVLID, bidderCode: BIDDER_CODE}); +export const storage = getStorageManager({gvlid: GVLID, bidderCode: BIDDER_CODE}); export const tripleliftAdapterSpec = { gvlid: GVLID, diff --git a/test/spec/modules/tripleliftBidAdapter_spec.js b/test/spec/modules/tripleliftBidAdapter_spec.js index fc33a7cd676..df176f0eb45 100644 --- a/test/spec/modules/tripleliftBidAdapter_spec.js +++ b/test/spec/modules/tripleliftBidAdapter_spec.js @@ -1,5 +1,5 @@ import { expect } from 'chai'; -import { tripleliftAdapterSpec } from 'modules/tripleliftBidAdapter.js'; +import { tripleliftAdapterSpec, storage } from 'modules/tripleliftBidAdapter.js'; import { newBidder } from 'src/adapters/bidderFactory.js'; import { deepClone } from 'src/utils.js'; import { config } from 'src/config.js'; @@ -833,6 +833,56 @@ describe('triplelift adapter', function () { expect(request.data.imp[0].fpd.context.data).to.haveOwnProperty('adUnitSpecificAttribute'); expect(request.data.imp[1].fpd).to.not.exist; }); + it('should send 1PlusX data as fpd if localStorage is available and no other fpd is defined', function() { + sandbox.stub(storage, 'getDataFromLocalStorage').callsFake(() => '{"kid":1,"s":"ySRdArquXuBolr/cVv0UNqrJhTO4QZsbNH/t+2kR3gXjbA==","t":"/yVtBrquXuBolr/cVv0UNtx1mssdLYeKFhWFI3Dq1dJnug=="}'); + const request = tripleliftAdapterSpec.buildRequests(bidRequests, bidderRequest); + expect(request.data.ext.fpd).to.deep.equal({ + 'user': { + 'data': [ + { + 'name': 'www.1plusx.com', + 'ext': { + 'kid': 1, + 's': 'ySRdArquXuBolr/cVv0UNqrJhTO4QZsbNH/t+2kR3gXjbA==', + 't': '/yVtBrquXuBolr/cVv0UNtx1mssdLYeKFhWFI3Dq1dJnug==' + } + } + ] + } + }) + }); + it('should append 1PlusX data to existing user.data entries if localStorage is available', function() { + const ortb2 = { + user: { + data: [ + { name: 'dataprovider.com', ext: { segtax: 4 }, segment: [{ id: '1' }] } + ] + } + }; + sandbox.stub(config, 'getConfig').callsFake(key => { + const config = { + ortb2 + }; + return utils.deepAccess(config, key); + }); + sandbox.stub(storage, 'getDataFromLocalStorage').callsFake(() => '{"kid":1,"s":"ySRdArquXuBolr/cVv0UNqrJhTO4QZsbNH/t+2kR3gXjbA==","t":"/yVtBrquXuBolr/cVv0UNtx1mssdLYeKFhWFI3Dq1dJnug=="}'); + const request = tripleliftAdapterSpec.buildRequests(bidRequests, bidderRequest); + expect(request.data.ext.fpd).to.deep.equal({ + 'user': { + 'data': [ + { 'name': 'dataprovider.com', 'ext': { 'segtax': 4 }, 'segment': [{ 'id': '1' }] }, + { + 'name': 'www.1plusx.com', + 'ext': { + 'kid': 1, + 's': 'ySRdArquXuBolr/cVv0UNqrJhTO4QZsbNH/t+2kR3gXjbA==', + 't': '/yVtBrquXuBolr/cVv0UNtx1mssdLYeKFhWFI3Dq1dJnug==' + } + } + ] + } + }) + }); }); describe('interpretResponse', function () { From 277d2696b559ecbf1361aae38a7375a3058dd239 Mon Sep 17 00:00:00 2001 From: Nick Llerandi Date: Mon, 16 May 2022 08:41:05 -0400 Subject: [PATCH 15/25] update localstorage key name --- modules/tripleliftBidAdapter.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/tripleliftBidAdapter.js b/modules/tripleliftBidAdapter.js index 7a1787610a9..13751aad8ee 100644 --- a/modules/tripleliftBidAdapter.js +++ b/modules/tripleliftBidAdapter.js @@ -232,7 +232,7 @@ function _getGlobalFpd() { } function _fetchOnePlusX() { - const oneplusx = storage.getDataFromLocalStorage('1plusx'); + const oneplusx = storage.getDataFromLocalStorage('opecloud_ctx'); if (oneplusx == null) return null; try { const parsedJson = JSON.parse(oneplusx); From 4f12fb94a0ff1fd22407d88d05a57bc360617246 Mon Sep 17 00:00:00 2001 From: Nick Llerandi Date: Mon, 16 May 2022 11:01:53 -0400 Subject: [PATCH 16/25] rename to opecloud --- modules/tripleliftBidAdapter.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/modules/tripleliftBidAdapter.js b/modules/tripleliftBidAdapter.js index 13751aad8ee..0ca295f53d8 100644 --- a/modules/tripleliftBidAdapter.js +++ b/modules/tripleliftBidAdapter.js @@ -199,20 +199,20 @@ function _getGlobalFpd() { const context = {} const user = {}; const ortbData = config.getConfig('ortb2') || {}; - const onePlusXStorage = _fetchOnePlusX(); + const opeCloudStorage = _fetchOpeCloud(); const fpdContext = Object.assign({}, ortbData.site); const fpdUser = Object.assign({}, ortbData.user); - // NEEDS TEST: check that onePlusXStorage is parseable - if (onePlusXStorage) { + // NEEDS TEST: check that opeCloudStorage is parseable + if (opeCloudStorage) { fpdUser.data = fpdUser.data || [] // NEEDS TEST: check that fpdUser.data is an array before pushing; // publisher may accidentally make it an object try { fpdUser.data.push({ name: 'www.1plusx.com', - ext: onePlusXStorage + ext: opeCloudStorage }) } catch (err) { logError('Triplelift: error adding 1plusX segments: ', err); @@ -231,11 +231,11 @@ function _getGlobalFpd() { return fpd; } -function _fetchOnePlusX() { - const oneplusx = storage.getDataFromLocalStorage('opecloud_ctx'); - if (oneplusx == null) return null; +function _fetchOpeCloud() { + const opeCloud = storage.getDataFromLocalStorage('opecloud_ctx'); + if (opeCloud == null) return null; try { - const parsedJson = JSON.parse(oneplusx); + const parsedJson = JSON.parse(opeCloud); return parsedJson } catch (err) { logError('Triplelift: error parsing JSON: ', err); From 8552d3608f2a9be99b3522fe18704095e2683758 Mon Sep 17 00:00:00 2001 From: gbalboa0 Date: Fri, 20 May 2022 14:13:49 -0300 Subject: [PATCH 17/25] add frametype to tlBidAdapter --- modules/tripleliftBidAdapter.js | 98 +++++++++++++++++++ .../spec/modules/tripleliftBidAdapter_spec.js | 25 +++++ 2 files changed, 123 insertions(+) diff --git a/modules/tripleliftBidAdapter.js b/modules/tripleliftBidAdapter.js index 7e964661db6..c6b453672ba 100644 --- a/modules/tripleliftBidAdapter.js +++ b/modules/tripleliftBidAdapter.js @@ -8,6 +8,19 @@ const BIDDER_CODE = 'triplelift'; const STR_ENDPOINT = 'https://tlx.3lift.com/header/auction?'; const BANNER_TIME_TO_LIVE = 300; const INSTREAM_TIME_TO_LIVE = 3600; +const FRAME_TYPE_IDS = { + noFrame: 0, + friendlyFrame: 1, // same-origin, we escape to top by default + unfriendlyFrame: 2, // cross-origin so we can't escape, render inside the frame + webview: 3, + amp: 4, + safeFrame: 5, + mraid: 6, + friendlyFrameRender: 7, // same-origin but we still render inside the frame +}; +const MRAID_API_NAME = 'mraid'; +const SAFE_FRAME_API_NAME = '$sf'; +const FRAME_DEPTH_LIMIT = 5; let gdprApplies = true; let consentString = null; @@ -25,6 +38,7 @@ export const tripleliftAdapterSpec = { tlCall = tryAppendQueryString(tlCall, 'lib', 'prebid'); tlCall = tryAppendQueryString(tlCall, 'v', '$prebid.version$'); + tlCall = tryAppendQueryString(tlCall, 'ft', _determineFrameType()); if (bidderRequest && bidderRequest.refererInfo) { let referrer = bidderRequest.refererInfo.referer; @@ -364,4 +378,88 @@ function _buildResponseObject(bidderRequest, bid) { return bidResponse; } +function getSafeFrameApi() { + const safeFrameApi = _getApi(SAFE_FRAME_API_NAME); + if (safeFrameApi && safeFrameApi.ext) { + // we only want the safeframe api when we are inside + // a safe frame. there could a safeframe api on the + // publisher's top frame which is useless to us. + return safeFrameApi; + } + return null; +} + +function isAmp() { + return typeof window.context === 'object' && (window.context.tagName === 'AMP-AD' || window.context.tagName === 'AMP-EMBED'); +} + +function getMraidApi() { + return _getApi(MRAID_API_NAME); +} + +/** + * Check for the existence of a #tl-app element that signifies we're running in a mobile webview. + * @return {boolean} + */ +function isInApp() { + const tlAppEl = document.getElementById('tl-app'); + return !!tlAppEl; +} + +// Recursively check windows until api is found or +// depth limit is reached. +function _findApi(apiName, win, depth = 0) { + if (depth >= FRAME_DEPTH_LIMIT) { + return null; + } + + try { + if (win[apiName]) { + return win[apiName]; + } + } catch (e) { + // can't read property of undefined + // can't access property of cross-origin frame + return null; + } + + return _findApi(apiName, win.parent, depth + 1); +} + +function _getApi(apiName) { + return _findApi(apiName, window); +} + +function canAccessTopWindow() { + try { + if (window.top.location.href) { + return true; + } + } catch (error) { + return false; + } +} + +function _determineFrameType() { + if (isAmp()) { + return FRAME_TYPE_IDS.amp; + } + if (getMraidApi()) { + return FRAME_TYPE_IDS.mraid; + } + if (getSafeFrameApi()) { + return FRAME_TYPE_IDS.safeFrame; + } + if (isInApp()) { + return FRAME_TYPE_IDS.webview; + } + if (!canAccessTopWindow()) { + return FRAME_TYPE_IDS.unfriendlyFrame; + } + /* if (this.docInfo.document === this.docInfo.topWindow.document) { + return FRAME_TYPE_IDS.noFrame; + } */ + return FRAME_TYPE_IDS.friendlyFrame; +} + registerBidder(tripleliftAdapterSpec); diff --git a/test/spec/modules/tripleliftBidAdapter_spec.js b/test/spec/modules/tripleliftBidAdapter_spec.js index fc33a7cd676..a5d14dc8df9 100644 --- a/test/spec/modules/tripleliftBidAdapter_spec.js +++ b/test/spec/modules/tripleliftBidAdapter_spec.js @@ -13,6 +13,13 @@ describe('triplelift adapter', function () { const adapter = newBidder(tripleliftAdapterSpec); let bid, instreamBid, sandbox, logErrorSpy; + // safeFrame implementation + const $sf = { + ext: { + geom: function() {} + } + }; + this.beforeEach(() => { bid = { bidder: 'triplelift', @@ -727,6 +734,24 @@ describe('triplelift adapter', function () { const url = request.url; expect(url).not.to.match(/(\?|&)coppa=/); }); + it('should add the correct frame type param friendly frame', function () { + const request = tripleliftAdapterSpec.buildRequests(bidRequests, bidderRequest); + const url = request.url; + expect(url).to.match(/(\?|&)ft=1/); + }); + it('should add the correct frame type param amp frame', function () { + window.context = { tagName: 'AMP-AD' }; + const request = tripleliftAdapterSpec.buildRequests(bidRequests, bidderRequest); + window.context = {}; + const url = request.url; + expect(url).to.match(/(\?|&)ft=4/); + }); + it('should add the correct frame type param unfriendly frame', function () { + window.$sf = $sf + const request = tripleliftAdapterSpec.buildRequests(bidRequests, bidderRequest); + const url = request.url; + expect(url).to.match(/(\?|&)ft=5/); + }); it('should return schain when present', function() { const request = tripleliftAdapterSpec.buildRequests(bidRequests, bidderRequest); const { data: payload } = request; From ac384c34f6474acefff66b441c9bde6243ad7fad Mon Sep 17 00:00:00 2001 From: Nick Llerandi Date: Mon, 23 May 2022 09:19:15 -0400 Subject: [PATCH 18/25] removes comments --- modules/tripleliftBidAdapter.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/modules/tripleliftBidAdapter.js b/modules/tripleliftBidAdapter.js index 0ca295f53d8..6ccc89d4849 100644 --- a/modules/tripleliftBidAdapter.js +++ b/modules/tripleliftBidAdapter.js @@ -204,11 +204,8 @@ function _getGlobalFpd() { const fpdContext = Object.assign({}, ortbData.site); const fpdUser = Object.assign({}, ortbData.user); - // NEEDS TEST: check that opeCloudStorage is parseable if (opeCloudStorage) { fpdUser.data = fpdUser.data || [] - // NEEDS TEST: check that fpdUser.data is an array before pushing; - // publisher may accidentally make it an object try { fpdUser.data.push({ name: 'www.1plusx.com', From 7cd76f10efcafff59124e1c50b126ac6dc03f209 Mon Sep 17 00:00:00 2001 From: gbalboa0 Date: Thu, 26 May 2022 15:40:32 -0300 Subject: [PATCH 19/25] clean up + no frame ft --- modules/tripleliftBidAdapter.js | 24 +++++++++---------- .../spec/modules/tripleliftBidAdapter_spec.js | 2 +- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/modules/tripleliftBidAdapter.js b/modules/tripleliftBidAdapter.js index c6b453672ba..a79a4b75093 100644 --- a/modules/tripleliftBidAdapter.js +++ b/modules/tripleliftBidAdapter.js @@ -10,13 +10,12 @@ const BANNER_TIME_TO_LIVE = 300; const INSTREAM_TIME_TO_LIVE = 3600; const FRAME_TYPE_IDS = { noFrame: 0, - friendlyFrame: 1, // same-origin, we escape to top by default - unfriendlyFrame: 2, // cross-origin so we can't escape, render inside the frame + friendlyFrame: 1, + unfriendlyFrame: 2, webview: 3, amp: 4, safeFrame: 5, mraid: 6, - friendlyFrameRender: 7, // same-origin but we still render inside the frame }; const MRAID_API_NAME = 'mraid'; const SAFE_FRAME_API_NAME = '$sf'; @@ -381,9 +380,6 @@ function _buildResponseObject(bidderRequest, bid) { function getSafeFrameApi() { const safeFrameApi = _getApi(SAFE_FRAME_API_NAME); if (safeFrameApi && safeFrameApi.ext) { - // we only want the safeframe api when we are inside - // a safe frame. there could a safeframe api on the - // publisher's top frame which is useless to us. return safeFrameApi; } return null; @@ -397,10 +393,14 @@ function getMraidApi() { return _getApi(MRAID_API_NAME); } -/** - * Check for the existence of a #tl-app element that signifies we're running in a mobile webview. - * @return {boolean} - */ +function isInFrame() { + try { + return window.self !== window.top; + } catch (e) { + return true; + } +} + function isInApp() { const tlAppEl = document.getElementById('tl-app'); return !!tlAppEl; @@ -456,9 +456,9 @@ function _determineFrameType() { if (!canAccessTopWindow()) { return FRAME_TYPE_IDS.unfriendlyFrame; } - /* if (this.docInfo.document === this.docInfo.topWindow.document) { + if (!isInFrame()) { return FRAME_TYPE_IDS.noFrame; - } */ + } return FRAME_TYPE_IDS.friendlyFrame; } diff --git a/test/spec/modules/tripleliftBidAdapter_spec.js b/test/spec/modules/tripleliftBidAdapter_spec.js index a5d14dc8df9..ff89bff9409 100644 --- a/test/spec/modules/tripleliftBidAdapter_spec.js +++ b/test/spec/modules/tripleliftBidAdapter_spec.js @@ -746,7 +746,7 @@ describe('triplelift adapter', function () { const url = request.url; expect(url).to.match(/(\?|&)ft=4/); }); - it('should add the correct frame type param unfriendly frame', function () { + it('should add the correct frame type param safeframe', function () { window.$sf = $sf const request = tripleliftAdapterSpec.buildRequests(bidRequests, bidderRequest); const url = request.url; From c778e00779cc72b861fddb940d45bbebfa4721a3 Mon Sep 17 00:00:00 2001 From: Nick Llerandi Date: Wed, 1 Jun 2022 16:49:09 -0400 Subject: [PATCH 20/25] addressing feedback --- modules/tripleliftBidAdapter.js | 2 +- .../spec/modules/tripleliftBidAdapter_spec.js | 24 +++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/modules/tripleliftBidAdapter.js b/modules/tripleliftBidAdapter.js index 4024ec62ece..987dc9eb645 100644 --- a/modules/tripleliftBidAdapter.js +++ b/modules/tripleliftBidAdapter.js @@ -243,7 +243,7 @@ function _getGlobalFpd() { function _fetchOpeCloud() { const opeCloud = storage.getDataFromLocalStorage('opecloud_ctx'); - if (opeCloud == null) return null; + if (!opeCloud) return null; try { const parsedJson = JSON.parse(opeCloud); return parsedJson diff --git a/test/spec/modules/tripleliftBidAdapter_spec.js b/test/spec/modules/tripleliftBidAdapter_spec.js index 4044f269027..17937f55954 100644 --- a/test/spec/modules/tripleliftBidAdapter_spec.js +++ b/test/spec/modules/tripleliftBidAdapter_spec.js @@ -908,6 +908,30 @@ describe('triplelift adapter', function () { } }) }); + it('should not append anything if getDataFromLocalStorage returns null', function() { + const ortb2 = { + user: { + data: [ + { name: 'dataprovider.com', ext: { segtax: 4 }, segment: [{ id: '1' }] } + ] + } + }; + sandbox.stub(config, 'getConfig').callsFake(key => { + const config = { + ortb2 + }; + return utils.deepAccess(config, key); + }); + sandbox.stub(storage, 'getDataFromLocalStorage').callsFake(() => null); + const request = tripleliftAdapterSpec.buildRequests(bidRequests, bidderRequest); + expect(request.data.ext.fpd).to.deep.equal({ + 'user': { + 'data': [ + { 'name': 'dataprovider.com', 'ext': { 'segtax': 4 }, 'segment': [{ 'id': '1' }] }, + ] + } + }) + }); }); describe('interpretResponse', function () { From a94b99bb1b07bb34a12a7d353d20d50a333e9ffc Mon Sep 17 00:00:00 2001 From: gbalboa0 <47567497+gbalboa0@users.noreply.github.com> Date: Tue, 7 Jun 2022 16:26:42 -0300 Subject: [PATCH 21/25] Revert "TL-27859: add frame type to prebid adapter" --- modules/tripleliftBidAdapter.js | 98 ------------------- .../spec/modules/tripleliftBidAdapter_spec.js | 25 ----- 2 files changed, 123 deletions(-) diff --git a/modules/tripleliftBidAdapter.js b/modules/tripleliftBidAdapter.js index a79a4b75093..7e964661db6 100644 --- a/modules/tripleliftBidAdapter.js +++ b/modules/tripleliftBidAdapter.js @@ -8,18 +8,6 @@ const BIDDER_CODE = 'triplelift'; const STR_ENDPOINT = 'https://tlx.3lift.com/header/auction?'; const BANNER_TIME_TO_LIVE = 300; const INSTREAM_TIME_TO_LIVE = 3600; -const FRAME_TYPE_IDS = { - noFrame: 0, - friendlyFrame: 1, - unfriendlyFrame: 2, - webview: 3, - amp: 4, - safeFrame: 5, - mraid: 6, -}; -const MRAID_API_NAME = 'mraid'; -const SAFE_FRAME_API_NAME = '$sf'; -const FRAME_DEPTH_LIMIT = 5; let gdprApplies = true; let consentString = null; @@ -37,7 +25,6 @@ export const tripleliftAdapterSpec = { tlCall = tryAppendQueryString(tlCall, 'lib', 'prebid'); tlCall = tryAppendQueryString(tlCall, 'v', '$prebid.version$'); - tlCall = tryAppendQueryString(tlCall, 'ft', _determineFrameType()); if (bidderRequest && bidderRequest.refererInfo) { let referrer = bidderRequest.refererInfo.referer; @@ -377,89 +364,4 @@ function _buildResponseObject(bidderRequest, bid) { return bidResponse; } -function getSafeFrameApi() { - const safeFrameApi = _getApi(SAFE_FRAME_API_NAME); - if (safeFrameApi && safeFrameApi.ext) { - return safeFrameApi; - } - return null; -} - -function isAmp() { - return typeof window.context === 'object' && (window.context.tagName === 'AMP-AD' || window.context.tagName === 'AMP-EMBED'); -} - -function getMraidApi() { - return _getApi(MRAID_API_NAME); -} - -function isInFrame() { - try { - return window.self !== window.top; - } catch (e) { - return true; - } -} - -function isInApp() { - const tlAppEl = document.getElementById('tl-app'); - return !!tlAppEl; -} - -// Recursively check windows until api is found or -// depth limit is reached. -function _findApi(apiName, win, depth = 0) { - if (depth >= FRAME_DEPTH_LIMIT) { - return null; - } - - try { - if (win[apiName]) { - return win[apiName]; - } - } catch (e) { - // can't read property of undefined - // can't access property of cross-origin frame - return null; - } - - return _findApi(apiName, win.parent, depth + 1); -} - -function _getApi(apiName) { - return _findApi(apiName, window); -} - -function canAccessTopWindow() { - try { - if (window.top.location.href) { - return true; - } - } catch (error) { - return false; - } -} - -function _determineFrameType() { - if (isAmp()) { - return FRAME_TYPE_IDS.amp; - } - if (getMraidApi()) { - return FRAME_TYPE_IDS.mraid; - } - if (getSafeFrameApi()) { - return FRAME_TYPE_IDS.safeFrame; - } - if (isInApp()) { - return FRAME_TYPE_IDS.webview; - } - if (!canAccessTopWindow()) { - return FRAME_TYPE_IDS.unfriendlyFrame; - } - if (!isInFrame()) { - return FRAME_TYPE_IDS.noFrame; - } - return FRAME_TYPE_IDS.friendlyFrame; -} - registerBidder(tripleliftAdapterSpec); diff --git a/test/spec/modules/tripleliftBidAdapter_spec.js b/test/spec/modules/tripleliftBidAdapter_spec.js index ff89bff9409..fc33a7cd676 100644 --- a/test/spec/modules/tripleliftBidAdapter_spec.js +++ b/test/spec/modules/tripleliftBidAdapter_spec.js @@ -13,13 +13,6 @@ describe('triplelift adapter', function () { const adapter = newBidder(tripleliftAdapterSpec); let bid, instreamBid, sandbox, logErrorSpy; - // safeFrame implementation - const $sf = { - ext: { - geom: function() {} - } - }; - this.beforeEach(() => { bid = { bidder: 'triplelift', @@ -734,24 +727,6 @@ describe('triplelift adapter', function () { const url = request.url; expect(url).not.to.match(/(\?|&)coppa=/); }); - it('should add the correct frame type param friendly frame', function () { - const request = tripleliftAdapterSpec.buildRequests(bidRequests, bidderRequest); - const url = request.url; - expect(url).to.match(/(\?|&)ft=1/); - }); - it('should add the correct frame type param amp frame', function () { - window.context = { tagName: 'AMP-AD' }; - const request = tripleliftAdapterSpec.buildRequests(bidRequests, bidderRequest); - window.context = {}; - const url = request.url; - expect(url).to.match(/(\?|&)ft=4/); - }); - it('should add the correct frame type param safeframe', function () { - window.$sf = $sf - const request = tripleliftAdapterSpec.buildRequests(bidRequests, bidderRequest); - const url = request.url; - expect(url).to.match(/(\?|&)ft=5/); - }); it('should return schain when present', function() { const request = tripleliftAdapterSpec.buildRequests(bidRequests, bidderRequest); const { data: payload } = request; From 93a3a3ddc89e39d67a0b04fa6aa4d33d94a7e2ee Mon Sep 17 00:00:00 2001 From: Nick Llerandi Date: Tue, 7 Jun 2022 16:08:04 -0400 Subject: [PATCH 22/25] cleanup --- modules/tripleliftBidAdapter.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/tripleliftBidAdapter.js b/modules/tripleliftBidAdapter.js index dd6342437d1..4b905c00506 100644 --- a/modules/tripleliftBidAdapter.js +++ b/modules/tripleliftBidAdapter.js @@ -2,7 +2,7 @@ import { tryAppendQueryString, logMessage, logError, isEmpty, isStr, isPlainObje import { BANNER, VIDEO } from '../src/mediaTypes.js'; import { registerBidder } from '../src/adapters/bidderFactory.js'; import { config } from '../src/config.js'; -import {getStorageManager} from '../src/storageManager.js'; +import { getStorageManager } from '../src/storageManager.js'; const GVLID = 28; const BIDDER_CODE = 'triplelift'; From af4f3a1311e92a46bc9a57b1fdb02f6795f88367 Mon Sep 17 00:00:00 2001 From: Nick Llerandi Date: Wed, 8 Jun 2022 11:36:14 -0400 Subject: [PATCH 23/25] updates tests to work with prebid 7 --- .../spec/modules/tripleliftBidAdapter_spec.js | 20 ++++--------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/test/spec/modules/tripleliftBidAdapter_spec.js b/test/spec/modules/tripleliftBidAdapter_spec.js index 12dc842c700..7923a2bc613 100644 --- a/test/spec/modules/tripleliftBidAdapter_spec.js +++ b/test/spec/modules/tripleliftBidAdapter_spec.js @@ -846,19 +846,13 @@ describe('triplelift adapter', function () { }) }); it('should append 1PlusX data to existing user.data entries if localStorage is available', function() { - const ortb2 = { + bidderRequest.ortb2 = { user: { data: [ { name: 'dataprovider.com', ext: { segtax: 4 }, segment: [{ id: '1' }] } ] } - }; - sandbox.stub(config, 'getConfig').callsFake(key => { - const config = { - ortb2 - }; - return utils.deepAccess(config, key); - }); + } sandbox.stub(storage, 'getDataFromLocalStorage').callsFake(() => '{"kid":1,"s":"ySRdArquXuBolr/cVv0UNqrJhTO4QZsbNH/t+2kR3gXjbA==","t":"/yVtBrquXuBolr/cVv0UNtx1mssdLYeKFhWFI3Dq1dJnug=="}'); const request = tripleliftAdapterSpec.buildRequests(bidRequests, bidderRequest); expect(request.data.ext.fpd).to.deep.equal({ @@ -878,19 +872,13 @@ describe('triplelift adapter', function () { }) }); it('should not append anything if getDataFromLocalStorage returns null', function() { - const ortb2 = { + bidderRequest.ortb2 = { user: { data: [ { name: 'dataprovider.com', ext: { segtax: 4 }, segment: [{ id: '1' }] } ] } - }; - sandbox.stub(config, 'getConfig').callsFake(key => { - const config = { - ortb2 - }; - return utils.deepAccess(config, key); - }); + } sandbox.stub(storage, 'getDataFromLocalStorage').callsFake(() => null); const request = tripleliftAdapterSpec.buildRequests(bidRequests, bidderRequest); expect(request.data.ext.fpd).to.deep.equal({ From 0f7df9af77bbff5d7baff4d655e0daa5d6050c39 Mon Sep 17 00:00:00 2001 From: Nick Llerandi Date: Wed, 8 Jun 2022 11:46:57 -0400 Subject: [PATCH 24/25] permission to access storage --- test/spec/modules/tripleliftBidAdapter_spec.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/test/spec/modules/tripleliftBidAdapter_spec.js b/test/spec/modules/tripleliftBidAdapter_spec.js index 7923a2bc613..b605079502f 100644 --- a/test/spec/modules/tripleliftBidAdapter_spec.js +++ b/test/spec/modules/tripleliftBidAdapter_spec.js @@ -379,6 +379,12 @@ describe('triplelift adapter', function () { }; sandbox = sinon.sandbox.create(); logErrorSpy = sinon.spy(utils, 'logError'); + + $$PREBID_GLOBAL$$.bidderSettings = { + triplelift: { + storageAllowed: true + } + }; }); afterEach(() => { sandbox.restore(); From d60cdd22b9b934bc76abc2a5c9208e9f9021c868 Mon Sep 17 00:00:00 2001 From: Nick Llerandi Date: Wed, 8 Jun 2022 13:32:09 -0400 Subject: [PATCH 25/25] reset prebid global --- test/spec/modules/tripleliftBidAdapter_spec.js | 1 + 1 file changed, 1 insertion(+) diff --git a/test/spec/modules/tripleliftBidAdapter_spec.js b/test/spec/modules/tripleliftBidAdapter_spec.js index b605079502f..b0269aaf077 100644 --- a/test/spec/modules/tripleliftBidAdapter_spec.js +++ b/test/spec/modules/tripleliftBidAdapter_spec.js @@ -389,6 +389,7 @@ describe('triplelift adapter', function () { afterEach(() => { sandbox.restore(); utils.logError.restore(); + $$PREBID_GLOBAL$$.bidderSettings = {}; }); it('exists and is an object', function () {