Skip to content

Commit

Permalink
[PGE-178206904] Send Transaction ID to STX
Browse files Browse the repository at this point in the history
`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
  • Loading branch information
maphe committed Aug 31, 2022
1 parent 0f2abb4 commit b49d83e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
11 changes: 6 additions & 5 deletions modules/sharethroughBidAdapter.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { deepAccess, generateUUID, inIframe } from '../src/utils.js';
import { deepAccess, generateUUID, inIframe, mergeDeep } from '../src/utils.js';
import { registerBidder } from '../src/adapters/bidderFactory.js';
import { config } from '../src/config.js';
import { BANNER, VIDEO } from '../src/mediaTypes.js';
Expand Down Expand Up @@ -52,6 +52,7 @@ export const sharethroughAdapterSpec = {
ext: {},
},
source: {
tid: bidderRequest.auctionId,
ext: {
version: '$prebid.version$',
str: VERSION,
Expand Down Expand Up @@ -80,12 +81,12 @@ export const sharethroughAdapterSpec = {
}

const imps = bidRequests.map(bidReq => {
const impression = {};
const impression = { ext: {} };

mergeDeep(impression, bidReq.ortb2Imp);

const gpid = deepAccess(bidReq, 'ortb2Imp.ext.data.pbadslot');
if (gpid) {
impression.ext = { gpid: gpid };
}
if (gpid) impression.ext.gpid = gpid;

const videoRequest = deepAccess(bidReq, 'mediaTypes.video');

Expand Down
14 changes: 13 additions & 1 deletion test/spec/modules/sharethroughBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ describe('sharethrough adapter spec', function () {
},
ortb2Imp: {
ext: {
tid: 'transaction-id-1',
data: {
pbadslot: 'universal-id',
},
Expand Down Expand Up @@ -168,6 +169,7 @@ describe('sharethrough adapter spec', function () {
refererInfo: {
ref: 'https://referer.com',
},
auctionId: 'transactionId1',
};
});

Expand Down Expand Up @@ -229,6 +231,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(bidderRequest.auctionId);
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 +313,21 @@ 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;
});
});

Expand Down

0 comments on commit b49d83e

Please sign in to comment.