Skip to content

Commit

Permalink
Sharethrough Bid Adapter: Add support for Transaction ID (prebid#8988)
Browse files Browse the repository at this point in the history
* [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: prebid#8573

PGE-178206904

* Bump adapter version

* Fix Transaction ID + Be more conscious about what we put in `imp.ext`
  • Loading branch information
Mathieu Pheulpin authored and jorgeluisrocha committed May 18, 2023
1 parent e3075c7 commit cbc7454
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 8 deletions.
14 changes: 8 additions & 6 deletions modules/sharethroughBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -52,6 +52,7 @@ export const sharethroughAdapterSpec = {
ext: {},
},
source: {
tid: bidRequests[0].transactionId,
ext: {
version: '$prebid.version$',
str: VERSION,
Expand Down Expand Up @@ -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');

Expand Down
25 changes: 23 additions & 2 deletions test/spec/modules/sharethroughBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ describe('sharethrough adapter spec', function () {
{
bidder: 'sharethrough',
bidId: 'bidId1',
transactionId: 'transactionId1',
sizes: [[300, 250], [300, 600]],
params: {
pkey: 'aaaa1111',
Expand All @@ -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',
},
},
},
Expand Down Expand Up @@ -136,6 +139,7 @@ describe('sharethrough adapter spec', function () {
bidder: 'sharethrough',
bidId: 'bidId2',
sizes: [[600, 300]],
transactionId: 'transactionId2',
params: {
pkey: 'bbbb2222',
},
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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');
});
});

Expand Down

0 comments on commit cbc7454

Please sign in to comment.