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

Core & multiple modules: populate ortb2.source.tid #9862

Merged
merged 2 commits into from
May 1, 2023
Merged
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
4 changes: 2 additions & 2 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ name: "CodeQL"

on:
push:
branches: [ "master" ]
branches: [ "master", "prebid-8" ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ "master" ]
branches: [ "master", "prebid-8" ]
schedule:
- cron: '22 11 * * 0'

Expand Down
7 changes: 3 additions & 4 deletions libraries/ortbConverter/processors/default.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {deepSetValue, mergeDeep} from '../../../src/utils.js';
import {generateUUID, mergeDeep} from '../../../src/utils.js';
import {bannerResponseProcessor, fillBannerImp} from './banner.js';
import {fillVideoImp, fillVideoResponse} from './video.js';
import {setResponseMediaType} from './mediaType.js';
Expand All @@ -21,17 +21,16 @@ export const DEFAULT_PROCESSORS = {
fn: clientSectionChecker('ORTB request')
},
props: {
// sets request properties id, tmax, test, source.tid
// sets request properties id, tmax, test
fn(ortbRequest, bidderRequest) {
Object.assign(ortbRequest, {
id: ortbRequest.id || bidderRequest.auctionId,
id: ortbRequest.id || generateUUID(),
test: ortbRequest.test || 0
});
const timeout = parseInt(bidderRequest.timeout, 10);
if (!isNaN(timeout)) {
ortbRequest.tmax = timeout;
}
deepSetValue(ortbRequest, 'source.tid', ortbRequest.source?.tid || bidderRequest.auctionId);
}
}
},
Expand Down
1 change: 0 additions & 1 deletion modules/prebidServerBidAdapter/ortbConverter.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ const PBS_CONVERTER = ortbConverter({
const request = buildRequest(imps, proxyBidderRequest, context);

request.tmax = s2sBidRequest.s2sConfig.timeout;
deepSetValue(request, 'source.tid', proxyBidderRequest.auctionId);

[request.app, request.dooh, request.site].forEach(section => {
if (section && !section.publisher?.id) {
Expand Down
2 changes: 1 addition & 1 deletion src/adapterManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ adapterManager.makeBidRequests = hook('sync', function (adUnits, auctionStart, a
const bidderOrtb2 = ortb2Fragments.bidder || {};

function addOrtb2(bidderRequest) {
const fpd = Object.freeze(mergeDeep({}, ortb2, bidderOrtb2[bidderRequest.bidderCode]));
const fpd = Object.freeze(mergeDeep({source: {tid: auctionId}}, ortb2, bidderOrtb2[bidderRequest.bidderCode]));
bidderRequest.ortb2 = fpd;
bidderRequest.bids.forEach((bid) => bid.ortb2 = fpd);
return bidderRequest;
Expand Down
2 changes: 0 additions & 2 deletions test/spec/modules/ivsBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,7 @@ describe('ivsBidAdapter', function () {
it('should contain the required parameters', function () {
const bidRequest = spec.buildRequests(validBidRequests, validBidderRequest);
const bidderRequest = bidRequest.data;
assert.equal(bidderRequest.id, validBidderRequest.auctionId);
assert.ok(bidderRequest.site);
assert.ok(bidderRequest.source);
assert.lengthOf(bidderRequest.imp, 1);
});
});
Expand Down
1 change: 0 additions & 1 deletion test/spec/modules/nexx360BidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,6 @@ describe('Nexx360 bid adapter tests', function () {
const request = spec.buildRequests(displayBids, bidderRequest);
const requestContent = request.data;
expect(request).to.have.property('method').and.to.equal('POST');
expect(requestContent.id).to.be.eql('2e684815-b44e-4e04-b812-56da54adbe74');
expect(requestContent.cur[0]).to.be.eql('USD');
expect(requestContent.imp.length).to.be.eql(2);
expect(requestContent.imp[0].id).to.be.eql('44a2706ac3574');
Expand Down
13 changes: 5 additions & 8 deletions test/spec/modules/prebidServerBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -636,15 +636,12 @@ describe('S2S Adapter', function () {
resetSyncedStatus();
});

it('should set id and source.tid to auction ID', function () {
it('should pick source.tid from FPD', () => {
config.setConfig({ s2sConfig: CONFIG });

adapter.callBids(OUTSTREAM_VIDEO_REQUEST, BID_REQUESTS, addBidResponse, done, ajax);

const requestBid = JSON.parse(server.requests[0].requestBody);
expect(requestBid.id).to.equal(BID_REQUESTS[0].auctionId);
expect(requestBid.source.tid).to.equal(BID_REQUESTS[0].auctionId);
});
adapter.callBids({...REQUEST, ortb2Fragments: {global: {source: {tid: 'mock-tid'}}}}, BID_REQUESTS, addBidResponse, done, ajax);
const req = JSON.parse(server.requests[0].requestBody)
expect(req.source.tid).to.eql('mock-tid');
})

it('should set tmax to s2sConfig.timeout', () => {
const cfg = {...CONFIG, timeout: 123};
Expand Down
2 changes: 0 additions & 2 deletions test/spec/modules/scatteredBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,7 @@ describe('Scattered adapter', function () {
it('has the right fields filled', function () {
let request = spec.buildRequests(arrayOfValidBidRequests, validBidderRequest);
const bidderRequest = request.data;
assert.equal(bidderRequest.id, validBidderRequest.auctionId);
assert.ok(bidderRequest.site);
assert.ok(bidderRequest.source);
assert.lengthOf(bidderRequest.imp, 1);
});

Expand Down
5 changes: 5 additions & 0 deletions test/spec/unit/core/adapterManager_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1762,6 +1762,11 @@ describe('adapterManager tests', function () {
requests.appnexus.bids.forEach((bid) => expect(bid.ortb2).to.eql(requests.appnexus.ortb2));
});

it('should populate ortb2.source.tid with auctionId', () => {
const reqs = adapterManager.makeBidRequests(adUnits, 0, 'mockAuctionId', 1000, [], {global: {}});
expect(reqs[0].ortb2.source.tid).to.equal('mockAuctionId');
})

it('should merge in bid-level ortb2Imp with adUnit-level ortb2Imp', () => {
const adUnit = {
...adUnits[1],
Expand Down