Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missena Bid Adapter : send bid sizes #12560

Merged
merged 3 commits into from
Jan 15, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions modules/missenaBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {
buildUrl,
formatQS,
generateUUID,
isArray,
isFn,
logInfo,
safeJSONParse,
Expand Down Expand Up @@ -46,6 +47,25 @@ function getFloor(bidRequest) {
}
}

/* turn bid sizes into size object array */
function normalizeSizes(bidSizes) {
pdamoc marked this conversation as resolved.
Show resolved Hide resolved
let sizes = [];
if (isArray(bidSizes) && bidSizes.length === 2 && !isArray(bidSizes[0])) {
sizes.push({
width: parseInt(bidSizes[0], 10),
height: parseInt(bidSizes[1], 10),
});
} else if (isArray(bidSizes) && isArray(bidSizes[0])) {
bidSizes.forEach((size) => {
sizes.push({
width: parseInt(size[0], 10),
height: parseInt(size[1], 10),
});
});
}
return sizes;
}

/* Helper function that converts the prebid data to the payload expected by our servers */
function toPayload(bidRequest, bidderRequest) {
const payload = {
Expand Down Expand Up @@ -87,6 +107,7 @@ function toPayload(bidRequest, bidderRequest) {
payload.coppa = bidderRequest?.ortb2?.regs?.coppa ? 1 : 0;
payload.autoplay = isAutoplayEnabled() === true ? 1 : 0;
payload.screen = { height: screen.height, width: screen.width };
payload.sizes = normalizeSizes(bidRequest.mediaTypes.banner.sizes);

return {
method: 'POST',
Expand Down
15 changes: 12 additions & 3 deletions test/spec/modules/missenaBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ describe('Missena Adapter', function () {
const bid = {
bidder: 'missena',
bidId: bidId,
sizes: [[1, 1]],
mediaTypes: { banner: { sizes: [[1, 1]] } },
ortb2: {
device: {
Expand Down Expand Up @@ -55,14 +54,14 @@ describe('Missena Adapter', function () {
const bidWithoutFloor = {
bidder: 'missena',
bidId: bidId,
sizes: [[1, 1]],
mediaTypes: { banner: { sizes: [[1, 1]] } },
mediaTypes: { banner: { sizes: [1, 1] } },
params: {
apiKey: API_KEY,
placement: 'sticky',
formats: ['sticky-banner'],
},
};

const consentString = 'AAAAAAAAA==';

const bidderRequest = {
Expand Down Expand Up @@ -178,6 +177,16 @@ describe('Missena Adapter', function () {
expect(payload.screen.height).to.equal(screen.height);
});

it('should send size', function () {
expect(payload.sizes[0].width).to.equal(1);
expect(payload.sizes[0].height).to.equal(1);
});

it('should send single size', function () {
expect(payloadNoFloor.sizes[0].width).to.equal(1);
expect(payloadNoFloor.sizes[0].height).to.equal(1);
});

getDataFromLocalStorageStub.restore();
getDataFromLocalStorageStub = sinon.stub(
storage,
Expand Down
Loading