From 4422d44dd24131153223fe05e9fc3ee49a98fdba Mon Sep 17 00:00:00 2001 From: Alex404Damsa <114728686+Alex404Damsa@users.noreply.github.com> Date: Fri, 5 Jul 2024 22:42:30 +0300 Subject: [PATCH] Connatix Bid Adapter: Support For Video Media Type (#11933) * upgrade prebid js * added conversantBidAdapter * added criteoBidAdapter, tripleliftBidAdapter, pulsepointBidAdapter * adtelligent bid adapter * remove oneVideoBidAdapter from modules.json * added yieldmo bid adapter * build:connatix script * removed flocIdSystem & TrustxBidAdapter from modules.json * added aniview bid adapter * moved line * added nextMillennium adapter to modules.json * newline at the end of the file * added new adapters * added minutemedia adapter * added richaudience adapter * Revert "added richaudience adapter" This reverts commit d87cb0df7674fa414db70f52dad69cc1c21b25d7. * Revert "added minutemedia adapter" This reverts commit ac53dff7ef398219a881e6208ed992c41b0b9ad8. * Added Permutive RTD module * comma * [feat] add sharethroughBidAdapter * Add consentManagementGpp module * fix gpp signal (#5) * remove gpp module because no need to support it yet * LiveRamp submodule identityLink * added sonobi bid adapter * upgrade to prebid 8.17.0 * added pgamsspBidAdapter because its alias was removed from adtelligentBidAdapter in 8.x.0 * added ozone as Connatix bidder partner * added showheroes adapter * added seedtag bid adaptor * added minutemedia * removed duplicated minute media * added sovrn bid adapter * fix: add consentManagementGpp module * added new build and gannet adapters * renamed build command * added specific modules for gannett * added kueezRtb bid adaptor * added video media type support for connatix bid adapter * added all the recommended params to video media type mock * improved validateVideo function * impreoved validateVideo function once again:) * removed redundant checks in bid request validation * clarified test it statement * improved unit tests * updated validateVideo function * removed modules.json * removed connatix build script --------- Co-authored-by: Rares Mihai Preda Co-authored-by: Darian Co-authored-by: alexandru.calauz Co-authored-by: cosminser <80513728+cosminser@users.noreply.github.com> Co-authored-by: Gaina Dan Co-authored-by: Cristi Silav Co-authored-by: mariusszabo <33828291+mariusszabo@users.noreply.github.com> Co-authored-by: Marius Szabo Co-authored-by: Octavia Suceava Co-authored-by: Marius Potor --- modules/connatixBidAdapter.js | 44 ++++++++++++--- test/spec/modules/connatixBidAdapter_spec.js | 57 +++++++++++++++++++- 2 files changed, 91 insertions(+), 10 deletions(-) diff --git a/modules/connatixBidAdapter.js b/modules/connatixBidAdapter.js index 0b840db6c26..802ad855e27 100644 --- a/modules/connatixBidAdapter.js +++ b/modules/connatixBidAdapter.js @@ -11,7 +11,9 @@ import { } from '../src/utils.js'; import { + ADPOD, BANNER, + VIDEO, } from '../src/mediaTypes.js'; const BIDDER_CODE = 'connatix'; @@ -41,10 +43,28 @@ export function getBidFloor(bid) { } } +export function validateBanner(mediaTypes) { + if (!mediaTypes[BANNER]) { + return true; + } + + const banner = deepAccess(mediaTypes, BANNER, {}); + return (Boolean(banner.sizes) && isArray(mediaTypes[BANNER].sizes) && mediaTypes[BANNER].sizes.length > 0); +} + +export function validateVideo(mediaTypes) { + const video = mediaTypes[VIDEO]; + if (!video) { + return true; + } + + return video.context !== ADPOD; +} + export const spec = { code: BIDDER_CODE, gvlid: 143, - supportedMediaTypes: [BANNER], + supportedMediaTypes: [BANNER, VIDEO], /* * Validate the bid request. @@ -57,17 +77,24 @@ export const spec = { const params = deepAccess(bid, 'params', {}); const bidder = deepAccess(bid, 'bidder'); - const banner = deepAccess(mediaTypes, BANNER, {}); - const hasBidId = Boolean(bidId); const isValidBidder = (bidder === BIDDER_CODE); - const isValidSize = (Boolean(banner.sizes) && isArray(mediaTypes[BANNER].sizes) && mediaTypes[BANNER].sizes.length > 0); - const hasSizes = mediaTypes[BANNER] ? isValidSize : false; + const hasMediaTypes = Boolean(mediaTypes) && (Boolean(mediaTypes[BANNER]) || Boolean(mediaTypes[VIDEO])); + const isValidBanner = validateBanner(mediaTypes); + const isValidVideo = validateVideo(mediaTypes); const hasRequiredBidParams = Boolean(params.placementId); - const isValid = isValidBidder && hasBidId && hasSizes && hasRequiredBidParams; + const isValid = isValidBidder && hasBidId && hasMediaTypes && isValidBanner && isValidVideo && hasRequiredBidParams; if (!isValid) { - logError(`Invalid bid request: isValidBidder: ${isValidBidder} hasBidId: ${hasBidId}, hasSizes: ${hasSizes}, hasRequiredBidParams: ${hasRequiredBidParams}`); + logError( + `Invalid bid request: + isValidBidder: ${isValidBidder}, + hasBidId: ${hasBidId}, + hasMediaTypes: ${hasMediaTypes}, + isValidBanner: ${isValidBanner}, + isValidVideo: ${isValidVideo}, + hasRequiredBidParams: ${hasRequiredBidParams}` + ); } return isValid; }, @@ -129,12 +156,13 @@ export const spec = { cpm: bidResponse.Cpm, ttl: bidResponse.Ttl || DEFAULT_MAX_TTL, currency: 'USD', - mediaType: BANNER, + mediaType: bidResponse.VastXml ? VIDEO : BANNER, netRevenue: true, width: bidResponse.Width, height: bidResponse.Height, creativeId: bidResponse.CreativeId, ad: bidResponse.Ad, + vastXml: bidResponse.VastXml, referrer: referrer, })); }, diff --git a/test/spec/modules/connatixBidAdapter_spec.js b/test/spec/modules/connatixBidAdapter_spec.js index 4d816c4e816..1bf04ed9db8 100644 --- a/test/spec/modules/connatixBidAdapter_spec.js +++ b/test/spec/modules/connatixBidAdapter_spec.js @@ -3,7 +3,7 @@ import { spec, getBidFloor as connatixGetBidFloor } from '../../../modules/connatixBidAdapter.js'; -import { BANNER } from '../../../src/mediaTypes.js'; +import { ADPOD, BANNER, VIDEO } from '../../../src/mediaTypes.js'; describe('connatixBidAdapter', function () { let bid; @@ -24,6 +24,26 @@ describe('connatixBidAdapter', function () { }; }; + function addVideoToBidMock(bid) { + const mediaTypes = { + video: { + context: 'instream', + w: 1280, + h: 720, + playerSize: [1280, 720], + placement: 1, + plcmt: 1, + api: [1, 2], + mimes: ['video/mp4', 'application/javascript'], + minduration: 30, + maxduration: 60, + startdelay: 0, + } + } + + bid.mediaTypes = mediaTypes; + } + describe('isBidRequestValid', function () { this.beforeEach(function () { bid = mockBidRequest(); @@ -52,7 +72,7 @@ describe('connatixBidAdapter', function () { delete bid.mediaTypes; expect(spec.isBidRequestValid(bid)).to.be.false; }); - it('Should return false if banner is missing from mediaTypes ', function () { + it('Should return false if both banner and video are missing from mediaTypes', function () { delete bid.mediaTypes.banner; expect(spec.isBidRequestValid(bid)).to.be.false; }); @@ -68,6 +88,15 @@ describe('connatixBidAdapter', function () { bid.mediaTypes.banner.sizes = []; expect(spec.isBidRequestValid(bid)).to.be.false; }); + it('Should return true if video is set correctly', function () { + addVideoToBidMock(bid); + expect(spec.isBidRequestValid(bid)).to.be.true; + }); + it('Should return false if context is set to adpod on video media type', function() { + addVideoToBidMock(bid); + bid.mediaTypes.video.context = ADPOD; + expect(spec.isBidRequestValid(bid)).to.be.false; + }); it('Should return true if add an extra field was added to the bidRequest', function () { bid.params.test = 1; expect(spec.isBidRequestValid(bid)).to.be.true; @@ -197,6 +226,30 @@ describe('connatixBidAdapter', function () { expect(bidResponses[0].cpm).to.equal(firstBidCpm); expect(bidResponses[1].cpm).to.equal(secondBidCpm); }); + + it('Should contain specific values for banner bids', function () { + const adHtml = 'ad html' + serverResponse.body.Bids = [ { ...Bid, Ad: adHtml } ]; + + const bidResponses = spec.interpretResponse(serverResponse); + const [ bidResponse ] = bidResponses; + + expect(bidResponse.vastXml).to.be.undefined; + expect(bidResponse.ad).to.equal(adHtml); + expect(bidResponse.mediaType).to.equal(BANNER); + }); + + it('Should contain specific values for video bids', function () { + const adVastXml = 'ad vast xml' + serverResponse.body.Bids = [ { ...Bid, VastXml: adVastXml } ]; + + const bidResponses = spec.interpretResponse(serverResponse); + const [ bidResponse ] = bidResponses; + + expect(bidResponse.ad).to.be.undefined; + expect(bidResponse.vastXml).to.equal(adVastXml); + expect(bidResponse.mediaType).to.equal(VIDEO); + }); }); describe('getUserSyncs', function() {