Skip to content

Commit

Permalink
Connatix Bid Adapter: Support For Video Media Type (prebid#11933)
Browse files Browse the repository at this point in the history
* 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 d87cb0d.

* Revert "added minutemedia adapter"

This reverts commit ac53dff.

* 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 <rares.preda@connatix.com>
Co-authored-by: Darian <darian.avasan@connatix.com>
Co-authored-by: alexandru.calauz <alexandru.calauz@connatix.com>
Co-authored-by: cosminser <80513728+cosminser@users.noreply.github.com>
Co-authored-by: Gaina Dan <dan.gaina@connatix.com>
Co-authored-by: Cristi Silav <cristian.silav@connatix.com>
Co-authored-by: mariusszabo <33828291+mariusszabo@users.noreply.github.com>
Co-authored-by: Marius Szabo <marius.szabo@connatix.com>
Co-authored-by: Octavia Suceava <octavia.suceava@connatix.com>
Co-authored-by: Marius Potor <marius.potor@connatix.com>
  • Loading branch information
11 people authored Jul 5, 2024
1 parent b6184e2 commit 4422d44
Show file tree
Hide file tree
Showing 2 changed files with 91 additions and 10 deletions.
44 changes: 36 additions & 8 deletions modules/connatixBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ import {
} from '../src/utils.js';

import {
ADPOD,
BANNER,
VIDEO,
} from '../src/mediaTypes.js';

const BIDDER_CODE = 'connatix';
Expand Down Expand Up @@ -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.
Expand All @@ -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;
},
Expand Down Expand Up @@ -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,
}));
},
Expand Down
57 changes: 55 additions & 2 deletions test/spec/modules/connatixBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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();
Expand Down Expand Up @@ -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;
});
Expand All @@ -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;
Expand Down Expand Up @@ -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() {
Expand Down

0 comments on commit 4422d44

Please sign in to comment.