From d49b56a6a397bf34a60d0a67410a589ae98b05bb Mon Sep 17 00:00:00 2001 From: Fatih Kaya Date: Wed, 19 Oct 2022 16:59:00 +0300 Subject: [PATCH 01/57] Admatic Bidder Adaptor --- modules/admaticBidAdapter.js | 147 ++++++++++++++++++++ modules/admaticBidAdapter.md | 48 +++++++ src/adloader.js | 1 + test/spec/modules/admaticBidAdapter_spec.js | 46 ++++++ 4 files changed, 242 insertions(+) create mode 100644 modules/admaticBidAdapter.js create mode 100644 modules/admaticBidAdapter.md create mode 100644 test/spec/modules/admaticBidAdapter_spec.js diff --git a/modules/admaticBidAdapter.js b/modules/admaticBidAdapter.js new file mode 100644 index 00000000000..039f27e5de0 --- /dev/null +++ b/modules/admaticBidAdapter.js @@ -0,0 +1,147 @@ +import { getValue, logError, deepAccess, getBidIdParameter, isArray } from '../src/utils.js'; +import { loadExternalScript } from '../src/adloader.js'; +import {registerBidder} from '../src/adapters/bidderFactory.js'; + +const ENDPOINT_URL = 'https://layer.serve.admatic.com.tr/pb'; +const SYNC_URL = 'https://cdn.serve.admatic.com.tr/showad/sync.js'; +const BIDDER_CODE = 'admatic'; + +export const spec = { + code: 'admatic', + supportedMediaTypes: ['video', 'banner'], + /** + * Determines whether or not the given bid request is valid. + * + * @param {BidRequest} bid The bid params to validate. + * @return boolean True if this is a valid bid, and false otherwise. + */ + isBidRequestValid: function(bid) { + let isValid = false; + if (typeof bid.params !== 'undefined') { + let isValidNetworkId = _validateId(getValue(bid.params, 'networkId')); + isValid = isValidNetworkId;// && isValidTypeId; + } + + if (!isValid) { + logError('AdMatic networkId parameters are required. Bid aborted.'); + } + return isValid; + }, + /** + * Make a server request from the list of BidRequests. + * + * @param {validBidRequests[]} an array of bids + * @return ServerRequest Info describing the request to the server. + */ + buildRequests: function(validBidRequests, bidderRequest) { + const bids = validBidRequests.map(buildRequestObject); + const networkId = getValue(validBidRequests[0].params, 'networkId'); + const currency = getValue(validBidRequests[0].params, 'currency') || 'TRY'; + + setTimeout(() => { + loadExternalScript(SYNC_URL, BIDDER_CODE); + }, bidderRequest.timeout); + + const payload = { + 'user': { + 'ua': navigator.userAgent + }, + 'blacklist': [], + 'site': { + 'page': location.href, + 'ref': location.origin, + 'publisher': { + 'name': location.hostname, + 'publisherId': networkId + } + }, + imp: bids, + ext: { + 'cur': currency, + 'type': 'admatic' + } + }; + + const payloadString = JSON.stringify(payload); + return { + method: 'POST', + url: ENDPOINT_URL, + data: payloadString, + options: { + contentType: 'application/json' + } + }; + }, + /** + * Unpack the response from the server into a list of bids. + * + * @param {*} serverResponse A successful response from the server. + * @return {Bid[]} An array of bids which were nested inside the server. + */ + interpretResponse: (response, request) => { + const body = response.body || response; + const bidResponses = []; + if (body.data.length > 0) { + body.data.forEach(function (bid) { + const resbid = { + requestId: bid.id, + cpm: bid.price, + width: bid.width, + height: bid.height, + currency: body.cur, + netRevenue: true, + ad: bid.party_tag, + creativeId: bid.creative_id, + meta: { + advertiserDomains: bid && bid.adomain ? bid.adomain : [] + }, + ttl: 360, + bidder: 'admatic', + timeToRespond: 1, + requestTimestamp: 1 + }; + bidResponses.push(resbid); + }); + }; + return bidResponses; + } +}; + +function buildRequestObject(bid) { + const reqObj = {}; + reqObj.size = getSizes(bid); + reqObj.id = getBidIdParameter('bidId', bid); + reqObj.floor = getValue(bid.params, 'floor') || 0.01; + return reqObj; +} + +function getSizes(bid) { + return concatSizes(bid); +} + +function concatSizes(bid) { + let playerSize = deepAccess(bid, 'mediaTypes.video.playerSize'); + let videoSizes = deepAccess(bid, 'mediaTypes.video.sizes'); + let bannerSizes = deepAccess(bid, 'mediaTypes.banner.sizes'); + + if (isArray(bannerSizes) || isArray(playerSize) || isArray(videoSizes)) { + let mediaTypesSizes = [bannerSizes, videoSizes, playerSize]; + return mediaTypesSizes + .reduce(function(acc, currSize) { + if (isArray(currSize)) { + if (isArray(currSize[0])) { + currSize.forEach(function (childSize) { + acc.push({ w: childSize[0], h: childSize[1] }); + }) + } + } + return acc; + }, []); + } +} + +function _validateId(id) { + return (parseInt(id) > 0); +} + +registerBidder(spec); diff --git a/modules/admaticBidAdapter.md b/modules/admaticBidAdapter.md new file mode 100644 index 00000000000..7040855e296 --- /dev/null +++ b/modules/admaticBidAdapter.md @@ -0,0 +1,48 @@ +# Overview + +**Module Name**: Admatic Bidder Adapter +**Module Type**: Bidder Adapter +**Maintainer**: prebid.js@admatic.com.tr + +# Description + +Use `admatic` as bidder. + +`networkId` & `typeId` are required and must be integers. + +## AdUnits configuration example +``` + var adUnits = [{ + code: 'your-slot_1-div', //use exactly the same code as your slot div id. + sizes: [[300, 250]], + bids: [{ + bidder: 'admatic', + params: { + placementId: 12345, + pageId: 14 + } + }] + },{ + code: 'your-slot_2-div', //use exactly the same code as your slot div id. + sizes: [[600, 800]], + bids: [{ + bidder: 'admatic', + params: { + placementId: 12345, + pageId: 9 + } + }] + }]; +``` + +## UserSync example + +``` +pbjs.setConfig({ + userSync: { + iframeEnabled: true, + syncEnabled: true, + syncDelay: 1 + } +}); +``` diff --git a/src/adloader.js b/src/adloader.js index 6b7427d3e52..add5863ddf2 100644 --- a/src/adloader.js +++ b/src/adloader.js @@ -6,6 +6,7 @@ const _requestCache = new WeakMap(); const _approvedLoadExternalJSList = [ 'debugging', 'adloox', + 'admatic', 'criteo', 'outstream', 'adagio', diff --git a/test/spec/modules/admaticBidAdapter_spec.js b/test/spec/modules/admaticBidAdapter_spec.js new file mode 100644 index 00000000000..c7d391cfaca --- /dev/null +++ b/test/spec/modules/admaticBidAdapter_spec.js @@ -0,0 +1,46 @@ +import {expect} from 'chai'; +import {spec, storage} from 'modules/admaticBidAdapter.js'; +import {newBidder} from 'src/adapters/bidderFactory.js'; +import {getStorageManager} from 'src/storageManager'; + +const ENDPOINT = 'https://layer.serve.admatic.com.tr/v1'; + +describe('admaticBidAdapter', () => { + const adapter = newBidder(spec); + + describe('inherited functions', () => { + it('exists and is a function', () => { + expect(adapter.callBids).to.exist.and.to.be.a('function'); + }); + }); + + describe('isBidRequestValid', function() { + let bid = { + 'bidder': 'admatic', + 'params': { + 'networkId': 10433394 + }, + 'adUnitCode': 'adunit-code', + 'sizes': [[300, 250], [300, 600]], + 'bidId': '30b31c1838de1e', + 'bidderRequestId': '22edbae2733bf6', + 'auctionId': '1d1a030790a475', + 'creativeId': 'er2ee' + }; + + it('should return true when required params found', function() { + expect(spec.isBidRequestValid(bid)).to.equal(true); + }); + + it('should return false when required params are not passed', function() { + let bid = Object.assign({}, bid); + delete bid.params; + + bid.params = { + 'networkId': 0 + }; + + expect(spec.isBidRequestValid(bid)).to.equal(false); + }); + }); +}); From e582645b08ac261dc4bd6e616ac50cc861d29586 Mon Sep 17 00:00:00 2001 From: Fatih Kaya Date: Wed, 19 Oct 2022 21:29:55 +0300 Subject: [PATCH 02/57] Update admaticBidAdapter.md --- modules/admaticBidAdapter.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/admaticBidAdapter.md b/modules/admaticBidAdapter.md index 7040855e296..9400d0235dd 100644 --- a/modules/admaticBidAdapter.md +++ b/modules/admaticBidAdapter.md @@ -2,13 +2,13 @@ **Module Name**: Admatic Bidder Adapter **Module Type**: Bidder Adapter -**Maintainer**: prebid.js@admatic.com.tr +**Maintainer**: prebid@admatic.com.tr # Description Use `admatic` as bidder. -`networkId` & `typeId` are required and must be integers. +`networkId` is required and must be integer. ## AdUnits configuration example ``` @@ -19,7 +19,7 @@ Use `admatic` as bidder. bidder: 'admatic', params: { placementId: 12345, - pageId: 14 + floor: 0.5 } }] },{ @@ -29,7 +29,7 @@ Use `admatic` as bidder. bidder: 'admatic', params: { placementId: 12345, - pageId: 9 + floor: 0.5 } }] }]; From 4c4c06aa371f3a94bd93b8cb02b378be6cf6df61 Mon Sep 17 00:00:00 2001 From: Fatih Kaya Date: Fri, 28 Oct 2022 23:39:46 +0300 Subject: [PATCH 03/57] Update admaticBidAdapter.md --- modules/admaticBidAdapter.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/admaticBidAdapter.md b/modules/admaticBidAdapter.md index 9400d0235dd..de84998d0af 100644 --- a/modules/admaticBidAdapter.md +++ b/modules/admaticBidAdapter.md @@ -18,7 +18,7 @@ Use `admatic` as bidder. bids: [{ bidder: 'admatic', params: { - placementId: 12345, + networkId: 12345, floor: 0.5 } }] @@ -28,7 +28,7 @@ Use `admatic` as bidder. bids: [{ bidder: 'admatic', params: { - placementId: 12345, + networkId: 12345, floor: 0.5 } }] From 7a23b055ccd4ea23d23e73248e82b21bc6f69d90 Mon Sep 17 00:00:00 2001 From: Fatih Kaya Date: Mon, 31 Oct 2022 19:29:52 +0300 Subject: [PATCH 04/57] remove floor parameter --- modules/admaticBidAdapter.js | 1 - modules/admaticBidAdapter.md | 6 ++---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/modules/admaticBidAdapter.js b/modules/admaticBidAdapter.js index 039f27e5de0..8c7a0f4015d 100644 --- a/modules/admaticBidAdapter.js +++ b/modules/admaticBidAdapter.js @@ -111,7 +111,6 @@ function buildRequestObject(bid) { const reqObj = {}; reqObj.size = getSizes(bid); reqObj.id = getBidIdParameter('bidId', bid); - reqObj.floor = getValue(bid.params, 'floor') || 0.01; return reqObj; } diff --git a/modules/admaticBidAdapter.md b/modules/admaticBidAdapter.md index de84998d0af..0496f40e881 100644 --- a/modules/admaticBidAdapter.md +++ b/modules/admaticBidAdapter.md @@ -18,8 +18,7 @@ Use `admatic` as bidder. bids: [{ bidder: 'admatic', params: { - networkId: 12345, - floor: 0.5 + networkId: 12345 } }] },{ @@ -28,8 +27,7 @@ Use `admatic` as bidder. bids: [{ bidder: 'admatic', params: { - networkId: 12345, - floor: 0.5 + networkId: 12345 } }] }]; From 7a845b7151bbb08addfb58ea9bd5b44167cc8a4e Mon Sep 17 00:00:00 2001 From: Fatih Kaya Date: Tue, 1 Nov 2022 00:21:22 +0300 Subject: [PATCH 05/57] Update admaticBidAdapter.js --- modules/admaticBidAdapter.js | 52 +++++++++++++++++++++++++++++++++++- 1 file changed, 51 insertions(+), 1 deletion(-) diff --git a/modules/admaticBidAdapter.js b/modules/admaticBidAdapter.js index 8c7a0f4015d..dc252fb2e28 100644 --- a/modules/admaticBidAdapter.js +++ b/modules/admaticBidAdapter.js @@ -1,6 +1,7 @@ import { getValue, logError, deepAccess, getBidIdParameter, isArray } from '../src/utils.js'; import { loadExternalScript } from '../src/adloader.js'; -import {registerBidder} from '../src/adapters/bidderFactory.js'; +import { registerBidder } from '../src/adapters/bidderFactory.js'; +import { BANNER, VIDEO } from '../src/mediaTypes.js'; const ENDPOINT_URL = 'https://layer.serve.admatic.com.tr/pb'; const SYNC_URL = 'https://cdn.serve.admatic.com.tr/showad/sync.js'; @@ -100,6 +101,7 @@ export const spec = { timeToRespond: 1, requestTimestamp: 1 }; + bidResponses.push(resbid); }); }; @@ -107,10 +109,58 @@ export const spec = { } }; +function enrichSlotWithFloors(slot, bidRequest) { + try { + const slotFloors = {}; + + if (bidRequest.getFloor) { + if (bidRequest.mediaTypes?.banner) { + slotFloors.banner = {}; + const bannerSizes = parseSizes(deepAccess(bidRequest, 'mediaTypes.banner.sizes')) + bannerSizes.forEach(bannerSize => slotFloors.banner[parseSize(bannerSize).toString()] = bidRequest.getFloor({ size: bannerSize, mediaType: BANNER })); + } + + if (bidRequest.mediaTypes?.video) { + slotFloors.video = {}; + const videoSizes = parseSizes(deepAccess(bidRequest, 'mediaTypes.video.playerSize')) + videoSizes.forEach(videoSize => slotFloors.video[parseSize(videoSize).toString()] = bidRequest.getFloor({ size: videoSize, mediaType: VIDEO })); + } + + if (Object.keys(slotFloors).length > 0) { + if (!slot) { + slot = {} + } + Object.assign(slot, { + floors: slotFloors + }); + } + } + } catch (e) { + logError('Could not parse floors from Prebid: ' + e); + } +} + +function parseSizes(sizes, parser = s => s) { + if (sizes == undefined) { + return []; + } + if (Array.isArray(sizes[0])) { // is there several sizes ? (ie. [[728,90],[200,300]]) + return sizes.map(size => parser(size)); + } + return [parser(sizes)]; // or a single one ? (ie. [728,90]) +} + +function parseSize(size) { + return size[0] + 'x' + size[1]; +} + function buildRequestObject(bid) { const reqObj = {}; reqObj.size = getSizes(bid); reqObj.id = getBidIdParameter('bidId', bid); + + enrichSlotWithFloors(reqObj, bid); + return reqObj; } From 7a2e0e29c49e2f876b68aafe886b336fe2fe6fcb Mon Sep 17 00:00:00 2001 From: Fatih Kaya Date: Fri, 4 Nov 2022 10:09:41 +0300 Subject: [PATCH 06/57] Admatic Bid Adapter: alias and bid floor features activated --- modules/admaticBidAdapter.js | 23 ++++++++++++++--------- modules/admaticBidAdapter.md | 7 ++++--- src/adloader.js | 1 + 3 files changed, 19 insertions(+), 12 deletions(-) diff --git a/modules/admaticBidAdapter.js b/modules/admaticBidAdapter.js index dc252fb2e28..b139b58da46 100644 --- a/modules/admaticBidAdapter.js +++ b/modules/admaticBidAdapter.js @@ -2,13 +2,13 @@ import { getValue, logError, deepAccess, getBidIdParameter, isArray } from '../s import { loadExternalScript } from '../src/adloader.js'; import { registerBidder } from '../src/adapters/bidderFactory.js'; import { BANNER, VIDEO } from '../src/mediaTypes.js'; - -const ENDPOINT_URL = 'https://layer.serve.admatic.com.tr/pb'; const SYNC_URL = 'https://cdn.serve.admatic.com.tr/showad/sync.js'; -const BIDDER_CODE = 'admatic'; export const spec = { code: 'admatic', + aliases: [ + {code: 'adpixel'} + ], supportedMediaTypes: ['video', 'banner'], /** * Determines whether or not the given bid request is valid. @@ -20,11 +20,12 @@ export const spec = { let isValid = false; if (typeof bid.params !== 'undefined') { let isValidNetworkId = _validateId(getValue(bid.params, 'networkId')); - isValid = isValidNetworkId;// && isValidTypeId; + let isValidHost = getValue(bid.params, 'host'); + isValid = isValidNetworkId && isValidHost; } if (!isValid) { - logError('AdMatic networkId parameters are required. Bid aborted.'); + logError(`${bid.bidder} networkId and host parameters are required. Bid aborted.`); } return isValid; }, @@ -36,11 +37,13 @@ export const spec = { */ buildRequests: function(validBidRequests, bidderRequest) { const bids = validBidRequests.map(buildRequestObject); + const bidderName = validBidRequests[0].bidder; const networkId = getValue(validBidRequests[0].params, 'networkId'); + const host = getValue(validBidRequests[0].params, 'host'); const currency = getValue(validBidRequests[0].params, 'currency') || 'TRY'; setTimeout(() => { - loadExternalScript(SYNC_URL, BIDDER_CODE); + loadExternalScript(SYNC_URL, bidderName); }, bidderRequest.timeout); const payload = { @@ -59,14 +62,14 @@ export const spec = { imp: bids, ext: { 'cur': currency, - 'type': 'admatic' + 'bidder': bidderName } }; const payloadString = JSON.stringify(payload); return { method: 'POST', - url: ENDPOINT_URL, + url: `https://${host}/pb?bidder=${bidderName}`, data: payloadString, options: { contentType: 'application/json' @@ -97,7 +100,7 @@ export const spec = { advertiserDomains: bid && bid.adomain ? bid.adomain : [] }, ttl: 360, - bidder: 'admatic', + bidder: JSON.parse(request.data).ext.bidder, timeToRespond: 1, requestTimestamp: 1 }; @@ -109,6 +112,8 @@ export const spec = { } }; +registerBidder(spec); + function enrichSlotWithFloors(slot, bidRequest) { try { const slotFloors = {}; diff --git a/modules/admaticBidAdapter.md b/modules/admaticBidAdapter.md index 0496f40e881..b12aebe5f72 100644 --- a/modules/admaticBidAdapter.md +++ b/modules/admaticBidAdapter.md @@ -18,7 +18,8 @@ Use `admatic` as bidder. bids: [{ bidder: 'admatic', params: { - networkId: 12345 + networkId: 12345, + host: 'layer.serve.admatic.com.tr' } }] },{ @@ -27,14 +28,14 @@ Use `admatic` as bidder. bids: [{ bidder: 'admatic', params: { - networkId: 12345 + networkId: 12345, + host: 'layer.serve.admatic.com.tr' } }] }]; ``` ## UserSync example - ``` pbjs.setConfig({ userSync: { diff --git a/src/adloader.js b/src/adloader.js index add5863ddf2..5cf7af5231e 100644 --- a/src/adloader.js +++ b/src/adloader.js @@ -7,6 +7,7 @@ const _approvedLoadExternalJSList = [ 'debugging', 'adloox', 'admatic', + 'adpixel', 'criteo', 'outstream', 'adagio', From de7ac85981b1ba3ad8c5d1dc95c5dadbdf5b9895 Mon Sep 17 00:00:00 2001 From: Fatih Kaya Date: Fri, 4 Nov 2022 10:29:39 +0300 Subject: [PATCH 07/57] Admatic adapter: host param control changed --- modules/admaticBidAdapter.js | 6 +++++- test/spec/modules/admaticBidAdapter_spec.js | 8 +++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/modules/admaticBidAdapter.js b/modules/admaticBidAdapter.js index b139b58da46..c20c263743c 100644 --- a/modules/admaticBidAdapter.js +++ b/modules/admaticBidAdapter.js @@ -20,7 +20,7 @@ export const spec = { let isValid = false; if (typeof bid.params !== 'undefined') { let isValidNetworkId = _validateId(getValue(bid.params, 'networkId')); - let isValidHost = getValue(bid.params, 'host'); + let isValidHost = _validateString(getValue(bid.params, 'host')); isValid = isValidNetworkId && isValidHost; } @@ -198,4 +198,8 @@ function _validateId(id) { return (parseInt(id) > 0); } +function _validateString(str) { + return (typeof str == 'string'); +} + registerBidder(spec); diff --git a/test/spec/modules/admaticBidAdapter_spec.js b/test/spec/modules/admaticBidAdapter_spec.js index c7d391cfaca..ffe2274ae7b 100644 --- a/test/spec/modules/admaticBidAdapter_spec.js +++ b/test/spec/modules/admaticBidAdapter_spec.js @@ -3,7 +3,7 @@ import {spec, storage} from 'modules/admaticBidAdapter.js'; import {newBidder} from 'src/adapters/bidderFactory.js'; import {getStorageManager} from 'src/storageManager'; -const ENDPOINT = 'https://layer.serve.admatic.com.tr/v1'; +const ENDPOINT = 'https://layer.serve.admatic.com.tr/pb'; describe('admaticBidAdapter', () => { const adapter = newBidder(spec); @@ -18,7 +18,8 @@ describe('admaticBidAdapter', () => { let bid = { 'bidder': 'admatic', 'params': { - 'networkId': 10433394 + 'networkId': 10433394, + 'host': 'layer.serve.admatic.com.tr' }, 'adUnitCode': 'adunit-code', 'sizes': [[300, 250], [300, 600]], @@ -37,7 +38,8 @@ describe('admaticBidAdapter', () => { delete bid.params; bid.params = { - 'networkId': 0 + 'networkId': 0, + 'host': 'layer.serve.admatic.com.tr' }; expect(spec.isBidRequestValid(bid)).to.equal(false); From 661c54f9b2397e8f25c257144d73161e13466281 Mon Sep 17 00:00:00 2001 From: Fatih Kaya Date: Fri, 4 Nov 2022 11:02:27 +0300 Subject: [PATCH 08/57] Alias name changed. --- modules/admaticBidAdapter.js | 2 +- src/adloader.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/admaticBidAdapter.js b/modules/admaticBidAdapter.js index c20c263743c..cf54557c6c8 100644 --- a/modules/admaticBidAdapter.js +++ b/modules/admaticBidAdapter.js @@ -7,7 +7,7 @@ const SYNC_URL = 'https://cdn.serve.admatic.com.tr/showad/sync.js'; export const spec = { code: 'admatic', aliases: [ - {code: 'adpixel'} + {code: 'pixad'} ], supportedMediaTypes: ['video', 'banner'], /** diff --git a/src/adloader.js b/src/adloader.js index 5cf7af5231e..167ffb75476 100644 --- a/src/adloader.js +++ b/src/adloader.js @@ -7,7 +7,7 @@ const _approvedLoadExternalJSList = [ 'debugging', 'adloox', 'admatic', - 'adpixel', + 'pixad', 'criteo', 'outstream', 'adagio', From 42675a0fbfcd2184c92cbc7772cc890cfa869bb0 Mon Sep 17 00:00:00 2001 From: Fatih Kaya Date: Fri, 4 Nov 2022 22:39:28 +0300 Subject: [PATCH 09/57] Revert "Admatic adapter: host param control changed" This reverts commit de7ac85981b1ba3ad8c5d1dc95c5dadbdf5b9895. --- modules/admaticBidAdapter.js | 6 +----- test/spec/modules/admaticBidAdapter_spec.js | 8 +++----- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/modules/admaticBidAdapter.js b/modules/admaticBidAdapter.js index cf54557c6c8..5556a181f7f 100644 --- a/modules/admaticBidAdapter.js +++ b/modules/admaticBidAdapter.js @@ -20,7 +20,7 @@ export const spec = { let isValid = false; if (typeof bid.params !== 'undefined') { let isValidNetworkId = _validateId(getValue(bid.params, 'networkId')); - let isValidHost = _validateString(getValue(bid.params, 'host')); + let isValidHost = getValue(bid.params, 'host'); isValid = isValidNetworkId && isValidHost; } @@ -198,8 +198,4 @@ function _validateId(id) { return (parseInt(id) > 0); } -function _validateString(str) { - return (typeof str == 'string'); -} - registerBidder(spec); diff --git a/test/spec/modules/admaticBidAdapter_spec.js b/test/spec/modules/admaticBidAdapter_spec.js index ffe2274ae7b..c7d391cfaca 100644 --- a/test/spec/modules/admaticBidAdapter_spec.js +++ b/test/spec/modules/admaticBidAdapter_spec.js @@ -3,7 +3,7 @@ import {spec, storage} from 'modules/admaticBidAdapter.js'; import {newBidder} from 'src/adapters/bidderFactory.js'; import {getStorageManager} from 'src/storageManager'; -const ENDPOINT = 'https://layer.serve.admatic.com.tr/pb'; +const ENDPOINT = 'https://layer.serve.admatic.com.tr/v1'; describe('admaticBidAdapter', () => { const adapter = newBidder(spec); @@ -18,8 +18,7 @@ describe('admaticBidAdapter', () => { let bid = { 'bidder': 'admatic', 'params': { - 'networkId': 10433394, - 'host': 'layer.serve.admatic.com.tr' + 'networkId': 10433394 }, 'adUnitCode': 'adunit-code', 'sizes': [[300, 250], [300, 600]], @@ -38,8 +37,7 @@ describe('admaticBidAdapter', () => { delete bid.params; bid.params = { - 'networkId': 0, - 'host': 'layer.serve.admatic.com.tr' + 'networkId': 0 }; expect(spec.isBidRequestValid(bid)).to.equal(false); From 6ec8f4539ea6be403a0d7e08dad5c7a5228f28a1 Mon Sep 17 00:00:00 2001 From: Fatih Kaya Date: Fri, 4 Nov 2022 22:49:31 +0300 Subject: [PATCH 10/57] added alias feature and host param --- modules/admaticBidAdapter.js | 6 +++++- modules/admaticBidAdapter.md | 1 + test/spec/modules/admaticBidAdapter_spec.js | 6 ++++-- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/modules/admaticBidAdapter.js b/modules/admaticBidAdapter.js index 5556a181f7f..cf54557c6c8 100644 --- a/modules/admaticBidAdapter.js +++ b/modules/admaticBidAdapter.js @@ -20,7 +20,7 @@ export const spec = { let isValid = false; if (typeof bid.params !== 'undefined') { let isValidNetworkId = _validateId(getValue(bid.params, 'networkId')); - let isValidHost = getValue(bid.params, 'host'); + let isValidHost = _validateString(getValue(bid.params, 'host')); isValid = isValidNetworkId && isValidHost; } @@ -198,4 +198,8 @@ function _validateId(id) { return (parseInt(id) > 0); } +function _validateString(str) { + return (typeof str == 'string'); +} + registerBidder(spec); diff --git a/modules/admaticBidAdapter.md b/modules/admaticBidAdapter.md index b12aebe5f72..2bf9afb3cdc 100644 --- a/modules/admaticBidAdapter.md +++ b/modules/admaticBidAdapter.md @@ -36,6 +36,7 @@ Use `admatic` as bidder. ``` ## UserSync example + ``` pbjs.setConfig({ userSync: { diff --git a/test/spec/modules/admaticBidAdapter_spec.js b/test/spec/modules/admaticBidAdapter_spec.js index c7d391cfaca..9cbee2fb06b 100644 --- a/test/spec/modules/admaticBidAdapter_spec.js +++ b/test/spec/modules/admaticBidAdapter_spec.js @@ -18,7 +18,8 @@ describe('admaticBidAdapter', () => { let bid = { 'bidder': 'admatic', 'params': { - 'networkId': 10433394 + 'networkId': 10433394, + 'host': 'layer.serve.admatic.com.tr' }, 'adUnitCode': 'adunit-code', 'sizes': [[300, 250], [300, 600]], @@ -37,7 +38,8 @@ describe('admaticBidAdapter', () => { delete bid.params; bid.params = { - 'networkId': 0 + 'networkId': 0, + 'host': 'layer.serve.admatic.com.tr' }; expect(spec.isBidRequestValid(bid)).to.equal(false); From 63e1fc6c74cc9ddc92a60a860bf0af1af3b0f8d0 Mon Sep 17 00:00:00 2001 From: Fatih Kaya Date: Sat, 5 Nov 2022 11:53:31 +0300 Subject: [PATCH 11/57] Revert "added alias feature and host param" This reverts commit 6ec8f4539ea6be403a0d7e08dad5c7a5228f28a1. --- modules/admaticBidAdapter.js | 6 +----- modules/admaticBidAdapter.md | 1 - test/spec/modules/admaticBidAdapter_spec.js | 6 ++---- 3 files changed, 3 insertions(+), 10 deletions(-) diff --git a/modules/admaticBidAdapter.js b/modules/admaticBidAdapter.js index cf54557c6c8..5556a181f7f 100644 --- a/modules/admaticBidAdapter.js +++ b/modules/admaticBidAdapter.js @@ -20,7 +20,7 @@ export const spec = { let isValid = false; if (typeof bid.params !== 'undefined') { let isValidNetworkId = _validateId(getValue(bid.params, 'networkId')); - let isValidHost = _validateString(getValue(bid.params, 'host')); + let isValidHost = getValue(bid.params, 'host'); isValid = isValidNetworkId && isValidHost; } @@ -198,8 +198,4 @@ function _validateId(id) { return (parseInt(id) > 0); } -function _validateString(str) { - return (typeof str == 'string'); -} - registerBidder(spec); diff --git a/modules/admaticBidAdapter.md b/modules/admaticBidAdapter.md index 2bf9afb3cdc..b12aebe5f72 100644 --- a/modules/admaticBidAdapter.md +++ b/modules/admaticBidAdapter.md @@ -36,7 +36,6 @@ Use `admatic` as bidder. ``` ## UserSync example - ``` pbjs.setConfig({ userSync: { diff --git a/test/spec/modules/admaticBidAdapter_spec.js b/test/spec/modules/admaticBidAdapter_spec.js index 9cbee2fb06b..c7d391cfaca 100644 --- a/test/spec/modules/admaticBidAdapter_spec.js +++ b/test/spec/modules/admaticBidAdapter_spec.js @@ -18,8 +18,7 @@ describe('admaticBidAdapter', () => { let bid = { 'bidder': 'admatic', 'params': { - 'networkId': 10433394, - 'host': 'layer.serve.admatic.com.tr' + 'networkId': 10433394 }, 'adUnitCode': 'adunit-code', 'sizes': [[300, 250], [300, 600]], @@ -38,8 +37,7 @@ describe('admaticBidAdapter', () => { delete bid.params; bid.params = { - 'networkId': 0, - 'host': 'layer.serve.admatic.com.tr' + 'networkId': 0 }; expect(spec.isBidRequestValid(bid)).to.equal(false); From 6da6565e93a1800b5a117f9c8b5eabdbcdbd7bba Mon Sep 17 00:00:00 2001 From: Fatih Kaya Date: Sat, 5 Nov 2022 11:54:45 +0300 Subject: [PATCH 12/57] Revert "Alias name changed." This reverts commit 661c54f9b2397e8f25c257144d73161e13466281. --- modules/admaticBidAdapter.js | 2 +- src/adloader.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/admaticBidAdapter.js b/modules/admaticBidAdapter.js index 5556a181f7f..b139b58da46 100644 --- a/modules/admaticBidAdapter.js +++ b/modules/admaticBidAdapter.js @@ -7,7 +7,7 @@ const SYNC_URL = 'https://cdn.serve.admatic.com.tr/showad/sync.js'; export const spec = { code: 'admatic', aliases: [ - {code: 'pixad'} + {code: 'adpixel'} ], supportedMediaTypes: ['video', 'banner'], /** diff --git a/src/adloader.js b/src/adloader.js index 167ffb75476..5cf7af5231e 100644 --- a/src/adloader.js +++ b/src/adloader.js @@ -7,7 +7,7 @@ const _approvedLoadExternalJSList = [ 'debugging', 'adloox', 'admatic', - 'pixad', + 'adpixel', 'criteo', 'outstream', 'adagio', From 549f34961ea53d7764607705dd8abb2d6238577b Mon Sep 17 00:00:00 2001 From: Fatih Kaya Date: Sat, 5 Nov 2022 11:55:15 +0300 Subject: [PATCH 13/57] Revert "Admatic Bid Adapter: alias and bid floor features activated" This reverts commit 7a2e0e29c49e2f876b68aafe886b336fe2fe6fcb. --- modules/admaticBidAdapter.js | 23 +++++++++-------------- modules/admaticBidAdapter.md | 7 +++---- src/adloader.js | 1 - 3 files changed, 12 insertions(+), 19 deletions(-) diff --git a/modules/admaticBidAdapter.js b/modules/admaticBidAdapter.js index b139b58da46..dc252fb2e28 100644 --- a/modules/admaticBidAdapter.js +++ b/modules/admaticBidAdapter.js @@ -2,13 +2,13 @@ import { getValue, logError, deepAccess, getBidIdParameter, isArray } from '../s import { loadExternalScript } from '../src/adloader.js'; import { registerBidder } from '../src/adapters/bidderFactory.js'; import { BANNER, VIDEO } from '../src/mediaTypes.js'; + +const ENDPOINT_URL = 'https://layer.serve.admatic.com.tr/pb'; const SYNC_URL = 'https://cdn.serve.admatic.com.tr/showad/sync.js'; +const BIDDER_CODE = 'admatic'; export const spec = { code: 'admatic', - aliases: [ - {code: 'adpixel'} - ], supportedMediaTypes: ['video', 'banner'], /** * Determines whether or not the given bid request is valid. @@ -20,12 +20,11 @@ export const spec = { let isValid = false; if (typeof bid.params !== 'undefined') { let isValidNetworkId = _validateId(getValue(bid.params, 'networkId')); - let isValidHost = getValue(bid.params, 'host'); - isValid = isValidNetworkId && isValidHost; + isValid = isValidNetworkId;// && isValidTypeId; } if (!isValid) { - logError(`${bid.bidder} networkId and host parameters are required. Bid aborted.`); + logError('AdMatic networkId parameters are required. Bid aborted.'); } return isValid; }, @@ -37,13 +36,11 @@ export const spec = { */ buildRequests: function(validBidRequests, bidderRequest) { const bids = validBidRequests.map(buildRequestObject); - const bidderName = validBidRequests[0].bidder; const networkId = getValue(validBidRequests[0].params, 'networkId'); - const host = getValue(validBidRequests[0].params, 'host'); const currency = getValue(validBidRequests[0].params, 'currency') || 'TRY'; setTimeout(() => { - loadExternalScript(SYNC_URL, bidderName); + loadExternalScript(SYNC_URL, BIDDER_CODE); }, bidderRequest.timeout); const payload = { @@ -62,14 +59,14 @@ export const spec = { imp: bids, ext: { 'cur': currency, - 'bidder': bidderName + 'type': 'admatic' } }; const payloadString = JSON.stringify(payload); return { method: 'POST', - url: `https://${host}/pb?bidder=${bidderName}`, + url: ENDPOINT_URL, data: payloadString, options: { contentType: 'application/json' @@ -100,7 +97,7 @@ export const spec = { advertiserDomains: bid && bid.adomain ? bid.adomain : [] }, ttl: 360, - bidder: JSON.parse(request.data).ext.bidder, + bidder: 'admatic', timeToRespond: 1, requestTimestamp: 1 }; @@ -112,8 +109,6 @@ export const spec = { } }; -registerBidder(spec); - function enrichSlotWithFloors(slot, bidRequest) { try { const slotFloors = {}; diff --git a/modules/admaticBidAdapter.md b/modules/admaticBidAdapter.md index b12aebe5f72..0496f40e881 100644 --- a/modules/admaticBidAdapter.md +++ b/modules/admaticBidAdapter.md @@ -18,8 +18,7 @@ Use `admatic` as bidder. bids: [{ bidder: 'admatic', params: { - networkId: 12345, - host: 'layer.serve.admatic.com.tr' + networkId: 12345 } }] },{ @@ -28,14 +27,14 @@ Use `admatic` as bidder. bids: [{ bidder: 'admatic', params: { - networkId: 12345, - host: 'layer.serve.admatic.com.tr' + networkId: 12345 } }] }]; ``` ## UserSync example + ``` pbjs.setConfig({ userSync: { diff --git a/src/adloader.js b/src/adloader.js index 5cf7af5231e..add5863ddf2 100644 --- a/src/adloader.js +++ b/src/adloader.js @@ -7,7 +7,6 @@ const _approvedLoadExternalJSList = [ 'debugging', 'adloox', 'admatic', - 'adpixel', 'criteo', 'outstream', 'adagio', From 0b8718eff8e0ea13e0bc1bfb8b0f10b1daf33911 Mon Sep 17 00:00:00 2001 From: Fatih Kaya Date: Sat, 5 Nov 2022 11:55:36 +0300 Subject: [PATCH 14/57] Revert "Update admaticBidAdapter.js" This reverts commit 7a845b7151bbb08addfb58ea9bd5b44167cc8a4e. --- modules/admaticBidAdapter.js | 52 +----------------------------------- 1 file changed, 1 insertion(+), 51 deletions(-) diff --git a/modules/admaticBidAdapter.js b/modules/admaticBidAdapter.js index dc252fb2e28..8c7a0f4015d 100644 --- a/modules/admaticBidAdapter.js +++ b/modules/admaticBidAdapter.js @@ -1,7 +1,6 @@ import { getValue, logError, deepAccess, getBidIdParameter, isArray } from '../src/utils.js'; import { loadExternalScript } from '../src/adloader.js'; -import { registerBidder } from '../src/adapters/bidderFactory.js'; -import { BANNER, VIDEO } from '../src/mediaTypes.js'; +import {registerBidder} from '../src/adapters/bidderFactory.js'; const ENDPOINT_URL = 'https://layer.serve.admatic.com.tr/pb'; const SYNC_URL = 'https://cdn.serve.admatic.com.tr/showad/sync.js'; @@ -101,7 +100,6 @@ export const spec = { timeToRespond: 1, requestTimestamp: 1 }; - bidResponses.push(resbid); }); }; @@ -109,58 +107,10 @@ export const spec = { } }; -function enrichSlotWithFloors(slot, bidRequest) { - try { - const slotFloors = {}; - - if (bidRequest.getFloor) { - if (bidRequest.mediaTypes?.banner) { - slotFloors.banner = {}; - const bannerSizes = parseSizes(deepAccess(bidRequest, 'mediaTypes.banner.sizes')) - bannerSizes.forEach(bannerSize => slotFloors.banner[parseSize(bannerSize).toString()] = bidRequest.getFloor({ size: bannerSize, mediaType: BANNER })); - } - - if (bidRequest.mediaTypes?.video) { - slotFloors.video = {}; - const videoSizes = parseSizes(deepAccess(bidRequest, 'mediaTypes.video.playerSize')) - videoSizes.forEach(videoSize => slotFloors.video[parseSize(videoSize).toString()] = bidRequest.getFloor({ size: videoSize, mediaType: VIDEO })); - } - - if (Object.keys(slotFloors).length > 0) { - if (!slot) { - slot = {} - } - Object.assign(slot, { - floors: slotFloors - }); - } - } - } catch (e) { - logError('Could not parse floors from Prebid: ' + e); - } -} - -function parseSizes(sizes, parser = s => s) { - if (sizes == undefined) { - return []; - } - if (Array.isArray(sizes[0])) { // is there several sizes ? (ie. [[728,90],[200,300]]) - return sizes.map(size => parser(size)); - } - return [parser(sizes)]; // or a single one ? (ie. [728,90]) -} - -function parseSize(size) { - return size[0] + 'x' + size[1]; -} - function buildRequestObject(bid) { const reqObj = {}; reqObj.size = getSizes(bid); reqObj.id = getBidIdParameter('bidId', bid); - - enrichSlotWithFloors(reqObj, bid); - return reqObj; } From e7f6902ac9abc2ecbf5118b3c0acbf666099845c Mon Sep 17 00:00:00 2001 From: Fatih Kaya Date: Sat, 5 Nov 2022 11:56:52 +0300 Subject: [PATCH 15/57] Revert "remove floor parameter" This reverts commit 7a23b055ccd4ea23d23e73248e82b21bc6f69d90. --- modules/admaticBidAdapter.js | 1 + modules/admaticBidAdapter.md | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/modules/admaticBidAdapter.js b/modules/admaticBidAdapter.js index 8c7a0f4015d..039f27e5de0 100644 --- a/modules/admaticBidAdapter.js +++ b/modules/admaticBidAdapter.js @@ -111,6 +111,7 @@ function buildRequestObject(bid) { const reqObj = {}; reqObj.size = getSizes(bid); reqObj.id = getBidIdParameter('bidId', bid); + reqObj.floor = getValue(bid.params, 'floor') || 0.01; return reqObj; } diff --git a/modules/admaticBidAdapter.md b/modules/admaticBidAdapter.md index 0496f40e881..de84998d0af 100644 --- a/modules/admaticBidAdapter.md +++ b/modules/admaticBidAdapter.md @@ -18,7 +18,8 @@ Use `admatic` as bidder. bids: [{ bidder: 'admatic', params: { - networkId: 12345 + networkId: 12345, + floor: 0.5 } }] },{ @@ -27,7 +28,8 @@ Use `admatic` as bidder. bids: [{ bidder: 'admatic', params: { - networkId: 12345 + networkId: 12345, + floor: 0.5 } }] }]; From 3c797b120c8e0fe2b851381300ac5c4b1f92c6e2 Mon Sep 17 00:00:00 2001 From: Fatih Kaya Date: Sat, 5 Nov 2022 12:01:03 +0300 Subject: [PATCH 16/57] Admatic adapter: host param control && Add new Bidder --- modules/admaticBidAdapter.js | 80 ++++++++++++++++++--- modules/admaticBidAdapter.md | 4 +- src/adloader.js | 1 + test/spec/modules/admaticBidAdapter_spec.js | 6 +- 4 files changed, 76 insertions(+), 15 deletions(-) diff --git a/modules/admaticBidAdapter.js b/modules/admaticBidAdapter.js index 039f27e5de0..cf54557c6c8 100644 --- a/modules/admaticBidAdapter.js +++ b/modules/admaticBidAdapter.js @@ -1,13 +1,14 @@ import { getValue, logError, deepAccess, getBidIdParameter, isArray } from '../src/utils.js'; import { loadExternalScript } from '../src/adloader.js'; -import {registerBidder} from '../src/adapters/bidderFactory.js'; - -const ENDPOINT_URL = 'https://layer.serve.admatic.com.tr/pb'; +import { registerBidder } from '../src/adapters/bidderFactory.js'; +import { BANNER, VIDEO } from '../src/mediaTypes.js'; const SYNC_URL = 'https://cdn.serve.admatic.com.tr/showad/sync.js'; -const BIDDER_CODE = 'admatic'; export const spec = { code: 'admatic', + aliases: [ + {code: 'pixad'} + ], supportedMediaTypes: ['video', 'banner'], /** * Determines whether or not the given bid request is valid. @@ -19,11 +20,12 @@ export const spec = { let isValid = false; if (typeof bid.params !== 'undefined') { let isValidNetworkId = _validateId(getValue(bid.params, 'networkId')); - isValid = isValidNetworkId;// && isValidTypeId; + let isValidHost = _validateString(getValue(bid.params, 'host')); + isValid = isValidNetworkId && isValidHost; } if (!isValid) { - logError('AdMatic networkId parameters are required. Bid aborted.'); + logError(`${bid.bidder} networkId and host parameters are required. Bid aborted.`); } return isValid; }, @@ -35,11 +37,13 @@ export const spec = { */ buildRequests: function(validBidRequests, bidderRequest) { const bids = validBidRequests.map(buildRequestObject); + const bidderName = validBidRequests[0].bidder; const networkId = getValue(validBidRequests[0].params, 'networkId'); + const host = getValue(validBidRequests[0].params, 'host'); const currency = getValue(validBidRequests[0].params, 'currency') || 'TRY'; setTimeout(() => { - loadExternalScript(SYNC_URL, BIDDER_CODE); + loadExternalScript(SYNC_URL, bidderName); }, bidderRequest.timeout); const payload = { @@ -58,14 +62,14 @@ export const spec = { imp: bids, ext: { 'cur': currency, - 'type': 'admatic' + 'bidder': bidderName } }; const payloadString = JSON.stringify(payload); return { method: 'POST', - url: ENDPOINT_URL, + url: `https://${host}/pb?bidder=${bidderName}`, data: payloadString, options: { contentType: 'application/json' @@ -96,10 +100,11 @@ export const spec = { advertiserDomains: bid && bid.adomain ? bid.adomain : [] }, ttl: 360, - bidder: 'admatic', + bidder: JSON.parse(request.data).ext.bidder, timeToRespond: 1, requestTimestamp: 1 }; + bidResponses.push(resbid); }); }; @@ -107,11 +112,60 @@ export const spec = { } }; +registerBidder(spec); + +function enrichSlotWithFloors(slot, bidRequest) { + try { + const slotFloors = {}; + + if (bidRequest.getFloor) { + if (bidRequest.mediaTypes?.banner) { + slotFloors.banner = {}; + const bannerSizes = parseSizes(deepAccess(bidRequest, 'mediaTypes.banner.sizes')) + bannerSizes.forEach(bannerSize => slotFloors.banner[parseSize(bannerSize).toString()] = bidRequest.getFloor({ size: bannerSize, mediaType: BANNER })); + } + + if (bidRequest.mediaTypes?.video) { + slotFloors.video = {}; + const videoSizes = parseSizes(deepAccess(bidRequest, 'mediaTypes.video.playerSize')) + videoSizes.forEach(videoSize => slotFloors.video[parseSize(videoSize).toString()] = bidRequest.getFloor({ size: videoSize, mediaType: VIDEO })); + } + + if (Object.keys(slotFloors).length > 0) { + if (!slot) { + slot = {} + } + Object.assign(slot, { + floors: slotFloors + }); + } + } + } catch (e) { + logError('Could not parse floors from Prebid: ' + e); + } +} + +function parseSizes(sizes, parser = s => s) { + if (sizes == undefined) { + return []; + } + if (Array.isArray(sizes[0])) { // is there several sizes ? (ie. [[728,90],[200,300]]) + return sizes.map(size => parser(size)); + } + return [parser(sizes)]; // or a single one ? (ie. [728,90]) +} + +function parseSize(size) { + return size[0] + 'x' + size[1]; +} + function buildRequestObject(bid) { const reqObj = {}; reqObj.size = getSizes(bid); reqObj.id = getBidIdParameter('bidId', bid); - reqObj.floor = getValue(bid.params, 'floor') || 0.01; + + enrichSlotWithFloors(reqObj, bid); + return reqObj; } @@ -144,4 +198,8 @@ function _validateId(id) { return (parseInt(id) > 0); } +function _validateString(str) { + return (typeof str == 'string'); +} + registerBidder(spec); diff --git a/modules/admaticBidAdapter.md b/modules/admaticBidAdapter.md index de84998d0af..2bf9afb3cdc 100644 --- a/modules/admaticBidAdapter.md +++ b/modules/admaticBidAdapter.md @@ -19,7 +19,7 @@ Use `admatic` as bidder. bidder: 'admatic', params: { networkId: 12345, - floor: 0.5 + host: 'layer.serve.admatic.com.tr' } }] },{ @@ -29,7 +29,7 @@ Use `admatic` as bidder. bidder: 'admatic', params: { networkId: 12345, - floor: 0.5 + host: 'layer.serve.admatic.com.tr' } }] }]; diff --git a/src/adloader.js b/src/adloader.js index add5863ddf2..167ffb75476 100644 --- a/src/adloader.js +++ b/src/adloader.js @@ -7,6 +7,7 @@ const _approvedLoadExternalJSList = [ 'debugging', 'adloox', 'admatic', + 'pixad', 'criteo', 'outstream', 'adagio', diff --git a/test/spec/modules/admaticBidAdapter_spec.js b/test/spec/modules/admaticBidAdapter_spec.js index c7d391cfaca..9cbee2fb06b 100644 --- a/test/spec/modules/admaticBidAdapter_spec.js +++ b/test/spec/modules/admaticBidAdapter_spec.js @@ -18,7 +18,8 @@ describe('admaticBidAdapter', () => { let bid = { 'bidder': 'admatic', 'params': { - 'networkId': 10433394 + 'networkId': 10433394, + 'host': 'layer.serve.admatic.com.tr' }, 'adUnitCode': 'adunit-code', 'sizes': [[300, 250], [300, 600]], @@ -37,7 +38,8 @@ describe('admaticBidAdapter', () => { delete bid.params; bid.params = { - 'networkId': 0 + 'networkId': 0, + 'host': 'layer.serve.admatic.com.tr' }; expect(spec.isBidRequestValid(bid)).to.equal(false); From f44bbebdd2da3e49efb8eaf77ce746a881b22ce0 Mon Sep 17 00:00:00 2001 From: Fatih Kaya Date: Sat, 5 Nov 2022 12:02:20 +0300 Subject: [PATCH 17/57] Revert "Admatic adapter: host param control && Add new Bidder" This reverts commit 3c797b120c8e0fe2b851381300ac5c4b1f92c6e2. --- modules/admaticBidAdapter.js | 80 +++------------------ modules/admaticBidAdapter.md | 4 +- src/adloader.js | 1 - test/spec/modules/admaticBidAdapter_spec.js | 6 +- 4 files changed, 15 insertions(+), 76 deletions(-) diff --git a/modules/admaticBidAdapter.js b/modules/admaticBidAdapter.js index cf54557c6c8..039f27e5de0 100644 --- a/modules/admaticBidAdapter.js +++ b/modules/admaticBidAdapter.js @@ -1,14 +1,13 @@ import { getValue, logError, deepAccess, getBidIdParameter, isArray } from '../src/utils.js'; import { loadExternalScript } from '../src/adloader.js'; -import { registerBidder } from '../src/adapters/bidderFactory.js'; -import { BANNER, VIDEO } from '../src/mediaTypes.js'; +import {registerBidder} from '../src/adapters/bidderFactory.js'; + +const ENDPOINT_URL = 'https://layer.serve.admatic.com.tr/pb'; const SYNC_URL = 'https://cdn.serve.admatic.com.tr/showad/sync.js'; +const BIDDER_CODE = 'admatic'; export const spec = { code: 'admatic', - aliases: [ - {code: 'pixad'} - ], supportedMediaTypes: ['video', 'banner'], /** * Determines whether or not the given bid request is valid. @@ -20,12 +19,11 @@ export const spec = { let isValid = false; if (typeof bid.params !== 'undefined') { let isValidNetworkId = _validateId(getValue(bid.params, 'networkId')); - let isValidHost = _validateString(getValue(bid.params, 'host')); - isValid = isValidNetworkId && isValidHost; + isValid = isValidNetworkId;// && isValidTypeId; } if (!isValid) { - logError(`${bid.bidder} networkId and host parameters are required. Bid aborted.`); + logError('AdMatic networkId parameters are required. Bid aborted.'); } return isValid; }, @@ -37,13 +35,11 @@ export const spec = { */ buildRequests: function(validBidRequests, bidderRequest) { const bids = validBidRequests.map(buildRequestObject); - const bidderName = validBidRequests[0].bidder; const networkId = getValue(validBidRequests[0].params, 'networkId'); - const host = getValue(validBidRequests[0].params, 'host'); const currency = getValue(validBidRequests[0].params, 'currency') || 'TRY'; setTimeout(() => { - loadExternalScript(SYNC_URL, bidderName); + loadExternalScript(SYNC_URL, BIDDER_CODE); }, bidderRequest.timeout); const payload = { @@ -62,14 +58,14 @@ export const spec = { imp: bids, ext: { 'cur': currency, - 'bidder': bidderName + 'type': 'admatic' } }; const payloadString = JSON.stringify(payload); return { method: 'POST', - url: `https://${host}/pb?bidder=${bidderName}`, + url: ENDPOINT_URL, data: payloadString, options: { contentType: 'application/json' @@ -100,11 +96,10 @@ export const spec = { advertiserDomains: bid && bid.adomain ? bid.adomain : [] }, ttl: 360, - bidder: JSON.parse(request.data).ext.bidder, + bidder: 'admatic', timeToRespond: 1, requestTimestamp: 1 }; - bidResponses.push(resbid); }); }; @@ -112,60 +107,11 @@ export const spec = { } }; -registerBidder(spec); - -function enrichSlotWithFloors(slot, bidRequest) { - try { - const slotFloors = {}; - - if (bidRequest.getFloor) { - if (bidRequest.mediaTypes?.banner) { - slotFloors.banner = {}; - const bannerSizes = parseSizes(deepAccess(bidRequest, 'mediaTypes.banner.sizes')) - bannerSizes.forEach(bannerSize => slotFloors.banner[parseSize(bannerSize).toString()] = bidRequest.getFloor({ size: bannerSize, mediaType: BANNER })); - } - - if (bidRequest.mediaTypes?.video) { - slotFloors.video = {}; - const videoSizes = parseSizes(deepAccess(bidRequest, 'mediaTypes.video.playerSize')) - videoSizes.forEach(videoSize => slotFloors.video[parseSize(videoSize).toString()] = bidRequest.getFloor({ size: videoSize, mediaType: VIDEO })); - } - - if (Object.keys(slotFloors).length > 0) { - if (!slot) { - slot = {} - } - Object.assign(slot, { - floors: slotFloors - }); - } - } - } catch (e) { - logError('Could not parse floors from Prebid: ' + e); - } -} - -function parseSizes(sizes, parser = s => s) { - if (sizes == undefined) { - return []; - } - if (Array.isArray(sizes[0])) { // is there several sizes ? (ie. [[728,90],[200,300]]) - return sizes.map(size => parser(size)); - } - return [parser(sizes)]; // or a single one ? (ie. [728,90]) -} - -function parseSize(size) { - return size[0] + 'x' + size[1]; -} - function buildRequestObject(bid) { const reqObj = {}; reqObj.size = getSizes(bid); reqObj.id = getBidIdParameter('bidId', bid); - - enrichSlotWithFloors(reqObj, bid); - + reqObj.floor = getValue(bid.params, 'floor') || 0.01; return reqObj; } @@ -198,8 +144,4 @@ function _validateId(id) { return (parseInt(id) > 0); } -function _validateString(str) { - return (typeof str == 'string'); -} - registerBidder(spec); diff --git a/modules/admaticBidAdapter.md b/modules/admaticBidAdapter.md index 2bf9afb3cdc..de84998d0af 100644 --- a/modules/admaticBidAdapter.md +++ b/modules/admaticBidAdapter.md @@ -19,7 +19,7 @@ Use `admatic` as bidder. bidder: 'admatic', params: { networkId: 12345, - host: 'layer.serve.admatic.com.tr' + floor: 0.5 } }] },{ @@ -29,7 +29,7 @@ Use `admatic` as bidder. bidder: 'admatic', params: { networkId: 12345, - host: 'layer.serve.admatic.com.tr' + floor: 0.5 } }] }]; diff --git a/src/adloader.js b/src/adloader.js index 167ffb75476..add5863ddf2 100644 --- a/src/adloader.js +++ b/src/adloader.js @@ -7,7 +7,6 @@ const _approvedLoadExternalJSList = [ 'debugging', 'adloox', 'admatic', - 'pixad', 'criteo', 'outstream', 'adagio', diff --git a/test/spec/modules/admaticBidAdapter_spec.js b/test/spec/modules/admaticBidAdapter_spec.js index 9cbee2fb06b..c7d391cfaca 100644 --- a/test/spec/modules/admaticBidAdapter_spec.js +++ b/test/spec/modules/admaticBidAdapter_spec.js @@ -18,8 +18,7 @@ describe('admaticBidAdapter', () => { let bid = { 'bidder': 'admatic', 'params': { - 'networkId': 10433394, - 'host': 'layer.serve.admatic.com.tr' + 'networkId': 10433394 }, 'adUnitCode': 'adunit-code', 'sizes': [[300, 250], [300, 600]], @@ -38,8 +37,7 @@ describe('admaticBidAdapter', () => { delete bid.params; bid.params = { - 'networkId': 0, - 'host': 'layer.serve.admatic.com.tr' + 'networkId': 0 }; expect(spec.isBidRequestValid(bid)).to.equal(false); From 68f2596d7531124b3230e4b7b67ddae8f4942dd1 Mon Sep 17 00:00:00 2001 From: Fatih Kaya Date: Sat, 5 Nov 2022 12:06:44 +0300 Subject: [PATCH 18/57] commit new features --- modules/admaticBidAdapter.js | 80 ++++++++++++++++++--- modules/admaticBidAdapter.md | 4 +- src/adloader.js | 4 +- test/spec/modules/admaticBidAdapter_spec.js | 6 +- 4 files changed, 77 insertions(+), 17 deletions(-) diff --git a/modules/admaticBidAdapter.js b/modules/admaticBidAdapter.js index 039f27e5de0..cf54557c6c8 100644 --- a/modules/admaticBidAdapter.js +++ b/modules/admaticBidAdapter.js @@ -1,13 +1,14 @@ import { getValue, logError, deepAccess, getBidIdParameter, isArray } from '../src/utils.js'; import { loadExternalScript } from '../src/adloader.js'; -import {registerBidder} from '../src/adapters/bidderFactory.js'; - -const ENDPOINT_URL = 'https://layer.serve.admatic.com.tr/pb'; +import { registerBidder } from '../src/adapters/bidderFactory.js'; +import { BANNER, VIDEO } from '../src/mediaTypes.js'; const SYNC_URL = 'https://cdn.serve.admatic.com.tr/showad/sync.js'; -const BIDDER_CODE = 'admatic'; export const spec = { code: 'admatic', + aliases: [ + {code: 'pixad'} + ], supportedMediaTypes: ['video', 'banner'], /** * Determines whether or not the given bid request is valid. @@ -19,11 +20,12 @@ export const spec = { let isValid = false; if (typeof bid.params !== 'undefined') { let isValidNetworkId = _validateId(getValue(bid.params, 'networkId')); - isValid = isValidNetworkId;// && isValidTypeId; + let isValidHost = _validateString(getValue(bid.params, 'host')); + isValid = isValidNetworkId && isValidHost; } if (!isValid) { - logError('AdMatic networkId parameters are required. Bid aborted.'); + logError(`${bid.bidder} networkId and host parameters are required. Bid aborted.`); } return isValid; }, @@ -35,11 +37,13 @@ export const spec = { */ buildRequests: function(validBidRequests, bidderRequest) { const bids = validBidRequests.map(buildRequestObject); + const bidderName = validBidRequests[0].bidder; const networkId = getValue(validBidRequests[0].params, 'networkId'); + const host = getValue(validBidRequests[0].params, 'host'); const currency = getValue(validBidRequests[0].params, 'currency') || 'TRY'; setTimeout(() => { - loadExternalScript(SYNC_URL, BIDDER_CODE); + loadExternalScript(SYNC_URL, bidderName); }, bidderRequest.timeout); const payload = { @@ -58,14 +62,14 @@ export const spec = { imp: bids, ext: { 'cur': currency, - 'type': 'admatic' + 'bidder': bidderName } }; const payloadString = JSON.stringify(payload); return { method: 'POST', - url: ENDPOINT_URL, + url: `https://${host}/pb?bidder=${bidderName}`, data: payloadString, options: { contentType: 'application/json' @@ -96,10 +100,11 @@ export const spec = { advertiserDomains: bid && bid.adomain ? bid.adomain : [] }, ttl: 360, - bidder: 'admatic', + bidder: JSON.parse(request.data).ext.bidder, timeToRespond: 1, requestTimestamp: 1 }; + bidResponses.push(resbid); }); }; @@ -107,11 +112,60 @@ export const spec = { } }; +registerBidder(spec); + +function enrichSlotWithFloors(slot, bidRequest) { + try { + const slotFloors = {}; + + if (bidRequest.getFloor) { + if (bidRequest.mediaTypes?.banner) { + slotFloors.banner = {}; + const bannerSizes = parseSizes(deepAccess(bidRequest, 'mediaTypes.banner.sizes')) + bannerSizes.forEach(bannerSize => slotFloors.banner[parseSize(bannerSize).toString()] = bidRequest.getFloor({ size: bannerSize, mediaType: BANNER })); + } + + if (bidRequest.mediaTypes?.video) { + slotFloors.video = {}; + const videoSizes = parseSizes(deepAccess(bidRequest, 'mediaTypes.video.playerSize')) + videoSizes.forEach(videoSize => slotFloors.video[parseSize(videoSize).toString()] = bidRequest.getFloor({ size: videoSize, mediaType: VIDEO })); + } + + if (Object.keys(slotFloors).length > 0) { + if (!slot) { + slot = {} + } + Object.assign(slot, { + floors: slotFloors + }); + } + } + } catch (e) { + logError('Could not parse floors from Prebid: ' + e); + } +} + +function parseSizes(sizes, parser = s => s) { + if (sizes == undefined) { + return []; + } + if (Array.isArray(sizes[0])) { // is there several sizes ? (ie. [[728,90],[200,300]]) + return sizes.map(size => parser(size)); + } + return [parser(sizes)]; // or a single one ? (ie. [728,90]) +} + +function parseSize(size) { + return size[0] + 'x' + size[1]; +} + function buildRequestObject(bid) { const reqObj = {}; reqObj.size = getSizes(bid); reqObj.id = getBidIdParameter('bidId', bid); - reqObj.floor = getValue(bid.params, 'floor') || 0.01; + + enrichSlotWithFloors(reqObj, bid); + return reqObj; } @@ -144,4 +198,8 @@ function _validateId(id) { return (parseInt(id) > 0); } +function _validateString(str) { + return (typeof str == 'string'); +} + registerBidder(spec); diff --git a/modules/admaticBidAdapter.md b/modules/admaticBidAdapter.md index de84998d0af..2bf9afb3cdc 100644 --- a/modules/admaticBidAdapter.md +++ b/modules/admaticBidAdapter.md @@ -19,7 +19,7 @@ Use `admatic` as bidder. bidder: 'admatic', params: { networkId: 12345, - floor: 0.5 + host: 'layer.serve.admatic.com.tr' } }] },{ @@ -29,7 +29,7 @@ Use `admatic` as bidder. bidder: 'admatic', params: { networkId: 12345, - floor: 0.5 + host: 'layer.serve.admatic.com.tr' } }] }]; diff --git a/src/adloader.js b/src/adloader.js index 330b52b3ed5..167ffb75476 100644 --- a/src/adloader.js +++ b/src/adloader.js @@ -7,6 +7,7 @@ const _approvedLoadExternalJSList = [ 'debugging', 'adloox', 'admatic', + 'pixad', 'criteo', 'outstream', 'adagio', @@ -20,8 +21,7 @@ const _approvedLoadExternalJSList = [ 'inskin', 'hadron', 'medianet', - 'improvedigital', - 'aaxBlockmeter' + 'improvedigital' ] /** diff --git a/test/spec/modules/admaticBidAdapter_spec.js b/test/spec/modules/admaticBidAdapter_spec.js index c7d391cfaca..9cbee2fb06b 100644 --- a/test/spec/modules/admaticBidAdapter_spec.js +++ b/test/spec/modules/admaticBidAdapter_spec.js @@ -18,7 +18,8 @@ describe('admaticBidAdapter', () => { let bid = { 'bidder': 'admatic', 'params': { - 'networkId': 10433394 + 'networkId': 10433394, + 'host': 'layer.serve.admatic.com.tr' }, 'adUnitCode': 'adunit-code', 'sizes': [[300, 250], [300, 600]], @@ -37,7 +38,8 @@ describe('admaticBidAdapter', () => { delete bid.params; bid.params = { - 'networkId': 0 + 'networkId': 0, + 'host': 'layer.serve.admatic.com.tr' }; expect(spec.isBidRequestValid(bid)).to.equal(false); From 7fd1f26e2494475e83ef2331e0457e64c8efa2f3 Mon Sep 17 00:00:00 2001 From: Fatih Kaya Date: Sun, 6 Nov 2022 20:43:56 +0300 Subject: [PATCH 19/57] Update admaticBidAdapter.js --- modules/admaticBidAdapter.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/modules/admaticBidAdapter.js b/modules/admaticBidAdapter.js index cf54557c6c8..435738ee593 100644 --- a/modules/admaticBidAdapter.js +++ b/modules/admaticBidAdapter.js @@ -100,9 +100,7 @@ export const spec = { advertiserDomains: bid && bid.adomain ? bid.adomain : [] }, ttl: 360, - bidder: JSON.parse(request.data).ext.bidder, - timeToRespond: 1, - requestTimestamp: 1 + bidder: JSON.parse(request.data).ext.bidder }; bidResponses.push(resbid); From e883ef6881a9a1234bb427510298b69d95c3ca98 Mon Sep 17 00:00:00 2001 From: Fatih Kaya Date: Sat, 12 Nov 2022 03:57:46 +0300 Subject: [PATCH 20/57] updated for coverage --- modules/admaticBidAdapter.js | 95 ++++--- test/spec/modules/admaticBidAdapter_spec.js | 259 +++++++++++++++++++- 2 files changed, 300 insertions(+), 54 deletions(-) diff --git a/modules/admaticBidAdapter.js b/modules/admaticBidAdapter.js index 435738ee593..4e2606b3064 100644 --- a/modules/admaticBidAdapter.js +++ b/modules/admaticBidAdapter.js @@ -3,24 +3,22 @@ import { loadExternalScript } from '../src/adloader.js'; import { registerBidder } from '../src/adapters/bidderFactory.js'; import { BANNER, VIDEO } from '../src/mediaTypes.js'; const SYNC_URL = 'https://cdn.serve.admatic.com.tr/showad/sync.js'; - +const BIDDER_CODE = 'admatic'; export const spec = { - code: 'admatic', + code: BIDDER_CODE, aliases: [ {code: 'pixad'} ], - supportedMediaTypes: ['video', 'banner'], - /** - * Determines whether or not the given bid request is valid. - * - * @param {BidRequest} bid The bid params to validate. - * @return boolean True if this is a valid bid, and false otherwise. + supportedMediaTypes: [BANNER, VIDEO], + /** f + * @param {object} bid + * @return {boolean} */ - isBidRequestValid: function(bid) { + isBidRequestValid: (bid) => { let isValid = false; - if (typeof bid.params !== 'undefined') { - let isValidNetworkId = _validateId(getValue(bid.params, 'networkId')); - let isValidHost = _validateString(getValue(bid.params, 'host')); + if (bid?.params) { + const isValidNetworkId = _validateId(getValue(bid.params, 'networkId')); + const isValidHost = _validateString(getValue(bid.params, 'host')); isValid = isValidNetworkId && isValidHost; } @@ -29,70 +27,63 @@ export const spec = { } return isValid; }, + /** - * Make a server request from the list of BidRequests. - * - * @param {validBidRequests[]} an array of bids - * @return ServerRequest Info describing the request to the server. + * @param {BidRequest[]} validBidRequests + * @return {ServerRequest} */ - buildRequests: function(validBidRequests, bidderRequest) { + buildRequests: (validBidRequests, bidderRequest) => { const bids = validBidRequests.map(buildRequestObject); - const bidderName = validBidRequests[0].bidder; const networkId = getValue(validBidRequests[0].params, 'networkId'); const host = getValue(validBidRequests[0].params, 'host'); const currency = getValue(validBidRequests[0].params, 'currency') || 'TRY'; - - setTimeout(() => { - loadExternalScript(SYNC_URL, bidderName); - }, bidderRequest.timeout); + const bidderName = validBidRequests[0].bidder; const payload = { - 'user': { - 'ua': navigator.userAgent + user: { + ua: navigator.userAgent }, - 'blacklist': [], - 'site': { - 'page': location.href, - 'ref': location.origin, - 'publisher': { - 'name': location.hostname, - 'publisherId': networkId + blacklist: [], + site: { + page: location.href, + ref: location.origin, + publisher: { + name: location.hostname, + publisherId: networkId } }, imp: bids, ext: { - 'cur': currency, - 'bidder': bidderName + cur: currency, + bidder: bidderName } }; - const payloadString = JSON.stringify(payload); - return { - method: 'POST', - url: `https://${host}/pb?bidder=${bidderName}`, - data: payloadString, - options: { - contentType: 'application/json' - } - }; + setTimeout(() => { + loadExternalScript(SYNC_URL, bidderName); + }, 10); + + if (payload) { + return { method: 'POST', url: `https://${host}/pb?bidder=${bidderName}`, data: payload, options: { contentType: 'application/json' } }; + } }, + /** - * Unpack the response from the server into a list of bids. - * - * @param {*} serverResponse A successful response from the server. - * @return {Bid[]} An array of bids which were nested inside the server. + * @param {*} response + * @param {ServerRequest} request + * @return {Bid[]} */ interpretResponse: (response, request) => { const body = response.body || response; const bidResponses = []; - if (body.data.length > 0) { - body.data.forEach(function (bid) { + if (body && body?.data && isArray(body.data)) { + body.data.forEach(bid => { const resbid = { requestId: bid.id, cpm: bid.price, width: bid.width, height: bid.height, - currency: body.cur, + currency: body.cur || 'TRY', netRevenue: true, ad: bid.party_tag, creativeId: bid.creative_id, @@ -100,18 +91,16 @@ export const spec = { advertiserDomains: bid && bid.adomain ? bid.adomain : [] }, ttl: 360, - bidder: JSON.parse(request.data).ext.bidder + bidder: bid.bidder }; bidResponses.push(resbid); }); - }; + } return bidResponses; } }; -registerBidder(spec); - function enrichSlotWithFloors(slot, bidRequest) { try { const slotFloors = {}; diff --git a/test/spec/modules/admaticBidAdapter_spec.js b/test/spec/modules/admaticBidAdapter_spec.js index 9cbee2fb06b..65a7b4111b7 100644 --- a/test/spec/modules/admaticBidAdapter_spec.js +++ b/test/spec/modules/admaticBidAdapter_spec.js @@ -3,7 +3,7 @@ import {spec, storage} from 'modules/admaticBidAdapter.js'; import {newBidder} from 'src/adapters/bidderFactory.js'; import {getStorageManager} from 'src/storageManager'; -const ENDPOINT = 'https://layer.serve.admatic.com.tr/v1'; +const ENDPOINT = 'https://layer.serve.admatic.com.tr/pb?bidder=admatic'; describe('admaticBidAdapter', () => { const adapter = newBidder(spec); @@ -45,4 +45,261 @@ describe('admaticBidAdapter', () => { expect(spec.isBidRequestValid(bid)).to.equal(false); }); }); + + describe('buildRequests', function () { + it('sends bid request to ENDPOINT via POST', function () { + let validRequest = [ { + 'bidder': 'admatic', + 'params': { + 'networkId': 10433394, + 'host': 'layer.serve.admatic.com.tr' + }, + 'mediaTypes': { + 'banner': { + 'sizes': [[300, 250], [728, 90]] + } + }, + getFloor: inputParams => { + if (inputParams.mediaType === BANNER && inputParams.size[0] === 300 && inputParams.size[1] === 250) { + return { + currency: 'USD', + floor: 1.0 + }; + } else if (inputParams.mediaType === BANNER && inputParams.size[0] === 728 && inputParams.size[1] === 90) { + return { + currency: 'USD', + floor: 2.0 + }; + } else { + return {} + } + }, + 'user': { + 'ua': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36' + }, + 'blacklist': [], + 'site': { + 'page': 'http://localhost:8888/admatic.html', + 'ref': 'http://localhost:8888', + 'publisher': { + 'name': 'localhost', + 'publisherId': 12321312 + } + }, + 'imp': [ + { + 'size': [ + { + 'w': 300, + 'h': 250 + }, + { + 'w': 728, + 'h': 90 + } + ], + 'id': '2205da7a81846b', + 'floors': { + 'banner': { + '300x250': { 'currency': 'USD', 'floor': 1 }, + '728x90': { 'currency': 'USD', 'floor': 2 } + } + } + } + ], + 'ext': { + 'cur': 'USD', + 'bidder': 'admatic' + } + } ]; + let bidderRequest = { + 'bidder': 'admatic', + 'params': { + 'networkId': 10433394, + 'host': 'layer.serve.admatic.com.tr' + }, + 'mediaTypes': { + 'banner': { + 'sizes': [[300, 250], [728, 90]] + } + }, + getFloor: inputParams => { + if (inputParams.mediaType === BANNER && inputParams.size[0] === 300 && inputParams.size[1] === 250) { + return { + currency: 'USD', + floor: 1.0 + }; + } else if (inputParams.mediaType === BANNER && inputParams.size[0] === 728 && inputParams.size[1] === 90) { + return { + currency: 'USD', + floor: 2.0 + }; + } else { + return {} + } + }, + 'user': { + 'ua': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36' + }, + 'blacklist': [], + 'site': { + 'page': 'http://localhost:8888/admatic.html', + 'ref': 'http://localhost:8888', + 'publisher': { + 'name': 'localhost', + 'publisherId': 12321312 + } + }, + 'imp': [ + { + 'size': [ + { + 'w': 300, + 'h': 250 + }, + { + 'w': 728, + 'h': 90 + } + ], + 'id': '2205da7a81846b', + 'floors': { + 'banner': { + '300x250': { 'currency': 'USD', 'floor': 1 }, + '728x90': { 'currency': 'USD', 'floor': 2 } + } + } + } + ], + 'ext': { + 'cur': 'USD', + 'bidder': 'admatic' + } + }; + const request = spec.buildRequests(validRequest, bidderRequest); + expect(request.url).to.equal(ENDPOINT); + expect(request.method).to.equal('POST'); + }); + + it('should properly build a banner request with floors', function () { + let bidRequests = [ + { + 'bidder': 'admatic', + 'params': { + 'networkId': 10433394, + 'host': 'layer.serve.admatic.com.tr' + }, + 'mediaTypes': { + 'banner': { + 'sizes': [[300, 250], [728, 90]] + } + }, + getFloor: inputParams => { + if (inputParams.mediaType === BANNER && inputParams.size[0] === 300 && inputParams.size[1] === 250) { + return { + currency: 'USD', + floor: 1.0 + }; + } else if (inputParams.mediaType === BANNER && inputParams.size[0] === 728 && inputParams.size[1] === 90) { + return { + currency: 'USD', + floor: 2.0 + }; + } else { + return {} + } + } + }, + ]; + let bidderRequest = { + 'bidder': 'admatic', + 'params': { + 'networkId': 10433394, + 'host': 'layer.serve.admatic.com.tr' + }, + 'adUnitCode': 'adunit-code', + 'sizes': [[300, 250], [728, 90]], + 'bidId': '30b31c1838de1e', + 'bidderRequestId': '22edbae2733bf6', + 'auctionId': '1d1a030790a475', + 'creativeId': 'er2ee', + 'mediaTypes': { + 'banner': { + 'sizes': [[300, 250], [728, 90]] + } + } + }; + const request = spec.buildRequests(bidRequests, bidderRequest); + request.data.imp[0].floors = { + 'banner': { + '300x250': { 'currency': 'USD', 'floor': 1 }, + '728x90': { 'currency': 'USD', 'floor': 2 } + } + }; + }); + }); + + describe('interpretResponse', function () { + it('should get correct bid responses', function() { + let bids = { body: { + data: [ + { + 'id': 1, + 'creative_id': '374', + 'width': 300, + 'height': 250, + 'price': 0.01, + 'bidder': 'admatic', + 'adomain': ['admatic.com.tr'], + 'party_tag': '
' + } + ], + 'queryId': 'cdnbh24rlv0hhkpfpln0', + 'status': true + }}; + + let expectedResponse = [ + { + requestId: 1, + cpm: 0.01, + width: 300, + height: 250, + currency: 'TRY', + netRevenue: true, + ad: '
', + creativeId: '374', + meta: { + advertiserDomains: ['admatic.com.tr'] + }, + ttl: 360, + bidder: 'admatic' + } + ]; + const request = { + ext: { + 'cur': 'TRY', + 'type': 'admatic' + } + }; + let result = spec.interpretResponse(bids, {data: request}); + expect(result).to.eql(expectedResponse); + }); + + it('handles nobid responses', function () { + let request = { + ext: { + 'cur': 'TRY', + 'type': 'admatic' + } + }; + let bids = { body: { + data: [], + 'queryId': 'cdnbh24rlv0hhkpfpln0', + 'status': true + }}; + + let result = spec.interpretResponse(bids, {data: request}); + expect(result.length).to.equal(0); + }); + }); }); From 6961cae17ca0db1ec41b6b35550ab44e5fab8759 Mon Sep 17 00:00:00 2001 From: Fatih Kaya Date: Mon, 14 Nov 2022 16:17:57 +0300 Subject: [PATCH 21/57] sync updated --- modules/admaticBidAdapter.js | 16 ++++++++++------ src/adloader.js | 2 -- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/modules/admaticBidAdapter.js b/modules/admaticBidAdapter.js index 4e2606b3064..ec4401b77c9 100644 --- a/modules/admaticBidAdapter.js +++ b/modules/admaticBidAdapter.js @@ -1,8 +1,7 @@ import { getValue, logError, deepAccess, getBidIdParameter, isArray } from '../src/utils.js'; -import { loadExternalScript } from '../src/adloader.js'; import { registerBidder } from '../src/adapters/bidderFactory.js'; import { BANNER, VIDEO } from '../src/mediaTypes.js'; -const SYNC_URL = 'https://cdn.serve.admatic.com.tr/showad/sync.js'; +const SYNC_URL = 'https://cdn.serve.admatic.com.tr/showad/sync.html'; const BIDDER_CODE = 'admatic'; export const spec = { code: BIDDER_CODE, @@ -59,15 +58,20 @@ export const spec = { } }; - setTimeout(() => { - loadExternalScript(SYNC_URL, bidderName); - }, 10); - if (payload) { return { method: 'POST', url: `https://${host}/pb?bidder=${bidderName}`, data: payload, options: { contentType: 'application/json' } }; } }, + getUserSyncs: function (syncOptions, responses) { + if (syncOptions.iframeEnabled) { + return [{ + type: 'iframe', + url: SYNC_URL + }]; + } + }, + /** * @param {*} response * @param {ServerRequest} request diff --git a/src/adloader.js b/src/adloader.js index 167ffb75476..6b7427d3e52 100644 --- a/src/adloader.js +++ b/src/adloader.js @@ -6,8 +6,6 @@ const _requestCache = new WeakMap(); const _approvedLoadExternalJSList = [ 'debugging', 'adloox', - 'admatic', - 'pixad', 'criteo', 'outstream', 'adagio', From a3b299f2860a0018c977236a83cc0ad032b24536 Mon Sep 17 00:00:00 2001 From: Fatih Kaya Date: Mon, 14 Nov 2022 16:40:53 +0300 Subject: [PATCH 22/57] Update adloader.js --- src/adloader.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/adloader.js b/src/adloader.js index 6b7427d3e52..64408683e9f 100644 --- a/src/adloader.js +++ b/src/adloader.js @@ -19,7 +19,8 @@ const _approvedLoadExternalJSList = [ 'inskin', 'hadron', 'medianet', - 'improvedigital' + 'improvedigital', + 'aaxBlockmeter' ] /** From e2547078b0e19f78ba23c47b8a90c6d9fa2df366 Mon Sep 17 00:00:00 2001 From: Fatih Kaya Date: Fri, 18 Nov 2022 13:43:55 +0300 Subject: [PATCH 23/57] AdMatic Bidder: development of user sync url --- modules/admaticBidAdapter.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/modules/admaticBidAdapter.js b/modules/admaticBidAdapter.js index ec4401b77c9..5bae129363e 100644 --- a/modules/admaticBidAdapter.js +++ b/modules/admaticBidAdapter.js @@ -1,7 +1,7 @@ import { getValue, logError, deepAccess, getBidIdParameter, isArray } from '../src/utils.js'; import { registerBidder } from '../src/adapters/bidderFactory.js'; import { BANNER, VIDEO } from '../src/mediaTypes.js'; -const SYNC_URL = 'https://cdn.serve.admatic.com.tr/showad/sync.html'; +let SYNC_URL = ''; const BIDDER_CODE = 'admatic'; export const spec = { code: BIDDER_CODE, @@ -59,6 +59,15 @@ export const spec = { }; if (payload) { + switch (bidderName) { + case 'pixad': + SYNC_URL = 'https://rtb.pixad.com.tr/sync.html'; + break; + default: + SYNC_URL = 'https://cdn.serve.admatic.com.tr/showad/sync.html'; + break; + } + return { method: 'POST', url: `https://${host}/pb?bidder=${bidderName}`, data: payload, options: { contentType: 'application/json' } }; } }, From ba99adf49ff157ec16e6e2e8242e5123fcca7d70 Mon Sep 17 00:00:00 2001 From: Fatih Kaya Date: Fri, 18 Nov 2022 14:05:18 +0300 Subject: [PATCH 24/57] Update admaticBidAdapter.js --- modules/admaticBidAdapter.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/admaticBidAdapter.js b/modules/admaticBidAdapter.js index 5bae129363e..148424c0a98 100644 --- a/modules/admaticBidAdapter.js +++ b/modules/admaticBidAdapter.js @@ -61,7 +61,7 @@ export const spec = { if (payload) { switch (bidderName) { case 'pixad': - SYNC_URL = 'https://rtb.pixad.com.tr/sync.html'; + SYNC_URL = 'https://static.pixad.com.tr/sync.html'; break; default: SYNC_URL = 'https://cdn.serve.admatic.com.tr/showad/sync.html'; From 2fc2b1c6a622bfe5c6aed247bd46b06b88216b06 Mon Sep 17 00:00:00 2001 From: Fatih Kaya Date: Mon, 23 Jan 2023 13:50:12 +0300 Subject: [PATCH 25/57] Set currency for AdserverCurrency: bug fix --- modules/admaticBidAdapter.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/admaticBidAdapter.js b/modules/admaticBidAdapter.js index 148424c0a98..808c788fcb9 100644 --- a/modules/admaticBidAdapter.js +++ b/modules/admaticBidAdapter.js @@ -1,5 +1,6 @@ import { getValue, logError, deepAccess, getBidIdParameter, isArray } from '../src/utils.js'; import { registerBidder } from '../src/adapters/bidderFactory.js'; +import { config } from '../src/config.js'; import { BANNER, VIDEO } from '../src/mediaTypes.js'; let SYNC_URL = ''; const BIDDER_CODE = 'admatic'; @@ -35,7 +36,7 @@ export const spec = { const bids = validBidRequests.map(buildRequestObject); const networkId = getValue(validBidRequests[0].params, 'networkId'); const host = getValue(validBidRequests[0].params, 'host'); - const currency = getValue(validBidRequests[0].params, 'currency') || 'TRY'; + const currency = config.getConfig('currency.adServerCurrency') || 'TRY'; const bidderName = validBidRequests[0].bidder; const payload = { From 74f135bfee37c0d2fc71461aecb0b7002b08973a Mon Sep 17 00:00:00 2001 From: Fatih Kaya Date: Mon, 17 Apr 2023 13:01:11 +0300 Subject: [PATCH 26/57] Update admaticBidAdapter.js --- modules/admaticBidAdapter.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/modules/admaticBidAdapter.js b/modules/admaticBidAdapter.js index 808c788fcb9..a159a2b605c 100644 --- a/modules/admaticBidAdapter.js +++ b/modules/admaticBidAdapter.js @@ -1,4 +1,4 @@ -import { getValue, logError, deepAccess, getBidIdParameter, isArray } from '../src/utils.js'; +import { getValue, logError, isEmpty, deepAccess, getBidIdParameter, isArray } from '../src/utils.js'; import { registerBidder } from '../src/adapters/bidderFactory.js'; import { config } from '../src/config.js'; import { BANNER, VIDEO } from '../src/mediaTypes.js'; @@ -34,6 +34,7 @@ export const spec = { */ buildRequests: (validBidRequests, bidderRequest) => { const bids = validBidRequests.map(buildRequestObject); + const blacklist = bidderRequest.ortb2 || {}; const networkId = getValue(validBidRequests[0].params, 'networkId'); const host = getValue(validBidRequests[0].params, 'host'); const currency = config.getConfig('currency.adServerCurrency') || 'TRY'; @@ -59,6 +60,10 @@ export const spec = { } }; + if (!isEmpty(blacklist.badv)) { + payload.blacklist = blacklist.badv; + }; + if (payload) { switch (bidderName) { case 'pixad': From e6b167248cabc26c9fbe5f0ebbd50e37f042765a Mon Sep 17 00:00:00 2001 From: Fatih Kaya Date: Mon, 17 Apr 2023 17:58:27 +0300 Subject: [PATCH 27/57] update --- modules/admaticBidAdapter.js | 2 +- test/spec/modules/admaticBidAdapter_spec.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/admaticBidAdapter.js b/modules/admaticBidAdapter.js index a159a2b605c..c216c66c78e 100644 --- a/modules/admaticBidAdapter.js +++ b/modules/admaticBidAdapter.js @@ -74,7 +74,7 @@ export const spec = { break; } - return { method: 'POST', url: `https://${host}/pb?bidder=${bidderName}`, data: payload, options: { contentType: 'application/json' } }; + return { method: 'POST', url: `https://${host}/pb`, data: payload, options: { contentType: 'application/json' } }; } }, diff --git a/test/spec/modules/admaticBidAdapter_spec.js b/test/spec/modules/admaticBidAdapter_spec.js index 65a7b4111b7..ce4a4a2f0fb 100644 --- a/test/spec/modules/admaticBidAdapter_spec.js +++ b/test/spec/modules/admaticBidAdapter_spec.js @@ -3,7 +3,7 @@ import {spec, storage} from 'modules/admaticBidAdapter.js'; import {newBidder} from 'src/adapters/bidderFactory.js'; import {getStorageManager} from 'src/storageManager'; -const ENDPOINT = 'https://layer.serve.admatic.com.tr/pb?bidder=admatic'; +const ENDPOINT = 'https://layer.serve.admatic.com.tr/pb'; describe('admaticBidAdapter', () => { const adapter = newBidder(spec); From 31e69e88fd9355e143f736754ac2e47fe49b65b6 Mon Sep 17 00:00:00 2001 From: Fatih Kaya Date: Wed, 26 Apr 2023 15:13:11 +0300 Subject: [PATCH 28/57] admatic adapter video params update --- modules/admaticBidAdapter.js | 13 +++++++++++-- package-lock.json | 18 +++++++++++------- test/spec/modules/admaticBidAdapter_spec.js | 19 +++++++++++-------- 3 files changed, 33 insertions(+), 17 deletions(-) diff --git a/modules/admaticBidAdapter.js b/modules/admaticBidAdapter.js index c216c66c78e..2c1b68af258 100644 --- a/modules/admaticBidAdapter.js +++ b/modules/admaticBidAdapter.js @@ -109,8 +109,9 @@ export const spec = { meta: { advertiserDomains: bid && bid.adomain ? bid.adomain : [] }, - ttl: 360, - bidder: bid.bidder + bidder: bid.bidder, + mediaType: bid.type, + ttl: 360 }; bidResponses.push(resbid); @@ -168,6 +169,14 @@ function parseSize(size) { function buildRequestObject(bid) { const reqObj = {}; reqObj.size = getSizes(bid); + if (bid.mediaTypes?.banner) { + reqObj.type = 'banner'; + reqObj.mediatype = {}; + } + if (bid.mediaTypes?.video) { + reqObj.type = 'video'; + reqObj.mediatype = bid.mediaTypes.video; + } reqObj.id = getBidIdParameter('bidId', bid); enrichSlotWithFloors(reqObj, bid); diff --git a/package-lock.json b/package-lock.json index 7baf4ab3094..5d86cc204bc 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6,7 +6,7 @@ "packages": { "": { "name": "prebid.js", - "version": "7.42.0-pre", + "version": "7.47.0-pre", "license": "Apache-2.0", "dependencies": { "@babel/core": "^7.16.7", @@ -6994,9 +6994,9 @@ "dev": true }, "node_modules/caniuse-lite": { - "version": "1.0.30001429", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001429.tgz", - "integrity": "sha512-511ThLu1hF+5RRRt0zYCf2U2yRr9GPF6m5y90SBCWsvSoYoW7yAGlv/elyPaNfvGCkp6kj/KFZWU0BMA69Prsg==", + "version": "1.0.30001481", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001481.tgz", + "integrity": "sha512-KCqHwRnaa1InZBtqXzP98LPg0ajCVujMKjqKDhZEthIpAsJl/YEIa3YvXjGXPVqzZVguccuu7ga9KOE1J9rKPQ==", "funding": [ { "type": "opencollective", @@ -7005,6 +7005,10 @@ { "type": "tidelift", "url": "https://tidelift.com/funding/github/npm/caniuse-lite" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" } ] }, @@ -30623,9 +30627,9 @@ "dev": true }, "caniuse-lite": { - "version": "1.0.30001429", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001429.tgz", - "integrity": "sha512-511ThLu1hF+5RRRt0zYCf2U2yRr9GPF6m5y90SBCWsvSoYoW7yAGlv/elyPaNfvGCkp6kj/KFZWU0BMA69Prsg==" + "version": "1.0.30001481", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001481.tgz", + "integrity": "sha512-KCqHwRnaa1InZBtqXzP98LPg0ajCVujMKjqKDhZEthIpAsJl/YEIa3YvXjGXPVqzZVguccuu7ga9KOE1J9rKPQ==" }, "caseless": { "version": "0.12.0", diff --git a/test/spec/modules/admaticBidAdapter_spec.js b/test/spec/modules/admaticBidAdapter_spec.js index ce4a4a2f0fb..34c4a38f16c 100644 --- a/test/spec/modules/admaticBidAdapter_spec.js +++ b/test/spec/modules/admaticBidAdapter_spec.js @@ -22,6 +22,7 @@ describe('admaticBidAdapter', () => { 'host': 'layer.serve.admatic.com.tr' }, 'adUnitCode': 'adunit-code', + 'mediaType': 'banner', 'sizes': [[300, 250], [300, 600]], 'bidId': '30b31c1838de1e', 'bidderRequestId': '22edbae2733bf6', @@ -34,15 +35,11 @@ describe('admaticBidAdapter', () => { }); it('should return false when required params are not passed', function() { - let bid = Object.assign({}, bid); - delete bid.params; - - bid.params = { - 'networkId': 0, - 'host': 'layer.serve.admatic.com.tr' + let bid2 = {}; + bid2.params = { + 'someIncorrectParam': 0 }; - - expect(spec.isBidRequestValid(bid)).to.equal(false); + expect(spec.isBidRequestValid(bid2)).to.equal(false); }); }); @@ -98,6 +95,8 @@ describe('admaticBidAdapter', () => { 'h': 90 } ], + 'mediatype': {}, + 'type': 'banner', 'id': '2205da7a81846b', 'floors': { 'banner': { @@ -163,6 +162,8 @@ describe('admaticBidAdapter', () => { } ], 'id': '2205da7a81846b', + 'mediatype': {}, + 'type': 'banner', 'floors': { 'banner': { '300x250': { 'currency': 'USD', 'floor': 1 }, @@ -249,6 +250,7 @@ describe('admaticBidAdapter', () => { 'width': 300, 'height': 250, 'price': 0.01, + 'type': 'banner', 'bidder': 'admatic', 'adomain': ['admatic.com.tr'], 'party_tag': '
' @@ -265,6 +267,7 @@ describe('admaticBidAdapter', () => { width: 300, height: 250, currency: 'TRY', + mediaType: 'banner', netRevenue: true, ad: '
', creativeId: '374', From 60a28cae302b711366dab0bff9f49b11862fb8ee Mon Sep 17 00:00:00 2001 From: Fatih Kaya Date: Wed, 26 Apr 2023 21:21:16 +0300 Subject: [PATCH 29/57] Update admaticBidAdapter.js --- modules/admaticBidAdapter.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/modules/admaticBidAdapter.js b/modules/admaticBidAdapter.js index 2c1b68af258..a6a4a5d1e63 100644 --- a/modules/admaticBidAdapter.js +++ b/modules/admaticBidAdapter.js @@ -104,7 +104,9 @@ export const spec = { height: bid.height, currency: body.cur || 'TRY', netRevenue: true, - ad: bid.party_tag, + ad: bid.type == "banner" ? bid.party_tag : undefined, + vastXml: bid.type == "video" ? bid.party_tag : undefined, + vastImpUrl: bid.type == "video" ? bid.iurl : undefined, creativeId: bid.creative_id, meta: { advertiserDomains: bid && bid.adomain ? bid.adomain : [] From a5316e74b612a5b2cd16cf42586334321fc87770 Mon Sep 17 00:00:00 2001 From: Fatih Kaya Date: Wed, 26 Apr 2023 22:59:40 +0300 Subject: [PATCH 30/57] update --- modules/admaticBidAdapter.js | 10 +++++++--- test/spec/modules/admaticBidAdapter_spec.js | 4 +++- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/modules/admaticBidAdapter.js b/modules/admaticBidAdapter.js index a6a4a5d1e63..85b441b3db9 100644 --- a/modules/admaticBidAdapter.js +++ b/modules/admaticBidAdapter.js @@ -104,9 +104,6 @@ export const spec = { height: bid.height, currency: body.cur || 'TRY', netRevenue: true, - ad: bid.type == "banner" ? bid.party_tag : undefined, - vastXml: bid.type == "video" ? bid.party_tag : undefined, - vastImpUrl: bid.type == "video" ? bid.iurl : undefined, creativeId: bid.creative_id, meta: { advertiserDomains: bid && bid.adomain ? bid.adomain : [] @@ -116,6 +113,13 @@ export const spec = { ttl: 360 }; + if (resbid.mediaType === "video") { + resbid.vastXml = bid.party_tag; + resbid.vastImpUrl = bid.iurl; + } else if (resbid.mediaType === "banner") { + resbid.ad = bid.party_tag; + }; + bidResponses.push(resbid); }); } diff --git a/test/spec/modules/admaticBidAdapter_spec.js b/test/spec/modules/admaticBidAdapter_spec.js index 34c4a38f16c..53ae39c642b 100644 --- a/test/spec/modules/admaticBidAdapter_spec.js +++ b/test/spec/modules/admaticBidAdapter_spec.js @@ -253,7 +253,9 @@ describe('admaticBidAdapter', () => { 'type': 'banner', 'bidder': 'admatic', 'adomain': ['admatic.com.tr'], - 'party_tag': '
' + 'party_tag': '
', + 'iurl': 'https://www.admatic.com.tr', + 'type': "banner" } ], 'queryId': 'cdnbh24rlv0hhkpfpln0', From 38fd7abec701d8a4750f9e95eaeb40fb67e9f0e6 Mon Sep 17 00:00:00 2001 From: Fatih Kaya Date: Thu, 27 Apr 2023 09:44:30 +0300 Subject: [PATCH 31/57] Update admaticBidAdapter.js --- modules/admaticBidAdapter.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/modules/admaticBidAdapter.js b/modules/admaticBidAdapter.js index 85b441b3db9..4905c19be40 100644 --- a/modules/admaticBidAdapter.js +++ b/modules/admaticBidAdapter.js @@ -113,7 +113,10 @@ export const spec = { ttl: 360 }; - if (resbid.mediaType === "video") { + if (resbid.mediaType === "video" && isUrl(bid.party_tag)) { + resbid.vastUrl = bid.party_tag; + resbid.vastImpUrl = bid.iurl; + } else if (resbid.mediaType === "video") { resbid.vastXml = bid.party_tag; resbid.vastImpUrl = bid.iurl; } else if (resbid.mediaType === "banner") { @@ -127,6 +130,15 @@ export const spec = { } }; +function isUrl(str) { + try { + new URL(str); + return true; + } catch (error) { + return false; + } +}; + function enrichSlotWithFloors(slot, bidRequest) { try { const slotFloors = {}; From f381a453f9389bebd58dcfa719e9ec17f939f338 Mon Sep 17 00:00:00 2001 From: Fatih Kaya Date: Thu, 27 Apr 2023 11:28:04 +0300 Subject: [PATCH 32/57] update --- modules/admaticBidAdapter.js | 8 ++++---- test/spec/modules/admaticBidAdapter_spec.js | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/modules/admaticBidAdapter.js b/modules/admaticBidAdapter.js index 4905c19be40..f2b717a0367 100644 --- a/modules/admaticBidAdapter.js +++ b/modules/admaticBidAdapter.js @@ -110,16 +110,16 @@ export const spec = { }, bidder: bid.bidder, mediaType: bid.type, - ttl: 360 + ttl: 60 }; - if (resbid.mediaType === "video" && isUrl(bid.party_tag)) { + if (resbid.mediaType === 'video' && isUrl(bid.party_tag)) { resbid.vastUrl = bid.party_tag; resbid.vastImpUrl = bid.iurl; - } else if (resbid.mediaType === "video") { + } else if (resbid.mediaType === 'video') { resbid.vastXml = bid.party_tag; resbid.vastImpUrl = bid.iurl; - } else if (resbid.mediaType === "banner") { + } else if (resbid.mediaType === 'banner') { resbid.ad = bid.party_tag; }; diff --git a/test/spec/modules/admaticBidAdapter_spec.js b/test/spec/modules/admaticBidAdapter_spec.js index 53ae39c642b..9bafcf0d33e 100644 --- a/test/spec/modules/admaticBidAdapter_spec.js +++ b/test/spec/modules/admaticBidAdapter_spec.js @@ -255,7 +255,7 @@ describe('admaticBidAdapter', () => { 'adomain': ['admatic.com.tr'], 'party_tag': '
', 'iurl': 'https://www.admatic.com.tr', - 'type': "banner" + 'type': 'banner' } ], 'queryId': 'cdnbh24rlv0hhkpfpln0', @@ -276,7 +276,7 @@ describe('admaticBidAdapter', () => { meta: { advertiserDomains: ['admatic.com.tr'] }, - ttl: 360, + ttl: 60, bidder: 'admatic' } ]; From 689ce9d21e08c27be49adb35c5fd5205aef5c35c Mon Sep 17 00:00:00 2001 From: Fatih Kaya Date: Thu, 27 Apr 2023 13:17:50 +0300 Subject: [PATCH 33/57] update --- modules/admaticBidAdapter.js | 5 +- test/spec/modules/admaticBidAdapter_spec.js | 154 +++++++++++++++++++- 2 files changed, 154 insertions(+), 5 deletions(-) diff --git a/modules/admaticBidAdapter.js b/modules/admaticBidAdapter.js index f2b717a0367..9f2e8b1943e 100644 --- a/modules/admaticBidAdapter.js +++ b/modules/admaticBidAdapter.js @@ -57,7 +57,8 @@ export const spec = { ext: { cur: currency, bidder: bidderName - } + }, + tmax: bidderRequest.timeout }; if (!isEmpty(blacklist.badv)) { @@ -132,7 +133,7 @@ export const spec = { function isUrl(str) { try { - new URL(str); + URL(str); return true; } catch (error) { return false; diff --git a/test/spec/modules/admaticBidAdapter_spec.js b/test/spec/modules/admaticBidAdapter_spec.js index 9bafcf0d33e..d100fc8e880 100644 --- a/test/spec/modules/admaticBidAdapter_spec.js +++ b/test/spec/modules/admaticBidAdapter_spec.js @@ -27,7 +27,8 @@ describe('admaticBidAdapter', () => { 'bidId': '30b31c1838de1e', 'bidderRequestId': '22edbae2733bf6', 'auctionId': '1d1a030790a475', - 'creativeId': 'er2ee' + 'creativeId': 'er2ee', + 'ortb2': { 'badv': ['admatic.com.tr'] } }; it('should return true when required params found', function() { @@ -51,6 +52,7 @@ describe('admaticBidAdapter', () => { 'networkId': 10433394, 'host': 'layer.serve.admatic.com.tr' }, + 'ortb2': { 'badv': ['admatic.com.tr'] }, 'mediaTypes': { 'banner': { 'sizes': [[300, 250], [728, 90]] @@ -104,6 +106,49 @@ describe('admaticBidAdapter', () => { '728x90': { 'currency': 'USD', 'floor': 2 } } } + }, + { + "size": [ + { + "w": 338, + "h": 280 + } + ], + "type": "video", + "mediatype": { + "context": "instream", + "mimes": [ + "video/mp4" + ], + "maxduration": 240, + "api": [ + 1, + 2 + ], + "playerSize": [ + [ + 338, + 280 + ] + ], + "protocols": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8 + ], + "skip": 1, + "playbackmethod": [ + 2 + ], + "linearity": 1, + "placement": 2 + }, + "id": "45e86fc7ce7fc93" } ], 'ext': { @@ -117,6 +162,7 @@ describe('admaticBidAdapter', () => { 'networkId': 10433394, 'host': 'layer.serve.admatic.com.tr' }, + 'ortb2': { 'badv': ['admatic.com.tr'] }, 'mediaTypes': { 'banner': { 'sizes': [[300, 250], [728, 90]] @@ -170,6 +216,49 @@ describe('admaticBidAdapter', () => { '728x90': { 'currency': 'USD', 'floor': 2 } } } + }, + { + "size": [ + { + "w": 338, + "h": 280 + } + ], + "type": "video", + "mediatype": { + "context": "instream", + "mimes": [ + "video/mp4" + ], + "maxduration": 240, + "api": [ + 1, + 2 + ], + "playerSize": [ + [ + 338, + 280 + ] + ], + "protocols": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8 + ], + "skip": 1, + "playbackmethod": [ + 2 + ], + "linearity": 1, + "placement": 2 + }, + "id": "45e86fc7ce7fc93" } ], 'ext': { @@ -195,6 +284,7 @@ describe('admaticBidAdapter', () => { 'sizes': [[300, 250], [728, 90]] } }, + 'ortb2': { 'badv': ['admatic.com.tr'] }, getFloor: inputParams => { if (inputParams.mediaType === BANNER && inputParams.size[0] === 300 && inputParams.size[1] === 250) { return { @@ -218,6 +308,7 @@ describe('admaticBidAdapter', () => { 'networkId': 10433394, 'host': 'layer.serve.admatic.com.tr' }, + 'ortb2': { 'badv': ['admatic.com.tr'] }, 'adUnitCode': 'adunit-code', 'sizes': [[300, 250], [728, 90]], 'bidId': '30b31c1838de1e', @@ -254,8 +345,31 @@ describe('admaticBidAdapter', () => { 'bidder': 'admatic', 'adomain': ['admatic.com.tr'], 'party_tag': '
', - 'iurl': 'https://www.admatic.com.tr', - 'type': 'banner' + 'iurl': 'https://www.admatic.com.tr' + }, + { + 'id': 2, + 'creative_id': '3741', + 'width': 300, + 'height': 250, + 'price': 0.01, + 'type': 'video', + 'bidder': 'admatic', + 'adomain': ['admatic.com.tr'], + 'party_tag': '', + 'iurl': 'https://www.admatic.com.tr' + }, + { + 'id': 3, + 'creative_id': '3741', + 'width': 300, + 'height': 250, + 'price': 0.01, + 'type': 'video', + 'bidder': 'admatic', + 'adomain': ['admatic.com.tr'], + 'party_tag': 'https://www.admatic.com.tr', + 'iurl': 'https://www.admatic.com.tr' } ], 'queryId': 'cdnbh24rlv0hhkpfpln0', @@ -278,6 +392,40 @@ describe('admaticBidAdapter', () => { }, ttl: 60, bidder: 'admatic' + }, + { + requestId: 2, + cpm: 0.01, + width: 300, + height: 250, + currency: 'TRY', + mediaType: 'video', + netRevenue: true, + vastImpUrl: 'https://www.admatic.com.tr', + vastXml: '', + creativeId: '3741', + meta: { + advertiserDomains: ['admatic.com.tr'] + }, + ttl: 60, + bidder: 'admatic' + }, + { + requestId: 3, + cpm: 0.01, + width: 300, + height: 250, + currency: 'TRY', + mediaType: 'video', + netRevenue: true, + vastImpUrl: 'https://www.admatic.com.tr', + vastXml: 'https://www.admatic.com.tr', + creativeId: '3741', + meta: { + advertiserDomains: ['admatic.com.tr'] + }, + ttl: 60, + bidder: 'admatic' } ]; const request = { From 1ca659798b0c9b912634b1673e15e54e547b81e7 Mon Sep 17 00:00:00 2001 From: Fatih Kaya Date: Thu, 27 Apr 2023 13:24:30 +0300 Subject: [PATCH 34/57] Update admaticBidAdapter_spec.js --- test/spec/modules/admaticBidAdapter_spec.js | 68 ++++++++++----------- 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/test/spec/modules/admaticBidAdapter_spec.js b/test/spec/modules/admaticBidAdapter_spec.js index d100fc8e880..1d2fb1e79cb 100644 --- a/test/spec/modules/admaticBidAdapter_spec.js +++ b/test/spec/modules/admaticBidAdapter_spec.js @@ -108,30 +108,30 @@ describe('admaticBidAdapter', () => { } }, { - "size": [ + 'size': [ { - "w": 338, - "h": 280 + 'w': 338, + 'h': 280 } ], - "type": "video", - "mediatype": { - "context": "instream", - "mimes": [ - "video/mp4" + 'type': 'video', + 'mediatype': { + 'context': 'instream', + 'mimes': [ + 'video/mp4' ], - "maxduration": 240, - "api": [ + 'maxduration': 240, + 'api': [ 1, 2 ], - "playerSize": [ + 'playerSize': [ [ 338, 280 ] ], - "protocols": [ + 'protocols': [ 1, 2, 3, @@ -141,14 +141,14 @@ describe('admaticBidAdapter', () => { 7, 8 ], - "skip": 1, - "playbackmethod": [ + 'skip': 1, + 'playbackmethod': [ 2 ], - "linearity": 1, - "placement": 2 + 'linearity': 1, + 'placement': 2 }, - "id": "45e86fc7ce7fc93" + 'id': '45e86fc7ce7fc93' } ], 'ext': { @@ -218,30 +218,30 @@ describe('admaticBidAdapter', () => { } }, { - "size": [ + 'size': [ { - "w": 338, - "h": 280 + 'w': 338, + 'h': 280 } ], - "type": "video", - "mediatype": { - "context": "instream", - "mimes": [ - "video/mp4" + 'type': 'video', + 'mediatype': { + 'context': 'instream', + 'mimes': [ + 'video/mp4' ], - "maxduration": 240, - "api": [ + 'maxduration': 240, + 'api': [ 1, 2 ], - "playerSize": [ + 'playerSize': [ [ 338, 280 ] ], - "protocols": [ + 'protocols': [ 1, 2, 3, @@ -251,14 +251,14 @@ describe('admaticBidAdapter', () => { 7, 8 ], - "skip": 1, - "playbackmethod": [ + 'skip': 1, + 'playbackmethod': [ 2 ], - "linearity": 1, - "placement": 2 + 'linearity': 1, + 'placement': 2 }, - "id": "45e86fc7ce7fc93" + 'id': '45e86fc7ce7fc93' } ], 'ext': { From b1929ece33bb4040a3bcd6b9332b50335356829c Mon Sep 17 00:00:00 2001 From: Fatih Kaya Date: Thu, 27 Apr 2023 14:48:58 +0300 Subject: [PATCH 35/57] Update admaticBidAdapter.js --- modules/admaticBidAdapter.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/modules/admaticBidAdapter.js b/modules/admaticBidAdapter.js index 9f2e8b1943e..b10f36968fd 100644 --- a/modules/admaticBidAdapter.js +++ b/modules/admaticBidAdapter.js @@ -57,8 +57,7 @@ export const spec = { ext: { cur: currency, bidder: bidderName - }, - tmax: bidderRequest.timeout + } }; if (!isEmpty(blacklist.badv)) { From 1216892fe55e5ab24dda8e045ea007ee6bb40ff8 Mon Sep 17 00:00:00 2001 From: Fatih Kaya Date: Fri, 28 Apr 2023 11:42:29 +0300 Subject: [PATCH 36/57] Update admaticBidAdapter.js --- modules/admaticBidAdapter.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/admaticBidAdapter.js b/modules/admaticBidAdapter.js index b10f36968fd..1a7c4038105 100644 --- a/modules/admaticBidAdapter.js +++ b/modules/admaticBidAdapter.js @@ -93,7 +93,7 @@ export const spec = { * @return {Bid[]} */ interpretResponse: (response, request) => { - const body = response.body || response; + const body = response.body; const bidResponses = []; if (body && body?.data && isArray(body.data)) { body.data.forEach(bid => { From 5d486e3d30f1b23a7139dbde61d699070c0e86ca Mon Sep 17 00:00:00 2001 From: Fatih Kaya Date: Fri, 28 Apr 2023 11:47:13 +0300 Subject: [PATCH 37/57] Revert "Update admaticBidAdapter.js" This reverts commit 1216892fe55e5ab24dda8e045ea007ee6bb40ff8. --- modules/admaticBidAdapter.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/admaticBidAdapter.js b/modules/admaticBidAdapter.js index 1a7c4038105..b10f36968fd 100644 --- a/modules/admaticBidAdapter.js +++ b/modules/admaticBidAdapter.js @@ -93,7 +93,7 @@ export const spec = { * @return {Bid[]} */ interpretResponse: (response, request) => { - const body = response.body; + const body = response.body || response; const bidResponses = []; if (body && body?.data && isArray(body.data)) { body.data.forEach(bid => { From 473e417fbdf29e71f16e0d3914daf8fad34d1797 Mon Sep 17 00:00:00 2001 From: Fatih Kaya Date: Fri, 28 Apr 2023 11:47:58 +0300 Subject: [PATCH 38/57] Revert "Update admaticBidAdapter.js" This reverts commit b1929ece33bb4040a3bcd6b9332b50335356829c. --- modules/admaticBidAdapter.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/admaticBidAdapter.js b/modules/admaticBidAdapter.js index b10f36968fd..9f2e8b1943e 100644 --- a/modules/admaticBidAdapter.js +++ b/modules/admaticBidAdapter.js @@ -57,7 +57,8 @@ export const spec = { ext: { cur: currency, bidder: bidderName - } + }, + tmax: bidderRequest.timeout }; if (!isEmpty(blacklist.badv)) { From 13b25ffe97d09c8b6e059edac7b3598e2076bf04 Mon Sep 17 00:00:00 2001 From: Fatih Kaya Date: Fri, 28 Apr 2023 11:48:05 +0300 Subject: [PATCH 39/57] Revert "Update admaticBidAdapter_spec.js" This reverts commit 1ca659798b0c9b912634b1673e15e54e547b81e7. --- test/spec/modules/admaticBidAdapter_spec.js | 68 ++++++++++----------- 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/test/spec/modules/admaticBidAdapter_spec.js b/test/spec/modules/admaticBidAdapter_spec.js index 1d2fb1e79cb..d100fc8e880 100644 --- a/test/spec/modules/admaticBidAdapter_spec.js +++ b/test/spec/modules/admaticBidAdapter_spec.js @@ -108,30 +108,30 @@ describe('admaticBidAdapter', () => { } }, { - 'size': [ + "size": [ { - 'w': 338, - 'h': 280 + "w": 338, + "h": 280 } ], - 'type': 'video', - 'mediatype': { - 'context': 'instream', - 'mimes': [ - 'video/mp4' + "type": "video", + "mediatype": { + "context": "instream", + "mimes": [ + "video/mp4" ], - 'maxduration': 240, - 'api': [ + "maxduration": 240, + "api": [ 1, 2 ], - 'playerSize': [ + "playerSize": [ [ 338, 280 ] ], - 'protocols': [ + "protocols": [ 1, 2, 3, @@ -141,14 +141,14 @@ describe('admaticBidAdapter', () => { 7, 8 ], - 'skip': 1, - 'playbackmethod': [ + "skip": 1, + "playbackmethod": [ 2 ], - 'linearity': 1, - 'placement': 2 + "linearity": 1, + "placement": 2 }, - 'id': '45e86fc7ce7fc93' + "id": "45e86fc7ce7fc93" } ], 'ext': { @@ -218,30 +218,30 @@ describe('admaticBidAdapter', () => { } }, { - 'size': [ + "size": [ { - 'w': 338, - 'h': 280 + "w": 338, + "h": 280 } ], - 'type': 'video', - 'mediatype': { - 'context': 'instream', - 'mimes': [ - 'video/mp4' + "type": "video", + "mediatype": { + "context": "instream", + "mimes": [ + "video/mp4" ], - 'maxduration': 240, - 'api': [ + "maxduration": 240, + "api": [ 1, 2 ], - 'playerSize': [ + "playerSize": [ [ 338, 280 ] ], - 'protocols': [ + "protocols": [ 1, 2, 3, @@ -251,14 +251,14 @@ describe('admaticBidAdapter', () => { 7, 8 ], - 'skip': 1, - 'playbackmethod': [ + "skip": 1, + "playbackmethod": [ 2 ], - 'linearity': 1, - 'placement': 2 + "linearity": 1, + "placement": 2 }, - 'id': '45e86fc7ce7fc93' + "id": "45e86fc7ce7fc93" } ], 'ext': { From 93b0e7d2b4377f59403137d12dee95ef15850d97 Mon Sep 17 00:00:00 2001 From: Fatih Kaya Date: Fri, 28 Apr 2023 11:48:12 +0300 Subject: [PATCH 40/57] Revert "update" This reverts commit 689ce9d21e08c27be49adb35c5fd5205aef5c35c. --- modules/admaticBidAdapter.js | 5 +- test/spec/modules/admaticBidAdapter_spec.js | 154 +------------------- 2 files changed, 5 insertions(+), 154 deletions(-) diff --git a/modules/admaticBidAdapter.js b/modules/admaticBidAdapter.js index 9f2e8b1943e..f2b717a0367 100644 --- a/modules/admaticBidAdapter.js +++ b/modules/admaticBidAdapter.js @@ -57,8 +57,7 @@ export const spec = { ext: { cur: currency, bidder: bidderName - }, - tmax: bidderRequest.timeout + } }; if (!isEmpty(blacklist.badv)) { @@ -133,7 +132,7 @@ export const spec = { function isUrl(str) { try { - URL(str); + new URL(str); return true; } catch (error) { return false; diff --git a/test/spec/modules/admaticBidAdapter_spec.js b/test/spec/modules/admaticBidAdapter_spec.js index d100fc8e880..9bafcf0d33e 100644 --- a/test/spec/modules/admaticBidAdapter_spec.js +++ b/test/spec/modules/admaticBidAdapter_spec.js @@ -27,8 +27,7 @@ describe('admaticBidAdapter', () => { 'bidId': '30b31c1838de1e', 'bidderRequestId': '22edbae2733bf6', 'auctionId': '1d1a030790a475', - 'creativeId': 'er2ee', - 'ortb2': { 'badv': ['admatic.com.tr'] } + 'creativeId': 'er2ee' }; it('should return true when required params found', function() { @@ -52,7 +51,6 @@ describe('admaticBidAdapter', () => { 'networkId': 10433394, 'host': 'layer.serve.admatic.com.tr' }, - 'ortb2': { 'badv': ['admatic.com.tr'] }, 'mediaTypes': { 'banner': { 'sizes': [[300, 250], [728, 90]] @@ -106,49 +104,6 @@ describe('admaticBidAdapter', () => { '728x90': { 'currency': 'USD', 'floor': 2 } } } - }, - { - "size": [ - { - "w": 338, - "h": 280 - } - ], - "type": "video", - "mediatype": { - "context": "instream", - "mimes": [ - "video/mp4" - ], - "maxduration": 240, - "api": [ - 1, - 2 - ], - "playerSize": [ - [ - 338, - 280 - ] - ], - "protocols": [ - 1, - 2, - 3, - 4, - 5, - 6, - 7, - 8 - ], - "skip": 1, - "playbackmethod": [ - 2 - ], - "linearity": 1, - "placement": 2 - }, - "id": "45e86fc7ce7fc93" } ], 'ext': { @@ -162,7 +117,6 @@ describe('admaticBidAdapter', () => { 'networkId': 10433394, 'host': 'layer.serve.admatic.com.tr' }, - 'ortb2': { 'badv': ['admatic.com.tr'] }, 'mediaTypes': { 'banner': { 'sizes': [[300, 250], [728, 90]] @@ -216,49 +170,6 @@ describe('admaticBidAdapter', () => { '728x90': { 'currency': 'USD', 'floor': 2 } } } - }, - { - "size": [ - { - "w": 338, - "h": 280 - } - ], - "type": "video", - "mediatype": { - "context": "instream", - "mimes": [ - "video/mp4" - ], - "maxduration": 240, - "api": [ - 1, - 2 - ], - "playerSize": [ - [ - 338, - 280 - ] - ], - "protocols": [ - 1, - 2, - 3, - 4, - 5, - 6, - 7, - 8 - ], - "skip": 1, - "playbackmethod": [ - 2 - ], - "linearity": 1, - "placement": 2 - }, - "id": "45e86fc7ce7fc93" } ], 'ext': { @@ -284,7 +195,6 @@ describe('admaticBidAdapter', () => { 'sizes': [[300, 250], [728, 90]] } }, - 'ortb2': { 'badv': ['admatic.com.tr'] }, getFloor: inputParams => { if (inputParams.mediaType === BANNER && inputParams.size[0] === 300 && inputParams.size[1] === 250) { return { @@ -308,7 +218,6 @@ describe('admaticBidAdapter', () => { 'networkId': 10433394, 'host': 'layer.serve.admatic.com.tr' }, - 'ortb2': { 'badv': ['admatic.com.tr'] }, 'adUnitCode': 'adunit-code', 'sizes': [[300, 250], [728, 90]], 'bidId': '30b31c1838de1e', @@ -345,31 +254,8 @@ describe('admaticBidAdapter', () => { 'bidder': 'admatic', 'adomain': ['admatic.com.tr'], 'party_tag': '
', - 'iurl': 'https://www.admatic.com.tr' - }, - { - 'id': 2, - 'creative_id': '3741', - 'width': 300, - 'height': 250, - 'price': 0.01, - 'type': 'video', - 'bidder': 'admatic', - 'adomain': ['admatic.com.tr'], - 'party_tag': '', - 'iurl': 'https://www.admatic.com.tr' - }, - { - 'id': 3, - 'creative_id': '3741', - 'width': 300, - 'height': 250, - 'price': 0.01, - 'type': 'video', - 'bidder': 'admatic', - 'adomain': ['admatic.com.tr'], - 'party_tag': 'https://www.admatic.com.tr', - 'iurl': 'https://www.admatic.com.tr' + 'iurl': 'https://www.admatic.com.tr', + 'type': 'banner' } ], 'queryId': 'cdnbh24rlv0hhkpfpln0', @@ -392,40 +278,6 @@ describe('admaticBidAdapter', () => { }, ttl: 60, bidder: 'admatic' - }, - { - requestId: 2, - cpm: 0.01, - width: 300, - height: 250, - currency: 'TRY', - mediaType: 'video', - netRevenue: true, - vastImpUrl: 'https://www.admatic.com.tr', - vastXml: '', - creativeId: '3741', - meta: { - advertiserDomains: ['admatic.com.tr'] - }, - ttl: 60, - bidder: 'admatic' - }, - { - requestId: 3, - cpm: 0.01, - width: 300, - height: 250, - currency: 'TRY', - mediaType: 'video', - netRevenue: true, - vastImpUrl: 'https://www.admatic.com.tr', - vastXml: 'https://www.admatic.com.tr', - creativeId: '3741', - meta: { - advertiserDomains: ['admatic.com.tr'] - }, - ttl: 60, - bidder: 'admatic' } ]; const request = { From 1c904d190cf987632dbcc314a94607b63ab7e50b Mon Sep 17 00:00:00 2001 From: Fatih Kaya Date: Fri, 28 Apr 2023 11:48:19 +0300 Subject: [PATCH 41/57] Revert "update" This reverts commit f381a453f9389bebd58dcfa719e9ec17f939f338. --- modules/admaticBidAdapter.js | 8 ++++---- test/spec/modules/admaticBidAdapter_spec.js | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/modules/admaticBidAdapter.js b/modules/admaticBidAdapter.js index f2b717a0367..4905c19be40 100644 --- a/modules/admaticBidAdapter.js +++ b/modules/admaticBidAdapter.js @@ -110,16 +110,16 @@ export const spec = { }, bidder: bid.bidder, mediaType: bid.type, - ttl: 60 + ttl: 360 }; - if (resbid.mediaType === 'video' && isUrl(bid.party_tag)) { + if (resbid.mediaType === "video" && isUrl(bid.party_tag)) { resbid.vastUrl = bid.party_tag; resbid.vastImpUrl = bid.iurl; - } else if (resbid.mediaType === 'video') { + } else if (resbid.mediaType === "video") { resbid.vastXml = bid.party_tag; resbid.vastImpUrl = bid.iurl; - } else if (resbid.mediaType === 'banner') { + } else if (resbid.mediaType === "banner") { resbid.ad = bid.party_tag; }; diff --git a/test/spec/modules/admaticBidAdapter_spec.js b/test/spec/modules/admaticBidAdapter_spec.js index 9bafcf0d33e..53ae39c642b 100644 --- a/test/spec/modules/admaticBidAdapter_spec.js +++ b/test/spec/modules/admaticBidAdapter_spec.js @@ -255,7 +255,7 @@ describe('admaticBidAdapter', () => { 'adomain': ['admatic.com.tr'], 'party_tag': '
', 'iurl': 'https://www.admatic.com.tr', - 'type': 'banner' + 'type': "banner" } ], 'queryId': 'cdnbh24rlv0hhkpfpln0', @@ -276,7 +276,7 @@ describe('admaticBidAdapter', () => { meta: { advertiserDomains: ['admatic.com.tr'] }, - ttl: 60, + ttl: 360, bidder: 'admatic' } ]; From c762aeb68b986a7033be7040933e604813fa8f46 Mon Sep 17 00:00:00 2001 From: Fatih Kaya Date: Fri, 28 Apr 2023 11:48:24 +0300 Subject: [PATCH 42/57] Revert "Update admaticBidAdapter.js" This reverts commit 38fd7abec701d8a4750f9e95eaeb40fb67e9f0e6. --- modules/admaticBidAdapter.js | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/modules/admaticBidAdapter.js b/modules/admaticBidAdapter.js index 4905c19be40..85b441b3db9 100644 --- a/modules/admaticBidAdapter.js +++ b/modules/admaticBidAdapter.js @@ -113,10 +113,7 @@ export const spec = { ttl: 360 }; - if (resbid.mediaType === "video" && isUrl(bid.party_tag)) { - resbid.vastUrl = bid.party_tag; - resbid.vastImpUrl = bid.iurl; - } else if (resbid.mediaType === "video") { + if (resbid.mediaType === "video") { resbid.vastXml = bid.party_tag; resbid.vastImpUrl = bid.iurl; } else if (resbid.mediaType === "banner") { @@ -130,15 +127,6 @@ export const spec = { } }; -function isUrl(str) { - try { - new URL(str); - return true; - } catch (error) { - return false; - } -}; - function enrichSlotWithFloors(slot, bidRequest) { try { const slotFloors = {}; From 0520e1c8e7388bbecfb314688c62e7c87c7e7ac7 Mon Sep 17 00:00:00 2001 From: Fatih Kaya Date: Fri, 28 Apr 2023 11:48:30 +0300 Subject: [PATCH 43/57] Revert "update" This reverts commit a5316e74b612a5b2cd16cf42586334321fc87770. --- modules/admaticBidAdapter.js | 10 +++------- test/spec/modules/admaticBidAdapter_spec.js | 4 +--- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/modules/admaticBidAdapter.js b/modules/admaticBidAdapter.js index 85b441b3db9..a6a4a5d1e63 100644 --- a/modules/admaticBidAdapter.js +++ b/modules/admaticBidAdapter.js @@ -104,6 +104,9 @@ export const spec = { height: bid.height, currency: body.cur || 'TRY', netRevenue: true, + ad: bid.type == "banner" ? bid.party_tag : undefined, + vastXml: bid.type == "video" ? bid.party_tag : undefined, + vastImpUrl: bid.type == "video" ? bid.iurl : undefined, creativeId: bid.creative_id, meta: { advertiserDomains: bid && bid.adomain ? bid.adomain : [] @@ -113,13 +116,6 @@ export const spec = { ttl: 360 }; - if (resbid.mediaType === "video") { - resbid.vastXml = bid.party_tag; - resbid.vastImpUrl = bid.iurl; - } else if (resbid.mediaType === "banner") { - resbid.ad = bid.party_tag; - }; - bidResponses.push(resbid); }); } diff --git a/test/spec/modules/admaticBidAdapter_spec.js b/test/spec/modules/admaticBidAdapter_spec.js index 53ae39c642b..34c4a38f16c 100644 --- a/test/spec/modules/admaticBidAdapter_spec.js +++ b/test/spec/modules/admaticBidAdapter_spec.js @@ -253,9 +253,7 @@ describe('admaticBidAdapter', () => { 'type': 'banner', 'bidder': 'admatic', 'adomain': ['admatic.com.tr'], - 'party_tag': '
', - 'iurl': 'https://www.admatic.com.tr', - 'type': "banner" + 'party_tag': '
' } ], 'queryId': 'cdnbh24rlv0hhkpfpln0', From 578c49b01b39cba55c1055958db3b0ab12792a20 Mon Sep 17 00:00:00 2001 From: Fatih Kaya Date: Fri, 28 Apr 2023 11:48:36 +0300 Subject: [PATCH 44/57] Revert "Update admaticBidAdapter.js" This reverts commit 60a28cae302b711366dab0bff9f49b11862fb8ee. --- modules/admaticBidAdapter.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/modules/admaticBidAdapter.js b/modules/admaticBidAdapter.js index a6a4a5d1e63..2c1b68af258 100644 --- a/modules/admaticBidAdapter.js +++ b/modules/admaticBidAdapter.js @@ -104,9 +104,7 @@ export const spec = { height: bid.height, currency: body.cur || 'TRY', netRevenue: true, - ad: bid.type == "banner" ? bid.party_tag : undefined, - vastXml: bid.type == "video" ? bid.party_tag : undefined, - vastImpUrl: bid.type == "video" ? bid.iurl : undefined, + ad: bid.party_tag, creativeId: bid.creative_id, meta: { advertiserDomains: bid && bid.adomain ? bid.adomain : [] From 6b04200f711c1daadeb5b563bf94a040793d9452 Mon Sep 17 00:00:00 2001 From: Fatih Kaya Date: Fri, 28 Apr 2023 11:48:41 +0300 Subject: [PATCH 45/57] Revert "admatic adapter video params update" This reverts commit 31e69e88fd9355e143f736754ac2e47fe49b65b6. --- modules/admaticBidAdapter.js | 13 ++----------- package-lock.json | 18 +++++++----------- test/spec/modules/admaticBidAdapter_spec.js | 19 ++++++++----------- 3 files changed, 17 insertions(+), 33 deletions(-) diff --git a/modules/admaticBidAdapter.js b/modules/admaticBidAdapter.js index 2c1b68af258..c216c66c78e 100644 --- a/modules/admaticBidAdapter.js +++ b/modules/admaticBidAdapter.js @@ -109,9 +109,8 @@ export const spec = { meta: { advertiserDomains: bid && bid.adomain ? bid.adomain : [] }, - bidder: bid.bidder, - mediaType: bid.type, - ttl: 360 + ttl: 360, + bidder: bid.bidder }; bidResponses.push(resbid); @@ -169,14 +168,6 @@ function parseSize(size) { function buildRequestObject(bid) { const reqObj = {}; reqObj.size = getSizes(bid); - if (bid.mediaTypes?.banner) { - reqObj.type = 'banner'; - reqObj.mediatype = {}; - } - if (bid.mediaTypes?.video) { - reqObj.type = 'video'; - reqObj.mediatype = bid.mediaTypes.video; - } reqObj.id = getBidIdParameter('bidId', bid); enrichSlotWithFloors(reqObj, bid); diff --git a/package-lock.json b/package-lock.json index 5d86cc204bc..7baf4ab3094 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6,7 +6,7 @@ "packages": { "": { "name": "prebid.js", - "version": "7.47.0-pre", + "version": "7.42.0-pre", "license": "Apache-2.0", "dependencies": { "@babel/core": "^7.16.7", @@ -6994,9 +6994,9 @@ "dev": true }, "node_modules/caniuse-lite": { - "version": "1.0.30001481", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001481.tgz", - "integrity": "sha512-KCqHwRnaa1InZBtqXzP98LPg0ajCVujMKjqKDhZEthIpAsJl/YEIa3YvXjGXPVqzZVguccuu7ga9KOE1J9rKPQ==", + "version": "1.0.30001429", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001429.tgz", + "integrity": "sha512-511ThLu1hF+5RRRt0zYCf2U2yRr9GPF6m5y90SBCWsvSoYoW7yAGlv/elyPaNfvGCkp6kj/KFZWU0BMA69Prsg==", "funding": [ { "type": "opencollective", @@ -7005,10 +7005,6 @@ { "type": "tidelift", "url": "https://tidelift.com/funding/github/npm/caniuse-lite" - }, - { - "type": "github", - "url": "https://github.com/sponsors/ai" } ] }, @@ -30627,9 +30623,9 @@ "dev": true }, "caniuse-lite": { - "version": "1.0.30001481", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001481.tgz", - "integrity": "sha512-KCqHwRnaa1InZBtqXzP98LPg0ajCVujMKjqKDhZEthIpAsJl/YEIa3YvXjGXPVqzZVguccuu7ga9KOE1J9rKPQ==" + "version": "1.0.30001429", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001429.tgz", + "integrity": "sha512-511ThLu1hF+5RRRt0zYCf2U2yRr9GPF6m5y90SBCWsvSoYoW7yAGlv/elyPaNfvGCkp6kj/KFZWU0BMA69Prsg==" }, "caseless": { "version": "0.12.0", diff --git a/test/spec/modules/admaticBidAdapter_spec.js b/test/spec/modules/admaticBidAdapter_spec.js index 34c4a38f16c..ce4a4a2f0fb 100644 --- a/test/spec/modules/admaticBidAdapter_spec.js +++ b/test/spec/modules/admaticBidAdapter_spec.js @@ -22,7 +22,6 @@ describe('admaticBidAdapter', () => { 'host': 'layer.serve.admatic.com.tr' }, 'adUnitCode': 'adunit-code', - 'mediaType': 'banner', 'sizes': [[300, 250], [300, 600]], 'bidId': '30b31c1838de1e', 'bidderRequestId': '22edbae2733bf6', @@ -35,11 +34,15 @@ describe('admaticBidAdapter', () => { }); it('should return false when required params are not passed', function() { - let bid2 = {}; - bid2.params = { - 'someIncorrectParam': 0 + let bid = Object.assign({}, bid); + delete bid.params; + + bid.params = { + 'networkId': 0, + 'host': 'layer.serve.admatic.com.tr' }; - expect(spec.isBidRequestValid(bid2)).to.equal(false); + + expect(spec.isBidRequestValid(bid)).to.equal(false); }); }); @@ -95,8 +98,6 @@ describe('admaticBidAdapter', () => { 'h': 90 } ], - 'mediatype': {}, - 'type': 'banner', 'id': '2205da7a81846b', 'floors': { 'banner': { @@ -162,8 +163,6 @@ describe('admaticBidAdapter', () => { } ], 'id': '2205da7a81846b', - 'mediatype': {}, - 'type': 'banner', 'floors': { 'banner': { '300x250': { 'currency': 'USD', 'floor': 1 }, @@ -250,7 +249,6 @@ describe('admaticBidAdapter', () => { 'width': 300, 'height': 250, 'price': 0.01, - 'type': 'banner', 'bidder': 'admatic', 'adomain': ['admatic.com.tr'], 'party_tag': '
' @@ -267,7 +265,6 @@ describe('admaticBidAdapter', () => { width: 300, height: 250, currency: 'TRY', - mediaType: 'banner', netRevenue: true, ad: '
', creativeId: '374', From 941bb03b14d0b8cf01413f034cae1ac1118fd7cd Mon Sep 17 00:00:00 2001 From: Fatih Kaya Date: Fri, 28 Apr 2023 12:13:21 +0300 Subject: [PATCH 46/57] update --- modules/admaticBidAdapter.js | 37 ++++- test/spec/modules/admaticBidAdapter_spec.js | 175 ++++++++++++++++++-- 2 files changed, 196 insertions(+), 16 deletions(-) diff --git a/modules/admaticBidAdapter.js b/modules/admaticBidAdapter.js index c216c66c78e..027f924ac5d 100644 --- a/modules/admaticBidAdapter.js +++ b/modules/admaticBidAdapter.js @@ -34,7 +34,7 @@ export const spec = { */ buildRequests: (validBidRequests, bidderRequest) => { const bids = validBidRequests.map(buildRequestObject); - const blacklist = bidderRequest.ortb2 || {}; + const blacklist = bidderRequest.ortb2; const networkId = getValue(validBidRequests[0].params, 'networkId'); const host = getValue(validBidRequests[0].params, 'host'); const currency = config.getConfig('currency.adServerCurrency') || 'TRY'; @@ -93,7 +93,7 @@ export const spec = { * @return {Bid[]} */ interpretResponse: (response, request) => { - const body = response.body || response; + const body = response.body; const bidResponses = []; if (body && body?.data && isArray(body.data)) { body.data.forEach(bid => { @@ -104,13 +104,23 @@ export const spec = { height: bid.height, currency: body.cur || 'TRY', netRevenue: true, - ad: bid.party_tag, creativeId: bid.creative_id, meta: { advertiserDomains: bid && bid.adomain ? bid.adomain : [] }, - ttl: 360, - bidder: bid.bidder + bidder: bid.bidder, + mediaType: bid.type, + ttl: 60 + }; + + if (resbid.mediaType === 'video' && isUrl(bid.party_tag)) { + resbid.vastUrl = bid.party_tag; + resbid.vastImpUrl = bid.iurl; + } else if (resbid.mediaType === 'video') { + resbid.vastXml = bid.party_tag; + resbid.vastImpUrl = bid.iurl; + } else if (resbid.mediaType === 'banner') { + resbid.ad = bid.party_tag; }; bidResponses.push(resbid); @@ -120,6 +130,15 @@ export const spec = { } }; +function isUrl(str) { + try { + URL(str); + return true; + } catch (error) { + return false; + } +}; + function enrichSlotWithFloors(slot, bidRequest) { try { const slotFloors = {}; @@ -168,6 +187,14 @@ function parseSize(size) { function buildRequestObject(bid) { const reqObj = {}; reqObj.size = getSizes(bid); + if (bid.mediaTypes?.banner) { + reqObj.type = 'banner'; + reqObj.mediatype = {}; + } + if (bid.mediaTypes?.video) { + reqObj.type = 'video'; + reqObj.mediatype = bid.mediaTypes.video; + } reqObj.id = getBidIdParameter('bidId', bid); enrichSlotWithFloors(reqObj, bid); diff --git a/test/spec/modules/admaticBidAdapter_spec.js b/test/spec/modules/admaticBidAdapter_spec.js index ce4a4a2f0fb..1d2fb1e79cb 100644 --- a/test/spec/modules/admaticBidAdapter_spec.js +++ b/test/spec/modules/admaticBidAdapter_spec.js @@ -22,11 +22,13 @@ describe('admaticBidAdapter', () => { 'host': 'layer.serve.admatic.com.tr' }, 'adUnitCode': 'adunit-code', + 'mediaType': 'banner', 'sizes': [[300, 250], [300, 600]], 'bidId': '30b31c1838de1e', 'bidderRequestId': '22edbae2733bf6', 'auctionId': '1d1a030790a475', - 'creativeId': 'er2ee' + 'creativeId': 'er2ee', + 'ortb2': { 'badv': ['admatic.com.tr'] } }; it('should return true when required params found', function() { @@ -34,15 +36,11 @@ describe('admaticBidAdapter', () => { }); it('should return false when required params are not passed', function() { - let bid = Object.assign({}, bid); - delete bid.params; - - bid.params = { - 'networkId': 0, - 'host': 'layer.serve.admatic.com.tr' + let bid2 = {}; + bid2.params = { + 'someIncorrectParam': 0 }; - - expect(spec.isBidRequestValid(bid)).to.equal(false); + expect(spec.isBidRequestValid(bid2)).to.equal(false); }); }); @@ -54,6 +52,7 @@ describe('admaticBidAdapter', () => { 'networkId': 10433394, 'host': 'layer.serve.admatic.com.tr' }, + 'ortb2': { 'badv': ['admatic.com.tr'] }, 'mediaTypes': { 'banner': { 'sizes': [[300, 250], [728, 90]] @@ -98,6 +97,8 @@ describe('admaticBidAdapter', () => { 'h': 90 } ], + 'mediatype': {}, + 'type': 'banner', 'id': '2205da7a81846b', 'floors': { 'banner': { @@ -105,6 +106,49 @@ describe('admaticBidAdapter', () => { '728x90': { 'currency': 'USD', 'floor': 2 } } } + }, + { + 'size': [ + { + 'w': 338, + 'h': 280 + } + ], + 'type': 'video', + 'mediatype': { + 'context': 'instream', + 'mimes': [ + 'video/mp4' + ], + 'maxduration': 240, + 'api': [ + 1, + 2 + ], + 'playerSize': [ + [ + 338, + 280 + ] + ], + 'protocols': [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8 + ], + 'skip': 1, + 'playbackmethod': [ + 2 + ], + 'linearity': 1, + 'placement': 2 + }, + 'id': '45e86fc7ce7fc93' } ], 'ext': { @@ -118,6 +162,7 @@ describe('admaticBidAdapter', () => { 'networkId': 10433394, 'host': 'layer.serve.admatic.com.tr' }, + 'ortb2': { 'badv': ['admatic.com.tr'] }, 'mediaTypes': { 'banner': { 'sizes': [[300, 250], [728, 90]] @@ -163,12 +208,57 @@ describe('admaticBidAdapter', () => { } ], 'id': '2205da7a81846b', + 'mediatype': {}, + 'type': 'banner', 'floors': { 'banner': { '300x250': { 'currency': 'USD', 'floor': 1 }, '728x90': { 'currency': 'USD', 'floor': 2 } } } + }, + { + 'size': [ + { + 'w': 338, + 'h': 280 + } + ], + 'type': 'video', + 'mediatype': { + 'context': 'instream', + 'mimes': [ + 'video/mp4' + ], + 'maxduration': 240, + 'api': [ + 1, + 2 + ], + 'playerSize': [ + [ + 338, + 280 + ] + ], + 'protocols': [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8 + ], + 'skip': 1, + 'playbackmethod': [ + 2 + ], + 'linearity': 1, + 'placement': 2 + }, + 'id': '45e86fc7ce7fc93' } ], 'ext': { @@ -194,6 +284,7 @@ describe('admaticBidAdapter', () => { 'sizes': [[300, 250], [728, 90]] } }, + 'ortb2': { 'badv': ['admatic.com.tr'] }, getFloor: inputParams => { if (inputParams.mediaType === BANNER && inputParams.size[0] === 300 && inputParams.size[1] === 250) { return { @@ -217,6 +308,7 @@ describe('admaticBidAdapter', () => { 'networkId': 10433394, 'host': 'layer.serve.admatic.com.tr' }, + 'ortb2': { 'badv': ['admatic.com.tr'] }, 'adUnitCode': 'adunit-code', 'sizes': [[300, 250], [728, 90]], 'bidId': '30b31c1838de1e', @@ -249,9 +341,35 @@ describe('admaticBidAdapter', () => { 'width': 300, 'height': 250, 'price': 0.01, + 'type': 'banner', 'bidder': 'admatic', 'adomain': ['admatic.com.tr'], - 'party_tag': '
' + 'party_tag': '
', + 'iurl': 'https://www.admatic.com.tr' + }, + { + 'id': 2, + 'creative_id': '3741', + 'width': 300, + 'height': 250, + 'price': 0.01, + 'type': 'video', + 'bidder': 'admatic', + 'adomain': ['admatic.com.tr'], + 'party_tag': '', + 'iurl': 'https://www.admatic.com.tr' + }, + { + 'id': 3, + 'creative_id': '3741', + 'width': 300, + 'height': 250, + 'price': 0.01, + 'type': 'video', + 'bidder': 'admatic', + 'adomain': ['admatic.com.tr'], + 'party_tag': 'https://www.admatic.com.tr', + 'iurl': 'https://www.admatic.com.tr' } ], 'queryId': 'cdnbh24rlv0hhkpfpln0', @@ -265,13 +383,48 @@ describe('admaticBidAdapter', () => { width: 300, height: 250, currency: 'TRY', + mediaType: 'banner', netRevenue: true, ad: '
', creativeId: '374', meta: { advertiserDomains: ['admatic.com.tr'] }, - ttl: 360, + ttl: 60, + bidder: 'admatic' + }, + { + requestId: 2, + cpm: 0.01, + width: 300, + height: 250, + currency: 'TRY', + mediaType: 'video', + netRevenue: true, + vastImpUrl: 'https://www.admatic.com.tr', + vastXml: '', + creativeId: '3741', + meta: { + advertiserDomains: ['admatic.com.tr'] + }, + ttl: 60, + bidder: 'admatic' + }, + { + requestId: 3, + cpm: 0.01, + width: 300, + height: 250, + currency: 'TRY', + mediaType: 'video', + netRevenue: true, + vastImpUrl: 'https://www.admatic.com.tr', + vastXml: 'https://www.admatic.com.tr', + creativeId: '3741', + meta: { + advertiserDomains: ['admatic.com.tr'] + }, + ttl: 60, bidder: 'admatic' } ]; From bbbf3618ad915f9c679527c87142b61ea6453b95 Mon Sep 17 00:00:00 2001 From: Fatih Kaya Date: Thu, 15 Jun 2023 18:38:40 +0300 Subject: [PATCH 47/57] Update admaticBidAdapter.js --- modules/admaticBidAdapter.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/modules/admaticBidAdapter.js b/modules/admaticBidAdapter.js index 027f924ac5d..436f918a0f6 100644 --- a/modules/admaticBidAdapter.js +++ b/modules/admaticBidAdapter.js @@ -195,6 +195,11 @@ function buildRequestObject(bid) { reqObj.type = 'video'; reqObj.mediatype = bid.mediaTypes.video; } + + if (deepAccess(bid, 'ortb2Imp.ext')) { + reqObj.ext = bid.ortb2Imp.ext; + } + reqObj.id = getBidIdParameter('bidId', bid); enrichSlotWithFloors(reqObj, bid); From 2999463b768970b7bb26f1a6383395b937848b8d Mon Sep 17 00:00:00 2001 From: Fatih Kaya Date: Tue, 8 Aug 2023 10:09:37 +0300 Subject: [PATCH 48/57] Update admaticBidAdapter_spec.js --- test/spec/modules/admaticBidAdapter_spec.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/spec/modules/admaticBidAdapter_spec.js b/test/spec/modules/admaticBidAdapter_spec.js index 1d2fb1e79cb..8c9969e4d46 100644 --- a/test/spec/modules/admaticBidAdapter_spec.js +++ b/test/spec/modules/admaticBidAdapter_spec.js @@ -28,6 +28,7 @@ describe('admaticBidAdapter', () => { 'bidderRequestId': '22edbae2733bf6', 'auctionId': '1d1a030790a475', 'creativeId': 'er2ee', + 'ortb2Imp': { 'ext': { 'instl': 1 } }, 'ortb2': { 'badv': ['admatic.com.tr'] } }; @@ -52,6 +53,7 @@ describe('admaticBidAdapter', () => { 'networkId': 10433394, 'host': 'layer.serve.admatic.com.tr' }, + 'ortb2Imp': { 'ext': { 'instl': 1 } }, 'ortb2': { 'badv': ['admatic.com.tr'] }, 'mediaTypes': { 'banner': { @@ -162,6 +164,7 @@ describe('admaticBidAdapter', () => { 'networkId': 10433394, 'host': 'layer.serve.admatic.com.tr' }, + 'ortb2Imp': { 'ext': { 'instl': 1 } }, 'ortb2': { 'badv': ['admatic.com.tr'] }, 'mediaTypes': { 'banner': { @@ -284,6 +287,7 @@ describe('admaticBidAdapter', () => { 'sizes': [[300, 250], [728, 90]] } }, + 'ortb2Imp': { 'ext': { 'instl': 1 } }, 'ortb2': { 'badv': ['admatic.com.tr'] }, getFloor: inputParams => { if (inputParams.mediaType === BANNER && inputParams.size[0] === 300 && inputParams.size[1] === 250) { @@ -308,6 +312,7 @@ describe('admaticBidAdapter', () => { 'networkId': 10433394, 'host': 'layer.serve.admatic.com.tr' }, + 'ortb2Imp': { 'ext': { 'instl': 1 } }, 'ortb2': { 'badv': ['admatic.com.tr'] }, 'adUnitCode': 'adunit-code', 'sizes': [[300, 250], [728, 90]], From 090397e34e72dcb585a0ce071c63b7d3803275ac Mon Sep 17 00:00:00 2001 From: Fatih Kaya Date: Sat, 7 Oct 2023 14:22:03 +0300 Subject: [PATCH 49/57] mime_type add --- modules/admaticBidAdapter.js | 1 + test/spec/modules/admaticBidAdapter_spec.js | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/modules/admaticBidAdapter.js b/modules/admaticBidAdapter.js index 52c06318ec0..eeb0cddde89 100644 --- a/modules/admaticBidAdapter.js +++ b/modules/admaticBidAdapter.js @@ -106,6 +106,7 @@ export const spec = { netRevenue: true, creativeId: bid.creative_id, meta: { + model: bid.mime_type, advertiserDomains: bid && bid.adomain ? bid.adomain : [] }, bidder: bid.bidder, diff --git a/test/spec/modules/admaticBidAdapter_spec.js b/test/spec/modules/admaticBidAdapter_spec.js index 8c9969e4d46..b378ec2d2a4 100644 --- a/test/spec/modules/admaticBidAdapter_spec.js +++ b/test/spec/modules/admaticBidAdapter_spec.js @@ -348,6 +348,7 @@ describe('admaticBidAdapter', () => { 'price': 0.01, 'type': 'banner', 'bidder': 'admatic', + 'mime_type': 'iframe', 'adomain': ['admatic.com.tr'], 'party_tag': '
', 'iurl': 'https://www.admatic.com.tr' @@ -359,6 +360,7 @@ describe('admaticBidAdapter', () => { 'height': 250, 'price': 0.01, 'type': 'video', + 'mime_type': 'iframe', 'bidder': 'admatic', 'adomain': ['admatic.com.tr'], 'party_tag': '', @@ -371,6 +373,7 @@ describe('admaticBidAdapter', () => { 'height': 250, 'price': 0.01, 'type': 'video', + 'mime_type': 'iframe', 'bidder': 'admatic', 'adomain': ['admatic.com.tr'], 'party_tag': 'https://www.admatic.com.tr', @@ -393,6 +396,7 @@ describe('admaticBidAdapter', () => { ad: '
', creativeId: '374', meta: { + model: 'iframe', advertiserDomains: ['admatic.com.tr'] }, ttl: 60, @@ -410,6 +414,7 @@ describe('admaticBidAdapter', () => { vastXml: '', creativeId: '3741', meta: { + model: 'iframe', advertiserDomains: ['admatic.com.tr'] }, ttl: 60, @@ -427,6 +432,7 @@ describe('admaticBidAdapter', () => { vastXml: 'https://www.admatic.com.tr', creativeId: '3741', meta: { + model: 'iframe', advertiserDomains: ['admatic.com.tr'] }, ttl: 60, From bd0d50c8985dc0815f21a2d15318d9c08b2166b9 Mon Sep 17 00:00:00 2001 From: Fatih Kaya Date: Thu, 26 Oct 2023 16:55:42 +0300 Subject: [PATCH 50/57] add native adapter --- modules/admaticBidAdapter.js | 87 ++++++++++- test/spec/modules/admaticBidAdapter_spec.js | 152 ++++++++++++++++++++ 2 files changed, 233 insertions(+), 6 deletions(-) diff --git a/modules/admaticBidAdapter.js b/modules/admaticBidAdapter.js index eeb0cddde89..fc5cf9c8f7b 100644 --- a/modules/admaticBidAdapter.js +++ b/modules/admaticBidAdapter.js @@ -1,15 +1,38 @@ import {getValue, logError, isEmpty, deepAccess, isArray, getBidIdParameter} from '../src/utils.js'; import { registerBidder } from '../src/adapters/bidderFactory.js'; import { config } from '../src/config.js'; -import { BANNER, VIDEO } from '../src/mediaTypes.js'; +import { BANNER, VIDEO, NATIVE } from '../src/mediaTypes.js'; +export const OPENRTB = { + NATIVE: { + IMAGE_TYPE: { + ICON: 1, + MAIN: 3, + }, + ASSET_ID: { + TITLE: 1, + IMAGE: 2, + ICON: 3, + BODY: 4, + SPONSORED: 5, + CTA: 6 + }, + DATA_ASSET_TYPE: { + SPONSORED: 1, + DESC: 2, + CTA_TEXT: 12, + }, + } +}; + let SYNC_URL = ''; const BIDDER_CODE = 'admatic'; + export const spec = { code: BIDDER_CODE, aliases: [ {code: 'pixad'} ], - supportedMediaTypes: [BANNER, VIDEO], + supportedMediaTypes: [BANNER, VIDEO, NATIVE], /** f * @param {object} bid * @return {boolean} @@ -46,10 +69,10 @@ export const spec = { }, blacklist: [], site: { - page: location.href, - ref: location.origin, + page: bidderRequest.refererInfo.page, + ref: bidderRequest.refererInfo.page, publisher: { - name: location.hostname, + name: bidderRequest.refererInfo.domain, publisherId: networkId } }, @@ -122,6 +145,8 @@ export const spec = { resbid.vastImpUrl = bid.iurl; } else if (resbid.mediaType === 'banner') { resbid.ad = bid.party_tag; + } else if (resbid.mediaType === 'native') { + resbid.native = interpretNativeAd(bid.party_tag) }; bidResponses.push(resbid); @@ -157,6 +182,11 @@ function enrichSlotWithFloors(slot, bidRequest) { videoSizes.forEach(videoSize => slotFloors.video[parseSize(videoSize).toString()] = bidRequest.getFloor({ size: videoSize, mediaType: VIDEO })); } + if (bidRequest.mediaTypes?.native) { + slotFloors.native = {}; + slotFloors.native['*'] = bidRequest.getFloor({ size: '*', mediaType: NATIVE }); + } + if (Object.keys(slotFloors).length > 0) { if (!slot) { slot = {} @@ -196,6 +226,11 @@ function buildRequestObject(bid) { reqObj.type = 'video'; reqObj.mediatype = bid.mediaTypes.video; } + if (bid.mediaTypes?.native) { + reqObj.type = 'native'; + reqObj.size = [{w: 1, h: 1}]; + reqObj.mediatype = bid.mediaTypes.native; + } if (deepAccess(bid, 'ortb2Imp.ext')) { reqObj.ext = bid.ortb2Imp.ext; @@ -215,10 +250,11 @@ function getSizes(bid) { function concatSizes(bid) { let playerSize = deepAccess(bid, 'mediaTypes.video.playerSize'); let videoSizes = deepAccess(bid, 'mediaTypes.video.sizes'); + let nativeSizes = deepAccess(bid, 'mediaTypes.native.sizes'); let bannerSizes = deepAccess(bid, 'mediaTypes.banner.sizes'); if (isArray(bannerSizes) || isArray(playerSize) || isArray(videoSizes)) { - let mediaTypesSizes = [bannerSizes, videoSizes, playerSize]; + let mediaTypesSizes = [bannerSizes, videoSizes, nativeSizes, playerSize]; return mediaTypesSizes .reduce(function(acc, currSize) { if (isArray(currSize)) { @@ -233,6 +269,45 @@ function concatSizes(bid) { } } +function interpretNativeAd(adm) { + const native = JSON.parse(adm).native; + const result = { + clickUrl: encodeURI(native.link.url), + impressionTrackers: native.imptrackers + }; + native.assets.forEach(asset => { + switch (asset.id) { + case OPENRTB.NATIVE.ASSET_ID.TITLE: + result.title = asset.title.text; + break; + case OPENRTB.NATIVE.ASSET_ID.IMAGE: + result.image = { + url: encodeURI(asset.img.url), + width: asset.img.w, + height: asset.img.h + }; + break; + case OPENRTB.NATIVE.ASSET_ID.ICON: + result.icon = { + url: encodeURI(asset.img.url), + width: asset.img.w, + height: asset.img.h + }; + break; + case OPENRTB.NATIVE.ASSET_ID.BODY: + result.body = asset.data.value; + break; + case OPENRTB.NATIVE.ASSET_ID.SPONSORED: + result.sponsoredBy = asset.data.value; + break; + case OPENRTB.NATIVE.ASSET_ID.CTA: + result.cta = asset.data.value; + break; + } + }); + return result; +} + function _validateId(id) { return (parseInt(id) > 0); } diff --git a/test/spec/modules/admaticBidAdapter_spec.js b/test/spec/modules/admaticBidAdapter_spec.js index b378ec2d2a4..bd409958b1a 100644 --- a/test/spec/modules/admaticBidAdapter_spec.js +++ b/test/spec/modules/admaticBidAdapter_spec.js @@ -16,6 +16,10 @@ describe('admaticBidAdapter', () => { describe('isBidRequestValid', function() { let bid = { + 'refererInfo': { + 'page': 'https://www.admatic.com.tr', + 'domain': 'https://www.admatic.com.tr', + }, 'bidder': 'admatic', 'params': { 'networkId': 10433394, @@ -48,6 +52,10 @@ describe('admaticBidAdapter', () => { describe('buildRequests', function () { it('sends bid request to ENDPOINT via POST', function () { let validRequest = [ { + 'refererInfo': { + 'page': 'https://www.admatic.com.tr', + 'domain': 'https://www.admatic.com.tr', + }, 'bidder': 'admatic', 'params': { 'networkId': 10433394, @@ -151,6 +159,51 @@ describe('admaticBidAdapter', () => { 'placement': 2 }, 'id': '45e86fc7ce7fc93' + }, + { + 'size': [ + { + 'w': 1, + 'h': 1 + } + ], + 'type': 'native', + 'mediatype': { + 'title': { + 'required': true, + 'len': 120 + }, + 'image': { + 'required': true + }, + 'icon': { + 'required': false, + 'sizes': [ + 640, + 480 + ] + }, + 'sponsoredBy': { + 'required': false + }, + 'body': { + 'required': false + }, + 'clickUrl': { + 'required': false + }, + 'displayUrl': { + 'required': false + } + }, + 'ext': { + 'instl': 0, + 'gpid': 'native-INS_b1b1269f-9570-fe3c-9bf4-f187827ec94a', + 'data': { + 'pbadslot': 'native-INS_b1b1269f-9570-fe3c-9bf4-f187827ec94a' + } + }, + 'id': '16e0c8982318f91' } ], 'ext': { @@ -159,6 +212,10 @@ describe('admaticBidAdapter', () => { } } ]; let bidderRequest = { + 'refererInfo': { + 'page': 'https://www.admatic.com.tr', + 'domain': 'https://www.admatic.com.tr', + }, 'bidder': 'admatic', 'params': { 'networkId': 10433394, @@ -262,6 +319,51 @@ describe('admaticBidAdapter', () => { 'placement': 2 }, 'id': '45e86fc7ce7fc93' + }, + { + 'size': [ + { + 'w': 1, + 'h': 1 + } + ], + 'type': 'native', + 'mediatype': { + 'title': { + 'required': true, + 'len': 120 + }, + 'image': { + 'required': true + }, + 'icon': { + 'required': false, + 'sizes': [ + 640, + 480 + ] + }, + 'sponsoredBy': { + 'required': false + }, + 'body': { + 'required': false + }, + 'clickUrl': { + 'required': false + }, + 'displayUrl': { + 'required': false + } + }, + 'ext': { + 'instl': 0, + 'gpid': 'native-INS_b1b1269f-9570-fe3c-9bf4-f187827ec94a', + 'data': { + 'pbadslot': 'native-INS_b1b1269f-9570-fe3c-9bf4-f187827ec94a' + } + }, + 'id': '16e0c8982318f91' } ], 'ext': { @@ -307,6 +409,10 @@ describe('admaticBidAdapter', () => { }, ]; let bidderRequest = { + 'refererInfo': { + 'page': 'https://www.admatic.com.tr', + 'domain': 'https://www.admatic.com.tr', + }, 'bidder': 'admatic', 'params': { 'networkId': 10433394, @@ -378,6 +484,19 @@ describe('admaticBidAdapter', () => { 'adomain': ['admatic.com.tr'], 'party_tag': 'https://www.admatic.com.tr', 'iurl': 'https://www.admatic.com.tr' + }, + { + 'id': 4, + 'creative_id': '3742', + 'width': 1, + 'height': 1, + 'price': 0.01, + 'type': 'native', + 'mime_type': 'iframe', + 'bidder': 'admatic', + 'adomain': ['admatic.com.tr'], + 'party_tag': '{"native":{"ver":"1.1","assets":[{"id":1,"title":{"text":"title"}},{"id":4,"data":{"value":"body"}},{"id":5,"data":{"value":"sponsored"}},{"id":2,"img":{"url":"https://www.admatic.com.tr","w":1200,"h":628}},{"id":3,"img":{"url":"https://www.admatic.com.tr","w":640,"h":480}}],"link":{"url":"https://www.admatic.com.tr"},"imptrackers":["https://www.admatic.com.tr"]}}', + 'iurl': 'https://www.admatic.com.tr' } ], 'queryId': 'cdnbh24rlv0hhkpfpln0', @@ -437,6 +556,39 @@ describe('admaticBidAdapter', () => { }, ttl: 60, bidder: 'admatic' + }, + { + requestId: 4, + cpm: 0.01, + width: 1, + height: 1, + currency: 'TRY', + mediaType: 'native', + netRevenue: true, + native: { + 'clickUrl': 'https://www.admatic.com.tr', + 'impressionTrackers': ['https://www.admatic.com.tr'], + 'title': 'title', + 'body': 'body', + 'sponsoredBy': 'sponsored', + 'image': { + 'url': 'https://www.admatic.com.tr', + 'width': 1200, + 'height': 628 + }, + 'icon': { + 'url': 'https://www.admatic.com.tr', + 'width': 640, + 'height': 480 + } + }, + creativeId: '3742', + meta: { + model: 'iframe', + advertiserDomains: ['admatic.com.tr'] + }, + ttl: 60, + bidder: 'admatic' } ]; const request = { From 5d9ea451d233d43f318f87495314d27e5284c57f Mon Sep 17 00:00:00 2001 From: Fatih Kaya Date: Sat, 9 Dec 2023 22:19:10 +0300 Subject: [PATCH 51/57] AdMatic Adapter: Consent Management --- modules/admaticBidAdapter.js | 131 ++- test/spec/modules/admaticBidAdapter_spec.js | 1057 ++++++++++++------- 2 files changed, 818 insertions(+), 370 deletions(-) diff --git a/modules/admaticBidAdapter.js b/modules/admaticBidAdapter.js index fc5cf9c8f7b..236114f6396 100644 --- a/modules/admaticBidAdapter.js +++ b/modules/admaticBidAdapter.js @@ -1,4 +1,4 @@ -import {getValue, logError, isEmpty, deepAccess, isArray, getBidIdParameter} from '../src/utils.js'; +import {getValue, formatQS, logError, deepAccess, isArray, getBidIdParameter} from '../src/utils.js'; import { registerBidder } from '../src/adapters/bidderFactory.js'; import { config } from '../src/config.js'; import { BANNER, VIDEO, NATIVE } from '../src/mediaTypes.js'; @@ -56,18 +56,16 @@ export const spec = { * @return {ServerRequest} */ buildRequests: (validBidRequests, bidderRequest) => { + const tmax = bidderRequest.timeout; const bids = validBidRequests.map(buildRequestObject); - const blacklist = bidderRequest.ortb2; + const ortb = bidderRequest.ortb2; const networkId = getValue(validBidRequests[0].params, 'networkId'); const host = getValue(validBidRequests[0].params, 'host'); const currency = config.getConfig('currency.adServerCurrency') || 'TRY'; const bidderName = validBidRequests[0].bidder; const payload = { - user: { - ua: navigator.userAgent - }, - blacklist: [], + ortb, site: { page: bidderRequest.refererInfo.page, ref: bidderRequest.refererInfo.page, @@ -80,17 +78,59 @@ export const spec = { ext: { cur: currency, bidder: bidderName - } + }, + schain: {}, + regs: { + ext: { + } + }, + user: { + ext: {} + }, + at: 1, + tmax: parseInt(tmax) }; - if (!isEmpty(blacklist.badv)) { - payload.blacklist = blacklist.badv; - }; + if (bidderRequest && bidderRequest.gdprConsent && bidderRequest.gdprConsent.gdprApplies) { + const consentStr = (bidderRequest.gdprConsent.consentString) + ? bidderRequest.gdprConsent.consentString.replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/, '') : ''; + const gdpr = bidderRequest.gdprConsent.gdprApplies ? 1 : 0; + payload.regs.ext.gdpr = gdpr; + payload.regs.ext.consent = consentStr; + } + + if (bidderRequest && bidderRequest.coppa) { + payload.regs.ext.coppa = bidderRequest.coppa === true ? 1 : (bidderRequest.coppa === false ? 0 : undefined); + } + + if (bidderRequest && bidderRequest.ortb2?.regs?.gpp) { + payload.regs.ext.gpp = bidderRequest.ortb2?.regs?.gpp; + } + + if (bidderRequest && bidderRequest.ortb2?.regs?.gpp_sid) { + payload.regs.ext.gpp_sid = bidderRequest.ortb2?.regs?.gpp_sid; + } + + if (bidderRequest && bidderRequest.uspConsent) { + payload.regs.ext.uspIab = bidderRequest.uspConsent; + } + + if (validBidRequests[0].schain) { + const schain = mapSchain(validBidRequests[0].schain); + if (schain) { + payload.schain = schain; + } + } + + if (validBidRequests[0].userIdAsEids) { + const eids = { eids: validBidRequests[0].userIdAsEids }; + payload.user.ext = { ...payload.user.ext, ...eids }; + } if (payload) { switch (bidderName) { case 'pixad': - SYNC_URL = 'https://static.pixad.com.tr/sync.html'; + SYNC_URL = 'https://static.cdn.pixad.com.tr/sync.html'; break; default: SYNC_URL = 'https://cdn.serve.admatic.com.tr/showad/sync.html'; @@ -101,12 +141,36 @@ export const spec = { } }, - getUserSyncs: function (syncOptions, responses) { - if (syncOptions.iframeEnabled) { - return [{ + getUserSyncs: function (syncOptions, responses, gdprConsent, uspConsent, gppConsent) { + if (!hasSynced && syncOptions.iframeEnabled) { + // data is only assigned if params are available to pass to syncEndpoint + let params = {}; + + if (gdprConsent) { + if (typeof gdprConsent.gdprApplies === 'boolean') { + params['gdpr'] = Number(gdprConsent.gdprApplies); + } + if (typeof gdprConsent.consentString === 'string') { + params['gdpr_consent'] = gdprConsent.consentString; + } + } + + if (uspConsent) { + params['us_privacy'] = encodeURIComponent(uspConsent); + } + + if (gppConsent?.gppString) { + params['gpp'] = gppConsent.gppString; + params['gpp_sid'] = gppConsent.applicableSections?.toString(); + } + + params = Object.keys(params).length ? `?${formatQS(params)}` : ''; + + hasSynced = true; + return { type: 'iframe', - url: SYNC_URL - }]; + url: SYNC_URL + params + }; } }, @@ -156,6 +220,41 @@ export const spec = { } }; +var hasSynced = false; + +export function resetUserSync() { + hasSynced = false; +} + +/** + * @param {object} schain object set by Publisher + * @returns {object} OpenRTB SupplyChain object + */ +function mapSchain(schain) { + if (!schain) { + return null; + } + if (!validateSchain(schain)) { + logError('AdMatic: required schain params missing'); + return null; + } + return schain; +} + +/** + * @param {object} schain object set by Publisher + * @returns {object} bool + */ +function validateSchain(schain) { + if (!schain.nodes) { + return false; + } + const requiredFields = ['asi', 'sid', 'hp']; + return schain.nodes.every(node => { + return requiredFields.every(field => node[field]); + }); +} + function isUrl(str) { try { URL(str); diff --git a/test/spec/modules/admaticBidAdapter_spec.js b/test/spec/modules/admaticBidAdapter_spec.js index bd409958b1a..b4d84634962 100644 --- a/test/spec/modules/admaticBidAdapter_spec.js +++ b/test/spec/modules/admaticBidAdapter_spec.js @@ -1,12 +1,553 @@ -import {expect} from 'chai'; -import {spec, storage} from 'modules/admaticBidAdapter.js'; -import {newBidder} from 'src/adapters/bidderFactory.js'; -import {getStorageManager} from 'src/storageManager'; +import { expect } from 'chai'; +import { spec } from 'modules/admaticBidAdapter.js'; +import { newBidder } from 'src/adapters/bidderFactory.js'; +import { config } from 'src/config.js'; const ENDPOINT = 'https://layer.serve.admatic.com.tr/pb'; describe('admaticBidAdapter', () => { const adapter = newBidder(spec); + let validRequest = [ { + 'refererInfo': { + 'page': 'https://www.admatic.com.tr', + 'domain': 'https://www.admatic.com.tr', + }, + 'bidder': 'admatic', + 'params': { + 'networkId': 10433394, + 'host': 'layer.serve.admatic.com.tr' + }, + 'ortb2Imp': { 'ext': { 'instl': 1 } }, + 'ortb2': { 'badv': ['admatic.com.tr'] }, + 'mediaTypes': { + 'banner': { + 'sizes': [[300, 250], [728, 90]] + }, + 'native': { + }, + 'video': { + } + }, + getFloor: inputParams => { + if (inputParams.mediaType === BANNER && inputParams.size[0] === 300 && inputParams.size[1] === 250) { + return { + currency: 'USD', + floor: 1.0 + }; + } else if (inputParams.mediaType === BANNER && inputParams.size[0] === 728 && inputParams.size[1] === 90) { + return { + currency: 'USD', + floor: 2.0 + }; + } else if (inputParams.mediaType === VIDEO) { + return { + currency: 'USD', + floor: 1.0 + }; + } else if (inputParams.mediaType === NATIVE) { + return { + currency: 'USD', + floor: 1.0 + }; + } else { + return {} + } + }, + 'schain': { + 'ver': '1.0', + 'complete': 1, + 'nodes': [ + { + 'asi': 'pixad.com.tr', + 'sid': 'px-pub-3000856707', + 'hp': 1 + } + ] + }, + 'at': 1, + 'tmax': 1000, + 'user': { + 'ext': { + 'eids': [ + { + 'source': 'id5-sync.com', + 'uids': [ + { + 'id': '0', + 'atype': 1, + 'ext': { + 'linkType': 0, + 'pba': 'wMh3sAXcnhDq7CfSa6ji1g==' + } + } + ] + }, + { + 'source': 'pubcid.org', + 'uids': [ + { + 'id': '5a49273f-a424-454b-b478-169c3551aa72', + 'atype': 1 + } + ] + } + ] + } + }, + 'ortb': { + 'badv': [], + 'bcat': [], + 'site': { + 'page': 'http://localhost:8888/admatic.html', + 'ref': 'http://localhost:8888', + 'publisher': { + 'name': 'localhost' + } + }, + 'device': { + 'ua': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36' + } + }, + 'site': { + 'page': 'http://localhost:8888/admatic.html', + 'ref': 'http://localhost:8888', + 'publisher': { + 'name': 'localhost', + 'publisherId': 12321312 + } + }, + 'imp': [ + { + 'size': [ + { + 'w': 300, + 'h': 250 + }, + { + 'w': 728, + 'h': 90 + } + ], + 'mediatype': {}, + 'type': 'banner', + 'id': '2205da7a81846b', + 'floors': { + 'banner': { + '300x250': { 'currency': 'USD', 'floor': 1 }, + '728x90': { 'currency': 'USD', 'floor': 2 } + } + } + }, + { + 'size': [ + { + 'w': 338, + 'h': 280 + } + ], + 'type': 'video', + 'mediatype': { + 'context': 'instream', + 'mimes': [ + 'video/mp4' + ], + 'maxduration': 240, + 'api': [ + 1, + 2 + ], + 'playerSize': [ + [ + 338, + 280 + ] + ], + 'protocols': [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8 + ], + 'skip': 1, + 'playbackmethod': [ + 2 + ], + 'linearity': 1, + 'placement': 2 + }, + 'floors': { + 'video': { + '338x280': { 'currency': 'USD', 'floor': 1 } + } + }, + 'id': '45e86fc7ce7fc93' + }, + { + 'size': [ + { + 'w': 1, + 'h': 1 + } + ], + 'type': 'native', + 'mediatype': { + 'title': { + 'required': true, + 'len': 120 + }, + 'image': { + 'required': true + }, + 'icon': { + 'required': false, + 'sizes': [ + 640, + 480 + ] + }, + 'sponsoredBy': { + 'required': false + }, + 'body': { + 'required': false + }, + 'clickUrl': { + 'required': false + }, + 'displayUrl': { + 'required': false + } + }, + 'ext': { + 'instl': 0, + 'gpid': 'native-INS_b1b1269f-9570-fe3c-9bf4-f187827ec94a', + 'data': { + 'pbadslot': 'native-INS_b1b1269f-9570-fe3c-9bf4-f187827ec94a' + } + }, + 'floors': { + 'native': { + '*': { 'currency': 'USD', 'floor': 1 } + } + }, + 'id': '16e0c8982318f91' + } + ], + 'ext': { + 'cur': 'USD', + 'bidder': 'admatic' + } + } ]; + let bidderRequest = { + 'refererInfo': { + 'page': 'https://www.admatic.com.tr', + 'domain': 'https://www.admatic.com.tr', + }, + 'bidder': 'admatic', + 'params': { + 'networkId': 10433394, + 'host': 'layer.serve.admatic.com.tr' + }, + 'ortb2Imp': { 'ext': { 'instl': 1 } }, + 'ortb2': { 'badv': ['admatic.com.tr'] }, + 'mediaTypes': { + 'banner': { + 'sizes': [[300, 250], [728, 90]] + }, + 'native': { + }, + 'video': { + 'playerSize': [ + 336, + 280 + ] + } + }, + 'userId': { + 'id5id': { + 'uid': '0', + 'ext': { + 'linkType': 0, + 'pba': 'wMh3sAXcnhDq7CfSa6ji1g==' + } + }, + 'pubcid': '5a49273f-a424-454b-b478-169c3551aa72' + }, + 'userIdAsEids': [ + { + 'source': 'id5-sync.com', + 'uids': [ + { + 'id': '0', + 'atype': 1, + 'ext': { + 'linkType': 0, + 'pba': 'wMh3sAXcnhDq7CfSa6ji1g==' + } + } + ] + }, + { + 'source': 'pubcid.org', + 'uids': [ + { + 'id': '5a49273f-a424-454b-b478-169c3551aa72', + 'atype': 1 + } + ] + } + ], + getFloor: inputParams => { + if (inputParams.mediaType === BANNER && inputParams.size[0] === 300 && inputParams.size[1] === 250) { + return { + currency: 'USD', + floor: 1.0 + }; + } else if (inputParams.mediaType === BANNER && inputParams.size[0] === 728 && inputParams.size[1] === 90) { + return { + currency: 'USD', + floor: 2.0 + }; + } else if (inputParams.mediaType === VIDEO) { + return { + currency: 'USD', + floor: 1.0 + }; + } else if (inputParams.mediaType === NATIVE) { + return { + currency: 'USD', + floor: 1.0 + }; + } else { + return {} + } + }, + 'schain': { + 'ver': '1.0', + 'complete': 1, + 'nodes': [ + { + 'asi': 'pixad.com.tr', + 'sid': 'px-pub-3000856707', + 'hp': 1 + } + ] + }, + 'at': 1, + 'tmax': 1000, + 'user': { + 'ext': { + 'eids': [ + { + 'source': 'id5-sync.com', + 'uids': [ + { + 'id': '0', + 'atype': 1, + 'ext': { + 'linkType': 0, + 'pba': 'wMh3sAXcnhDq7CfSa6ji1g==' + } + } + ] + }, + { + 'source': 'pubcid.org', + 'uids': [ + { + 'id': '5a49273f-a424-454b-b478-169c3551aa72', + 'atype': 1 + } + ] + } + ] + } + }, + 'ortb': { + 'source': {}, + 'site': { + 'domain': 'localhost:8888', + 'publisher': { + 'domain': 'localhost:8888' + }, + 'page': 'http://localhost:8888/', + 'name': 'http://localhost:8888' + }, + 'badv': [], + 'bcat': [], + 'device': { + 'w': 896, + 'h': 979, + 'dnt': 0, + 'ua': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36', + 'language': 'tr', + 'sua': { + 'source': 1, + 'platform': { + 'brand': 'macOS' + }, + 'browsers': [ + { + 'brand': 'Google Chrome', + 'version': [ + '119' + ] + }, + { + 'brand': 'Chromium', + 'version': [ + '119' + ] + }, + { + 'brand': 'Not?A_Brand', + 'version': [ + '24' + ] + } + ], + 'mobile': 0 + } + } + }, + 'site': { + 'page': 'http://localhost:8888/admatic.html', + 'ref': 'http://localhost:8888', + 'publisher': { + 'name': 'localhost', + 'publisherId': 12321312 + } + }, + 'imp': [ + { + 'size': [ + { + 'w': 300, + 'h': 250 + }, + { + 'w': 728, + 'h': 90 + } + ], + 'id': '2205da7a81846b', + 'mediatype': {}, + 'type': 'banner', + 'floors': { + 'banner': { + '300x250': { 'currency': 'USD', 'floor': 1 }, + '728x90': { 'currency': 'USD', 'floor': 2 } + } + } + }, + { + 'size': [ + { + 'w': 338, + 'h': 280 + } + ], + 'type': 'video', + 'mediatype': { + 'context': 'instream', + 'mimes': [ + 'video/mp4' + ], + 'maxduration': 240, + 'api': [ + 1, + 2 + ], + 'playerSize': [ + [ + 338, + 280 + ] + ], + 'protocols': [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8 + ], + 'skip': 1, + 'playbackmethod': [ + 2 + ], + 'linearity': 1, + 'placement': 2 + }, + 'floors': { + 'video': { + '338x280': { 'currency': 'USD', 'floor': 1 } + } + }, + 'id': '45e86fc7ce7fc93' + }, + { + 'size': [ + { + 'w': 1, + 'h': 1 + } + ], + 'type': 'native', + 'mediatype': { + 'title': { + 'required': true, + 'len': 120 + }, + 'image': { + 'required': true + }, + 'icon': { + 'required': false, + 'sizes': [ + 640, + 480 + ] + }, + 'sponsoredBy': { + 'required': false + }, + 'body': { + 'required': false + }, + 'clickUrl': { + 'required': false + }, + 'displayUrl': { + 'required': false + } + }, + 'ext': { + 'instl': 0, + 'gpid': 'native-INS_b1b1269f-9570-fe3c-9bf4-f187827ec94a', + 'data': { + 'pbadslot': 'native-INS_b1b1269f-9570-fe3c-9bf4-f187827ec94a' + } + }, + 'floors': { + 'native': { + '*': { 'currency': 'USD', 'floor': 1 } + } + }, + 'id': '16e0c8982318f91' + } + ], + 'ext': { + 'cur': 'USD', + 'bidder': 'admatic' + } + }; describe('inherited functions', () => { it('exists and is a function', () => { @@ -51,353 +592,147 @@ describe('admaticBidAdapter', () => { describe('buildRequests', function () { it('sends bid request to ENDPOINT via POST', function () { - let validRequest = [ { - 'refererInfo': { - 'page': 'https://www.admatic.com.tr', - 'domain': 'https://www.admatic.com.tr', - }, - 'bidder': 'admatic', - 'params': { - 'networkId': 10433394, - 'host': 'layer.serve.admatic.com.tr' - }, - 'ortb2Imp': { 'ext': { 'instl': 1 } }, - 'ortb2': { 'badv': ['admatic.com.tr'] }, - 'mediaTypes': { - 'banner': { - 'sizes': [[300, 250], [728, 90]] - } - }, - getFloor: inputParams => { - if (inputParams.mediaType === BANNER && inputParams.size[0] === 300 && inputParams.size[1] === 250) { - return { - currency: 'USD', - floor: 1.0 - }; - } else if (inputParams.mediaType === BANNER && inputParams.size[0] === 728 && inputParams.size[1] === 90) { - return { - currency: 'USD', - floor: 2.0 - }; - } else { - return {} - } - }, - 'user': { - 'ua': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36' - }, - 'blacklist': [], - 'site': { - 'page': 'http://localhost:8888/admatic.html', - 'ref': 'http://localhost:8888', - 'publisher': { - 'name': 'localhost', - 'publisherId': 12321312 + const request = spec.buildRequests(validRequest, bidderRequest); + expect(request.url).to.equal(ENDPOINT); + expect(request.method).to.equal('POST'); + }); + + it('should not populate GDPR if for non-EEA users', function () { + let bidRequest = Object.assign([], validRequest); + const request = spec.buildRequests( + bidRequest, + Object.assign({}, bidderRequest, { + gdprConsent: { + gdprApplies: true, + consentString: 'BOJ8RZsOJ8RZsABAB8AAAAAZ+A==' } - }, - 'imp': [ - { - 'size': [ - { - 'w': 300, - 'h': 250 - }, - { - 'w': 728, - 'h': 90 - } - ], - 'mediatype': {}, - 'type': 'banner', - 'id': '2205da7a81846b', - 'floors': { - 'banner': { - '300x250': { 'currency': 'USD', 'floor': 1 }, - '728x90': { 'currency': 'USD', 'floor': 2 } - } - } - }, - { - 'size': [ - { - 'w': 338, - 'h': 280 - } - ], - 'type': 'video', - 'mediatype': { - 'context': 'instream', - 'mimes': [ - 'video/mp4' - ], - 'maxduration': 240, - 'api': [ - 1, - 2 - ], - 'playerSize': [ - [ - 338, - 280 - ] - ], - 'protocols': [ - 1, - 2, - 3, - 4, - 5, - 6, - 7, - 8 - ], - 'skip': 1, - 'playbackmethod': [ - 2 - ], - 'linearity': 1, - 'placement': 2 - }, - 'id': '45e86fc7ce7fc93' - }, - { - 'size': [ - { - 'w': 1, - 'h': 1 - } - ], - 'type': 'native', - 'mediatype': { - 'title': { - 'required': true, - 'len': 120 - }, - 'image': { - 'required': true - }, - 'icon': { - 'required': false, - 'sizes': [ - 640, - 480 - ] - }, - 'sponsoredBy': { - 'required': false - }, - 'body': { - 'required': false - }, - 'clickUrl': { - 'required': false - }, - 'displayUrl': { - 'required': false - } - }, - 'ext': { - 'instl': 0, - 'gpid': 'native-INS_b1b1269f-9570-fe3c-9bf4-f187827ec94a', - 'data': { - 'pbadslot': 'native-INS_b1b1269f-9570-fe3c-9bf4-f187827ec94a' - } - }, - 'id': '16e0c8982318f91' + }) + ); + expect(request.data.regs.ext.gdpr).to.equal(1); + expect(request.data.regs.ext.consent).to.equal('BOJ8RZsOJ8RZsABAB8AAAAAZ-A'); + }); + + it('should populate GDPR and empty consent string if available for EEA users without consent string but with consent', function () { + let bidRequest = Object.assign([], validRequest); + const request = spec.buildRequests( + bidRequest, + Object.assign({}, bidderRequest, { + gdprConsent: { + gdprApplies: true } - ], - 'ext': { - 'cur': 'USD', - 'bidder': 'admatic' + }) + ); + expect(request.data.regs.ext.gdpr).to.equal(1); + expect(request.data.regs.ext.consent).to.equal(''); + }); + + it('should properly build a request when coppa flag is true', function () { + let bidRequest = Object.assign([], validRequest); + const request = spec.buildRequests( + bidRequest, + Object.assign({}, bidderRequest, { + coppa: true + }) + ); + expect(request.data.regs.ext.coppa).to.not.be.undefined; + expect(request.data.regs.ext.coppa).to.equal(1); + }); + + it('should properly build a request with gpp consent field', function () { + let bidRequest = Object.assign([], validRequest); + const ortb2 = { + regs: { + gpp: 'gpp_consent_string', + gpp_sid: [0, 1, 2] } - } ]; - let bidderRequest = { - 'refererInfo': { - 'page': 'https://www.admatic.com.tr', - 'domain': 'https://www.admatic.com.tr', - }, - 'bidder': 'admatic', - 'params': { - 'networkId': 10433394, - 'host': 'layer.serve.admatic.com.tr' - }, - 'ortb2Imp': { 'ext': { 'instl': 1 } }, - 'ortb2': { 'badv': ['admatic.com.tr'] }, - 'mediaTypes': { - 'banner': { - 'sizes': [[300, 250], [728, 90]] - } - }, - getFloor: inputParams => { - if (inputParams.mediaType === BANNER && inputParams.size[0] === 300 && inputParams.size[1] === 250) { - return { - currency: 'USD', - floor: 1.0 - }; - } else if (inputParams.mediaType === BANNER && inputParams.size[0] === 728 && inputParams.size[1] === 90) { - return { - currency: 'USD', - floor: 2.0 - }; - } else { - return {} - } - }, - 'user': { - 'ua': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36' - }, - 'blacklist': [], - 'site': { - 'page': 'http://localhost:8888/admatic.html', - 'ref': 'http://localhost:8888', - 'publisher': { - 'name': 'localhost', - 'publisherId': 12321312 - } - }, - 'imp': [ - { - 'size': [ - { - 'w': 300, - 'h': 250 - }, - { - 'w': 728, - 'h': 90 - } - ], - 'id': '2205da7a81846b', - 'mediatype': {}, - 'type': 'banner', - 'floors': { - 'banner': { - '300x250': { 'currency': 'USD', 'floor': 1 }, - '728x90': { 'currency': 'USD', 'floor': 2 } - } + }; + const request = spec.buildRequests(bidRequest, { ...bidderRequest, ortb2 }); + expect(request.data.regs.ext.gpp).to.equal('gpp_consent_string'); + expect(request.data.regs.ext.gpp_sid).to.deep.equal([0, 1, 2]); + }); + + it('should properly build a request with ccpa consent field', function () { + let bidRequest = Object.assign([], validRequest); + const request = spec.buildRequests( + bidRequest, + Object.assign({}, bidderRequest, { + uspConsent: '1---' + }) + ); + expect(request.data.regs.ext.uspIab).to.not.be.null; + expect(request.data.regs.ext.uspIab).to.equal('1---'); + }); + + it('should properly forward eids', function () { + const bidRequests = [ + { + bidder: 'admatic', + adUnitCode: 'bid-123', + transactionId: 'transaction-123', + mediaTypes: { + banner: { + sizes: [[728, 90]] } }, - { - 'size': [ - { - 'w': 338, - 'h': 280 - } - ], - 'type': 'video', - 'mediatype': { - 'context': 'instream', - 'mimes': [ - 'video/mp4' - ], - 'maxduration': 240, - 'api': [ - 1, - 2 - ], - 'playerSize': [ - [ - 338, - 280 - ] - ], - 'protocols': [ - 1, - 2, - 3, - 4, - 5, - 6, - 7, - 8 - ], - 'skip': 1, - 'playbackmethod': [ - 2 - ], - 'linearity': 1, - 'placement': 2 - }, - 'id': '45e86fc7ce7fc93' - }, - { - 'size': [ - { - 'w': 1, - 'h': 1 - } - ], - 'type': 'native', - 'mediatype': { - 'title': { - 'required': true, - 'len': 120 - }, - 'image': { - 'required': true - }, - 'icon': { - 'required': false, - 'sizes': [ - 640, - 480 - ] - }, - 'sponsoredBy': { - 'required': false - }, - 'body': { - 'required': false - }, - 'clickUrl': { - 'required': false - }, - 'displayUrl': { - 'required': false - } - }, - 'ext': { - 'instl': 0, - 'gpid': 'native-INS_b1b1269f-9570-fe3c-9bf4-f187827ec94a', - 'data': { - 'pbadslot': 'native-INS_b1b1269f-9570-fe3c-9bf4-f187827ec94a' - } - }, - 'id': '16e0c8982318f91' - } - ], - 'ext': { - 'cur': 'USD', - 'bidder': 'admatic' + userIdAsEids: [ + { + source: 'admatic.com.tr', + uids: [{ + id: 'abc', + atype: 1 + }] + } + ], + params: {} + }, + ]; + const request = spec.buildRequests(bidRequests, bidderRequest); + const ortbRequest = request.data; + expect(ortbRequest.user.ext.eids).to.deep.equal([ + { + source: 'admatic.com.tr', + uids: [{ + id: 'abc', + atype: 1 + }] } - }; - const request = spec.buildRequests(validRequest, bidderRequest); - expect(request.url).to.equal(ENDPOINT); - expect(request.method).to.equal('POST'); + ]); }); it('should properly build a banner request with floors', function () { - let bidRequests = [ + const request = spec.buildRequests(validRequest, bidderRequest); + request.data.imp[0].floors = { + 'banner': { + '300x250': { 'currency': 'USD', 'floor': 1 }, + '728x90': { 'currency': 'USD', 'floor': 2 } + } + }; + }); + + it('should properly build a video request with several player sizes with floors', function () { + const bidRequests = [ { 'bidder': 'admatic', - 'params': { - 'networkId': 10433394, - 'host': 'layer.serve.admatic.com.tr' - }, + 'adUnitCode': 'bid-123', + 'transactionId': 'transaction-123', 'mediaTypes': { - 'banner': { - 'sizes': [[300, 250], [728, 90]] + 'video': { + 'playerSize': [[300, 250], [728, 90]] } }, 'ortb2Imp': { 'ext': { 'instl': 1 } }, 'ortb2': { 'badv': ['admatic.com.tr'] }, + 'params': { + 'networkId': 10433394, + 'host': 'layer.serve.admatic.com.tr' + }, getFloor: inputParams => { - if (inputParams.mediaType === BANNER && inputParams.size[0] === 300 && inputParams.size[1] === 250) { + if (inputParams.mediaType === VIDEO && inputParams.size[0] === 300 && inputParams.size[1] === 250) { return { currency: 'USD', floor: 1.0 }; - } else if (inputParams.mediaType === BANNER && inputParams.size[0] === 728 && inputParams.size[1] === 90) { + } else if (inputParams.mediaType === VIDEO && inputParams.size[0] === 728 && inputParams.size[1] === 90) { return { currency: 'USD', floor: 2.0 @@ -408,37 +743,50 @@ describe('admaticBidAdapter', () => { } }, ]; - let bidderRequest = { + const bidderRequest = { 'refererInfo': { 'page': 'https://www.admatic.com.tr', 'domain': 'https://www.admatic.com.tr', - }, - 'bidder': 'admatic', - 'params': { - 'networkId': 10433394, - 'host': 'layer.serve.admatic.com.tr' - }, - 'ortb2Imp': { 'ext': { 'instl': 1 } }, - 'ortb2': { 'badv': ['admatic.com.tr'] }, - 'adUnitCode': 'adunit-code', - 'sizes': [[300, 250], [728, 90]], - 'bidId': '30b31c1838de1e', - 'bidderRequestId': '22edbae2733bf6', - 'auctionId': '1d1a030790a475', - 'creativeId': 'er2ee', - 'mediaTypes': { - 'banner': { - 'sizes': [[300, 250], [728, 90]] - } } }; const request = spec.buildRequests(bidRequests, bidderRequest); - request.data.imp[0].floors = { - 'banner': { - '300x250': { 'currency': 'USD', 'floor': 1 }, - '728x90': { 'currency': 'USD', 'floor': 2 } + }); + + it('should properly build a native request with floors', function () { + const bidRequests = [ + { + 'bidder': 'admatic', + 'adUnitCode': 'bid-123', + 'transactionId': 'transaction-123', + 'mediaTypes': { + 'native': { + } + }, + 'ortb2Imp': { 'ext': { 'instl': 1 } }, + 'ortb2': { 'badv': ['admatic.com.tr'] }, + 'params': { + 'networkId': 10433394, + 'host': 'layer.serve.admatic.com.tr' + }, + getFloor: inputParams => { + if (inputParams.mediaType === NATIVE) { + return { + currency: 'USD', + floor: 1.0 + }; + } else { + return {} + } + } + }, + ]; + const bidderRequest = { + 'refererInfo': { + 'page': 'https://www.admatic.com.tr', + 'domain': 'https://www.admatic.com.tr', } }; + const request = spec.buildRequests(bidRequests, bidderRequest); }); }); @@ -495,7 +843,7 @@ describe('admaticBidAdapter', () => { 'mime_type': 'iframe', 'bidder': 'admatic', 'adomain': ['admatic.com.tr'], - 'party_tag': '{"native":{"ver":"1.1","assets":[{"id":1,"title":{"text":"title"}},{"id":4,"data":{"value":"body"}},{"id":5,"data":{"value":"sponsored"}},{"id":2,"img":{"url":"https://www.admatic.com.tr","w":1200,"h":628}},{"id":3,"img":{"url":"https://www.admatic.com.tr","w":640,"h":480}}],"link":{"url":"https://www.admatic.com.tr"},"imptrackers":["https://www.admatic.com.tr"]}}', + 'party_tag': '{"native":{"ver":"1.1","assets":[{"id":1,"title":{"text":"title"}},{"id":4,"data":{"value":"body"}},{"id":5,"data":{"value":"sponsored"}},{"id":6,"data":{"value":"cta"}},{"id":2,"img":{"url":"https://www.admatic.com.tr","w":1200,"h":628}},{"id":3,"img":{"url":"https://www.admatic.com.tr","w":640,"h":480}}],"link":{"url":"https://www.admatic.com.tr"},"imptrackers":["https://www.admatic.com.tr"]}}', 'iurl': 'https://www.admatic.com.tr' } ], @@ -571,6 +919,7 @@ describe('admaticBidAdapter', () => { 'title': 'title', 'body': 'body', 'sponsoredBy': 'sponsored', + 'cta': 'cta', 'image': { 'url': 'https://www.admatic.com.tr', 'width': 1200, From 7273ec5ae5d7fc14aa1efb462d23e56e11246c54 Mon Sep 17 00:00:00 2001 From: Fatih Kaya Date: Thu, 14 Mar 2024 15:18:20 +0300 Subject: [PATCH 52/57] added gvlid --- modules/admaticBidAdapter.js | 104 +++++--- test/spec/modules/admaticBidAdapter_spec.js | 266 +++++++++++++++++--- 2 files changed, 299 insertions(+), 71 deletions(-) diff --git a/modules/admaticBidAdapter.js b/modules/admaticBidAdapter.js index 3f87476def7..6c268b2d382 100644 --- a/modules/admaticBidAdapter.js +++ b/modules/admaticBidAdapter.js @@ -2,6 +2,7 @@ import {getValue, formatQS, logError, deepAccess, isArray, getBidIdParameter} fr import { registerBidder } from '../src/adapters/bidderFactory.js'; import { config } from '../src/config.js'; import { BANNER, VIDEO, NATIVE } from '../src/mediaTypes.js'; +import { Renderer } from '../src/Renderer.js'; /** * @typedef {import('../src/adapters/bidderFactory.js').BidRequest} BidRequest @@ -33,11 +34,13 @@ export const OPENRTB = { let SYNC_URL = ''; const BIDDER_CODE = 'admatic'; +const RENDERER_URL = 'https://acdn.adnxs.com/video/outstream/ANOutstreamVideo.js'; export const spec = { code: BIDDER_CODE, + gvlid: 1281, aliases: [ - {code: 'pixad'} + {code: 'pixad', gvlid: 1281} ], supportedMediaTypes: [BANNER, VIDEO, NATIVE], /** @@ -190,38 +193,45 @@ export const spec = { interpretResponse: (response, request) => { const body = response.body; const bidResponses = []; + if (body && body?.data && isArray(body.data)) { body.data.forEach(bid => { - const resbid = { - requestId: bid.id, - cpm: bid.price, - width: bid.width, - height: bid.height, - currency: body.cur || 'TRY', - netRevenue: true, - creativeId: bid.creative_id, - meta: { - model: bid.mime_type, - advertiserDomains: bid && bid.adomain ? bid.adomain : [] - }, - bidder: bid.bidder, - mediaType: bid.type, - ttl: 60 - }; - - if (resbid.mediaType === 'video' && isUrl(bid.party_tag)) { - resbid.vastUrl = bid.party_tag; - resbid.vastImpUrl = bid.iurl; - } else if (resbid.mediaType === 'video') { - resbid.vastXml = bid.party_tag; - resbid.vastImpUrl = bid.iurl; - } else if (resbid.mediaType === 'banner') { - resbid.ad = bid.party_tag; - } else if (resbid.mediaType === 'native') { - resbid.native = interpretNativeAd(bid.party_tag) - }; + const bidRequest = getAssociatedBidRequest(request.data.imp, bid); + if (bidRequest) { + const resbid = { + requestId: bid.id, + cpm: bid.price, + width: bid.width, + height: bid.height, + currency: body.cur || 'TRY', + netRevenue: true, + creativeId: bid.creative_id, + meta: { + model: bid.mime_type, + advertiserDomains: bid && bid.adomain ? bid.adomain : [] + }, + bidder: bid.bidder, + mediaType: bid.type, + ttl: 60 + }; + + if (resbid.mediaType === 'video' && isUrl(bid.party_tag)) { + resbid.vastUrl = bid.party_tag; + } else if (resbid.mediaType === 'video') { + resbid.vastXml = bid.party_tag; + } else if (resbid.mediaType === 'banner') { + resbid.ad = bid.party_tag; + } else if (resbid.mediaType === 'native') { + resbid.native = interpretNativeAd(bid.party_tag) + }; + + const context = deepAccess(bidRequest, 'mediatype.context'); + if (resbid.mediaType === 'video' && context === 'outstream') { + resbid.renderer = createOutstreamVideoRenderer(bid); + } - bidResponses.push(resbid); + bidResponses.push(resbid); + } }); } return bidResponses; @@ -272,6 +282,40 @@ function isUrl(str) { } }; +function outstreamRender (bid) { + bid.renderer.push(() => { + window.ANOutstreamVideo.renderAd({ + targetId: bid.adUnitCode, + adResponse: bid.adResponse + }); + }); +} + +function createOutstreamVideoRenderer(bid) { + const renderer = Renderer.install({ + id: bid.bidId, + url: RENDERER_URL, + loaded: false + }); + + try { + renderer.setRender(outstreamRender); + } catch (err) { + logError('Prebid Error calling setRender on renderer' + err); + } + + return renderer; +} + +function getAssociatedBidRequest(bidRequests, bid) { + for (const request of bidRequests) { + if (request.id === bid.id) { + return request; + } + } + return undefined; +} + function enrichSlotWithFloors(slot, bidRequest) { try { const slotFloors = {}; diff --git a/test/spec/modules/admaticBidAdapter_spec.js b/test/spec/modules/admaticBidAdapter_spec.js index b4d84634962..8730f2c1a0d 100644 --- a/test/spec/modules/admaticBidAdapter_spec.js +++ b/test/spec/modules/admaticBidAdapter_spec.js @@ -130,7 +130,7 @@ describe('admaticBidAdapter', () => { ], 'mediatype': {}, 'type': 'banner', - 'id': '2205da7a81846b', + 'id': 1, 'floors': { 'banner': { '300x250': { 'currency': 'USD', 'floor': 1 }, @@ -434,7 +434,7 @@ describe('admaticBidAdapter', () => { 'h': 90 } ], - 'id': '2205da7a81846b', + 'id': 1, 'mediatype': {}, 'type': 'banner', 'floors': { @@ -802,7 +802,10 @@ describe('admaticBidAdapter', () => { 'price': 0.01, 'type': 'banner', 'bidder': 'admatic', - 'mime_type': 'iframe', + 'mime_type': { + 'name': 'backfill', + 'force': false + }, 'adomain': ['admatic.com.tr'], 'party_tag': '
', 'iurl': 'https://www.admatic.com.tr' @@ -814,7 +817,10 @@ describe('admaticBidAdapter', () => { 'height': 250, 'price': 0.01, 'type': 'video', - 'mime_type': 'iframe', + 'mime_type': { + 'name': 'backfill', + 'force': false + }, 'bidder': 'admatic', 'adomain': ['admatic.com.tr'], 'party_tag': '', @@ -822,25 +828,15 @@ describe('admaticBidAdapter', () => { }, { 'id': 3, - 'creative_id': '3741', - 'width': 300, - 'height': 250, - 'price': 0.01, - 'type': 'video', - 'mime_type': 'iframe', - 'bidder': 'admatic', - 'adomain': ['admatic.com.tr'], - 'party_tag': 'https://www.admatic.com.tr', - 'iurl': 'https://www.admatic.com.tr' - }, - { - 'id': 4, 'creative_id': '3742', 'width': 1, 'height': 1, 'price': 0.01, 'type': 'native', - 'mime_type': 'iframe', + 'mime_type': { + 'name': 'backfill', + 'force': false + }, 'bidder': 'admatic', 'adomain': ['admatic.com.tr'], 'party_tag': '{"native":{"ver":"1.1","assets":[{"id":1,"title":{"text":"title"}},{"id":4,"data":{"value":"body"}},{"id":5,"data":{"value":"sponsored"}},{"id":6,"data":{"value":"cta"}},{"id":2,"img":{"url":"https://www.admatic.com.tr","w":1200,"h":628}},{"id":3,"img":{"url":"https://www.admatic.com.tr","w":640,"h":480}}],"link":{"url":"https://www.admatic.com.tr"},"imptrackers":["https://www.admatic.com.tr"]}}', @@ -863,7 +859,10 @@ describe('admaticBidAdapter', () => { ad: '
', creativeId: '374', meta: { - model: 'iframe', + model: { + 'name': 'backfill', + 'force': false + }, advertiserDomains: ['admatic.com.tr'] }, ttl: 60, @@ -877,11 +876,13 @@ describe('admaticBidAdapter', () => { currency: 'TRY', mediaType: 'video', netRevenue: true, - vastImpUrl: 'https://www.admatic.com.tr', vastXml: '', creativeId: '3741', meta: { - model: 'iframe', + model: { + 'name': 'backfill', + 'force': false + }, advertiserDomains: ['admatic.com.tr'] }, ttl: 60, @@ -890,24 +891,6 @@ describe('admaticBidAdapter', () => { { requestId: 3, cpm: 0.01, - width: 300, - height: 250, - currency: 'TRY', - mediaType: 'video', - netRevenue: true, - vastImpUrl: 'https://www.admatic.com.tr', - vastXml: 'https://www.admatic.com.tr', - creativeId: '3741', - meta: { - model: 'iframe', - advertiserDomains: ['admatic.com.tr'] - }, - ttl: 60, - bidder: 'admatic' - }, - { - requestId: 4, - cpm: 0.01, width: 1, height: 1, currency: 'TRY', @@ -933,7 +916,10 @@ describe('admaticBidAdapter', () => { }, creativeId: '3742', meta: { - model: 'iframe', + model: { + 'name': 'backfill', + 'force': false + }, advertiserDomains: ['admatic.com.tr'] }, ttl: 60, @@ -944,8 +930,206 @@ describe('admaticBidAdapter', () => { ext: { 'cur': 'TRY', 'type': 'admatic' - } + }, + imp: [ + { + 'size': [ + { + 'w': 320, + 'h': 100 + } + ], + 'type': 'banner', + 'mediatype': {}, + 'ext': { + 'instl': 0, + 'gpid': 'desktop-standard', + 'pxid': [ + '1111111111' + ], + 'pxtype': 'pixad', + 'ortbstatus': true, + 'viewability': 100, + 'data': { + 'pbadslot': 'desktop-standard' + }, + 'ae': 1 + }, + 'id': 1, + 'floors': { + 'banner': { + '320x100': { + 'floor': 0.1, + 'currency': 'TRY' + } + } + } + }, + { + 'size': [ + { + 'w': 320, + 'h': 100 + } + ], + 'type': 'video', + 'mediatype': { + 'context': 'instream', + 'mimes': [ + 'video/mp4' + ], + 'maxduration': 240, + 'api': [ + 1, + 2 + ], + 'playerSize': [ + [ + 320, + 100 + ] + ], + 'protocols': [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8 + ], + 'skip': 0, + 'playbackmethod': [ + 2 + ], + 'linearity': 1, + 'placement': 2, + 'plcmt': 4 + }, + 'ext': { + 'gpid': 'outstream-desktop-standard', + 'pxtype': 'pixad', + 'pxid': [ + '1111111111' + ], + 'ortbstatus': true, + 'viewability': 100, + 'data': { + 'pbadslot': 'outstream-desktop-standard' + }, + 'ae': 1 + }, + 'id': 2, + 'floors': { + 'video': { + '320x100': { + 'floor': 0.1, + 'currency': 'TRY' + } + } + } + }, + { + 'size': [ + { + 'w': 1, + 'h': 1 + } + ], + 'type': 'native', + 'mediatype': { + 'sendTargetingKeys': false, + 'ortb': { + 'ver': '1.1', + 'context': 2, + 'plcmttype': 1, + 'privacy': 1, + 'assets': [ + { + 'id': 1, + 'required': 1, + 'title': { + 'len': 120 + } + }, + { + 'id': 2, + 'required': 1, + 'img': { + 'type': 3, + 'w': 640, + 'h': 480 + } + }, + { + 'id': 3, + 'required': 0, + 'img': { + 'type': 1, + 'w': 640, + 'h': 480 + } + }, + { + 'id': 4, + 'required': 0, + 'data': { + 'type': 2 + } + }, + { + 'id': 5, + 'required': 0, + 'data': { + 'type': 1 + } + }, + { + 'id': 6, + 'required': 0, + 'data': { + 'type': 11 + } + } + ], + 'eventtrackers': [ + { + 'event': 1, + 'methods': [ + 1, + 2 + ] + } + ] + } + }, + 'ext': { + 'gpid': 'native-desktop-standard', + 'pxtype': 'pixad', + 'pxid': [ + '1111111111' + ], + 'ortbstatus': true, + 'viewability': 100, + 'data': { + 'pbadslot': 'native-desktop-standard' + }, + 'ae': 1 + }, + 'id': 3, + 'floors': { + 'native': { + '*': { + 'floor': 0.1, + 'currency': 'TRY' + } + } + } + } + ] }; + let result = spec.interpretResponse(bids, {data: request}); expect(result).to.eql(expectedResponse); }); From 1023229fbca6f696705ee9c9791a93546a182084 Mon Sep 17 00:00:00 2001 From: Fatih Kaya Date: Tue, 4 Jun 2024 09:40:33 +0300 Subject: [PATCH 53/57] Update admaticBidAdapter.js --- modules/admaticBidAdapter.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/modules/admaticBidAdapter.js b/modules/admaticBidAdapter.js index 6c268b2d382..34a6ec788bd 100644 --- a/modules/admaticBidAdapter.js +++ b/modules/admaticBidAdapter.js @@ -40,7 +40,8 @@ export const spec = { code: BIDDER_CODE, gvlid: 1281, aliases: [ - {code: 'pixad', gvlid: 1281} + {code: 'pixad', gvlid: 1281}, + {code: 'monetixads', gvlid: 1281} ], supportedMediaTypes: [BANNER, VIDEO, NATIVE], /** @@ -140,11 +141,14 @@ export const spec = { if (payload) { switch (bidderName) { + case 'monetixads': + SYNC_URL = 'https://static.cdn.monetixads.com/sync.html'; + break; case 'pixad': SYNC_URL = 'https://static.cdn.pixad.com.tr/sync.html'; break; default: - SYNC_URL = 'https://cdn.serve.admatic.com.tr/showad/sync.html'; + SYNC_URL = 'https://static.cdn.admatic.com.tr/sync.html'; break; } From 9ea240ed8bc5587801342ee683d8e920594a3f53 Mon Sep 17 00:00:00 2001 From: Fatih Kaya Date: Mon, 2 Sep 2024 18:58:04 +0300 Subject: [PATCH 54/57] admatic cur update --- modules/admaticBidAdapter.js | 8 +++++--- test/spec/modules/admaticBidAdapter_spec.js | 13 +++++++++---- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/modules/admaticBidAdapter.js b/modules/admaticBidAdapter.js index 34a6ec788bd..79fac6460b0 100644 --- a/modules/admaticBidAdapter.js +++ b/modules/admaticBidAdapter.js @@ -73,7 +73,6 @@ export const spec = { const ortb = bidderRequest.ortb2; const networkId = getValue(validBidRequests[0].params, 'networkId'); const host = getValue(validBidRequests[0].params, 'host'); - const currency = config.getConfig('currency.adServerCurrency') || 'TRY'; const bidderName = validBidRequests[0].bidder; const payload = { @@ -88,7 +87,6 @@ export const spec = { }, imp: bids, ext: { - cur: currency, bidder: bidderName }, schain: {}, @@ -103,6 +101,10 @@ export const spec = { tmax: parseInt(tmax) }; + if (config.getConfig('currency.adServerCurrency')) { + payload.ext.cur = config.getConfig('currency.adServerCurrency'); + } + if (bidderRequest && bidderRequest.gdprConsent && bidderRequest.gdprConsent.gdprApplies) { const consentStr = (bidderRequest.gdprConsent.consentString) ? bidderRequest.gdprConsent.consentString.replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/, '') : ''; @@ -207,7 +209,7 @@ export const spec = { cpm: bid.price, width: bid.width, height: bid.height, - currency: body.cur || 'TRY', + currency: body.cur, netRevenue: true, creativeId: bid.creative_id, meta: { diff --git a/test/spec/modules/admaticBidAdapter_spec.js b/test/spec/modules/admaticBidAdapter_spec.js index 8730f2c1a0d..50700a7b4e1 100644 --- a/test/spec/modules/admaticBidAdapter_spec.js +++ b/test/spec/modules/admaticBidAdapter_spec.js @@ -802,6 +802,7 @@ describe('admaticBidAdapter', () => { 'price': 0.01, 'type': 'banner', 'bidder': 'admatic', + 'currency': 'TRY', 'mime_type': { 'name': 'backfill', 'force': false @@ -816,6 +817,7 @@ describe('admaticBidAdapter', () => { 'width': 300, 'height': 250, 'price': 0.01, + 'currency': 'TRY', 'type': 'video', 'mime_type': { 'name': 'backfill', @@ -832,6 +834,7 @@ describe('admaticBidAdapter', () => { 'width': 1, 'height': 1, 'price': 0.01, + 'currency': 'TRY', 'type': 'native', 'mime_type': { 'name': 'backfill', @@ -843,6 +846,7 @@ describe('admaticBidAdapter', () => { 'iurl': 'https://www.admatic.com.tr' } ], + 'cur': 'TRY', 'queryId': 'cdnbh24rlv0hhkpfpln0', 'status': true }}; @@ -853,9 +857,9 @@ describe('admaticBidAdapter', () => { cpm: 0.01, width: 300, height: 250, - currency: 'TRY', mediaType: 'banner', netRevenue: true, + currency: 'TRY', ad: '
', creativeId: '374', meta: { @@ -873,9 +877,9 @@ describe('admaticBidAdapter', () => { cpm: 0.01, width: 300, height: 250, - currency: 'TRY', mediaType: 'video', netRevenue: true, + currency: 'TRY', vastXml: '', creativeId: '3741', meta: { @@ -893,9 +897,9 @@ describe('admaticBidAdapter', () => { cpm: 0.01, width: 1, height: 1, - currency: 'TRY', mediaType: 'native', netRevenue: true, + currency: 'TRY', native: { 'clickUrl': 'https://www.admatic.com.tr', 'impressionTrackers': ['https://www.admatic.com.tr'], @@ -1144,7 +1148,8 @@ describe('admaticBidAdapter', () => { let bids = { body: { data: [], 'queryId': 'cdnbh24rlv0hhkpfpln0', - 'status': true + 'status': true, + 'cur': 'TRY' }}; let result = spec.interpretResponse(bids, {data: request}); From 1ee12ef01bb98ed694dac5f501f71a559f5e6378 Mon Sep 17 00:00:00 2001 From: Fatih Kaya Date: Mon, 2 Sep 2024 19:04:46 +0300 Subject: [PATCH 55/57] Update admaticBidAdapter.js --- modules/admaticBidAdapter.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/modules/admaticBidAdapter.js b/modules/admaticBidAdapter.js index 79fac6460b0..7eac25b89fa 100644 --- a/modules/admaticBidAdapter.js +++ b/modules/admaticBidAdapter.js @@ -11,7 +11,7 @@ import { Renderer } from '../src/Renderer.js'; */ export const OPENRTB = { - NATIVE: { + N: { IMAGE_TYPE: { ICON: 1, MAIN: 3, @@ -434,30 +434,30 @@ function interpretNativeAd(adm) { }; native.assets.forEach(asset => { switch (asset.id) { - case OPENRTB.NATIVE.ASSET_ID.TITLE: + case OPENRTB.N.ASSET_ID.TITLE: result.title = asset.title.text; break; - case OPENRTB.NATIVE.ASSET_ID.IMAGE: + case OPENRTB.N.ASSET_ID.IMAGE: result.image = { url: encodeURI(asset.img.url), width: asset.img.w, height: asset.img.h }; break; - case OPENRTB.NATIVE.ASSET_ID.ICON: + case OPENRTB.N.ASSET_ID.ICON: result.icon = { url: encodeURI(asset.img.url), width: asset.img.w, height: asset.img.h }; break; - case OPENRTB.NATIVE.ASSET_ID.BODY: + case OPENRTB.N.ASSET_ID.BODY: result.body = asset.data.value; break; - case OPENRTB.NATIVE.ASSET_ID.SPONSORED: + case OPENRTB.N.ASSET_ID.SPONSORED: result.sponsoredBy = asset.data.value; break; - case OPENRTB.NATIVE.ASSET_ID.CTA: + case OPENRTB.N.ASSET_ID.CTA: result.cta = asset.data.value; break; } From 6e25b898b256cd2f1b99f625dd429bb908c5bdc0 Mon Sep 17 00:00:00 2001 From: Fatih Kaya Date: Tue, 8 Oct 2024 16:23:18 +0300 Subject: [PATCH 56/57] Update admaticBidAdapter.js --- modules/admaticBidAdapter.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/modules/admaticBidAdapter.js b/modules/admaticBidAdapter.js index a5ebe91f98a..74c063042ef 100644 --- a/modules/admaticBidAdapter.js +++ b/modules/admaticBidAdapter.js @@ -41,8 +41,10 @@ export const spec = { code: BIDDER_CODE, gvlid: 1281, aliases: [ + {code: 'admaticde', gvlid: 1281}, {code: 'pixad', gvlid: 1281}, - {code: 'monetixads', gvlid: 1281} + {code: 'monetixads', gvlid: 1281}, + {code: 'netaddiction', gvlid: 1281} ], supportedMediaTypes: [BANNER, VIDEO, NATIVE], /** @@ -144,12 +146,18 @@ export const spec = { if (payload) { switch (bidderName) { + case 'netaddiction': + SYNC_URL = 'https://static.cdn.netaddiction.tech/netaddiction/sync.html'; + break; case 'monetixads': - SYNC_URL = 'https://static.cdn.monetixads.com/sync.html'; + SYNC_URL = 'https://static.cdn.monetixads.com/monetixads/sync.html'; break; case 'pixad': SYNC_URL = 'https://static.cdn.pixad.com.tr/sync.html'; break; + case 'admaticde': + SYNC_URL = 'https://static.cdn.admatic.de/admaticde/sync.html'; + break; default: SYNC_URL = 'https://static.cdn.admatic.com.tr/sync.html'; break; From b201fe435e0991addf47f17b99cb85d3b46bb4de Mon Sep 17 00:00:00 2001 From: Fatih Kaya Date: Fri, 15 Nov 2024 17:07:39 +0300 Subject: [PATCH 57/57] Update admaticBidAdapter.js --- modules/admaticBidAdapter.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/modules/admaticBidAdapter.js b/modules/admaticBidAdapter.js index 78e76651177..ed38cc975e8 100644 --- a/modules/admaticBidAdapter.js +++ b/modules/admaticBidAdapter.js @@ -23,7 +23,8 @@ export const spec = { {code: 'admaticde', gvlid: 1281}, {code: 'pixad', gvlid: 1281}, {code: 'monetixads', gvlid: 1281}, - {code: 'netaddiction', gvlid: 1281} + {code: 'netaddiction', gvlid: 1281}, + {code: 'adt', gvlid: 779} ], supportedMediaTypes: [BANNER, VIDEO, NATIVE], /** @@ -54,7 +55,7 @@ export const spec = { const bids = validBidRequests.map(buildRequestObject); const ortb = bidderRequest.ortb2; const networkId = getValue(validBidRequests[0].params, 'networkId'); - const host = getValue(validBidRequests[0].params, 'host'); + let host = getValue(validBidRequests[0].params, 'host'); const bidderName = validBidRequests[0].bidder; const payload = { @@ -137,11 +138,15 @@ export const spec = { case 'admaticde': SYNC_URL = 'https://static.cdn.admatic.de/admaticde/sync.html'; break; + case 'adt': + SYNC_URL = 'https://static.cdn.adtarget.org/adt/sync.html'; + break; default: SYNC_URL = 'https://static.cdn.admatic.com.tr/sync.html'; break; } + host = host?.replace('https://', '')?.replace('http://', '')?.replace('/', ''); return { method: 'POST', url: `https://${host}/pb`, data: payload, options: { contentType: 'application/json' } }; } }, @@ -150,7 +155,7 @@ export const spec = { if (!hasSynced && syncOptions.iframeEnabled) { // data is only assigned if params are available to pass to syncEndpoint let params = getUserSyncParams(gdprConsent, uspConsent, gppConsent); - params = Object.keys(params).length ? `?${formatQS(params)}` : ''; + params = Object.keys(params).length ? `&${formatQS(params)}` : ''; hasSynced = true; return {