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 : Remove GroupM as alias #8386

Merged
merged 21 commits into from
May 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
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
17 changes: 6 additions & 11 deletions modules/pubmaticBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { registerBidder } from '../src/adapters/bidderFactory.js';
import { BANNER, VIDEO, NATIVE } from '../src/mediaTypes.js';
import {config} from '../src/config.js';
import { Renderer } from '../src/Renderer.js';
import { bidderSettings } from '../src/bidderSettings.js';

const BIDDER_CODE = 'pubmatic';
const LOG_WARN_PREFIX = 'PubMatic: ';
Expand All @@ -11,8 +12,6 @@ const USER_SYNC_URL_IFRAME = 'https://ads.pubmatic.com/AdServer/js/user_sync.htm
const USER_SYNC_URL_IMAGE = 'https://image8.pubmatic.com/AdServer/ImgSync?p=';
const DEFAULT_CURRENCY = 'USD';
const AUCTION_TYPE = 1;
const GROUPM_ALIAS = {code: 'groupm', gvlid: 98};
const MARKETPLACE_PARTNERS = ['groupm']
const UNDEFINED = undefined;
const DEFAULT_WIDTH = 0;
const DEFAULT_HEIGHT = 0;
Expand Down Expand Up @@ -1026,7 +1025,6 @@ export const spec = {
code: BIDDER_CODE,
gvlid: 76,
supportedMediaTypes: [BANNER, VIDEO, NATIVE],
aliases: [GROUPM_ALIAS],
/**
* Determines whether or not the given bid request is valid. Valid bid request must have placementId and hbid
*
Expand Down Expand Up @@ -1085,12 +1083,6 @@ export const spec = {
* @return ServerRequest Info describing the request to the server.
*/
buildRequests: (validBidRequests, bidderRequest) => {
if (bidderRequest && MARKETPLACE_PARTNERS.includes(bidderRequest.bidderCode)) {
// We have got the buildRequests function call for Marketplace Partners
logInfo('For all publishers using ' + bidderRequest.bidderCode + ' bidder, the PubMatic bidder will also be enabled so PubMatic server will respond back with the bids that needs to be submitted for PubMatic and ' + bidderRequest.bidderCode + ' in the network call sent by PubMatic bidder. Hence we do not want to create a network call for ' + bidderRequest.bidderCode + '. This way we are trying to save a network call from browser.');
return;
}

var refererInfo;
if (bidderRequest && bidderRequest.refererInfo) {
refererInfo = bidderRequest.refererInfo;
Expand Down Expand Up @@ -1156,6 +1148,10 @@ export const spec = {
payload.ext.wrapper.wv = $$REPO_AND_VERSION$$;
payload.ext.wrapper.transactionId = conf.transactionId;
payload.ext.wrapper.wp = 'pbjs';
if (bidderRequest && bidderRequest.bidderCode) {
payload.ext.allowAlternateBidderCodes = bidderSettings.get(bidderRequest.bidderCode, 'allowAlternateBidderCodes');
payload.ext.allowedAlternateBidderCodes = bidderSettings.get(bidderRequest.bidderCode, 'allowedAlternateBidderCodes');
}
payload.user.gender = (conf.gender ? conf.gender.trim() : UNDEFINED);
payload.user.geo = {};
payload.user.geo.lat = _parseSlotParam('lat', conf.lat);
Expand Down Expand Up @@ -1328,9 +1324,8 @@ export const spec = {

// if from the server-response the bid.ext.marketplace is set then
// submit the bid to Prebid as marketplace name
if (bid.ext && !!bid.ext.marketplace && MARKETPLACE_PARTNERS.includes(bid.ext.marketplace)) {
if (bid.ext && !!bid.ext.marketplace) {
newBid.bidderCode = bid.ext.marketplace;
newBid.bidder = bid.ext.marketplace;
}

bidResponses.push(newBid);
Expand Down
13 changes: 2 additions & 11 deletions test/spec/modules/pubmaticBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4031,7 +4031,7 @@ describe('PubMatic adapter', function () {
});
});

describe('GroupM params', function() {
describe('Marketplace params', function() {
let sandbox, utilsMock, newBidRequests, newBidResponses;
beforeEach(() => {
utilsMock = sinon.mock(utils);
Expand All @@ -4048,22 +4048,13 @@ describe('PubMatic adapter', function () {
sandbox.restore();
})

it('Should log info when bidder is groupm and return', function () {
let request = spec.buildRequests(newBidRequests, {bidderCode: 'groupm',
auctionId: 'new-auction-id'
});
sinon.assert.calledOnce(utils.logInfo);
expect(request).to.equal(undefined);
});

it('Should add bidder code & bidder as groupm for marketplace groupm response', function () {
it('Should add bidder code as groupm for marketplace groupm response', function () {
let request = spec.buildRequests(newBidRequests, {
auctionId: 'new-auction-id'
});
let response = spec.interpretResponse(newBidResponses, request);
expect(response).to.be.an('array').with.length.above(0);
expect(response[0].bidderCode).to.equal('groupm');
expect(response[0].bidder).to.equal('groupm');
});
});
});