Skip to content

Commit 688d0b9

Browse files
authored
TheMediaGrid Bid Adapter: added support genre and cat from config ortb2.site (#8041)
* TheMediaGrid: added support genre and cat from config ortb2.site * TheMediaGrid: fix bug with possible undefined cat or pagecat
1 parent efbeaf0 commit 688d0b9

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

modules/gridBidAdapter.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,20 @@ export const spec = {
272272
request.regs.coppa = 1;
273273
}
274274

275+
const site = config.getConfig('ortb2.site');
276+
if (site) {
277+
const pageCategory = [...(site.cat || []), ...(site.pagecat || [])].filter((category) => {
278+
return category && typeof category === 'string'
279+
});
280+
if (pageCategory.length) {
281+
request.site.cat = pageCategory;
282+
}
283+
const genre = deepAccess(site, 'content.genre');
284+
if (genre && typeof genre === 'string') {
285+
request.site.content = {...request.site.content, genre};
286+
}
287+
}
288+
275289
return {
276290
method: 'POST',
277291
url: ENDPOINT_URL,

test/spec/modules/gridBidAdapter_spec.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,24 @@ describe('TheMediaGrid Adapter', function () {
118118
}
119119
];
120120

121+
it('should be content categories and genre', function () {
122+
const site = {
123+
cat: ['IAB2'],
124+
pagecat: ['IAB2-2'],
125+
content: {
126+
genre: 'Adventure'
127+
}
128+
};
129+
130+
const getConfigStub = sinon.stub(config, 'getConfig').callsFake(
131+
arg => arg === 'ortb2.site' ? site : null);
132+
const request = spec.buildRequests([bidRequests[0]], bidderRequest);
133+
const payload = parseRequest(request.data);
134+
expect(payload.site.cat).to.deep.equal([...site.cat, ...site.pagecat]);
135+
expect(payload.site.content.genre).to.deep.equal(site.content.genre);
136+
getConfigStub.restore();
137+
});
138+
121139
it('should attach valid params to the tag', function () {
122140
const fpdUserIdVal = '0b0f84a1-1596-4165-9742-2e1a7dfac57f';
123141
const getDataFromLocalStorageStub = sinon.stub(storage, 'getDataFromLocalStorage').callsFake(

0 commit comments

Comments
 (0)