From 0ad32448b86d3fbe2eb39a9e98290cf6e89cfe3f Mon Sep 17 00:00:00 2001 From: bjorn-lw <32431346+bjorn-lw@users.noreply.github.com> Date: Thu, 1 Feb 2024 14:34:24 +0100 Subject: [PATCH] Livewrapped Bidder: add support for ortb2imp (#11026) * Added support for the Price Floors Module * Use the ad server's currency when getting prices from the floors module * Default to USD if the ad server's currency can't be retrieved * Set the default currency at the right place * Added tests and made a minor change in how device width and height are calculated * Only include flrCur when ad requests contain floors * Use ortb native * Read ortb2imp --------- Co-authored-by: msmeza --- modules/livewrappedBidAdapter.js | 6 +- .../modules/livewrappedBidAdapter_spec.js | 222 +++++++++++++++--- 2 files changed, 190 insertions(+), 38 deletions(-) diff --git a/modules/livewrappedBidAdapter.js b/modules/livewrappedBidAdapter.js index cf1e690d862..cfbd2b5b3b5 100644 --- a/modules/livewrappedBidAdapter.js +++ b/modules/livewrappedBidAdapter.js @@ -4,7 +4,6 @@ import {config} from '../src/config.js'; import {find} from '../src/polyfill.js'; import {BANNER, NATIVE, VIDEO} from '../src/mediaTypes.js'; import {getStorageManager} from '../src/storageManager.js'; -import { convertOrtbRequestToProprietaryNative } from '../src/native.js'; /** * @typedef {import('../src/adapters/bidderFactory.js').BidRequest} BidRequest @@ -52,9 +51,6 @@ export const spec = { * @return ServerRequest Info describing the request to the server. */ buildRequests: function(bidRequests, bidderRequest) { - // convert Native ORTB definition to old-style prebid native definition - bidRequests = convertOrtbRequestToProprietaryNative(bidRequests); - const userId = find(bidRequests, hasUserId); const pubcid = find(bidRequests, hasPubcid); const publisherId = find(bidRequests, hasPublisherId); @@ -236,9 +232,9 @@ function bidToAdRequest(bid, currency) { adUnitId: bid.params.adUnitId, callerAdUnitId: bid.params.adUnitName || bid.adUnitCode || bid.placementCode, bidId: bid.bidId, - transactionId: bid.ortb2Imp?.ext?.tid, formats: getSizes(bid).map(sizeToFormat), flr: getBidFloor(bid, currency), + rtbData: bid.ortb2Imp, options: bid.params.options }; diff --git a/test/spec/modules/livewrappedBidAdapter_spec.js b/test/spec/modules/livewrappedBidAdapter_spec.js index 52eaf8d7d76..5ab00859d81 100644 --- a/test/spec/modules/livewrappedBidAdapter_spec.js +++ b/test/spec/modules/livewrappedBidAdapter_spec.js @@ -38,10 +38,9 @@ describe('Livewrapped adapter tests', function () { auctionId: 'F7557995-65F5-4682-8782-7D5D34D82A8C', ortb2Imp: { ext: { - tid: '3D1C8CF7-D288-4D7F-8ADD-97C553056C3D' + tid: '3D1C8CF7-D288-4D7F-8ADD-97C553056C3D', } }, - transactionId: '3D1C8CF7-D288-4D7F-8ADD-97C553056C3D' } ], start: 1472239426002, @@ -120,8 +119,49 @@ describe('Livewrapped adapter tests', function () { adUnitId: '9E153CED-61BC-479E-98DF-24DC0D01BA37', callerAdUnitId: 'panorama_d_1', bidId: '2ffb201a808da7', - transactionId: '3D1C8CF7-D288-4D7F-8ADD-97C553056C3D', - formats: [{width: 980, height: 240}, {width: 980, height: 120}] + formats: [{width: 980, height: 240}, {width: 980, height: 120}], + rtbData: { + ext: { + tid: '3D1C8CF7-D288-4D7F-8ADD-97C553056C3D' + }, + } + }] + }; + + expect(data).to.deep.equal(expectedQuery); + }); + + it('should send ortb2Imp', function() { + sandbox.stub(utils, 'isSafariBrowser').callsFake(() => false); + sandbox.stub(storage, 'cookiesAreEnabled').callsFake(() => true); + let ortb2ImpRequest = clone(bidderRequest); + ortb2ImpRequest.bids[0].ortb2Imp.ext.data = {key: 'value'}; + let result = spec.buildRequests(ortb2ImpRequest.bids, ortb2ImpRequest); + let data = JSON.parse(result.data); + + expect(result.url).to.equal('https://lwadm.com/ad'); + + let expectedQuery = { + auctionId: 'F7557995-65F5-4682-8782-7D5D34D82A8C', + publisherId: '26947112-2289-405D-88C1-A7340C57E63E', + userId: 'user id', + url: 'https://www.domain.com', + seats: {'dsp': ['seat 1']}, + version: '1.4', + width: 100, + height: 100, + cookieSupport: true, + adRequests: [{ + adUnitId: '9E153CED-61BC-479E-98DF-24DC0D01BA37', + callerAdUnitId: 'panorama_d_1', + bidId: '2ffb201a808da7', + formats: [{width: 980, height: 240}, {width: 980, height: 120}], + rtbData: { + ext: { + data: {key: 'value'}, + tid: '3D1C8CF7-D288-4D7F-8ADD-97C553056C3D' + }, + } }] }; @@ -157,12 +197,20 @@ describe('Livewrapped adapter tests', function () { adUnitId: '9E153CED-61BC-479E-98DF-24DC0D01BA37', callerAdUnitId: 'panorama_d_1', bidId: '2ffb201a808da7', - transactionId: '3D1C8CF7-D288-4D7F-8ADD-97C553056C3D', + rtbData: { + ext: { + tid: '3D1C8CF7-D288-4D7F-8ADD-97C553056C3D' + }, + }, formats: [{width: 980, height: 240}, {width: 980, height: 120}] }, { callerAdUnitId: 'box_d_1', bidId: '3ffb201a808da7', - transactionId: '3D1C8CF7-D288-4D7F-8ADD-97C553056C3D', + rtbData: { + ext: { + tid: '3D1C8CF7-D288-4D7F-8ADD-97C553056C3D' + }, + }, formats: [{width: 300, height: 250}] }] }; @@ -194,7 +242,11 @@ describe('Livewrapped adapter tests', function () { adRequests: [{ callerAdUnitId: 'caller id 1', bidId: '2ffb201a808da7', - transactionId: '3D1C8CF7-D288-4D7F-8ADD-97C553056C3D', + rtbData: { + ext: { + tid: '3D1C8CF7-D288-4D7F-8ADD-97C553056C3D' + }, + }, formats: [{width: 980, height: 240}, {width: 980, height: 120}] }] }; @@ -225,7 +277,11 @@ describe('Livewrapped adapter tests', function () { adRequests: [{ callerAdUnitId: 'panorama_d_1', bidId: '2ffb201a808da7', - transactionId: '3D1C8CF7-D288-4D7F-8ADD-97C553056C3D', + rtbData: { + ext: { + tid: '3D1C8CF7-D288-4D7F-8ADD-97C553056C3D' + }, + }, formats: [{width: 980, height: 240}, {width: 980, height: 120}] }] }; @@ -256,7 +312,11 @@ describe('Livewrapped adapter tests', function () { adUnitId: '9E153CED-61BC-479E-98DF-24DC0D01BA37', callerAdUnitId: 'panorama_d_1', bidId: '2ffb201a808da7', - transactionId: '3D1C8CF7-D288-4D7F-8ADD-97C553056C3D', + rtbData: { + ext: { + tid: '3D1C8CF7-D288-4D7F-8ADD-97C553056C3D' + }, + }, formats: [{width: 980, height: 240}, {width: 980, height: 120}] }] }; @@ -289,7 +349,11 @@ describe('Livewrapped adapter tests', function () { adRequests: [{ callerAdUnitId: 'panorama_d_1', bidId: '2ffb201a808da7', - transactionId: '3D1C8CF7-D288-4D7F-8ADD-97C553056C3D', + rtbData: { + ext: { + tid: '3D1C8CF7-D288-4D7F-8ADD-97C553056C3D' + }, + }, formats: [{width: 980, height: 240}, {width: 980, height: 120}] }] }; @@ -322,7 +386,11 @@ describe('Livewrapped adapter tests', function () { adRequests: [{ callerAdUnitId: 'panorama_d_1', bidId: '2ffb201a808da7', - transactionId: '3D1C8CF7-D288-4D7F-8ADD-97C553056C3D', + rtbData: { + ext: { + tid: '3D1C8CF7-D288-4D7F-8ADD-97C553056C3D' + }, + }, formats: [{width: 980, height: 240}, {width: 980, height: 120}] }] }; @@ -352,7 +420,11 @@ describe('Livewrapped adapter tests', function () { adRequests: [{ callerAdUnitId: 'panorama_d_1', bidId: '2ffb201a808da7', - transactionId: '3D1C8CF7-D288-4D7F-8ADD-97C553056C3D', + rtbData: { + ext: { + tid: '3D1C8CF7-D288-4D7F-8ADD-97C553056C3D' + }, + }, formats: [{width: 980, height: 240}, {width: 980, height: 120}], options: {keyvalues: [{key: 'key', value: 'value'}]} }] @@ -384,7 +456,11 @@ describe('Livewrapped adapter tests', function () { adRequests: [{ callerAdUnitId: 'panorama_d_1', bidId: '2ffb201a808da7', - transactionId: '3D1C8CF7-D288-4D7F-8ADD-97C553056C3D', + rtbData: { + ext: { + tid: '3D1C8CF7-D288-4D7F-8ADD-97C553056C3D' + }, + }, formats: [{width: 980, height: 240}, {width: 980, height: 120}] }] }; @@ -414,7 +490,11 @@ describe('Livewrapped adapter tests', function () { adRequests: [{ callerAdUnitId: 'panorama_d_1', bidId: '2ffb201a808da7', - transactionId: '3D1C8CF7-D288-4D7F-8ADD-97C553056C3D', + rtbData: { + ext: { + tid: '3D1C8CF7-D288-4D7F-8ADD-97C553056C3D' + }, + }, formats: [{width: 980, height: 240}, {width: 980, height: 120}], native: {'nativedata': 'content parsed serverside only'} }] @@ -445,7 +525,11 @@ describe('Livewrapped adapter tests', function () { adRequests: [{ callerAdUnitId: 'panorama_d_1', bidId: '2ffb201a808da7', - transactionId: '3D1C8CF7-D288-4D7F-8ADD-97C553056C3D', + rtbData: { + ext: { + tid: '3D1C8CF7-D288-4D7F-8ADD-97C553056C3D' + }, + }, formats: [{width: 980, height: 240}, {width: 980, height: 120}], native: {'nativedata': 'content parsed serverside only'}, banner: true @@ -477,7 +561,11 @@ describe('Livewrapped adapter tests', function () { adRequests: [{ callerAdUnitId: 'panorama_d_1', bidId: '2ffb201a808da7', - transactionId: '3D1C8CF7-D288-4D7F-8ADD-97C553056C3D', + rtbData: { + ext: { + tid: '3D1C8CF7-D288-4D7F-8ADD-97C553056C3D' + }, + }, formats: [{width: 980, height: 240}, {width: 980, height: 120}], video: {'videodata': 'content parsed serverside only'} }] @@ -525,7 +613,11 @@ describe('Livewrapped adapter tests', function () { adUnitId: '9E153CED-61BC-479E-98DF-24DC0D01BA37', callerAdUnitId: 'panorama_d_1', bidId: '2ffb201a808da7', - transactionId: '3D1C8CF7-D288-4D7F-8ADD-97C553056C3D', + rtbData: { + ext: { + tid: '3D1C8CF7-D288-4D7F-8ADD-97C553056C3D' + }, + }, formats: [{width: 980, height: 240}, {width: 980, height: 120}] }] }; @@ -555,7 +647,11 @@ describe('Livewrapped adapter tests', function () { adRequests: [{ callerAdUnitId: 'panorama_d_1', bidId: '2ffb201a808da7', - transactionId: '3D1C8CF7-D288-4D7F-8ADD-97C553056C3D', + rtbData: { + ext: { + tid: '3D1C8CF7-D288-4D7F-8ADD-97C553056C3D' + }, + }, formats: [{width: 728, height: 90}] }] }; @@ -592,7 +688,11 @@ describe('Livewrapped adapter tests', function () { adUnitId: '9E153CED-61BC-479E-98DF-24DC0D01BA37', callerAdUnitId: 'panorama_d_1', bidId: '2ffb201a808da7', - transactionId: '3D1C8CF7-D288-4D7F-8ADD-97C553056C3D', + rtbData: { + ext: { + tid: '3D1C8CF7-D288-4D7F-8ADD-97C553056C3D' + }, + }, formats: [{width: 980, height: 240}, {width: 980, height: 120}] }] }; @@ -627,7 +727,11 @@ describe('Livewrapped adapter tests', function () { adUnitId: '9E153CED-61BC-479E-98DF-24DC0D01BA37', callerAdUnitId: 'panorama_d_1', bidId: '2ffb201a808da7', - transactionId: '3D1C8CF7-D288-4D7F-8ADD-97C553056C3D', + rtbData: { + ext: { + tid: '3D1C8CF7-D288-4D7F-8ADD-97C553056C3D' + }, + }, formats: [{width: 980, height: 240}, {width: 980, height: 120}] }] }; @@ -660,7 +764,11 @@ describe('Livewrapped adapter tests', function () { adUnitId: '9E153CED-61BC-479E-98DF-24DC0D01BA37', callerAdUnitId: 'panorama_d_1', bidId: '2ffb201a808da7', - transactionId: '3D1C8CF7-D288-4D7F-8ADD-97C553056C3D', + rtbData: { + ext: { + tid: '3D1C8CF7-D288-4D7F-8ADD-97C553056C3D' + }, + }, formats: [{width: 980, height: 240}, {width: 980, height: 120}] }] }; @@ -700,7 +808,11 @@ describe('Livewrapped adapter tests', function () { adUnitId: '9E153CED-61BC-479E-98DF-24DC0D01BA37', callerAdUnitId: 'panorama_d_1', bidId: '2ffb201a808da7', - transactionId: '3D1C8CF7-D288-4D7F-8ADD-97C553056C3D', + rtbData: { + ext: { + tid: '3D1C8CF7-D288-4D7F-8ADD-97C553056C3D' + }, + }, formats: [{width: 980, height: 240}, {width: 980, height: 120}] }] }; @@ -730,7 +842,11 @@ describe('Livewrapped adapter tests', function () { adUnitId: '9E153CED-61BC-479E-98DF-24DC0D01BA37', callerAdUnitId: 'panorama_d_1', bidId: '2ffb201a808da7', - transactionId: '3D1C8CF7-D288-4D7F-8ADD-97C553056C3D', + rtbData: { + ext: { + tid: '3D1C8CF7-D288-4D7F-8ADD-97C553056C3D' + }, + }, formats: [{width: 980, height: 240}, {width: 980, height: 120}] }] }; @@ -760,7 +876,11 @@ describe('Livewrapped adapter tests', function () { adUnitId: '9E153CED-61BC-479E-98DF-24DC0D01BA37', callerAdUnitId: 'panorama_d_1', bidId: '2ffb201a808da7', - transactionId: '3D1C8CF7-D288-4D7F-8ADD-97C553056C3D', + rtbData: { + ext: { + tid: '3D1C8CF7-D288-4D7F-8ADD-97C553056C3D' + }, + }, formats: [{width: 980, height: 240}, {width: 980, height: 120}] }] }; @@ -810,7 +930,11 @@ describe('Livewrapped adapter tests', function () { adUnitId: '9E153CED-61BC-479E-98DF-24DC0D01BA37', callerAdUnitId: 'panorama_d_1', bidId: '2ffb201a808da7', - transactionId: '3D1C8CF7-D288-4D7F-8ADD-97C553056C3D', + rtbData: { + ext: { + tid: '3D1C8CF7-D288-4D7F-8ADD-97C553056C3D' + }, + }, formats: [{width: 980, height: 240}, {width: 980, height: 120}] }] }; @@ -842,7 +966,11 @@ describe('Livewrapped adapter tests', function () { adUnitId: '9E153CED-61BC-479E-98DF-24DC0D01BA37', callerAdUnitId: 'panorama_d_1', bidId: '2ffb201a808da7', - transactionId: '3D1C8CF7-D288-4D7F-8ADD-97C553056C3D', + rtbData: { + ext: { + tid: '3D1C8CF7-D288-4D7F-8ADD-97C553056C3D' + }, + }, formats: [{width: 980, height: 240}, {width: 980, height: 120}] }] }; @@ -876,7 +1004,11 @@ describe('Livewrapped adapter tests', function () { adUnitId: '9E153CED-61BC-479E-98DF-24DC0D01BA37', callerAdUnitId: 'panorama_d_1', bidId: '2ffb201a808da7', - transactionId: '3D1C8CF7-D288-4D7F-8ADD-97C553056C3D', + rtbData: { + ext: { + tid: '3D1C8CF7-D288-4D7F-8ADD-97C553056C3D' + }, + }, formats: [{width: 980, height: 240}, {width: 980, height: 120}] }] }; @@ -910,7 +1042,11 @@ describe('Livewrapped adapter tests', function () { adUnitId: '9E153CED-61BC-479E-98DF-24DC0D01BA37', callerAdUnitId: 'panorama_d_1', bidId: '2ffb201a808da7', - transactionId: '3D1C8CF7-D288-4D7F-8ADD-97C553056C3D', + rtbData: { + ext: { + tid: '3D1C8CF7-D288-4D7F-8ADD-97C553056C3D' + }, + }, formats: [{width: 980, height: 240}, {width: 980, height: 120}] }] }; @@ -946,7 +1082,11 @@ describe('Livewrapped adapter tests', function () { adUnitId: '9E153CED-61BC-479E-98DF-24DC0D01BA37', callerAdUnitId: 'panorama_d_1', bidId: '2ffb201a808da7', - transactionId: '3D1C8CF7-D288-4D7F-8ADD-97C553056C3D', + rtbData: { + ext: { + tid: '3D1C8CF7-D288-4D7F-8ADD-97C553056C3D' + }, + }, formats: [{width: 980, height: 240}, {width: 980, height: 120}] }] }; @@ -982,7 +1122,11 @@ describe('Livewrapped adapter tests', function () { adUnitId: '9E153CED-61BC-479E-98DF-24DC0D01BA37', callerAdUnitId: 'panorama_d_1', bidId: '2ffb201a808da7', - transactionId: '3D1C8CF7-D288-4D7F-8ADD-97C553056C3D', + rtbData: { + ext: { + tid: '3D1C8CF7-D288-4D7F-8ADD-97C553056C3D' + }, + }, formats: [{width: 980, height: 240}, {width: 980, height: 120}] }] }; @@ -1018,7 +1162,11 @@ describe('Livewrapped adapter tests', function () { adUnitId: '9E153CED-61BC-479E-98DF-24DC0D01BA37', callerAdUnitId: 'panorama_d_1', bidId: '2ffb201a808da7', - transactionId: '3D1C8CF7-D288-4D7F-8ADD-97C553056C3D', + rtbData: { + ext: { + tid: '3D1C8CF7-D288-4D7F-8ADD-97C553056C3D' + }, + }, formats: [{width: 980, height: 240}, {width: 980, height: 120}] }] }; @@ -1063,7 +1211,11 @@ describe('Livewrapped adapter tests', function () { adUnitId: '9E153CED-61BC-479E-98DF-24DC0D01BA37', callerAdUnitId: 'panorama_d_1', bidId: '2ffb201a808da7', - transactionId: '3D1C8CF7-D288-4D7F-8ADD-97C553056C3D', + rtbData: { + ext: { + tid: '3D1C8CF7-D288-4D7F-8ADD-97C553056C3D' + }, + }, formats: [{width: 980, height: 240}, {width: 980, height: 120}], flr: 10 }] @@ -1101,7 +1253,11 @@ describe('Livewrapped adapter tests', function () { adUnitId: '9E153CED-61BC-479E-98DF-24DC0D01BA37', callerAdUnitId: 'panorama_d_1', bidId: '2ffb201a808da7', - transactionId: '3D1C8CF7-D288-4D7F-8ADD-97C553056C3D', + rtbData: { + ext: { + tid: '3D1C8CF7-D288-4D7F-8ADD-97C553056C3D' + }, + }, formats: [{width: 980, height: 240}, {width: 980, height: 120}], flr: 10 }]