Skip to content

Commit

Permalink
Grab sourceAgnostic IDs first, then fallback to regular IDs (#6400)
Browse files Browse the repository at this point in the history
  • Loading branch information
robertrmartinez authored Mar 10, 2021
1 parent 89d5d41 commit 20f3cd8
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 8 deletions.
4 changes: 2 additions & 2 deletions modules/rubiconAnalyticsAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -482,8 +482,8 @@ function subscribeToGamSlots() {
// these come in as `null` from Gpt, which when stringified does not get removed
// so set explicitly to undefined when not a number
'advertiserId', advertiserId => utils.isNumber(advertiserId) ? advertiserId : undefined,
'creativeId', creativeId => utils.isNumber(creativeId) ? creativeId : undefined,
'lineItemId', lineItemId => utils.isNumber(lineItemId) ? lineItemId : undefined,
'creativeId', creativeId => utils.isNumber(event.sourceAgnosticCreativeId) ? event.sourceAgnosticCreativeId : utils.isNumber(creativeId) ? creativeId : undefined,
'lineItemId', lineItemId => utils.isNumber(event.sourceAgnosticLineItemId) ? event.sourceAgnosticLineItemId : utils.isNumber(lineItemId) ? lineItemId : undefined,
'adSlot', () => event.slot.getAdUnitPath(),
'isSlotEmpty', () => event.isEmpty || undefined
]);
Expand Down
44 changes: 38 additions & 6 deletions test/spec/modules/rubiconAnalyticsAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1436,8 +1436,8 @@ describe('rubicon analytics adapter', function () {
slot: gptSlot0,
isEmpty: false,
advertiserId: 1111,
creativeId: 2222,
lineItemId: 3333
sourceAgnosticCreativeId: 2222,
sourceAgnosticLineItemId: 3333
}
};

Expand All @@ -1448,8 +1448,8 @@ describe('rubicon analytics adapter', function () {
slot: gptSlot1,
isEmpty: false,
advertiserId: 4444,
creativeId: 5555,
lineItemId: 6666
sourceAgnosticCreativeId: 5555,
sourceAgnosticLineItemId: 6666
}
};
});
Expand Down Expand Up @@ -1515,8 +1515,8 @@ describe('rubicon analytics adapter', function () {
slot: gptSlot1,
isEmpty: false,
advertiserId: 0,
creativeId: 0,
lineItemId: 0
sourceAgnosticCreativeId: 0,
sourceAgnosticLineItemId: 0
}
}]);
expect(server.requests.length).to.equal(1);
Expand All @@ -1540,6 +1540,38 @@ describe('rubicon analytics adapter', function () {
expect(message).to.deep.equal(expectedMessage);
});

it('should pick backup Ids if no sourceAgnostic available first', function () {
performStandardAuction([gptSlotRenderEnded0, {
eventName: 'slotRenderEnded',
params: {
slot: gptSlot1,
isEmpty: false,
advertiserId: 0,
lineItemId: 1234,
creativeId: 5678
}
}]);
expect(server.requests.length).to.equal(1);
let request = server.requests[0];
let message = JSON.parse(request.requestBody);
validate(message);

let expectedMessage = utils.deepClone(ANALYTICS_MESSAGE);
expectedMessage.auctions[0].adUnits[0].gam = {
advertiserId: 1111,
creativeId: 2222,
lineItemId: 3333,
adSlot: '/19968336/header-bid-tag-0'
};
expectedMessage.auctions[0].adUnits[1].gam = {
advertiserId: 0,
creativeId: 5678,
lineItemId: 1234,
adSlot: '/19968336/header-bid-tag1'
};
expect(message).to.deep.equal(expectedMessage);
});

it('should correctly set adUnit for associated slots', function () {
performStandardAuction([gptSlotRenderEnded0, gptSlotRenderEnded1]);
expect(server.requests.length).to.equal(1);
Expand Down

0 comments on commit 20f3cd8

Please sign in to comment.