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

fluct Bid Adapter: Add user data support #14

Closed
wants to merge 1 commit into from
Closed
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
19 changes: 18 additions & 1 deletion modules/fluctBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@ 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',
];

export const spec = {
code: BIDDER_CODE,
aliases: ['adingo'],
Expand Down Expand Up @@ -38,6 +48,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 +61,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
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