Skip to content

Commit

Permalink
take meta mediaType into account (#12700)
Browse files Browse the repository at this point in the history
  • Loading branch information
robertrmartinez authored Jan 30, 2025
1 parent 6d9e068 commit d7e4b7f
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
3 changes: 2 additions & 1 deletion modules/magniteAnalyticsAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,8 @@ export const parseBidResponse = (bid, previousBidResponse) => {
return pick(bid, [
'bidPriceUSD', () => responsePrice,
'dealId', dealId => dealId || undefined,
'mediaType',
'mediaType', () => bid?.meta?.mediaType ?? bid.mediaType,
'ogMediaType', () => bid?.meta?.mediaType && bid.mediaType !== bid?.meta?.mediaType ? bid.mediaType : undefined,
'dimensions', () => {
const width = bid.width || bid.playerWidth;
const height = bid.height || bid.playerHeight;
Expand Down
28 changes: 28 additions & 0 deletions test/spec/modules/magniteAnalyticsAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -759,6 +759,34 @@ describe('magnite analytics adapter', function () {
expect(message.auctions[0].adUnits[0].bids[0].bidResponse.networkId).to.equal(test.expected);
});
});

// meta mediatype handler things
[
{ input: undefined, expected: 'banner', hasOg: false },
{ input: 'banner', expected: 'banner', hasOg: false },
{ input: 'video', expected: 'video', hasOg: true }
].forEach((test, index) => {
it(`should handle meta mediaType stuff correctly - #${index + 1}`, function () {
events.emit(AUCTION_INIT, MOCK.AUCTION_INIT);
events.emit(BID_REQUESTED, MOCK.BID_REQUESTED);

let bidResponse = utils.deepClone(MOCK.BID_RESPONSE);
bidResponse.meta = {
mediaType: test.input
};

events.emit(BID_RESPONSE, bidResponse);
events.emit(BIDDER_DONE, MOCK.BIDDER_DONE);
events.emit(AUCTION_END, MOCK.AUCTION_END);
events.emit(BID_WON, MOCK.BID_WON);
clock.tick(rubiConf.analyticsBatchTimeout + 1000);

let message = JSON.parse(server.requests[0].requestBody);
expect(message.auctions[0].adUnits[0].bids[0].bidResponse.mediaType).to.equal(test.expected);
if (test.hasOg) expect(message.auctions[0].adUnits[0].bids[0].bidResponse.ogMediaType).to.equal('banner');
else expect(message.auctions[0].adUnits[0].bids[0].bidResponse).to.not.haveOwnProperty('ogMediaType');
});
});
});

describe('with session handling', function () {
Expand Down

0 comments on commit d7e4b7f

Please # to comment.