diff --git a/modules/tripleliftBidAdapter.js b/modules/tripleliftBidAdapter.js index 795c75ef9bc..fac6224d1dc 100644 --- a/modules/tripleliftBidAdapter.js +++ b/modules/tripleliftBidAdapter.js @@ -17,12 +17,15 @@ export const tripleliftAdapterSpec = { buildRequests: function(bidRequests, bidderRequest) { let tlCall = STR_ENDPOINT; - let referrer = utils.getTopWindowUrl(); let data = _buildPostBody(bidRequests); tlCall = utils.tryAppendQueryString(tlCall, 'lib', 'prebid'); tlCall = utils.tryAppendQueryString(tlCall, 'v', '$prebid.version$'); - tlCall = utils.tryAppendQueryString(tlCall, 'referrer', referrer); + + if (bidderRequest && bidderRequest.refererInfo) { + let referrer = bidderRequest.refererInfo.referer; + tlCall = utils.tryAppendQueryString(tlCall, 'referrer', referrer); + } if (bidderRequest && bidderRequest.timeout) { tlCall = utils.tryAppendQueryString(tlCall, 'tmax', bidderRequest.timeout); @@ -110,11 +113,11 @@ function _buildResponseObject(bidderRequest, bid) { let width = bid.width || 1; let height = bid.height || 1; let dealId = bid.deal_id || ''; - let creativeId = bid.imp_id; + let creativeId = bid.crid || ''; if (bid.cpm != 0 && bid.ad) { bidResponse = { - requestId: bidderRequest.bids[creativeId].bidId, + requestId: bidderRequest.bids[bid.imp_id].bidId, cpm: bid.cpm, width: width, height: height, diff --git a/test/spec/modules/tripleliftBidAdapter_spec.js b/test/spec/modules/tripleliftBidAdapter_spec.js index d3013d9be22..f614bdbd31a 100644 --- a/test/spec/modules/tripleliftBidAdapter_spec.js +++ b/test/spec/modules/tripleliftBidAdapter_spec.js @@ -68,19 +68,42 @@ describe('triplelift adapter', function () { } ]; + let bidderRequest = { + bidderCode: 'triplelift', + auctionId: 'a7ebcd1d-66ff-4b5c-a82c-6a21a6ee5a18', + bidderRequestId: '5c55612f99bc11', + bids: [ + { + imp_id: 0, + cpm: 1.062, + width: 300, + height: 250, + ad: 'ad-markup', + iurl: 'https://s.adroll.com/a/IYR/N36/IYRN366MFVDITBAGNNT5U6.jpg' + } + ], + refererInfo: { + referer: 'http://examplereferer.com' + }, + gdprConsent: { + consentString: 'BOONm0NOONm0NABABAENAa-AAAARh7______b9_3__7_9uz_Kv_K7Vf7nnG072lPVA9LTOQ6gEaY', + gdprApplies: true + } + }; + it('exists and is an object', function () { - const request = tripleliftAdapterSpec.buildRequests(bidRequests); + const request = tripleliftAdapterSpec.buildRequests(bidRequests, bidderRequest); expect(request).to.exist.and.to.be.a('object'); }); it('should only parse sizes that are of the proper length and format', function () { - const request = tripleliftAdapterSpec.buildRequests(bidRequests); + const request = tripleliftAdapterSpec.buildRequests(bidRequests, bidderRequest); expect(request.data.imp[0].banner.format).to.have.length(2); expect(request.data.imp[0].banner.format).to.deep.equal([{w: 300, h: 250}, {w: 300, h: 600}]); }); it('should be a post request and populate the payload', function () { - const request = tripleliftAdapterSpec.buildRequests(bidRequests); + const request = tripleliftAdapterSpec.buildRequests(bidRequests, bidderRequest); const payload = request.data; expect(payload).to.exist; expect(payload.imp[0].tagid).to.equal('12345'); @@ -89,16 +112,15 @@ describe('triplelift adapter', function () { }); it('should return a query string for TL call', function () { - const request = tripleliftAdapterSpec.buildRequests(bidRequests); + const request = tripleliftAdapterSpec.buildRequests(bidRequests, bidderRequest); const url = request.url; expect(url).to.exist; expect(url).to.be.a('string'); expect(url).to.match(/(?:tlx.3lift.com\/header\/auction)/) expect(url).to.match(/(?:lib=prebid)/) expect(url).to.match(/(?:prebid.version)/) - // expect(url).to.match(/(?:fe=)/) // - expect(url).to.match(/(?:referrer)/) - }) + expect(url).to.match(/(?:referrer)/); + }); }); describe('interpretResponse', function () { @@ -130,8 +152,11 @@ describe('triplelift adapter', function () { iurl: 'https://s.adroll.com/a/IYR/N36/IYRN366MFVDITBAGNNT5U6.jpg' } ], + refererInfo: { + referer: 'http://examplereferer.com' + }, gdprConsent: { - consentString: 'BOONm0NOONma-AAAARh7______b9_3__7_9uz_Kv_K7Vf7nnG072lPVOQ6gEaY', + consentString: 'BOONm0NOONm0NABABAENAa-AAAARh7______b9_3__7_9uz_Kv_K7Vf7nnG072lPVA9LTOQ6gEaY', gdprApplies: true } }; @@ -201,6 +226,9 @@ describe('triplelift adapter', function () { iurl: 'https://s.adroll.com/a/IYR/N36/IYRN366MFVDITBAGNNT5U6.jpg' } ], + refererInfo: { + referer: 'http://examplereferer.com' + }, gdprConsent: { consentString: 'BOONm0NOONm0NABABAENAa-AAAARh7______b9_3__7_9uz_Kv_K7Vf7nnG072lPVA9LTOQ6gEaY', gdprApplies: true