diff --git a/modules/dasBidAdapter.js b/modules/dasBidAdapter.js index 954da2265bb..a01aaa96149 100644 --- a/modules/dasBidAdapter.js +++ b/modules/dasBidAdapter.js @@ -298,6 +298,11 @@ function interpretResponse(serverResponse) { }, }; + const targeting = bid.ext?.targeting; + if (targeting) { + bidResponse.adserverTargeting = targeting; + } + if (bid.mtype === 1) { bidResponse.mediaType = BANNER; bidResponse.ad = bid.adm; diff --git a/test/spec/modules/dasBidAdapter_spec.js b/test/spec/modules/dasBidAdapter_spec.js index 825c7973ddd..d38592e47c4 100644 --- a/test/spec/modules/dasBidAdapter_spec.js +++ b/test/spec/modules/dasBidAdapter_spec.js @@ -338,6 +338,76 @@ describe('dasBidAdapter', function () { expect(spec.interpretResponse({ body: { seatbid: [] } })).to.be.an('array').that.is.empty; }); + it('should include adserverTargeting when targeting is present in ext', function () { + const responseWithTargeting = { + body: { + seatbid: [{ + bid: [{ + impid: 'bid123', + price: 3.5, + w: 300, + h: 250, + adm: '', + crid: 'crid123', + mtype: 1, + adomain: ['advertiser.com'], + ext: { + targeting: { + bidder_variant: 'variant_a' + } + } + }] + }], + cur: 'USD' + } + }; + + const bidResponses = spec.interpretResponse(responseWithTargeting); + + expect(bidResponses[0].adserverTargeting).to.deep.equal({ + 'bidder_variant': 'variant_a' + }); + }); + + it('should pass through all targeting keys from server', function () { + const responseWithMultipleTargeting = { + body: { + seatbid: [{ + bid: [{ + impid: 'bid123', + price: 3.5, + w: 300, + h: 250, + adm: '', + crid: 'crid123', + mtype: 1, + adomain: ['advertiser.com'], + ext: { + targeting: { + bidder_variant: 'variant_a', + custom_key: 'custom_value' + } + } + }] + }], + cur: 'USD' + } + }; + + const bidResponses = spec.interpretResponse(responseWithMultipleTargeting); + + expect(bidResponses[0].adserverTargeting).to.deep.equal({ + 'bidder_variant': 'variant_a', + 'custom_key': 'custom_value' + }); + }); + + it('should not include adserverTargeting when targeting is not present', function () { + const bidResponses = spec.interpretResponse(serverResponse); + + expect(bidResponses[0].adserverTargeting).to.be.undefined; + }); + it('should return proper bid response for native', function () { const nativeResponse = { body: {