Skip to content
Draft
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
35 changes: 0 additions & 35 deletions modules/imRtdProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,38 +53,6 @@ function getSegments(segments, moduleConfig) {
return segments.slice(0, maxSegments);
}

/**
* @param {string} bidderName
*/
export function getBidderFunction(bidderName) {
const biddersFunction = {
pubmatic: function (bid, data, moduleConfig) {
if (data.im_segments && data.im_segments.length) {
const segments = getSegments(data.im_segments, moduleConfig);
const dctr = deepAccess(bid, 'params.dctr');
deepSetValue(
bid,
'params.dctr',
`${dctr ? dctr + '|' : ''}im_segments=${segments.join(',')}`
);
}
return bid
},
fluct: function (bid, data, moduleConfig) {
if (data.im_segments && data.im_segments.length) {
const segments = getSegments(data.im_segments, moduleConfig);
deepSetValue(
bid,
'params.kv.imsids',
segments
);
}
return bid
}
}
return biddersFunction[bidderName] || null;
}

export function getCustomBidderFunction(config, bidder) {
const overwriteFn = deepAccess(config, `params.overwrites.${bidder}`)

Expand Down Expand Up @@ -122,12 +90,9 @@ export function setRealTimeData(bidConfig, moduleConfig, data) {

adUnits.forEach(adUnit => {
adUnit.bids.forEach(bid => {
const bidderFunction = getBidderFunction(bid.bidder);
const overwriteFunction = getCustomBidderFunction(moduleConfig, bid.bidder);
Copy link
Member Author

@eknis eknis Jul 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getCustomBidderFunctionは特定bidderに対しての機能ではないので問題ないはず

if (overwriteFunction) {
overwriteFunction(bid, data, utils, config);
} else if (bidderFunction) {
bidderFunction(bid, data, moduleConfig);
}
})
});
Expand Down
57 changes: 0 additions & 57 deletions test/spec/modules/imRtdProvider_spec.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import {
imRtdSubmodule,
storage,
getBidderFunction,
getCustomBidderFunction,
setRealTimeData,
getRealTimeData,
Expand Down Expand Up @@ -49,62 +48,6 @@ describe('imRtdProvider', function () {
})
})

describe('getBidderFunction', function () {
const assumedBidder = [
'pubmatic',
'fluct'
];
assumedBidder.forEach(bidderName => {
it(`should return bidderFunction with assumed bidder: ${bidderName}`, function () {
expect(getBidderFunction(bidderName)).to.exist.and.to.be.a('function');
});

it(`should return bid with correct key data: ${bidderName}`, function () {
const bid = {bidder: bidderName};
expect(getBidderFunction(bidderName)(bid, {'im_segments': ['12345', '67890']}, {params: {}})).to.equal(bid);
});
it(`should return bid without data: ${bidderName}`, function () {
const bid = {bidder: bidderName};
expect(getBidderFunction(bidderName)(bid, '', {params: {}})).to.equal(bid);
});
});
it(`should return null with unexpected bidder`, function () {
expect(getBidderFunction('test')).to.equal(null);
});
describe('fluct bidder function', function () {
it('should return a bid w/o im_segments if not any exists', function () {
const bid = {bidder: 'fluct'};
expect(getBidderFunction('fluct')(bid, '', {params: {}})).to.eql(bid);
});
it('should return a bid w/ im_segments if any exists', function () {
const bid = {
bidder: 'fluct',
params: {
kv: {
foo: ['foo1']
}
}
};
expect(getBidderFunction('fluct')(
bid,
{im_segments: ['12345', '67890', '09876']},
{params: {maxSegments: 2}}
))
.to.eql(
{
bidder: 'fluct',
params: {
kv: {
foo: ['foo1'],
imsids: ['12345', '67890']
}
}
}
);
});
});
})

describe('getCustomBidderFunction', function () {
it('should return config function', function () {
const config = {
Expand Down
Loading