diff --git a/modules/allegroBidAdapter.js b/modules/allegroBidAdapter.js index 67f337531b7..9fc4fe461ec 100644 --- a/modules/allegroBidAdapter.js +++ b/modules/allegroBidAdapter.js @@ -140,6 +140,12 @@ const converter = ortbConverter({ request(buildRequest, imps, bidderRequest, context) { const request = buildRequest(imps, bidderRequest, context); + const publisherId = bidderRequest.bids.find(bid => bid.params?.publisherId)?.params.publisherId; + if (publisherId) { + request.site = request.site || {}; + request.site['[com.allegro.dsp.site.ext]'] = { inventory: { id: publisherId } }; + } + if (request?.device?.dnt !== undefined) { request.device.dnt = request.device.dnt === 1; } @@ -164,7 +170,6 @@ const converter = ortbConverter({ return request; }, - /** * Post-processes each Prebid bid response, mapping Allegro DSP extension * fields onto the standard `meta` object so publishers can consume them. diff --git a/modules/allegroBidAdapter.md b/modules/allegroBidAdapter.md index 252c5427873..7fcaeb5f570 100644 --- a/modules/allegroBidAdapter.md +++ b/modules/allegroBidAdapter.md @@ -54,11 +54,21 @@ var adUnits = [{ } }, bids: [{ - bidder: 'allegro' + bidder: 'allegro', + params: { + publisherId: 'gwp' // publisher identifier; maps to site.[com.allegro.dsp.site.ext].inventory.id in the outgoing OpenRTB request + } }] }]; ``` +## Bid Request Parameters + +| Name | Scope | Type | Description | +|----------|----------|--------|-------------------------------------------------------------------------------------------------------------------------| +| `publisherId` | optional | String | Publisher identifier. When present, the value is written to the `[com.allegro.dsp.site.ext]` proto-JSON extension key on `site` as `inventory.id` in the outgoing OpenRTB bid request, enabling publisher-scoped bid entity filtering on the server side. | + + # Features ## Impression Tracking @@ -103,4 +113,3 @@ Example server bid response: - **TTL**: 360 seconds - **Net Revenue**: true - **Content Type**: text/plain - diff --git a/test/spec/modules/allegroBidAdapter_spec.js b/test/spec/modules/allegroBidAdapter_spec.js index 3134850b645..d75ffcae036 100644 --- a/test/spec/modules/allegroBidAdapter_spec.js +++ b/test/spec/modules/allegroBidAdapter_spec.js @@ -75,7 +75,7 @@ describe('Allegro Bid Adapter', () => { it('converts extension fields by default', () => { sinon.stub(config, 'getConfig').callsFake((key) => undefined); - const bidRequests = [buildBidRequest({})]; + const bidRequests = [buildBidRequest({ params: { publisherId: 'gwp_pb' } })]; const ortb2 = { site: { ext: { siteCustom: 'val' }, publisher: { ext: { pubCustom: 'pub' } } }, user: { ext: { userCustom: 'usr' }, data: [{ ext: { dataCustom: 'd1' } }] }, @@ -90,6 +90,7 @@ describe('Allegro Bid Adapter', () => { expect(data.site.ext).to.equal(undefined); expect(data.site['[com.google.doubleclick.site]'].siteCustom).to.equal('val'); + expect(data.site['[com.allegro.dsp.site.ext]'].inventory.id).to.equal('gwp_pb'); expect(data.site.publisher['[com.google.doubleclick.publisher]'].pubCustom).to.equal('pub'); expect(data.user['[com.google.doubleclick.user]'].userCustom).to.equal('usr'); expect(data.user.data[0]['[com.google.doubleclick.data]'].dataCustom).to.equal('d1'); @@ -113,6 +114,23 @@ describe('Allegro Bid Adapter', () => { expect(req.data.site['[com.google.doubleclick.site]']).to.equal(undefined); }); + it('does not add the inventory extension when publisherId is absent', () => { + sinon.stub(config, 'getConfig').callsFake((key) => undefined); + const bidRequests = [buildBidRequest({})]; + const req = spec.buildRequests(bidRequests, buildBidderRequest(bidRequests)); + expect(req.data.site?.['[com.allegro.dsp.site.ext]']).to.equal(undefined); + }); + + it('sets inventory.id even when allegro.convertExtensionFields = false', () => { + sinon.stub(config, 'getConfig').callsFake((key) => { + if (key === 'allegro.convertExtensionFields') return false; + return undefined; + }); + const bidRequests = [buildBidRequest({ params: { publisherId: 'gwp_pb' } })]; + const req = spec.buildRequests(bidRequests, buildBidderRequest(bidRequests)); + expect(req.data.site['[com.allegro.dsp.site.ext]'].inventory.id).to.equal('gwp_pb'); + }); + it('converts numeric flags to booleans (topframe, secure, test) when present', () => { sinon.stub(config, 'getConfig').callsFake((key) => undefined); const bidRequests = [buildBidRequest({ mediaTypes: { banner: { sizes: [[300, 250]], topframe: 1 } }, params: { secure: 1 } })];