From 3b6c64c484fbe40c0f4a9d6448782c3f3989e9e1 Mon Sep 17 00:00:00 2001 From: Saveliev Taras Date: Tue, 22 Aug 2023 20:00:10 +0200 Subject: [PATCH] Yandex Bid Adapter: (#10372) * added userIdAsEids support Co-authored-by: Taras Saveliev --- modules/yandexBidAdapter.js | 29 +++++++++++------- test/spec/modules/yandexBidAdapter_spec.js | 35 ++++++++++++++++++++++ 2 files changed, 53 insertions(+), 11 deletions(-) diff --git a/modules/yandexBidAdapter.js b/modules/yandexBidAdapter.js index 2a306acdcf0..9ca989b2259 100644 --- a/modules/yandexBidAdapter.js +++ b/modules/yandexBidAdapter.js @@ -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'; @@ -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, }, diff --git a/test/spec/modules/yandexBidAdapter_spec.js b/test/spec/modules/yandexBidAdapter_spec.js index eef476e21d2..f14e8df6c09 100644 --- a/test/spec/modules/yandexBidAdapter_spec.js +++ b/test/spec/modules/yandexBidAdapter_spec.js @@ -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({