From cabfac33222859a1087b74a11982c6b0d3f53308 Mon Sep 17 00:00:00 2001 From: David Andersen Date: Mon, 10 Feb 2020 17:56:24 -0500 Subject: [PATCH 1/2] Add COPPA support --- modules/tripleliftBidAdapter.js | 5 +++++ test/spec/modules/tripleliftBidAdapter_spec.js | 15 +++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/modules/tripleliftBidAdapter.js b/modules/tripleliftBidAdapter.js index 8cd1dda1120..9c20e36caec 100644 --- a/modules/tripleliftBidAdapter.js +++ b/modules/tripleliftBidAdapter.js @@ -1,6 +1,7 @@ import { BANNER } from '../src/mediaTypes'; import { registerBidder } from '../src/adapters/bidderFactory'; import * as utils from '../src/utils'; +import { config } from '../src/config'; const BIDDER_CODE = 'triplelift'; const STR_ENDPOINT = 'https://tlx.3lift.com/header/auction?'; @@ -46,6 +47,10 @@ export const tripleliftAdapterSpec = { tlCall = utils.tryAppendQueryString(tlCall, 'us_privacy', bidderRequest.uspConsent); } + if (config.getConfig('coppa') === true) { + tlCall = utils.tryAppendQueryString(tlCall, 'coppa', true); + } + if (tlCall.lastIndexOf('&') === tlCall.length - 1) { tlCall = tlCall.substring(0, tlCall.length - 1); } diff --git a/test/spec/modules/tripleliftBidAdapter_spec.js b/test/spec/modules/tripleliftBidAdapter_spec.js index fc8608f522a..7c92df35be1 100644 --- a/test/spec/modules/tripleliftBidAdapter_spec.js +++ b/test/spec/modules/tripleliftBidAdapter_spec.js @@ -2,6 +2,7 @@ import { expect } from 'chai'; import { tripleliftAdapterSpec } from 'modules/tripleliftBidAdapter'; import { newBidder } from 'src/adapters/bidderFactory'; import { deepClone } from 'src/utils'; +import { config } from 'src/config'; import prebid from '../../../package.json'; const ENDPOINT = 'https://tlx.3lift.com/header/auction?'; @@ -273,6 +274,20 @@ describe('triplelift adapter', function () { const url = request.url; expect(url).to.match(/(\?|&)us_privacy=1YYY/); }); + it('should return coppa param when COPPA config is set to true', function() { + sinon.stub(config, 'getConfig').withArgs('coppa').returns(true); + const request = tripleliftAdapterSpec.buildRequests(bidRequests, bidderRequest); + config.getConfig.restore(); + const url = request.url; + expect(url).to.match(/(\?|&)coppa=true/); + }); + it('should not return coppa param when COPPA config is set to false', function() { + sinon.stub(config, 'getConfig').withArgs('coppa').returns(false); + const request = tripleliftAdapterSpec.buildRequests(bidRequests, bidderRequest); + config.getConfig.restore(); + const url = request.url; + expect(url).not.to.match(/(\?|&)coppa=true/); + }); it('should return schain when present', function() { const request = tripleliftAdapterSpec.buildRequests(bidRequests, bidderRequest); const { data: payload } = request; From afc5310e9a65aa29a2ad1323d29ce360ed5036b8 Mon Sep 17 00:00:00 2001 From: David Andersen Date: Wed, 12 Feb 2020 15:05:53 -0500 Subject: [PATCH 2/2] Modify test --- test/spec/modules/tripleliftBidAdapter_spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/spec/modules/tripleliftBidAdapter_spec.js b/test/spec/modules/tripleliftBidAdapter_spec.js index 7c92df35be1..6642e59d7c3 100644 --- a/test/spec/modules/tripleliftBidAdapter_spec.js +++ b/test/spec/modules/tripleliftBidAdapter_spec.js @@ -286,7 +286,7 @@ describe('triplelift adapter', function () { const request = tripleliftAdapterSpec.buildRequests(bidRequests, bidderRequest); config.getConfig.restore(); const url = request.url; - expect(url).not.to.match(/(\?|&)coppa=true/); + expect(url).not.to.match(/(\?|&)coppa=/); }); it('should return schain when present', function() { const request = tripleliftAdapterSpec.buildRequests(bidRequests, bidderRequest);