Skip to content

Commit

Permalink
Ogury Bid Adapter: support userId and userIdAsEids (#10669)
Browse files Browse the repository at this point in the history
* get userId and userIdasEids if exist

* unit tests updated and refactor
  • Loading branch information
AurelienMozoo authored Nov 15, 2023
1 parent 31747cf commit 97d3daa
Show file tree
Hide file tree
Showing 2 changed files with 92 additions and 9 deletions.
9 changes: 8 additions & 1 deletion modules/oguryBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const DEFAULT_TIMEOUT = 1000;
const BID_HOST = 'https://mweb-hb.presage.io/api/header-bidding-request';
const TIMEOUT_MONITORING_HOST = 'https://ms-ads-monitoring-events.presage.io';
const MS_COOKIE_SYNC_DOMAIN = 'https://ms-cookie-sync.presage.io';
const ADAPTER_VERSION = '1.5.0';
const ADAPTER_VERSION = '1.6.0';

function getClientWidth() {
const documentElementClientWidth = window.top.document.documentElement.clientWidth
Expand Down Expand Up @@ -122,6 +122,13 @@ function buildRequests(validBidRequests, bidderRequest) {
openRtbBidRequestBanner.site.id = bidRequest.params.assetKey;
const floor = getFloor(bidRequest);

if (bidRequest.userId) {
openRtbBidRequestBanner.user.ext.uids = bidRequest.userId
}
if (bidRequest.userIdAsEids) {
openRtbBidRequestBanner.user.ext.eids = bidRequest.userIdAsEids
}

openRtbBidRequestBanner.imp.push({
id: bidRequest.bidId,
tagid: bidRequest.params.adUnitId,
Expand Down
92 changes: 84 additions & 8 deletions test/spec/modules/oguryBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,21 @@ describe('OguryBidAdapter', function () {

return floorResult;
},
transactionId: 'transactionId'
transactionId: 'transactionId',
userId: {
pubcid: '2abb10e5-c4f6-4f70-9f45-2200e4487714'
},
userIdAsEids: [
{
source: 'pubcid.org',
uids: [
{
id: '2abb10e5-c4f6-4f70-9f45-2200e4487714',
atype: 1
}
]
}
]
},
{
adUnitCode: 'adUnitCode2',
Expand Down Expand Up @@ -407,12 +421,26 @@ describe('OguryBidAdapter', function () {
},
user: {
ext: {
consent: bidderRequest.gdprConsent.consentString
consent: bidderRequest.gdprConsent.consentString,
uids: {
pubcid: '2abb10e5-c4f6-4f70-9f45-2200e4487714'
},
eids: [
{
source: 'pubcid.org',
uids: [
{
id: '2abb10e5-c4f6-4f70-9f45-2200e4487714',
atype: 1
}
]
}
],
},
},
ext: {
prebidversion: '$prebid.version$',
adapterversion: '1.5.0'
adapterversion: '1.6.0'
},
device: {
w: stubbedWidth,
Expand Down Expand Up @@ -637,7 +665,9 @@ describe('OguryBidAdapter', function () {
},
user: {
ext: {
consent: ''
consent: '',
uids: expectedRequestObject.user.ext.uids,
eids: expectedRequestObject.user.ext.eids
},
}
};
Expand All @@ -663,7 +693,9 @@ describe('OguryBidAdapter', function () {
},
user: {
ext: {
consent: ''
consent: '',
uids: expectedRequestObject.user.ext.uids,
eids: expectedRequestObject.user.ext.eids
},
}
};
Expand All @@ -689,7 +721,9 @@ describe('OguryBidAdapter', function () {
},
user: {
ext: {
consent: ''
consent: '',
uids: expectedRequestObject.user.ext.uids,
eids: expectedRequestObject.user.ext.eids
},
}
};
Expand All @@ -701,6 +735,48 @@ describe('OguryBidAdapter', function () {
expect(request.data.regs.ext.gdpr).to.be.a('number');
});

it('should should not add uids infos if userId is undefined', () => {
const expectedRequestWithUndefinedUserId = {
...expectedRequestObject,
user: {
ext: {
consent: expectedRequestObject.user.ext.consent,
eids: expectedRequestObject.user.ext.eids
}
}
};

const validBidRequests = utils.deepClone(bidRequests);
validBidRequests[0] = {
...validBidRequests[0],
userId: undefined
};

const request = spec.buildRequests(validBidRequests, bidderRequest);
expect(request.data).to.deep.equal(expectedRequestWithUndefinedUserId);
});

it('should should not add uids infos if userIdAsEids is undefined', () => {
const expectedRequestWithUndefinedUserIdAsEids = {
...expectedRequestObject,
user: {
ext: {
consent: expectedRequestObject.user.ext.consent,
uids: expectedRequestObject.user.ext.uids
}
}
};

const validBidRequests = utils.deepClone(bidRequests);
validBidRequests[0] = {
...validBidRequests[0],
userIdAsEids: undefined
};

const request = spec.buildRequests(validBidRequests, bidderRequest);
expect(request.data).to.deep.equal(expectedRequestWithUndefinedUserIdAsEids);
});

it('should handle bidFloor undefined', () => {
const expectedRequestWithUndefinedFloor = {
...expectedRequestObject
Expand Down Expand Up @@ -814,7 +890,7 @@ describe('OguryBidAdapter', function () {
advertiserDomains: openRtbBidResponse.body.seatbid[0].bid[0].adomain
},
nurl: openRtbBidResponse.body.seatbid[0].bid[0].nurl,
adapterVersion: '1.5.0',
adapterVersion: '1.6.0',
prebidVersion: '$prebid.version$'
}, {
requestId: openRtbBidResponse.body.seatbid[0].bid[1].impid,
Expand All @@ -831,7 +907,7 @@ describe('OguryBidAdapter', function () {
advertiserDomains: openRtbBidResponse.body.seatbid[0].bid[1].adomain
},
nurl: openRtbBidResponse.body.seatbid[0].bid[1].nurl,
adapterVersion: '1.5.0',
adapterVersion: '1.6.0',
prebidVersion: '$prebid.version$'
}]

Expand Down

0 comments on commit 97d3daa

Please sign in to comment.