Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PGE-178206904] Send Transaction ID to STX #1544

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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