Skip to content

Commit

Permalink
handle weird advertiserDomain scenarios (#7908)
Browse files Browse the repository at this point in the history
  • Loading branch information
robertrmartinez authored Jan 13, 2022
1 parent 4183f5d commit a897fa6
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
5 changes: 3 additions & 2 deletions modules/rubiconAnalyticsAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -384,8 +384,9 @@ export function parseBidResponse(bid, previousBidResponse, auctionFloorData) {
'floorRuleValue', () => deepAccess(bid, 'floorData.floorRuleValue'),
'floorRule', () => debugTurnedOn() ? deepAccess(bid, 'floorData.floorRule') : undefined,
'adomains', () => {
let adomains = deepAccess(bid, 'meta.advertiserDomains');
return Array.isArray(adomains) && adomains.length > 0 ? adomains.slice(0, 10) : undefined
const adomains = deepAccess(bid, 'meta.advertiserDomains');
const validAdomains = Array.isArray(adomains) && adomains.filter(domain => typeof domain === 'string');
return validAdomains && validAdomains.length > 0 ? validAdomains.slice(0, 10) : undefined
}
]);
}
Expand Down
30 changes: 30 additions & 0 deletions test/spec/modules/rubiconAnalyticsAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -987,6 +987,36 @@ describe('rubicon analytics adapter', function () {
expect(message.auctions[0].adUnits[1].bids[0].bidResponse.adomains).to.be.undefined;
});

it('should NOT pass along adomians with other edge cases', function () {
events.emit(AUCTION_INIT, MOCK.AUCTION_INIT);
events.emit(BID_REQUESTED, MOCK.BID_REQUESTED);

// should filter out non string values and pass valid ones
let bidResponse1 = utils.deepClone(MOCK.BID_RESPONSE[0]);
bidResponse1.meta = {
advertiserDomains: [123, 'prebid.org', false, true, [], 'magnite.com', {}]
}

// array of arrays (as seen when passed by kargo bid adapter)
let bidResponse2 = utils.deepClone(MOCK.BID_RESPONSE[1]);
bidResponse2.meta = {
advertiserDomains: [['prebid.org']]
}

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.adomains).to.deep.equal(['prebid.org', 'magnite.com']);
expect(message.auctions[0].adUnits[1].bids[0].bidResponse.adomains).to.be.undefined;
});

it('should not pass empty adServerTargeting values', function () {
events.emit(AUCTION_INIT, MOCK.AUCTION_INIT);
events.emit(BID_REQUESTED, MOCK.BID_REQUESTED);
Expand Down

0 comments on commit a897fa6

Please sign in to comment.