Skip to content

Commit

Permalink
provide user data to fluctBidAdapter
Browse files Browse the repository at this point in the history
  • Loading branch information
yowcow committed Feb 2, 2022
1 parent 90cf3f9 commit 903075d
Show file tree
Hide file tree
Showing 4 changed files with 157 additions and 2 deletions.
25 changes: 24 additions & 1 deletion modules/fluctBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,22 @@ const VERSION = '1.2';
const NET_REVENUE = true;
const TTL = 300;

/**
* See modules/userId/eids.js for supported sources
*/
const SUPPORTED_USER_ID_SOURCES = [
'adserver.org',
'criteo.com',
'intimatemerger.com',
'liveramp.com',
];

const INCLUDE_URL_PARAMS = [
'dfpUnitCode',
'tagId',
'groupId',
];

export const spec = {
code: BIDDER_CODE,
aliases: ['adingo'],
Expand Down Expand Up @@ -38,6 +54,9 @@ export const spec = {
data.adUnitCode = request.adUnitCode;
data.bidId = request.bidId;
data.transactionId = request.transactionId;
data.user = {
eids: (request.userIdAsEids || []).filter((eid) => SUPPORTED_USER_ID_SOURCES.indexOf(eid.source) !== -1)
};

data.sizes = [];
_each(request.sizes, (size) => {
Expand All @@ -48,7 +67,11 @@ export const spec = {
});

data.params = request.params;
const searchParams = new URLSearchParams(request.params);
const searchParams = new URLSearchParams({
dfpUnitCode: request.params.dfpUnitCode,
tagId: request.params.tagId,
groupId: request.params.groupId,
});

serverRequests.push({
method: 'POST',
Expand Down
10 changes: 10 additions & 0 deletions modules/imRtdProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,16 @@ export function getBidderFunction(bidderName) {
);
}
return bid
},
fluct: function (bid, data) {
if (data.im_segments && data.im_segments.length) {
deepSetValue(
bid,
'params.kv.imsids',
data.im_segments
);
}
return bid
}
}
return biddersFunction[bidderName] || null;
Expand Down
92 changes: 92 additions & 0 deletions test/spec/modules/fluctBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,98 @@ describe('fluctAdapter', function () {
const request = spec.buildRequests(bidRequests, bidderRequest)[0];
expect(request.url).to.equal('https://hb.adingo.jp/prebid?dfpUnitCode=%2F100000%2Funit_code&tagId=10000%3A100000001&groupId=1000000002');
});

it('includes data.user.eids = [] by default', function () {
const request = spec.buildRequests(bidRequests, bidderRequest)[0];
expect(request.data.user.eids).to.eql([]);
});

it('includes no data.params.kv by default', function () {
const request = spec.buildRequests(bidRequests, bidderRequest)[0];
expect(request.data.params.kv).to.eql(undefined);
});

it('includes filtered user.eids if any exists', function () {
const bidRequests2 = bidRequests.map(
(bidReq) => Object.assign(bidReq, {
userIdAsEids: [
{
source: 'foobar.com',
uids: [
{ id: 'foobar-id' }
],
},
{
source: 'adserver.org',
uids: [
{ id: 'tdid' }
],
},
{
source: 'criteo.com',
uids: [
{ id: 'criteo-id' }
],
},
{
source: 'intimatemerger.com',
uids: [
{ id: 'imuid' }
],
},
{
source: 'liveramp.com',
uids: [
{ id: 'idl-env' }
],
},
],
})
);
const request = spec.buildRequests(bidRequests2, bidderRequest)[0];
expect(request.data.user.eids).to.eql([
{
source: 'adserver.org',
uids: [
{ id: 'tdid' }
],
},
{
source: 'criteo.com',
uids: [
{ id: 'criteo-id' }
],
},
{
source: 'intimatemerger.com',
uids: [
{ id: 'imuid' }
],
},
{
source: 'liveramp.com',
uids: [
{ id: 'idl-env' }
],
},
]);
});

it('includes data.params.kv if any exists', function () {
const bidRequests2 = bidRequests.map(
(bidReq) => Object.assign(bidReq, {
params: {
kv: {
imsids: ['imsid1', 'imsid2']
}
}
})
);
const request = spec.buildRequests(bidRequests2, bidderRequest)[0];
expect(request.data.params.kv).to.eql({
imsids: ['imsid1', 'imsid2']
});
});
});

describe('interpretResponse', function() {
Expand Down
32 changes: 31 additions & 1 deletion test/spec/modules/imRtdProvider_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ describe('imRtdProvider', function () {
describe('getBidderFunction', function () {
const assumedBidder = [
'ix',
'pubmatic'
'pubmatic',
'fluct'
];
assumedBidder.forEach(bidderName => {
it(`should return bidderFunction with assumed bidder: ${bidderName}`, function () {
Expand All @@ -70,6 +71,35 @@ describe('imRtdProvider', function () {
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, '')).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']}))
.to.eql(
{
bidder: 'fluct',
params: {
kv: {
foo: ['foo1'],
imsids: ['12345', '67890']
}
}
}
);
});
});
})

describe('getCustomBidderFunction', function () {
Expand Down

0 comments on commit 903075d

Please sign in to comment.