Skip to content

Commit

Permalink
fluct Bid Adapter: add user.data to bid requests (#10318)
Browse files Browse the repository at this point in the history
* no filter eids by source

* Update fluctBidAdapter_spec.js

kick off cirleci tests

* add user.data

* fix Object.assign side-effect

* merge ortb2.user.ext.eids into user.eids

* replace || w/ ??

* run circleci

* kick off tests

* kick

---------

Co-authored-by: Chris Huie <[email protected]>
  • Loading branch information
yowcow and ChrisHuie committed Aug 17, 2023
1 parent 57f2ac8 commit 8d6ca3e
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 24 deletions.
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.adUnitCode = request.adUnitCode;
data.bidId = request.bidId;
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 (impExt) {
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 @@ -192,14 +192,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 @@ -211,56 +211,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 @@ -277,7 +337,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 @@ -344,7 +404,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

0 comments on commit 8d6ca3e

Please sign in to comment.