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

Seedtag Bid Adapter: add topics and eids #11338

Merged
merged 2 commits into from
Apr 15, 2024
Merged
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
15 changes: 12 additions & 3 deletions modules/seedtagBidAdapter.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { isArray, _map, triggerPixel } from '../src/utils.js';
import { registerBidder } from '../src/adapters/bidderFactory.js';
import { VIDEO, BANNER } from '../src/mediaTypes.js';
import { config } from '../src/config.js';
import { BANNER, VIDEO } from '../src/mediaTypes.js';
import { _map, isArray, triggerPixel } from '../src/utils.js';

/**
* @typedef {import('../src/adapters/bidderFactory.js').BidRequest} BidRequest
Expand Down Expand Up @@ -125,7 +125,7 @@ function buildBidRequest(validBidRequest) {
adUnitCode: validBidRequest.adUnitCode,
geom: geom(validBidRequest.adUnitCode),
placement: params.placement,
requestCount: validBidRequest.bidderRequestsCount || 1, // FIXME : in unit test the parameter bidderRequestsCount is undefined
requestCount: validBidRequest.bidderRequestsCount || 1, // FIXME : in unit test the parameter bidderRequestsCount is undefinedt
};

if (hasVideoMediaType(validBidRequest)) {
Expand Down Expand Up @@ -284,6 +284,7 @@ export const spec = {
auctionStart: bidderRequest.auctionStart || Date.now(),
ttfb: ttfb(),
bidRequests: _map(validBidRequests, buildBidRequest),
user: { topics: [], eids: [] }
};

if (payload.cmp) {
Expand Down Expand Up @@ -316,7 +317,15 @@ export const spec = {
}
}

if (bidderRequest.ortb2?.user?.data) {
payload.user.topics = bidderRequest.ortb2.user.data
}
if (validBidRequests[0] && validBidRequests[0].userIdAsEids) {
payload.user.eids = validBidRequests[0].userIdAsEids
}

const payloadString = JSON.stringify(payload);

return {
method: 'POST',
url: SEEDTAG_SSP_ENDPOINT,
Expand Down
59 changes: 56 additions & 3 deletions test/spec/modules/seedtagBidAdapter_spec.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { expect } from 'chai';
import { spec, getTimeoutUrl } from 'modules/seedtagBidAdapter.js';
import { getTimeoutUrl, spec } from 'modules/seedtagBidAdapter.js';
import * as utils from 'src/utils.js';
import { config } from '../../../src/config.js';
import * as mockGpt from 'test/spec/integration/faker/googletag.js';
import { config } from '../../../src/config.js';

const PUBLISHER_ID = '0000-0000-01';
const ADUNIT_ID = '000000';
Expand Down Expand Up @@ -536,8 +536,61 @@ describe('Seedtag Adapter', function () {
expect(data.gppConsent).to.be.undefined;
});
});
});

describe('User param', function () {
it('should be added to payload user data param when bidderRequest has ortb2 user info', function () {
var ortb2 = {

user: {

data: [
{
ext: {
segtax: 601,
segclass: '4'
},
segment: [
{
id: '149'
}
],
name: 'randomname'
}

]
}
}
bidderRequest['ortb2'] = ortb2
const request = spec.buildRequests(validBidRequests, bidderRequest);
const data = JSON.parse(request.data);

expect(data.user).to.exist;
expect(data.user.topics).to.exist;
expect(data.user.topics).to.be.an('array').that.is.not.empty;
expect(data.user.topics[0].ext).to.eql(ortb2.user.data[0].ext);
expect(data.user.topics[0].segment).to.eql(ortb2.user.data[0].segment);
expect(data.user.topics[0].name).to.eql(ortb2.user.data[0].name);
})

it('should be added to payload user eids param when validRequest has userId info', function () {
var userIdAsEids = [{
source: 'sourceid',
uids: [{
atype: 1,
id: 'randomId'
}]
}]
validBidRequests[0]['userIdAsEids'] = userIdAsEids
const request = spec.buildRequests(validBidRequests, bidderRequest);
const data = JSON.parse(request.data);

expect(data.user).to.exist;
expect(data.user.eids).to.exist;
expect(data.user.eids).to.be.an('array').that.is.not.empty;
expect(data.user.eids).to.deep.equal(userIdAsEids);
})
});
})
describe('interpret response method', function () {
it('should return a void array, when the server response are not correct.', function () {
const request = { data: JSON.stringify({}) };
Expand Down