Skip to content

Commit

Permalink
Sortable Bid Adapter: add eids support (#6565)
Browse files Browse the repository at this point in the history
* Add Sortable adapter for Prebid 3.x

Update tests to reflect changes.

* Add .js in imports

* hostname not host: don't include port

* Trivial change to trigger build: failure wasn't our adapter

* More failures in other adapters

* PR Feedback

- use https for URL
- fix examples in markdown
- request to endpoint should work now

* Feedback: add native and video examples

* Update unit tests

Co-authored-by: Shannon Broekhoven <[email protected]>
  • Loading branch information
2 people authored and idettman committed May 21, 2021
1 parent 96fe1dc commit 78f4492
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 1 deletion.
9 changes: 9 additions & 0 deletions modules/sortableBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import * as utils from '../src/utils.js';
import { registerBidder } from '../src/adapters/bidderFactory.js';
import { config } from '../src/config.js';
import { BANNER, NATIVE, VIDEO } from '../src/mediaTypes.js';
import { createEidsArray } from './userId/eids.js';

const BIDDER_CODE = 'sortable';
const SERVER_URL = 'https://c.deployads.com';
Expand Down Expand Up @@ -218,6 +219,8 @@ export const spec = {
return rv;
});
const gdprConsent = bidderRequest && bidderRequest.gdprConsent;
const bidUserId = validBidReqs[0].userId;
const eids = createEidsArray(bidUserId);
const sortableBidReq = {
id: utils.getUniqueIdentifierStr(),
imp: sortableImps,
Expand All @@ -241,6 +244,9 @@ export const spec = {
h: screen.height
},
},
user: {
ext: {}
}
};
if (bidderRequest && bidderRequest.timeout > 0) {
sortableBidReq.tmax = bidderRequest.timeout;
Expand All @@ -255,6 +261,9 @@ export const spec = {
sortableBidReq.regs.ext.gdpr = gdprConsent.gdprApplies ? 1 : 0
}
}
if (eids.length) {
sortableBidReq.user.ext.eids = eids;
}
if (bidderRequest.uspConsent) {
sortableBidReq.regs.ext.us_privacy = bidderRequest.uspConsent;
}
Expand Down
35 changes: 34 additions & 1 deletion test/spec/modules/sortableBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,40 @@ describe('sortableBidAdapter', function() {
const gdprRequest = spec.buildRequests(gdprBidRequests, {refererInfo: { referer: 'http://localhost:9876/' }});
const gdprRequestBody = JSON.parse(gdprRequest.data);
expect(gdprRequestBody.regs).to.deep.equal({ext: {}});
expect(gdprRequestBody.user).to.equal(undefined);
expect(gdprRequestBody.user.ext.consent).to.equal(undefined);
})

const eidsBidRequests = [{
'bidder': 'sortable',
'params': {
'tagId': '403370',
'siteId': 'example.com',
'floor': 0.21,
'keywords': {},
'floorSizeMap': {}
},
'bidId': '30b31c1838de1e',
'bidderRequestId': '22edbae2733bf6',
'auctionId': '1d1a030790a475'
}];

it('should not set user ids when none present', function() {
const eidsRequest = spec.buildRequests(eidsBidRequests, {refererInfo: {
referer: 'http://localhost:9876/'
}});
const eidsRequestBody = JSON.parse(eidsRequest.data);

expect(eidsRequestBody.user.ext.eids).to.equal(undefined);
})

it('should set user ids when present', function() {
eidsBidRequests[0].userId = { criteoId: 'sample-userid' };
const eidsRequest = spec.buildRequests(eidsBidRequests, {refererInfo: {
referer: 'http://localhost:9876/'
}});
const eidsRequestBody = JSON.parse(eidsRequest.data);

expect(eidsRequestBody.user.ext.eids.length).to.equal(1);
})
});

Expand Down

0 comments on commit 78f4492

Please sign in to comment.