Skip to content

Commit

Permalink
Adnuntius Bid Adapter: Allow user ID to be passed as parameter (prebi…
Browse files Browse the repository at this point in the history
…d#11029)

* Removed linting issues

* Fixed merge issues.

* Bugfix on storageTool.

* Change to pass user ID as a parameter to the adserver.

* fetch user id from paraters comment.

---------

Co-authored-by: Antonios Sarhanis <tsarhanis@gmail.com>
  • Loading branch information
mikael-lundin and antosarho authored Feb 14, 2024
1 parent 8e5a2b9 commit 40e3f40
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 3 deletions.
11 changes: 8 additions & 3 deletions modules/adnuntiusBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,16 @@ const storageTool = (function () {
storage.setDataInLocalStorage(META_DATA_KEY, JSON.stringify(metaDataForSaving));
};

const getUsi = function (meta, ortb2) {
let usi = (meta && meta.usi) ? meta.usi : false;
const getUsi = function (meta, ortb2, bidderRequest) {
// Fetch user id from parameters.
const paramUsi = (bidderRequest.bids) ? bidderRequest.bids.find(bid => {
if (bid.params && bid.params.userId) return true
}).params.userId : false
let usi = (meta && meta.usi) ? meta.usi : false
if (ortb2 && ortb2.user && ortb2.user.id) {
usi = ortb2.user.id
}
if (paramUsi) usi = paramUsi
return usi;
}

Expand All @@ -131,7 +136,7 @@ const storageTool = (function () {
refreshStorage: function (bidderRequest) {
const ortb2 = bidderRequest.ortb2 || {};
metaInternal = getMetaInternal().reduce((a, entry) => ({ ...a, [entry.key]: entry.value }), {});
metaInternal.usi = getUsi(metaInternal, ortb2);
metaInternal.usi = getUsi(metaInternal, ortb2, bidderRequest);
if (!metaInternal.usi) {
delete metaInternal.usi;
}
Expand Down
21 changes: 21 additions & 0 deletions test/spec/modules/adnuntiusBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -660,6 +660,27 @@ describe('adnuntiusBidAdapter', function() {
expect(request[0]).to.have.property('url')
expect(request[0].url).to.equal(ENDPOINT_URL);
});

it('should user in user', function () {
config.setBidderConfig({
bidders: ['adnuntius'],
});
const req = [
{
bidId: 'adn-000000000008b6bc',
bidder: 'adnuntius',
params: {
auId: '000000000008b6bc',
network: 'adnuntius',
userId: 'different_user_id'
}
}
]
const request = config.runWithBidder('adnuntius', () => spec.buildRequests(req, { bids: req }));
expect(request.length).to.equal(1);
expect(request[0]).to.have.property('url')
expect(request[0].url).to.equal(`${ENDPOINT_URL_BASE}&userId=different_user_id`);
});
});

describe('user privacy', function() {
Expand Down

0 comments on commit 40e3f40

Please sign in to comment.