Skip to content

Commit

Permalink
Only set dimensions if can be resolved (#5769)
Browse files Browse the repository at this point in the history
  • Loading branch information
robertrmartinez authored Sep 21, 2020
1 parent 8ef4f9d commit 7c9c60d
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 5 deletions.
9 changes: 5 additions & 4 deletions modules/rubiconAnalyticsAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -328,10 +328,11 @@ export function parseBidResponse(bid, previousBidResponse, auctionFloorData) {
'dealId',
'status',
'mediaType',
'dimensions', () => utils.pick(bid, [
'width',
'height'
]),
'dimensions', () => {
const width = bid.width || bid.playerWidth;
const height = bid.height || bid.playerHeight;
return (width && height) ? {width, height} : undefined;
},
'seatBidId',
'floorValue', () => utils.deepAccess(bid, 'floorData.floorValue'),
'floorRule', () => utils.debugTurnedOn() ? utils.deepAccess(bid, 'floorData.floorRule') : undefined
Expand Down
35 changes: 35 additions & 0 deletions test/spec/modules/rubiconAnalyticsAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -687,6 +687,41 @@ describe('rubicon analytics adapter', function () {
expect(message).to.deep.equal(ANALYTICS_MESSAGE);
});

it('should handle bidResponse dimensions correctly', function () {
events.emit(AUCTION_INIT, MOCK.AUCTION_INIT);
events.emit(BID_REQUESTED, MOCK.BID_REQUESTED);

// mock bid response with playerWidth and playerHeight (NO width and height)
let bidResponse1 = utils.deepClone(MOCK.BID_RESPONSE[0]);
delete bidResponse1.width;
delete bidResponse1.height;
bidResponse1.playerWidth = 640;
bidResponse1.playerHeight = 480;

// mock bid response with no width height or playerwidth playerheight
let bidResponse2 = utils.deepClone(MOCK.BID_RESPONSE[1]);
delete bidResponse2.width;
delete bidResponse2.height;
delete bidResponse2.playerWidth;
delete bidResponse2.playerHeight;

events.emit(BID_RESPONSE, bidResponse1);
events.emit(BID_RESPONSE, bidResponse2);
events.emit(BIDDER_DONE, MOCK.BIDDER_DONE);
events.emit(AUCTION_END, MOCK.AUCTION_END);
events.emit(SET_TARGETING, MOCK.SET_TARGETING);
events.emit(BID_WON, MOCK.BID_WON[0]);
events.emit(BID_WON, MOCK.BID_WON[1]);

let message = JSON.parse(server.requests[0].requestBody);
validate(message);
expect(message.auctions[0].adUnits[0].bids[0].bidResponse.dimensions).to.deep.equal({
width: 640,
height: 480
});
expect(message.auctions[0].adUnits[1].bids[0].bidResponse.dimensions).to.equal(undefined);
});

function performFloorAuction(provider) {
let auctionInit = utils.deepClone(MOCK.AUCTION_INIT);
auctionInit.bidderRequests[0].bids[0].floorData = {
Expand Down
1 change: 0 additions & 1 deletion test/spec/modules/rubiconAnalyticsSchema.json
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,6 @@
"bidResponse": {
"type": "object",
"required": [
"dimensions",
"mediaType",
"bidPriceUSD"
],
Expand Down

0 comments on commit 7c9c60d

Please sign in to comment.