Skip to content

Commit

Permalink
kargo sizes and full bid request object (#3771)
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelhorwitz authored and Isaac Dettman committed Apr 30, 2019
1 parent e31b9d8 commit d6eeb31
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 5 deletions.
10 changes: 8 additions & 2 deletions modules/kargoBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ export const spec = {
const currencyObj = config.getConfig('currency');
const currency = (currencyObj && currencyObj.adServerCurrency) || 'USD';
const bidIds = {};
utils._each(validBidRequests, bid => bidIds[bid.bidId] = bid.params.placementId);
const bidSizes = {};
utils._each(validBidRequests, bid => {
bidIds[bid.bidId] = bid.params.placementId;
bidSizes[bid.bidId] = bid.sizes;
});
const transformedParams = Object.assign({}, {
timeout: bidderRequest.timeout,
currency: currency,
Expand All @@ -27,7 +31,9 @@ export const spec = {
floor: 0,
ceil: 20
},
bidIDs: bidIds
bidIDs: bidIds,
bidSizes: bidSizes,
prebidRawBidRequests: validBidRequests
}, spec._getAllMetadata());
const encodedParams = encodeURIComponent(JSON.stringify(transformedParams));
return Object.assign({}, bidderRequest, {
Expand Down
52 changes: 49 additions & 3 deletions test/spec/modules/kargoBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,19 +57,22 @@ describe('kargo adapter tests', function () {
params: {
placementId: 'foo'
},
bidId: 1
bidId: 1,
sizes: [[320, 50], [300, 250], [300, 600]]
},
{
params: {
placementId: 'bar'
},
bidId: 2
bidId: 2,
sizes: [[320, 50], [300, 250], [300, 600]]
},
{
params: {
placementId: 'bar'
},
bidId: 3
bidId: 3,
sizes: [[320, 50], [300, 250], [300, 600]]
}
];
});
Expand Down Expand Up @@ -185,6 +188,14 @@ describe('kargo adapter tests', function () {
setCookie('krg_crb', getInvalidKrgCrbType3OldStyle());
}

function getInvalidKrgCrbType4OldStyle() {
return '%7B%22v%22%3A%22bnVsbA%3D%3D%22%7D';
}

function initializeInvalidKrgCrbType4Cookie() {
setCookie('krg_crb', getInvalidKrgCrbType4OldStyle());
}

function getEmptyKrgCrb() {
return 'eyJleHBpcmVUaW1lIjoxNDk3NDQ5MzgyNjY4LCJsYXN0U3luY2VkQXQiOjE0OTczNjI5NzkwMTJ9';
}
Expand Down Expand Up @@ -216,6 +227,11 @@ describe('kargo adapter tests', function () {
2: 'bar',
3: 'bar'
},
bidSizes: {
1: [[320, 50], [300, 250], [300, 600]],
2: [[320, 50], [300, 250], [300, 600]],
3: [[320, 50], [300, 250], [300, 600]]
},
userIDs: {
kargoID: '5f108831-302d-11e7-bf6b-4595acd3bf6c',
clientID: '2410d8f2-c111-4811-88a5-7b5e190e475f',
Expand All @@ -241,6 +257,29 @@ describe('kargo adapter tests', function () {
]
},
pageURL: window.location.href,
prebidRawBidRequests: [
{
bidId: 1,
params: {
placementId: 'foo'
},
sizes: [[320, 50], [300, 250], [300, 600]]
},
{
bidId: 2,
params: {
placementId: 'bar'
},
sizes: [[320, 50], [300, 250], [300, 600]]
},
{
bidId: 3,
params: {
placementId: 'bar'
},
sizes: [[320, 50], [300, 250], [300, 600]]
}
],
rawCRB: expectedRawCRBCookie,
rawCRBLocalStorage: expectedRawCRB
};
Expand Down Expand Up @@ -339,6 +378,13 @@ describe('kargo adapter tests', function () {
testBuildRequests(getExpectedKrakenParams(true, undefined, null, getInvalidKrgCrbType3OldStyle()));
});

it('handles broken Kargo CRBs where inner JSON is falsey', function() {
initializeKruxUser();
initializeKruxSegments();
initializeInvalidKrgCrbType4Cookie();
testBuildRequests(getExpectedKrakenParams(true, undefined, null, getInvalidKrgCrbType4OldStyle()));
});

it('handles a non-existant currency object on the config', function() {
simulateNoCurrencyObject();
initializeKruxUser();
Expand Down

0 comments on commit d6eeb31

Please sign in to comment.