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

Only set dimensions if can be resolved #5769

Merged
merged 1 commit into from
Sep 21, 2020
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
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