Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dailymotion Bid Adaptor: get iabcats from ortb2.site.content.data #17

Merged
merged 1 commit into from
Apr 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 20 additions & 6 deletions modules/dailymotionBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,31 @@ function getVideoMetadata(bidRequest, bidderRequest) {
...videoBidderParams, // Bidder Specific overrides
};

// Store as object keys to ensure uniqueness
const iabcat1 = {};
const iabcat2 = {};

deepAccess(bidderRequest, 'ortb2.site.content.data', []).forEach((data) => {
if ([4, 5, 6, 7].includes(data?.ext?.segtax)) {
(Array.isArray(data.segment) ? data.segment : []).forEach((segment) => {
if (typeof segment.id === 'string') {
// See https://docs.prebid.org/features/firstPartyData.html#segments-and-taxonomy
// Only take IAB cats of taxonomy V1
if (data.ext.segtax === 4) iabcat1[segment.id] = 1;
// Only take IAB cats of taxonomy V2 or higher
if ([5, 6, 7].includes(data.ext.segtax)) iabcat2[segment.id] = 1;
}
});
}
});

const videoMetadata = {
description: videoParams.description || '',
duration: videoParams.duration || 0,
iabcat1: deepAccess(bidderRequest, 'ortb2.site.content.cat', [])
// Only take IAB cats of taxonomy V1
.filter(cat => cat.toLowerCase().indexOf('iab-') === 0),
iabcat1: Object.keys(iabcat1),
iabcat2: Array.isArray(videoParams.iabcat2)
? videoParams.iabcat2
// Only take IAB cats of taxonomy V2 or higher by excluding "IAB-" type categories
: deepAccess(bidderRequest, 'ortb2.site.content.cat', [])
.filter(cat => cat.toLowerCase().indexOf('iab-') !== 0),
: Object.keys(iabcat2),
id: videoParams.id || '',
lang: videoParams.lang || '',
private: videoParams.private || false,
Expand Down
56 changes: 53 additions & 3 deletions test/spec/modules/dailymotionBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,18 @@ describe('dailymotionBidAdapterTests', () => {
},
site: {
content: {
cat: ['IAB-1', '200'],
data: [
{
name: 'dataprovider.com',
ext: { segtax: 4 },
segment: [{ id: 'IAB-1' }],
},
{
name: 'dataprovider.com',
ext: { segtax: 5 },
segment: [{ id: '200' }],
},
],
},
},
},
Expand Down Expand Up @@ -171,7 +182,46 @@ describe('dailymotionBidAdapterTests', () => {
},
site: {
content: {
cat: ['6', '17'],
data: [
undefined, // Undefined to check proper handling of edge cases
{}, // Empty object to check proper handling of edge cases
{ ext: {} }, // Empty ext to check proper handling of edge cases
{
name: 'dataprovider.com',
ext: { segtax: 22 }, // Invalid segtax to check proper handling of edge cases
segment: [{ id: '400' }],
},
{
name: 'dataprovider.com',
ext: { segtax: 5 },
segment: undefined, // Invalid segment to check proper handling of edge cases
},
{
name: 'dataprovider.com',
ext: { segtax: 4 },
segment: undefined, // Invalid segment to check proper handling of edge cases
},
{
name: 'dataprovider.com',
ext: { segtax: 4 },
segment: [{ id: 2222 }], // Invalid segment id to check proper handling of edge cases
},
{
name: 'dataprovider.com',
ext: { segtax: 5 },
segment: [{ id: '6' }],
},
{
name: 'dataprovider.com',
ext: { segtax: 5 },
segment: [{ id: '6' }], // Check that same cat won't be duplicated
},
{
name: 'dataprovider.com',
ext: { segtax: 5 },
segment: [{ id: '17' }, { id: '20' }],
},
],
},
},
},
Expand Down Expand Up @@ -206,7 +256,7 @@ describe('dailymotionBidAdapterTests', () => {
description: bidRequestData[0].mediaTypes.video.description,
// No iabcat1 here because nothing matches taxonomy
iabcat1: [],
iabcat2: bidderRequestData.ortb2.site.content.cat,
iabcat2: ['6', '17', '20'],
id: bidRequestData[0].params.video.id,
lang: bidRequestData[0].params.video.lang,
private: bidRequestData[0].params.video.private,
Expand Down