Skip to content

Commit

Permalink
TheMediaGrid: added keywords formatting in the ad request (prebid#7164)
Browse files Browse the repository at this point in the history
* Added TheMediaGridNM Bid Adapter

* Updated required params for TheMediaGridNM Bid Adapter

* Update TheMediGridNM Bid Adapter

* Fix tests for TheMediaGridNM Bid Adapter

* Fixes after review for TheMediaGridNM Bid Adapter

* Add support of multi-format in TheMediaGrid Bid Adapter

* Update sync url for grid and gridNM Bid Adapters

* TheMediaGrid Bid Adapter: added keywords adUnit parameter

* Update TheMediaGrid Bid Adapter to support keywords from config

* Implement new request format for TheMediaGrid Bid Adapter

* Fix jwpseg params for TheMediaGrid Bid Adapter

* Update unit tests for The Media Grid Bid Adapter

* Fix typo in TheMediaGrid Bid Adapter

* Added test for jwTargeting in TheMediaGrid Bid Adapter

* The new request format was made by default in TheMediaGrid Bid Adapter

* Update userId format in ad request for TheMediaGrid Bid Adapter

* Added bidFloor parameter for TheMediaGrid Bid Adapter

* Fix for review TheMediaGrid Bid Adapter

* Support floorModule in TheMediaGrid Bid Adapter

* Fix empty bidfloor for TheMediaGrid Bid Adapter

* Some change to restart autotests

* Fix userIds format for TheMediaGrid Bid Adapter

* Remove digitrust userId from TheMediaGrid Bid Adapter

* Protocols was added in video section in ad request for TheMediaGrid Bid Adapter

* TheMediaGrid: fix trouble with alias using

* TheMediaGridNM: fix trouble with alias

* TheMediaGrid Bid Adapter: added support of PBAdSlot module

* TheMediaGrid Bid Adapter: fix typo

* GridNM Bid Adapter: use absent in params data from mediaTypes

* GridNM Bid Adapter: fix md file + add advertiserDomains support

* TheMediaGrid and gridNM Bid Adapter: minor netRevenue fixes

* gridNM Bid Adapter updates after review

* TheMediaGrid Bid Adapter: fix keywords workflow

* fix testing and kick off lgtm again

Co-authored-by: Chris Huie <phoenixtechnerd@gmail.com>
  • Loading branch information
TheMediaGrid and ChrisHuie authored Jul 12, 2021
1 parent 237c88b commit f150d71
Show file tree
Hide file tree
Showing 2 changed files with 83 additions and 7 deletions.
54 changes: 51 additions & 3 deletions modules/gridBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -213,9 +213,12 @@ export const spec = {
}

if (pageKeywords) {
request.ext = {
keywords: pageKeywords
};
pageKeywords = reformatKeywords(pageKeywords);
if (pageKeywords) {
request.ext = {
keywords: pageKeywords
};
}
}

if (gdprConsent && gdprConsent.gdprApplies) {
Expand Down Expand Up @@ -419,6 +422,51 @@ function createBannerRequest(bid, mediaType) {
return result;
}

function reformatKeywords(pageKeywords) {
const formatedPageKeywords = {};
Object.keys(pageKeywords).forEach((name) => {
const keywords = pageKeywords[name];
if (keywords) {
if (name === 'site' || name === 'user') {
const formatedKeywords = {};
Object.keys(keywords).forEach((pubName) => {
if (Array.isArray(keywords[pubName])) {
const formatedPublisher = [];
keywords[pubName].forEach((pubItem) => {
if (typeof pubItem === 'object' && pubItem.name) {
const formatedPubItem = { name: pubItem.name, segments: [] };
Object.keys(pubItem).forEach((key) => {
if (Array.isArray(pubItem[key])) {
pubItem[key].forEach((keyword) => {
if (keyword) {
if (typeof keyword === 'string') {
formatedPubItem.segments.push({ name: key, value: keyword });
} else if (key === 'segments' && typeof keyword.name === 'string' && typeof keyword.value === 'string') {
formatedPubItem.segments.push(keyword);
}
}
});
}
});
if (formatedPubItem.segments.length) {
formatedPublisher.push(formatedPubItem);
}
}
});
if (formatedPublisher.length) {
formatedKeywords[pubName] = formatedPublisher;
}
}
});
formatedPageKeywords[name] = formatedKeywords;
} else {
formatedPageKeywords[name] = keywords;
}
}
});
return Object.keys(formatedPageKeywords).length && formatedPageKeywords;
}

function outstreamRender (bid) {
bid.renderer.push(() => {
window.ANOutstreamVideo.renderAd({
Expand Down
36 changes: 32 additions & 4 deletions test/spec/modules/gridBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,17 @@ describe('TheMediaGrid Adapter', function () {
'topic': ['stress', 'fear']
}
]
},
'user': {
'formatedPublisher': [
{
'name': 'fomatedName',
'segments': [
{ 'name': 'segName1', 'value': 'segVal1' },
{ 'name': 'segName2', 'value': 'segVal2' }
]
}
]
}
};
const bidRequestWithKW = { ...bidRequests[0], params: { ...bidRequests[0].params, keywords } }
Expand All @@ -423,22 +434,39 @@ describe('TheMediaGrid Adapter', function () {
'somePublisher': [
{
'name': 'someName',
'brandsafety': ['disaster'],
'topic': ['stress', 'fear']
'segments': [
{ 'name': 'brandsafety', 'value': 'disaster' },
{ 'name': 'topic', 'value': 'stress' },
{ 'name': 'topic', 'value': 'fear' }
]
}
],
'ortb2': [
{
'name': 'keywords',
'keywords': ['bar']
'segments': [
{ 'name': 'keywords', 'value': 'bar' }
]
}
]
},
'user': {
'formatedPublisher': [
{
'name': 'fomatedName',
'segments': [
{ 'name': 'segName1', 'value': 'segVal1' },
{ 'name': 'segName2', 'value': 'segVal2' }
]
}
],
'ortb2': [
{
'name': 'keywords',
'keywords': ['foo', 'any']
'segments': [
{ 'name': 'keywords', 'value': 'foo' },
{ 'name': 'keywords', 'value': 'any' }
]
}
]
}
Expand Down

0 comments on commit f150d71

Please sign in to comment.