Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PubMatic Bid Adapter : support for InBannerVideo (IBV) Field in Bid Response with meta.mediaType #12484

Merged
merged 38 commits into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
d8c3dcc
Merge pull request #1 from prebid/master
pm-nitin-shirsat Oct 11, 2022
2dedab6
Implement functionality for deal priority
pm-nitin-shirsat Oct 12, 2022
afae888
Update test cases
pm-nitin-shirsat Oct 12, 2022
9447e84
kick off test manually
ChrisHuie Oct 13, 2022
400af75
Merge branch 'master' of https://github.com/prebid/Prebid.js into pre…
pm-nitin-shirsat May 3, 2023
5896b10
Merge branch 'prebid-master'
pm-nitin-shirsat May 3, 2023
ade41d3
Added support of GPP to PubMatic adapter
pm-nitin-shirsat May 3, 2023
7d0b86d
Merge pull request #3 from prebid/master
pm-nitin-shirsat May 12, 2023
caeae1a
Merge branch 'prebid-master-new' into master
pm-nitin-shirsat Jun 29, 2023
f21764b
Merge pull request #5 from pm-nitin-shirsat/master
pm-nitin-shirsat Jun 29, 2023
826e6e7
Merge pull request #6 from pm-nitin-shirsat/prebid-master-new
pm-nitin-shirsat Jun 29, 2023
92846e9
gpp_sid in user syncs supposed to encode as a string, not an array
pm-nitin-shirsat Jun 30, 2023
f92818a
Remove extra space
pm-nitin-shirsat Jul 5, 2023
fcb0dde
Remove trailing spaces
pm-nitin-shirsat Jul 5, 2023
51fc097
Merge pull request #7 from prebid/master
pm-nitin-shirsat Jul 31, 2023
6a72e8c
Merge pull request #8 from prebid/master
pm-nitin-shirsat Aug 25, 2023
2432d2f
Merge pull request #9 from prebid/master
pm-nitin-shirsat Sep 12, 2023
9fc89c6
Merge pull request #10 from prebid/master
pm-nitin-shirsat May 22, 2024
70b6e36
Remove the placement parameter and update test cases accordingly, Add…
pm-nitin-shirsat May 23, 2024
a3667c1
Supporting placement parameter and logging warning message, for the p…
pm-nitin-shirsat May 24, 2024
484c691
Remove commented code
pm-nitin-shirsat May 28, 2024
39af04f
Merge pull request #11 from prebid/master
pm-nitin-shirsat May 30, 2024
415037f
Merge pull request #12 from prebid/master
pm-nitin-shirsat May 31, 2024
14db919
Added plcmt in the pubmaticBidAdapter.md file
pm-nitin-shirsat May 31, 2024
8761239
Merge pull request #13 from prebid/master
pm-nitin-shirsat Jun 27, 2024
6cfb9be
Adding support for Banner battr object
pm-nitin-shirsat Jul 1, 2024
74330a8
Merge pull request #15 from prebid/master
pm-nitin-shirsat Jul 3, 2024
26a9bde
Merge pull request #16 from prebid/master
pm-nitin-shirsat Jul 4, 2024
cb85e20
reading battr from ortb2Imp.banner
pm-nitin-shirsat Jul 4, 2024
11e3c90
Merge branch 'UOE-10758' of https://github.com/pm-nitin-shirsat/Prebi…
pm-nitin-shirsat Jul 4, 2024
ba054e9
Merge pull request #17 from pm-nitin-shirsat/UOE-10758
pm-nitin-shirsat Jul 4, 2024
e0d9a5e
Merge pull request #18 from prebid/master
pm-nitin-shirsat Nov 14, 2024
83c3380
Hot fix: IBV field set to the bid.ext.ibv if present
pm-nitin-shirsat Nov 15, 2024
88dade5
Hot fix: IBV written unit test cases
pm-nitin-shirsat Nov 15, 2024
b0a6c49
IBV: Add support of bid.meta.mediaType to video in case of bid.ext.ib…
pm-nitin-shirsat Nov 15, 2024
00baef3
UOE-11548: Support meta.mediaType and override the same with value vi…
pm-nitin-shirsat Nov 20, 2024
439d1ba
Merge pull request #20 from prebid/master
pm-nitin-shirsat Nov 20, 2024
bb19359
Merge pull request #21 from prebid/master
pm-nitin-shirsat Nov 21, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 20 additions & 3 deletions modules/pubmaticBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -859,6 +859,18 @@ function _handleEids(payload, validBidRequests) {
}
}

// Setting IBV & meta.mediaType field into the bid response
export function setIBVField(bid, newBid) {
if (bid?.ext?.ibv) {
newBid.ext = newBid.ext || {};
newBid.ext['ibv'] = bid.ext.ibv;

// Overriding the mediaType field in meta with the `video` value if bid.ext.ibv is present
newBid.meta = newBid.meta || {};
newBid.meta.mediaType = VIDEO;
}
}

function _checkMediaType(bid, newBid) {
// Create a regex here to check the strings
if (bid.ext && bid.ext['bidtype'] != undefined) {
Expand Down Expand Up @@ -1008,7 +1020,7 @@ function isNonEmptyArray(test) {
* @param {*} bid : bids
*/
export function prepareMetaObject(br, bid, seat) {
br.meta = {};
br.meta = br.meta || {};

if (bid.ext && bid.ext.dspid) {
br.meta.networkId = bid.ext.dspid;
Expand Down Expand Up @@ -1047,6 +1059,11 @@ export function prepareMetaObject(br, bid, seat) {
if (bid.ext && bid.ext.dsa && Object.keys(bid.ext.dsa).length) {
br.meta.dsa = bid.ext.dsa;
}

// Initializing meta.mediaType field to the actual bidType returned by the bidder
if (br.mediaType) {
br.meta.mediaType = br.mediaType;
}
}

export const spec = {
Expand Down Expand Up @@ -1401,12 +1418,12 @@ export const spec = {
}
});
}
prepareMetaObject(newBid, bid, seatbidder.seat);
setIBVField(bid, newBid);
if (bid.ext && bid.ext.deal_channel) {
newBid['dealChannel'] = dealChannelValues[bid.ext.deal_channel] || null;
}

prepareMetaObject(newBid, bid, seatbidder.seat);

// adserverTargeting
if (seatbidder.ext && seatbidder.ext.buyid) {
newBid.adserverTargeting = {
Expand Down
88 changes: 85 additions & 3 deletions test/spec/modules/pubmaticBidAdapter_spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { expect } from 'chai';
import { spec, checkVideoPlacement, _getDomainFromURL, assignDealTier, prepareMetaObject, getDeviceConnectionType } from 'modules/pubmaticBidAdapter.js';
import { spec, checkVideoPlacement, _getDomainFromURL, assignDealTier, prepareMetaObject, getDeviceConnectionType, setIBVField } from 'modules/pubmaticBidAdapter.js';
import * as utils from 'src/utils.js';
import { config } from 'src/config.js';
import { createEidsArray } from 'modules/userId/eids.js';
Expand Down Expand Up @@ -3579,6 +3579,33 @@ describe('PubMatic adapter', function () {
expect(response[0].renderer).to.not.exist;
});

it('should set ibv field in bid.ext when bid.ext.ibv exists', function() {
let request = spec.buildRequests(bidRequests, {
auctionId: 'new-auction-id'
});

let copyOfBidResponse = utils.deepClone(bannerBidResponse);
let bidExt = utils.deepClone(copyOfBidResponse.body.seatbid[0].bid[0].ext);
copyOfBidResponse.body.seatbid[0].bid[0].ext = Object.assign(bidExt, {
ibv: true
});

let response = spec.interpretResponse(copyOfBidResponse, request);
expect(response[0].ext.ibv).to.equal(true);
expect(response[0].meta.mediaType).to.equal('video');
});

it('should not set ibv field when bid.ext does not exist ', function() {
let request = spec.buildRequests(bidRequests, {
auctionId: 'new-auction-id'
});

let response = spec.interpretResponse(bannerBidResponse, request);
expect(response[0].ext).to.not.exist;
expect(response[0].meta).to.exist;
expect(response[0].meta.mediaType).to.equal('banner');
});

if (FEATURES.VIDEO) {
it('should check for valid video mediaType in case of multiformat request', function() {
let request = spec.buildRequests(videoBidRequests, {
Expand Down Expand Up @@ -3878,10 +3905,12 @@ describe('PubMatic adapter', function () {
// dchain: 'dc',
// demandSource: 'ds',
// secondaryCatIds: ['secondaryCatIds']
}
},
};

const br = {};
const br = {
mediaType: 'video'
};
prepareMetaObject(br, bid, null);
expect(br.meta.networkId).to.equal(6); // dspid
expect(br.meta.buyerId).to.equal('12'); // adid
Expand All @@ -3900,6 +3929,7 @@ describe('PubMatic adapter', function () {
expect(br.meta.advertiserDomains).to.be.an('array').with.length.above(0); // adomain
expect(br.meta.clickUrl).to.equal('mystartab.com'); // adomain
expect(br.meta.dsa).to.equal(dsa); // dsa
expect(br.meta.mediaType).to.equal('video'); // mediaType
});

it('Should be empty, when ext and adomain is absent in bid object', function () {
Expand Down Expand Up @@ -4176,6 +4206,58 @@ describe('PubMatic adapter', function () {
expect(data.imp[0]['banner']['battr']).to.equal(undefined);
});
});

describe('setIBVField', function() {
it('should set ibv field in newBid.ext when bid.ext.ibv exists', function() {
const bid = {
ext: {
ibv: true
}
};
const newBid = {};
setIBVField(bid, newBid);
expect(newBid.ext).to.exist;
expect(newBid.ext.ibv).to.equal(true);
expect(newBid.meta).to.exist;
expect(newBid.meta.mediaType).to.equal('video');
});

it('should not set ibv field when bid.ext.ibv does not exist', function() {
const bid = {
ext: {}
};
const newBid = {};
setIBVField(bid, newBid);
expect(newBid.ext).to.not.exist;
expect(newBid.meta).to.not.exist;
});

it('should not set ibv field when bid.ext does not exist', function() {
const bid = {};
const newBid = {};
setIBVField(bid, newBid);
expect(newBid.ext).to.not.exist;
expect(newBid.meta).to.not.exist;
});

it('should preserve existing newBid.ext properties', function() {
const bid = {
ext: {
ibv: true
}
};
const newBid = {
ext: {
existingProp: 'should remain'
}
};
setIBVField(bid, newBid);
expect(newBid.ext.existingProp).to.equal('should remain');
expect(newBid.ext.ibv).to.equal(true);
expect(newBid.meta).to.exist;
expect(newBid.meta.mediaType).to.equal('video');
});
});
});

if (FEATURES.VIDEO) {
Expand Down