Skip to content

Commit

Permalink
omit empty targeting value (#7366)
Browse files Browse the repository at this point in the history
  • Loading branch information
robertrmartinez authored Sep 8, 2021
1 parent ab4a664 commit 5e11575
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion modules/rubiconAnalyticsAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ function stringProperties(obj) {
} else if (typeof value !== 'string') {
value = String(value);
}
newObj[prop] = value;
newObj[prop] = value || undefined;
return newObj;
}, {});
}
Expand Down
22 changes: 22 additions & 0 deletions test/spec/modules/rubiconAnalyticsAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -987,6 +987,28 @@ describe('rubicon analytics adapter', function () {
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);
events.emit(BID_RESPONSE, MOCK.BID_RESPONSE[0]);
events.emit(BID_RESPONSE, MOCK.BID_RESPONSE[1]);
events.emit(BIDDER_DONE, MOCK.BIDDER_DONE);
events.emit(AUCTION_END, MOCK.AUCTION_END);

const mockTargeting = utils.deepClone(MOCK.SET_TARGETING);
mockTargeting['/19968336/header-bid-tag-0'].hb_test = '';
mockTargeting['/19968336/header-bid-tag1'].hb_test = 'NOT_EMPTY';
events.emit(SET_TARGETING, mockTargeting);

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].adserverTargeting.hb_test).to.be.undefined;
expect(message.auctions[0].adUnits[1].adserverTargeting.hb_test).to.equal('NOT_EMPTY');
});

function performFloorAuction(provider) {
let auctionInit = utils.deepClone(MOCK.AUCTION_INIT);
auctionInit.bidderRequests[0].bids[0].floorData = {
Expand Down

0 comments on commit 5e11575

Please sign in to comment.