Skip to content

Commit

Permalink
Merge pull request #806 from PubMatic-OpenWrap/nightly_30jan
Browse files Browse the repository at this point in the history
Nightly for 30th Jan release
  • Loading branch information
kapil-tuptewar authored Jan 30, 2024
2 parents 5e0ee11 + 55869a8 commit dee544e
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 22 deletions.
44 changes: 23 additions & 21 deletions modules/pubmaticBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -1038,9 +1038,9 @@ function hasGetRequestEnabled() {
return randomValue100 <= testGroupPercentage;
}

function getUniqueNumber(rangeEnd) {
return Math.floor(Math.random() * rangeEnd) + 1;
}
// function getUniqueNumber(rangeEnd) {
// return Math.floor(Math.random() * rangeEnd) + 1;
// }

export const spec = {
code: BIDDER_CODE,
Expand Down Expand Up @@ -1317,35 +1317,36 @@ export const spec = {
delete payload.site;
}

const correlator = getUniqueNumber(1000);
let url = ENDPOINT + '?source=ow-client&correlator=' + correlator;
// const correlator = getUniqueNumber(1000);
// let url = ENDPOINT + '?source=ow-client&correlator=' + correlator;

let serverRequest = {
method: 'POST',
url: url,
url: ENDPOINT + '?source=ow-client',
data: JSON.stringify(payload),
bidderRequest: bidderRequest
};

// Allow translator request to execute it as GET Methoid if flag is set.
if (hasGetRequestEnabled()) {
// For Auction End Handler
if (bidderRequest) {
bidderRequest = bidderRequest || {};
bidderRequest.nwMonitor = {};
bidderRequest.nwMonitor.reqMethod = 'POST';
bidderRequest.nwMonitor.correlator = correlator;
bidderRequest.nwMonitor.requestUrlPayloadLength = url.length + JSON.stringify(payload).length;
// For Timeout handler
if (bidderRequest?.bids?.length && isArray(bidderRequest?.bids)) {
bidderRequest.bids.forEach(bid => bid.correlator = correlator);
}
}
// // nwMonitor object is used to identify the network latency, it is being no longer used.
// // For Auction End Handler
// if (bidderRequest) {
// bidderRequest = bidderRequest || {};
// bidderRequest.nwMonitor = {};
// bidderRequest.nwMonitor.reqMethod = 'POST';
// bidderRequest.nwMonitor.correlator = correlator;
// bidderRequest.nwMonitor.requestUrlPayloadLength = url.length + JSON.stringify(payload).length;
// // For Timeout handler
// if (bidderRequest?.bids?.length && isArray(bidderRequest?.bids)) {
// bidderRequest.bids.forEach(bid => bid.correlator = correlator);
// }
// }

const maxUrlLength = config.getConfig('translatorGetRequest.maxUrlLength') || 63000;
const configuredEndPoint = config.getConfig('translatorGetRequest.endPoint') || ENDPOINT;
const urlEncodedPayloadStr = parseQueryStringParameters({
'source': 'ow-client', 'payload': JSON.stringify(payload), 'correlator': correlator});
'source': 'ow-client', 'payload': JSON.stringify(payload)});
if ((configuredEndPoint + '?' + urlEncodedPayloadStr)?.length <= maxUrlLength) {
serverRequest = {
method: 'GET',
Expand All @@ -1354,8 +1355,9 @@ export const spec = {
bidderRequest: bidderRequest,
payloadStr: JSON.stringify(payload)
};
bidderRequest.nwMonitor.reqMethod = 'GET';
bidderRequest.nwMonitor.requestUrlPayloadLength = configuredEndPoint.length + '?'.length + urlEncodedPayloadStr.length;

// bidderRequest.nwMonitor.reqMethod = 'GET';
// bidderRequest.nwMonitor.requestUrlPayloadLength = configuredEndPoint.length + '?'.length + urlEncodedPayloadStr.length;
}
}

Expand Down
2 changes: 1 addition & 1 deletion test/spec/modules/pubmaticBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1069,7 +1069,7 @@ describe('PubMatic adapter', function () {
let request = spec.buildRequests(bidRequests, {
auctionId: 'new-auction-id'
});
const regExp = new RegExp('https://hbopenbid.pubmatic.com/translator\\?source=ow-client\&correlator=');
const regExp = new RegExp('https://hbopenbid.pubmatic.com/translator\\?source=ow-client');
expect(request.url).to.match(regExp);
expect(request.method).to.equal('POST');
});
Expand Down

0 comments on commit dee544e

Please sign in to comment.