Skip to content

Commit

Permalink
Prebid 8: remove bidder specific handling for 1plusX (#10093)
Browse files Browse the repository at this point in the history
* 1plusX: Do not set keywords for appnexus

* weborama: remove appnexus specific handling

* remove key=value keyword parsing for appnexus and its clones

* fix lint

* use 1plusX instead of 1plusx

* Revert "remove key=value keyword parsing for appnexus and its clones"

This reverts commit 80567cd.

* Revert "weborama: remove appnexus specific handling"

This reverts commit d6450d1.

* 1plusX: add segtax to user data
  • Loading branch information
dgirardi authored Jun 14, 2023
1 parent e0c6e74 commit b2f8d3a
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 35 deletions.
4 changes: 2 additions & 2 deletions libraries/appnexusKeywords/anKeywords.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import {getAllOrtbKeywords} from '../keywords/keywords.js';
import {CLIENT_SECTIONS} from '../../src/fpd/oneClient.js';

const ORTB_SEGTAX_KEY_MAP = {
526: '1plusx',
527: '1plusx',
526: '1plusX',
527: '1plusX',
541: 'captify_segments',
540: 'perid'
};
Expand Down
18 changes: 4 additions & 14 deletions modules/1plusXRtdProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,19 +152,15 @@ const getTargetingDataFromPapi = (papiUrl) => {
export const buildOrtb2Updates = ({ segments = [], topics = [] }) => {
const userData = {
name: ORTB2_NAME,
segment: segments.map((segmentId) => ({ id: segmentId }))
segment: segments.map((segmentId) => ({ id: segmentId })),
ext: { segtax: segtaxes.AUDIENCE }
};
const siteContentData = {
name: ORTB2_NAME,
segment: topics.map((topicId) => ({ id: topicId })),
ext: { segtax: segtaxes.CONTENT }
}
// Currently appnexus bidAdapter doesn't support topics in `site.content.data.segment`
// Therefore, writing them in `site.keywords` until it's supported
// Other bidAdapters do fine with `site.content.data.segment`
const siteKeywords = topics.map(topic => `1plusX=${topic}`).join(',');

return { userData, siteContentData, siteKeywords };
return { userData, siteContentData };
}

/**
Expand All @@ -174,16 +170,10 @@ export const buildOrtb2Updates = ({ segments = [], topics = [] }) => {
* @param {Object} biddersOrtb2 All current bidder configs
*/
export const updateBidderConfig = (bidder, ortb2Updates, biddersOrtb2) => {
const { siteKeywords, siteContentData, userData } = ortb2Updates;
const { siteContentData, userData } = ortb2Updates;
mergeDeep(biddersOrtb2, { [bidder]: {} });
const bidderConfig = deepAccess(biddersOrtb2, bidder);

{
// Legacy : cf. comment on buildOrtb2Updates
const siteKeywordsPath = 'site.keywords';
deepSetValue(bidderConfig, siteKeywordsPath, siteKeywords);
}

{
const siteDataPath = 'site.content.data';
const currentSiteContentData = deepAccess(bidderConfig, siteDataPath) || [];
Expand Down
35 changes: 17 additions & 18 deletions test/spec/modules/1plusXRtdProvider_spec.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
import assert from 'assert';
import { config } from 'src/config';
import {config} from 'src/config';
import {
onePlusXSubmodule,
buildOrtb2Updates,
extractConfig,
extractConsent,
extractFpid,
getPapiUrl,
onePlusXSubmodule,
segtaxes,
setTargetingDataToConfig,
updateBidderConfig,
} from 'modules/1plusXRtdProvider';
import {deepClone} from '../../../src/utils.js';

describe('1plusXRtdProvider', () => {
// Fake server config
Expand Down Expand Up @@ -168,7 +169,7 @@ describe('1plusXRtdProvider', () => {
})

describe('buildOrtb2Updates', () => {
it('fills site.content.data, user.data & site.keywords in the ortb2 config', () => {
it('fills site.content.data & user.data in the ortb2 config', () => {
const rtdData = { segments: fakeResponse.s, topics: fakeResponse.t };
const ortb2Updates = buildOrtb2Updates(rtdData, randomBidder());

Expand All @@ -180,9 +181,9 @@ describe('1plusXRtdProvider', () => {
},
userData: {
name: '1plusX.com',
segment: rtdData.segments.map((segmentId) => ({ id: segmentId }))
},
siteKeywords: rtdData.topics.map(topic => `1plusX=${topic}`).join(','),
segment: rtdData.segments.map((segmentId) => ({ id: segmentId })),
ext: { segtax: segtaxes.AUDIENCE }
}
}
expect([ortb2Updates]).to.deep.include.members([expectedOutput]);
});
Expand All @@ -199,9 +200,9 @@ describe('1plusXRtdProvider', () => {
},
userData: {
name: '1plusX.com',
segment: []
},
siteKeywords: rtdData.topics.map(topic => `1plusX=${topic}`).join(','),
segment: [],
ext: { segtax: segtaxes.AUDIENCE }
}
}
expect(ortb2Updates).to.deep.include(expectedOutput);
})
Expand All @@ -218,9 +219,9 @@ describe('1plusXRtdProvider', () => {
},
userData: {
name: '1plusX.com',
segment: rtdData.segments.map((segmentId) => ({ id: segmentId }))
segment: rtdData.segments.map((segmentId) => ({ id: segmentId })),
ext: { segtax: segtaxes.AUDIENCE }
},
siteKeywords: '',
}
expect(ortb2Updates, `${JSON.stringify(ortb2Updates, null, 2)}`).to.deep.include(expectedOutput);
})
Expand Down Expand Up @@ -327,13 +328,12 @@ describe('1plusXRtdProvider', () => {
name: '1plusX.com',
segment: fakeResponse.s.map((segmentId) => ({ id: segmentId }))
},
siteKeywords: fakeResponse.t.map(topic => `1plusX=${topic}`).join(','),
}

it('merges fetched data in bidderConfig for configured bidders', () => {
// Set initial config
const bidder = randomBidder();
const ortb2Fragments = { [bidder]: { ...bidderConfigInitial } }
const ortb2Fragments = { [bidder]: deepClone(bidderConfigInitial) }
// Call submodule's setBidderConfig
updateBidderConfig(bidder, ortb2Updates, ortb2Fragments);
const newBidderConfig = ortb2Fragments[bidder];
Expand All @@ -342,7 +342,6 @@ describe('1plusXRtdProvider', () => {
expect(newBidderConfig.user).not.to.be.null.and.not.to.be.undefined;
expect(newBidderConfig.site).not.to.be.null.and.not.to.be.undefined;
expect(newBidderConfig.user.data).to.deep.include(ortb2Updates.userData);
expect(newBidderConfig.site.keywords).to.deep.include(ortb2Updates.siteKeywords);
expect(newBidderConfig.site.content.data).to.deep.include(ortb2Updates.siteContentData);
// Check that existing config didn't get erased
expect(newBidderConfig.site).to.deep.include(bidderConfigInitial.site);
Expand Down Expand Up @@ -417,7 +416,6 @@ describe('1plusXRtdProvider', () => {
})

describe('setTargetingDataToConfig', () => {
const expectedKeywords = fakeResponse.t.map(topic => `1plusX=${topic}`).join(',');
const expectedSiteContentObj = {
data: [{
name: '1plusX.com',
Expand All @@ -428,16 +426,17 @@ describe('1plusXRtdProvider', () => {
const expectedUserObj = {
data: [{
name: '1plusX.com',
segment: fakeResponse.s.map((segmentId) => ({ id: segmentId }))
segment: fakeResponse.s.map((segmentId) => ({ id: segmentId })),
ext: { segtax: segtaxes.AUDIENCE }
}]
}
const expectedOrtb2 = {
appnexus: {
site: { content: expectedSiteContentObj, keywords: expectedKeywords },
site: { content: expectedSiteContentObj },
user: expectedUserObj
},
rubicon: {
site: { content: expectedSiteContentObj, keywords: expectedKeywords },
site: { content: expectedSiteContentObj },
user: expectedUserObj
}
}
Expand Down
2 changes: 1 addition & 1 deletion test/spec/modules/appnexusBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -839,7 +839,7 @@ describe('AppNexusAdapter', function () {
expectKeywords(payload.keywords, [{
'key': 'drill'
}, {
'key': '1plusx',
'key': '1plusX',
'value': ['cat', 'dog']
}, {
'key': 'perid',
Expand Down

0 comments on commit b2f8d3a

Please sign in to comment.