Skip to content

Commit

Permalink
update prebid adapter (prebid#10459)
Browse files Browse the repository at this point in the history
Co-authored-by: Dawid W <[email protected]>
  • Loading branch information
optidigital-prebid and dawidww authored Sep 11, 2023
1 parent 36eadbd commit 5c9e0cf
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 5 deletions.
12 changes: 12 additions & 0 deletions modules/optidigitalBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,12 @@ export const spec = {
payload.uspConsent = bidderRequest.uspConsent;
}

if (_getEids(validBidRequests[0])) {
payload.user = {
eids: _getEids(validBidRequests[0])
}
}

const payloadObject = JSON.stringify(payload);
return {
method: 'POST',
Expand Down Expand Up @@ -223,6 +229,12 @@ function _getFloor (bid, sizes, currency) {
return floor !== null ? floor : bid.params.floor;
}

function _getEids(bidRequest) {
if (deepAccess(bidRequest, 'userIdAsEids')) {
return bidRequest.userIdAsEids;
}
}

export function resetSync() {
isSynced = false;
}
Expand Down
13 changes: 8 additions & 5 deletions modules/optidigitalBidAdapter.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,13 @@ Bidder Adapter for Prebid.js.

```
pbjs.setConfig({
userSync: {
iframeEnabled: true,
syncEnabled: true,
syncDelay: 3000
}
  userSync: {
    filterSettings: {
      iframe: {
        bidders: '*', // '*' represents all bidders
        filter: 'include'
      }
    }
  }
});
```
22 changes: 22 additions & 0 deletions test/spec/modules/optidigitalBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,28 @@ describe('optidigitalAdapterTests', function () {
expect(payload.imp[0].bidFloor).to.exist;
});

it('should add userEids to payload', function() {
const userIdAsEids = [{
source: 'pubcid.org',
uids: [{
id: '121213434342343',
atype: 1
}]
}];
validBidRequests[0].userIdAsEids = userIdAsEids;
bidderRequest.userIdAsEids = userIdAsEids;
const request = spec.buildRequests(validBidRequests, bidderRequest);
const payload = JSON.parse(request.data);
expect(payload.user.eids).to.deep.equal(userIdAsEids);
});

it('should not add userIdAsEids to payload when userIdAsEids is not present', function() {
validBidRequests[0].userIdAsEids = undefined;
const request = spec.buildRequests(validBidRequests, bidderRequest);
const payload = JSON.parse(request.data);
expect(payload.user).to.deep.equal(undefined);
});

function returnBannerSizes(mediaTypes, expectedSizes) {
const bidRequest = Object.assign(validBidRequests[0], mediaTypes);
const request = spec.buildRequests([bidRequest], bidderRequest);
Expand Down

0 comments on commit 5c9e0cf

Please sign in to comment.