Skip to content

Commit

Permalink
Yandex Bid Adapter: (#10372)
Browse files Browse the repository at this point in the history
* added userIdAsEids support

Co-authored-by: Taras Saveliev <[email protected]>
  • Loading branch information
Saveliev and Taras Saveliev committed Aug 22, 2023
1 parent ddd6a3b commit 3b6c64c
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 11 deletions.
29 changes: 18 additions & 11 deletions modules/yandexBidAdapter.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { formatQS, deepAccess, triggerPixel, _each, _map } from '../src/utils.js';
import { formatQS, deepAccess, deepSetValue, triggerPixel, _each, _map } from '../src/utils.js';
import { registerBidder } from '../src/adapters/bidderFactory.js';
import { BANNER, NATIVE } from '../src/mediaTypes.js'
import { convertOrtbRequestToProprietaryNative } from '../src/native.js';
Expand Down Expand Up @@ -115,20 +115,27 @@ export const spec = {
queryParams['ssp-cur'] = currency;
}

const data = {
id: bidRequest.bidId,
imp: [imp],
site: {
ref: referrer,
page,
domain,
},
tmax: timeout,
};

const eids = deepAccess(bidRequest, 'userIdAsEids');
if (eids && eids.length) {
deepSetValue(data, 'user.ext.eids', eids);
}

const queryParamsString = formatQS(queryParams);
return {
method: 'POST',
url: BIDDER_URL + `/${pageId}?${queryParamsString}`,
data: {
id: bidRequest.bidId,
imp: [imp],
site: {
ref: referrer,
page,
domain,
},
tmax: timeout,
},
data,
options: {
withCredentials,
},
Expand Down
35 changes: 35 additions & 0 deletions test/spec/modules/yandexBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,41 @@ describe('Yandex adapter', function () {
expect(query['ssp-cur']).to.equal('USD');
});

it('should send eids if defined', function() {
const bannerRequest = getBidRequest({
userIdAsEids: [{
source: 'sharedid.org',
uids: [
{
id: '01',
atype: 1
}
]
}]
});

const requests = spec.buildRequests([bannerRequest], bidderRequest);

expect(requests).to.have.lengthOf(1);
const request = requests[0];

expect(request.data).to.exist;
const { data } = request;

expect(data.user).to.exist;
expect(data.user).to.deep.equal({
ext: {
eids: [{
source: 'sharedid.org',
uids: [{
id: '01',
atype: 1,
}],
}],
}
});
});

describe('banner', () => {
it('should create valid banner object', () => {
const bannerRequest = getBidRequest({
Expand Down

0 comments on commit 3b6c64c

Please sign in to comment.