Skip to content

Commit

Permalink
Yahoo SSP adapter support for extra site publisher info. (#9921)
Browse files Browse the repository at this point in the history
* Yahoo SSP adapter support for extra site publisher info.

* Yahoo SSP adapter support for extra site publisher info - docs.

---------

Co-authored-by: dumitrubarbos <[email protected]>
  • Loading branch information
radubarbos and dumitrubarbos authored May 17, 2023
1 parent 667bbda commit 92daa81
Show file tree
Hide file tree
Showing 3 changed files with 103 additions and 1 deletion.
6 changes: 6 additions & 0 deletions modules/yahoosspBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,7 @@ function appendFirstPartyData(outBoundBidRequest, bid) {
const ortb2Object = bid.ortb2;
const siteObject = deepAccess(ortb2Object, 'site') || undefined;
const siteContentObject = deepAccess(siteObject, 'content') || undefined;
const sitePublisherObject = deepAccess(siteObject, 'publisher') || undefined;
const siteContentDataArray = deepAccess(siteObject, 'content.data') || undefined;
const appContentObject = deepAccess(ortb2Object, 'app.content') || undefined;
const appContentDataArray = deepAccess(ortb2Object, 'app.content.data') || undefined;
Expand All @@ -394,6 +395,11 @@ function appendFirstPartyData(outBoundBidRequest, bid) {
outBoundBidRequest.site = validateAppendObject('object', allowedSiteObjectKeys, siteObject, outBoundBidRequest.site);
};

if (sitePublisherObject && isPlainObject(sitePublisherObject)) {
const allowedPublisherObjectKeys = ['ext'];
outBoundBidRequest.site.publisher = validateAppendObject('object', allowedPublisherObjectKeys, sitePublisherObject, outBoundBidRequest.site.publisher);
}

if (siteContentObject && isPlainObject(siteContentObject)) {
const allowedContentStringKeys = ['id', 'title', 'series', 'season', 'genre', 'contentrating', 'language'];
const allowedContentNumberkeys = ['episode', 'prodq', 'context', 'livestream', 'len'];
Expand Down
37 changes: 37 additions & 0 deletions modules/yahoosspBidAdapter.md
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,43 @@ pbjs.setConfig({
}
});
```

Notes: The first party site info is filtered and only the following specific keys are allowed in the bidRequests:

| Field | Type |
|-----------------------------|--------|
| site.name | String |
| site.domain | String |
| site.page | String |
| site.ref | String |
| site.keywords | String |
| site.search | String |
| site.cat | Array |
| site.sectioncat | Array |
| site.pagecat | Array |
| site.ext | Object |
| site.publisher.ext | Object |
| site.content.id | String |
| site.content.title | String |
| site.content.series | String |
| site.content.season | String |
| site.content.genre | String |
| site.content.contentrating | String |
| site.content.language | String |
| site.content.episode | Number |
| site.content.prodq | Number |
| site.content.context | Number |
| site.content.livestream | Number |
| site.content.len | Number |
| site.content.cat | Array |
| site.content.ext | Object |
| site.content.data | Array |
| site.content.data[].id | String |
| site.content.data[].name | String |
| site.content.data[].segment | Array |
| site.content.data[].ext | Object |


### Passing First Party "user" data:
```javascript
pbjs.setConfig({
Expand Down
61 changes: 60 additions & 1 deletion test/spec/modules/yahoosspBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,23 @@ describe('YahooSSP Bid Adapter:', () => {
});
});

const VALID_PUBLISHER_OBJECTS = ['ext'];
VALID_PUBLISHER_OBJECTS.forEach(param => {
it(`should determine that the ortb2.site.publisher Object key is valid and append to the bid-request: ${JSON.stringify(param)}`, () => {
const ortb2 = {
site: {
publisher: {
[param]: {a: '123', b: '456'}
}
}
};
const { validBidRequests, bidderRequest } = generateBuildRequestMock({ortb2});
const data = spec.buildRequests(validBidRequests, bidderRequest)[0].data;
expect(data.site.publisher[param]).to.be.a('object');
expect(data.site.publisher[param]).to.be.equal(ortb2.site.publisher[param]);
});
});

const VALID_CONTENT_ARRAYS = ['cat'];
VALID_CONTENT_ARRAYS.forEach(param => {
it(`should determine that the ortb2.site Array key is valid and append to the bid-request: ${JSON.stringify(param)}`, () => {
Expand Down Expand Up @@ -512,7 +529,6 @@ describe('YahooSSP Bid Adapter:', () => {
const data = spec.buildRequests(validBidRequests, bidderRequest)[0].data;
expect(data.site.content[param]).to.be.a('object');
expect(data.site.content[param]).to.be.equal(ortb2.site.content[param]);
config.setConfig({ortb2: {}});
});
});
});
Expand Down Expand Up @@ -959,6 +975,49 @@ describe('YahooSSP Bid Adapter:', () => {
expect(data.site.id).to.equal('1234567');
});

it('should use site publisher ortb2 config in default integration mode', () => {
const ortb2 = {
site: {
publisher: {
ext: {
publisherblob: 'pblob',
bucket: 'bucket'
}
}
}
}
let { validBidRequests, bidderRequest } = generateBuildRequestMock({ortb2});
const data = spec.buildRequests(validBidRequests, bidderRequest).data;
expect(data.site.publisher).to.deep.equal({
ext: {
publisherblob: 'pblob',
bucket: 'bucket'
}
});
});

it('should use site publisher ortb2 config when using "pubId" integration mode', () => {
const ortb2 = {
site: {
publisher: {
ext: {
publisherblob: 'pblob',
bucket: 'bucket'
}
}
}
}
let { validBidRequests, bidderRequest } = generateBuildRequestMock({pubIdMode: true, ortb2});
const data = spec.buildRequests(validBidRequests, bidderRequest).data;
expect(data.site.publisher).to.deep.equal({
id: DEFAULT_PUBID,
ext: {
publisherblob: 'pblob',
bucket: 'bucket'
}
});
});

it('should use placementId value as imp.tagid in the outbound bid-request when using "pubId" integration mode', () => {
let { validBidRequests, bidderRequest } = generateBuildRequestMock({pubIdMode: true});
validBidRequests[0].params.placementId = 'header-300x250';
Expand Down

0 comments on commit 92daa81

Please sign in to comment.