From cbc7454074546321ae08285be6b284921ef1a8fe Mon Sep 17 00:00:00 2001 From: Mathieu Pheulpin Date: Tue, 13 Sep 2022 20:21:42 -0700 Subject: [PATCH] Sharethrough Bid Adapter: Add support for Transaction ID (#8988) * [PGE-178206904] Send Transaction ID to STX `source.tid` is transaction id at the request level `bidReq.ortb2Imp` may carry a transaction id at the impression level (`imp.ext.tid`) Followed recommendations provided by contributors here: https://github.com/prebid/Prebid.js/issues/8573 PGE-178206904 * Bump adapter version * Fix Transaction ID + Be more conscious about what we put in `imp.ext` --- modules/sharethroughBidAdapter.js | 14 ++++++----- .../modules/sharethroughBidAdapter_spec.js | 25 +++++++++++++++++-- 2 files changed, 31 insertions(+), 8 deletions(-) diff --git a/modules/sharethroughBidAdapter.js b/modules/sharethroughBidAdapter.js index cfbd94096bd..4ae8b98efa4 100644 --- a/modules/sharethroughBidAdapter.js +++ b/modules/sharethroughBidAdapter.js @@ -4,7 +4,7 @@ import { config } from '../src/config.js'; import { BANNER, VIDEO } from '../src/mediaTypes.js'; import { createEidsArray } from './userId/eids.js'; -const VERSION = '4.2.0'; +const VERSION = '4.3.0'; const BIDDER_CODE = 'sharethrough'; const SUPPLY_ID = 'WYu2BXv1'; @@ -52,6 +52,7 @@ export const sharethroughAdapterSpec = { ext: {}, }, source: { + tid: bidRequests[0].transactionId, ext: { version: '$prebid.version$', str: VERSION, @@ -80,12 +81,13 @@ export const sharethroughAdapterSpec = { } const imps = bidRequests.map(bidReq => { - const impression = {}; + const impression = { ext: {} }; - const gpid = deepAccess(bidReq, 'ortb2Imp.ext.data.pbadslot'); - if (gpid) { - impression.ext = { gpid: gpid }; - } + // mergeDeep(impression, bidReq.ortb2Imp); // leaving this out for now as we may want to leave stuff out on purpose + const tid = deepAccess(bidReq, 'ortb2Imp.ext.tid'); + if (tid) impression.ext.tid = tid; + const gpid = deepAccess(bidReq, 'ortb2Imp.ext.gpid', deepAccess(bidReq, 'ortb2Imp.ext.data.pbadslot')); + if (gpid) impression.ext.gpid = gpid; const videoRequest = deepAccess(bidReq, 'mediaTypes.video'); diff --git a/test/spec/modules/sharethroughBidAdapter_spec.js b/test/spec/modules/sharethroughBidAdapter_spec.js index bb5e8e69b6e..bc9affd4d0d 100644 --- a/test/spec/modules/sharethroughBidAdapter_spec.js +++ b/test/spec/modules/sharethroughBidAdapter_spec.js @@ -72,6 +72,7 @@ describe('sharethrough adapter spec', function () { { bidder: 'sharethrough', bidId: 'bidId1', + transactionId: 'transactionId1', sizes: [[300, 250], [300, 600]], params: { pkey: 'aaaa1111', @@ -85,8 +86,10 @@ describe('sharethrough adapter spec', function () { }, ortb2Imp: { ext: { + tid: 'transaction-id-1', + gpid: 'universal-id', data: { - pbadslot: 'universal-id', + pbadslot: 'pbadslot-id', }, }, }, @@ -136,6 +139,7 @@ describe('sharethrough adapter spec', function () { bidder: 'sharethrough', bidId: 'bidId2', sizes: [[600, 300]], + transactionId: 'transactionId2', params: { pkey: 'bbbb2222', }, @@ -229,6 +233,7 @@ describe('sharethrough adapter spec', function () { expect(openRtbReq.device.ua).to.equal(navigator.userAgent); expect(openRtbReq.regs.coppa).to.equal(1); + expect(openRtbReq.source.tid).to.equal(bidRequests[0].transactionId); expect(openRtbReq.source.ext.version).not.to.be.undefined; expect(openRtbReq.source.ext.str).not.to.be.undefined; expect(openRtbReq.source.ext.schain).to.deep.equal(bidRequests[0].schain); @@ -310,12 +315,28 @@ describe('sharethrough adapter spec', function () { }); }); + describe('transaction id at the impression level', () => { + it('should include transaction id when provided', () => { + const requests = spec.buildRequests(bidRequests, bidderRequest); + + expect(requests[0].data.imp[0].ext.tid).to.equal('transaction-id-1'); + expect(requests[1].data.imp[0].ext).to.be.empty; + }); + }); + describe('universal id', () => { it('should include gpid when universal id is provided', () => { const requests = spec.buildRequests(bidRequests, bidderRequest); expect(requests[0].data.imp[0].ext.gpid).to.equal('universal-id'); - expect(requests[1].data.imp[0].ext).to.be.undefined; + expect(requests[1].data.imp[0].ext).to.be.empty; + }); + + it('should include gpid when pbadslot is provided without universal id', () => { + delete bidRequests[0].ortb2Imp.ext.gpid; + const requests = spec.buildRequests(bidRequests, bidderRequest); + + expect(requests[0].data.imp[0].ext.gpid).to.equal('pbadslot-id'); }); });