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 to bid requests #10318

Merged
17 changes: 6 additions & 11 deletions modules/fluctBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,6 @@ 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 All @@ -36,6 +26,7 @@ export const spec = {
* Make a server request from the list of BidRequests.
*
* @param {validBidRequests[]} - an array of bids.
* @param {bidderRequest} bidderRequest bidder request object.
* @return ServerRequest Info describing the request to the server.
*/
buildRequests: (validBidRequests, bidderRequest) => {
Expand All @@ -50,7 +41,11 @@ export const spec = {
data.bidId = request.bidId;
data.transactionId = request.ortb2Imp?.ext?.tid;
data.user = {
eids: (request.userIdAsEids || []).filter((eid) => SUPPORTED_USER_ID_SOURCES.indexOf(eid.source) !== -1)
data: bidderRequest.ortb2?.user?.data ?? [],
eids: [
...(request.userIdAsEids ?? []),
...(bidderRequest.ortb2?.user?.ext?.eids ?? []),
],
};

if (bidderRequest.gdprConsent) {
Expand Down
86 changes: 73 additions & 13 deletions test/spec/modules/fluctBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,14 +119,14 @@ describe('fluctAdapter', function () {
expect(request.data.regs).to.eql(undefined);
});

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

it('includes user.data if any exists', function () {
const bidderRequest2 = Object.assign({}, bidderRequest, {
ortb2: {
user: {
data: [
{
name: 'a1mediagroup.com',
ext: {
segtax: 900,
},
segment: [
{ id: 'seg-1' },
{ id: 'seg-2' },
],
},
],
ext: {
eids: [
{
source: 'a1mediagroup.com',
uids: [
{ id: 'aud-1' }
],
},
],
},
},
},
});
const request = spec.buildRequests(bidRequests, bidderRequest2)[0];
expect(request.data.user).to.eql({
data: [
{
name: 'a1mediagroup.com',
ext: {
segtax: 900,
},
segment: [
{ id: 'seg-1' },
{ id: 'seg-2' },
],
},
],
eids: [
{
source: 'a1mediagroup.com',
uids: [
{ id: 'aud-1' }
],
},
],
});
});

it('includes data.params.kv if any exists', function () {
const bidRequests2 = bidRequests.map(
(bidReq) => Object.assign(bidReq, {
(bidReq) => Object.assign({}, bidReq, {
params: {
kv: {
imsids: ['imsid1', 'imsid2']
Expand All @@ -204,7 +264,7 @@ describe('fluctAdapter', function () {
it('includes data.schain if any exists', function () {
// this should be done by schain.js
const bidRequests2 = bidRequests.map(
(bidReq) => Object.assign(bidReq, {
(bidReq) => Object.assign({}, bidReq, {
schain: {
ver: '1.0',
complete: 1,
Expand Down Expand Up @@ -271,7 +331,7 @@ describe('fluctAdapter', function () {
});
});

describe('interpretResponse', function() {
describe('should interpretResponse', function() {
const callBeaconSnippet = '<script type="application/javascript">' +
'(function() { var img = new Image(); img.src = ' +
'"https://i.adingo.jp/?test=1&et=hb&bidid=237f4d1a293f99"' +
Expand Down