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

Revert "Prebid Server Bid Adapter: auctionId to $.id UUID to $.source.tid + mergeDeep extPrebid" #7677

Closed
wants to merge 1 commit 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
6 changes: 3 additions & 3 deletions modules/prebidServerBidAdapter/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -731,7 +731,7 @@ const OPEN_RTB_PROTOCOL = {
return;
}
const request = {
id: firstBidRequest.auctionId,
id: s2sBidRequest.tid,
source: {tid: s2sBidRequest.tid},
tmax: s2sConfig.timeout,
imp: imps,
Expand All @@ -751,7 +751,7 @@ const OPEN_RTB_PROTOCOL = {
}
};

// This is no longer overwritten unless name and version explicitly overwritten by extPrebid (mergeDeep)
// Sets pbjs version, can be overwritten below if channel exists in s2sConfig.extPrebid
request.ext.prebid = Object.assign(request.ext.prebid, {channel: {name: 'pbjs', version: $$PREBID_GLOBAL$$.version}})

// set debug flag if in debug mode
Expand All @@ -761,7 +761,7 @@ const OPEN_RTB_PROTOCOL = {

// s2sConfig video.ext.prebid is passed through openrtb to PBS
if (s2sConfig.extPrebid && typeof s2sConfig.extPrebid === 'object') {
request.ext.prebid = mergeDeep(request.ext.prebid, s2sConfig.extPrebid);
request.ext.prebid = Object.assign(request.ext.prebid, s2sConfig.extPrebid);
}

/**
Expand Down
22 changes: 8 additions & 14 deletions src/adapterManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -262,16 +262,14 @@ adapterManager.makeBidRequests = hook('sync', function (adUnits, auctionStart, a
}

let adUnitsS2SCopy = getAdUnitCopyForPrebidServer(adUnits, s2sConfig);

// uniquePbsTid is so we know which server to send which bids to during the callBids function
let uniquePbsTid = generateUUID();
let tid = generateUUID();
adaptersServerSide.forEach(bidderCode => {
const bidderRequestId = getUniqueIdentifierStr();
const bidderRequest = {
bidderCode,
auctionId,
bidderRequestId,
uniquePbsTid,
tid,
bids: hookedGetBids({bidderCode, auctionId, bidderRequestId, 'adUnits': deepClone(adUnitsS2SCopy), labels, src: CONSTANTS.S2S.SRC}),
auctionStart: auctionStart,
timeout: s2sConfig.timeout,
Expand Down Expand Up @@ -352,7 +350,7 @@ adapterManager.callBids = (adUnits, bidRequests, addBidResponse, doneCb, request
serverBidRequests.forEach(serverBidRequest => {
var index = -1;
for (var i = 0; i < uniqueServerBidRequests.length; ++i) {
if (serverBidRequest.uniquePbsTid === uniqueServerBidRequests[i].uniquePbsTid) {
if (serverBidRequest.tid === uniqueServerBidRequests[i].tid) {
index = i;
break;
}
Expand All @@ -362,10 +360,7 @@ adapterManager.callBids = (adUnits, bidRequests, addBidResponse, doneCb, request
}
});

let counter = 0;

// $.source.tid MUST be a unique UUID and also THE SAME between all PBS Requests for a given Auction
const sourceTid = generateUUID();
let counter = 0
_s2sConfigs.forEach((s2sConfig) => {
if (s2sConfig && uniqueServerBidRequests[counter] && includes(s2sConfig.bidders, uniqueServerBidRequests[counter].bidderCode)) {
// s2s should get the same client side timeout as other client side requests.
Expand All @@ -375,13 +370,13 @@ adapterManager.callBids = (adUnits, bidRequests, addBidResponse, doneCb, request
} : undefined);
let adaptersServerSide = s2sConfig.bidders;
const s2sAdapter = _bidderRegistry[s2sConfig.adapter];
let uniquePbsTid = uniqueServerBidRequests[counter].uniquePbsTid;
let tid = uniqueServerBidRequests[counter].tid;
let adUnitsS2SCopy = uniqueServerBidRequests[counter].adUnitsS2SCopy;

let uniqueServerRequests = serverBidRequests.filter(serverBidRequest => serverBidRequest.uniquePbsTid === uniquePbsTid);
let uniqueServerRequests = serverBidRequests.filter(serverBidRequest => serverBidRequest.tid === tid)

if (s2sAdapter) {
let s2sBidRequest = {tid: sourceTid, 'ad_units': adUnitsS2SCopy, s2sConfig};
let s2sBidRequest = {tid, 'ad_units': adUnitsS2SCopy, s2sConfig};
if (s2sBidRequest.ad_units.length) {
let doneCbs = uniqueServerRequests.map(bidRequest => {
bidRequest.start = timestamp();
Expand All @@ -396,8 +391,7 @@ adapterManager.callBids = (adUnits, bidRequests, addBidResponse, doneCb, request

// fire BID_REQUESTED event for each s2s bidRequest
uniqueServerRequests.forEach(bidRequest => {
// add the new sourceTid
events.emit(CONSTANTS.EVENTS.BID_REQUESTED, {...bidRequest, tid: sourceTid});
events.emit(CONSTANTS.EVENTS.BID_REQUESTED, bidRequest);
});

// make bid requests
Expand Down
21 changes: 2 additions & 19 deletions test/spec/modules/prebidServerBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -507,17 +507,6 @@ describe('S2S Adapter', function () {
resetSyncedStatus();
});

it('should set id to auction ID and source.tid to tid', function () {
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('173afb6d132ba3');
expect(requestBid.source).to.be.an('object');
expect(requestBid.source.tid).to.equal('437fbbf5-33f5-487a-8e16-a7112903cfe5');
});

it('should block request if config did not define p1Consent URL in endpoint object config', function() {
let badConfig = utils.deepClone(CONFIG);
badConfig.endpoint = { noP1Consent: 'https://prebid.adnxs.com/pbs/v1/openrtb2/auction' };
Expand Down Expand Up @@ -1716,7 +1705,7 @@ describe('S2S Adapter', function () {
expect(parsedRequestBody.ext.prebid.channel).to.deep.equal({name: 'pbjs', version: 'v$prebid.version$'});
});

it('extPrebid is now mergedDeep -> should include default channel as well', () => {
it('does not set pbjs version in request if channel does exist in s2sConfig', () => {
const s2sBidRequest = utils.deepClone(REQUEST);
const bidRequests = utils.deepClone(BID_REQUESTS);

Expand All @@ -1725,13 +1714,7 @@ describe('S2S Adapter', function () {
adapter.callBids(s2sBidRequest, bidRequests, addBidResponse, done, ajax);

const parsedRequestBody = JSON.parse(server.requests[0].requestBody);

// extPrebid is now deep merged with
expect(parsedRequestBody.ext.prebid.channel).to.deep.equal({
name: 'pbjs',
test: 1,
version: 'v$prebid.version$'
});
expect(parsedRequestBody.ext.prebid.channel).to.deep.equal({test: 1});
});

it('passes first party data in request', () => {
Expand Down
23 changes: 4 additions & 19 deletions test/spec/unit/core/adapterManager_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ describe('adapterManager tests', function () {
'bidderCode': 'appnexus',
'auctionId': '1863e370099523',
'bidderRequestId': '2946b569352ef2',
'uniquePbsTid': '34566b569352ef2',
'tid': '34566b569352ef2',
'bids': [
{
'bidder': 'appnexus',
Expand Down Expand Up @@ -479,7 +479,7 @@ describe('adapterManager tests', function () {
'bidderCode': 'appnexus',
'auctionId': '1863e370099523',
'bidderRequestId': '2946b569352ef2',
'uniquePbsTid': '34566b569352ef2',
'tid': '34566b569352ef2',
'timeout': 1000,
'src': 's2s',
'adUnitsS2SCopy': [
Expand Down Expand Up @@ -708,7 +708,7 @@ describe('adapterManager tests', function () {
'bidderCode': 'appnexus',
'auctionId': '1863e370099523',
'bidderRequestId': '2946b569352ef2',
'uniquePbsTid': '34566b569352ef2',
'tid': '34566b569352ef2',
'timeout': 1000,
'src': 's2s',
'adUnitsS2SCopy': [
Expand Down Expand Up @@ -844,7 +844,7 @@ describe('adapterManager tests', function () {
'bidderCode': 'pubmatic',
'auctionId': '1863e370099523',
'bidderRequestId': '2946b569352ef2',
'uniquePbsTid': '2342342342lfi23',
'tid': '2342342342lfi23',
'timeout': 1000,
'src': 's2s',
'adUnitsS2SCopy': [
Expand Down Expand Up @@ -1041,21 +1041,6 @@ describe('adapterManager tests', function () {
sinon.assert.calledTwice(prebidServerAdapterMock.callBids);
});

it('should have one tid for ALL s2s bidRequests', function () {
let adUnits = utils.deepClone(getAdUnits()).map(adUnit => {
adUnit.bids = adUnit.bids.filter(bid => includes(['appnexus', 'pubmatic'], bid.bidder));
return adUnit;
})
let bidRequests = adapterManager.makeBidRequests(adUnits, 1111, 2222, 1000);
adapterManager.callBids(adUnits, bidRequests, () => {}, () => {});
sinon.assert.calledTwice(prebidServerAdapterMock.callBids);
const firstBid = prebidServerAdapterMock.callBids.firstCall.args[0];
const secondBid = prebidServerAdapterMock.callBids.secondCall.args[0];

// TIDS should be the same
expect(firstBid.tid).to.equal(secondBid.tid);
});

it('should fire for simultaneous s2s and client requests', function () {
adapterManager.bidderRegistry['adequant'] = adequantAdapterMock;
let adUnits = utils.deepClone(getAdUnits()).map(adUnit => {
Expand Down