Skip to content

Commit

Permalink
MgidX Bid Adapter: add optional region param (#10612)
Browse files Browse the repository at this point in the history
* new adapter - MgidX

* add new required param host

* rem host, add region

---------

Co-authored-by: Evgeny Nagorny <[email protected]>
Co-authored-by: xmgiddev <>
  • Loading branch information
xmgiddev and evjman authored Jan 30, 2024
1 parent eee58b0 commit 2592706
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 11 deletions.
13 changes: 11 additions & 2 deletions modules/mgidXBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { USERSYNC_DEFAULT_CONFIG } from '../src/userSync.js';

const BIDDER_CODE = 'mgidX';
const GVLID = 358;
const AD_URL = 'https://us-east-x.mgid.com/pbjs';
const AD_URL = 'https://#{REGION}#.mgid.com/pbjs';
const PIXEL_SYNC_URL = 'https://cm.mgid.com/i.gif';
const IFRAME_SYNC_URL = 'https://cm.mgid.com/i.html';

Expand Down Expand Up @@ -181,9 +181,18 @@ export const spec = {
placements.push(getPlacementReqData(bid));
}

const region = validBidRequests[0].params?.region;

let url;
if (region === 'eu') {
url = AD_URL.replace('#{REGION}#', 'eu');
} else {
url = AD_URL.replace('#{REGION}#', 'us-east-x');
}

return {
method: 'POST',
url: AD_URL,
url: url,
data: request
};
},
Expand Down
21 changes: 12 additions & 9 deletions test/spec/modules/mgidXBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { config } from '../../../src/config';
import { USERSYNC_DEFAULT_CONFIG } from '../../../src/userSync';

const bidder = 'mgidX'
const adUrl = 'https://us-east-x.mgid.com/pbjs';

describe('MGIDXBidAdapter', function () {
const bids = [
Expand All @@ -19,6 +18,7 @@ describe('MGIDXBidAdapter', function () {
}
},
params: {
region: 'eu',
placementId: 'testBanner',
}
},
Expand Down Expand Up @@ -56,6 +56,7 @@ describe('MGIDXBidAdapter', function () {
}
},
params: {
region: 'eu',
placementId: 'testNative',
}
}
Expand Down Expand Up @@ -108,8 +109,16 @@ describe('MGIDXBidAdapter', function () {
expect(serverRequest.method).to.equal('POST');
});

it('Returns valid URL', function () {
expect(serverRequest.url).to.equal(adUrl);
it('Returns valid EU URL', function () {
bids[0].params.region = 'eu';
serverRequest = spec.buildRequests(bids, bidderRequest);
expect(serverRequest.url).to.equal('https://eu.mgid.com/pbjs');
});

it('Returns valid EAST URL', function () {
bids[0].params.region = 'other';
serverRequest = spec.buildRequests(bids, bidderRequest);
expect(serverRequest.url).to.equal('https://us-east-x.mgid.com/pbjs');
});

it('Returns general data valid', function () {
Expand Down Expand Up @@ -193,12 +202,6 @@ describe('MGIDXBidAdapter', function () {
expect(data.ccpa).to.equal(bidderRequest.uspConsent);
expect(data.gdpr).to.not.exist;
});

it('Returns empty data if no valid requests are passed', function () {
serverRequest = spec.buildRequests([], bidderRequest);
let data = serverRequest.data;
expect(data.placements).to.be.an('array').that.is.empty;
});
});

describe('interpretResponse', function () {
Expand Down

0 comments on commit 2592706

Please sign in to comment.