Skip to content
This repository was archived by the owner on Mar 12, 2025. It is now read-only.

Commit d5d5e34

Browse files
bengel-iassnapwich
authored andcommitted
Pet 239 ias bid adapter bug fix for multiple slots (prebid#2653)
* PET-239 IAS bid adapter multiple slot fix (#1) * PET-239 Fix. Performs the request for multiple slots on 1 call. * PET-239 Fixed Prebid tests * PET-239 Additional unit tests * Fixed errors for PR 2653 (#2) * Pet 239 ias bid adapter bug fix for multiple slots (#3) * Fixed errors for PR 2653 * Removed unnecessary block from iasBidAdapter from the comments in pull 2653
1 parent a2bb255 commit d5d5e34

File tree

2 files changed

+61
-5
lines changed

2 files changed

+61
-5
lines changed

modules/iasBidAdapter.js

+18-3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import { registerBidder } from 'src/adapters/bidderFactory';
33

44
const BIDDER_CODE = 'ias';
55

6+
const otherBidIds = [];
7+
68
function isBidRequestValid(bid) {
79
const { pubId, adUnitPath } = bid.params;
810
return !!(pubId && adUnitPath);
@@ -37,11 +39,11 @@ function stringifySlot(bidRequest) {
3739
}
3840

3941
function stringifyWindowSize() {
40-
return [window.innerWidth || -1, window.innerHeight || -1].join('.');
42+
return [ window.innerWidth || -1, window.innerHeight || -1 ].join('.');
4143
}
4244

4345
function stringifyScreenSize() {
44-
return [(window.screen && window.screen.width) || -1, (window.screen && window.screen.height) || -1].join('.');
46+
return [ (window.screen && window.screen.width) || -1, (window.screen && window.screen.height) || -1 ].join('.');
4547
}
4648

4749
function buildRequests(bidRequests) {
@@ -60,12 +62,18 @@ function buildRequests(bidRequests) {
6062

6163
const queryString = encodeURI(queries.map(qs => qs.join('=')).join('&'));
6264

65+
bidRequests.forEach(function (request) {
66+
if (bidRequests[0].bidId != request.bidId) {
67+
otherBidIds.push(request.bidId);
68+
}
69+
});
70+
6371
return {
6472
method: 'GET',
6573
url: IAS_HOST,
6674
data: queryString,
6775
bidRequest: bidRequests[0]
68-
}
76+
};
6977
}
7078

7179
function getPageLevelKeywords(response) {
@@ -103,6 +111,13 @@ function interpretResponse(serverResponse, request) {
103111
shallowMerge(commonBidResponse, getPageLevelKeywords(iasResponse));
104112
commonBidResponse.slots = iasResponse.slots;
105113
bidResponses.push(commonBidResponse);
114+
115+
otherBidIds.forEach(function (bidId) {
116+
var otherResponse = Object.assign({}, commonBidResponse);
117+
otherResponse.requestId = bidId;
118+
bidResponses.push(otherResponse);
119+
});
120+
106121
return bidResponses;
107122
}
108123

test/spec/modules/iasBidAdapter_spec.js

+43-2
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,9 @@ describe('iasBidAdapter is an adapter that', () => {
8989
url: IAS_HOST
9090
});
9191
});
92+
it('only includes the first `bidRequest` as the bidRequest variable on a multiple slot request', () => {
93+
expect(spec.buildRequests(bidRequests).bidRequest.adUnitCode).to.equal(bidRequests[0].adUnitCode);
94+
});
9295
describe('has property `data` that is an encode query string containing information such as', () => {
9396
let val;
9497
const ANID_PARAM = 'anId';
@@ -124,8 +127,41 @@ describe('iasBidAdapter is an adapter that', () => {
124127
expect(spec.interpretResponse).to.be.a('function');
125128
});
126129
describe('returns a list of bid response that', () => {
127-
let bidResponse, slots;
130+
let bidRequests, bidResponse, slots, serverResponse;
128131
beforeEach(() => {
132+
bidRequests = [
133+
{
134+
adUnitCode: 'one-div-id',
135+
auctionId: 'someAuctionId',
136+
bidId: 'someBidId1',
137+
bidder: 'ias',
138+
bidderRequestId: 'someBidderRequestId',
139+
params: {
140+
pubId: '1234',
141+
adUnitPath: '/a/b/c'
142+
},
143+
sizes: [
144+
[10, 20],
145+
[300, 400]
146+
],
147+
transactionId: 'someTransactionId'
148+
},
149+
{
150+
adUnitCode: 'two-div-id',
151+
auctionId: 'someAuctionId',
152+
bidId: 'someBidId2',
153+
bidder: 'ias',
154+
bidderRequestId: 'someBidderRequestId',
155+
params: {
156+
pubId: '1234',
157+
adUnitPath: '/d/e/f'
158+
},
159+
sizes: [
160+
[50, 60]
161+
],
162+
transactionId: 'someTransactionId'
163+
}
164+
];
129165
const request = {
130166
bidRequest: {
131167
bidId: '102938'
@@ -140,7 +176,7 @@ describe('iasBidAdapter is an adapter that', () => {
140176
id: '5678',
141177
vw: ['80', '90']
142178
};
143-
const serverResponse = {
179+
serverResponse = {
144180
body: {
145181
brandSafety: {
146182
adt: 'adtVal',
@@ -185,6 +221,11 @@ describe('iasBidAdapter is an adapter that', () => {
185221
it('has property `slots`', () => {
186222
expect(bidResponse[0]).to.deep.include({ slots: slots });
187223
});
224+
it('response is the same for multiple slots', () => {
225+
var adapter = spec;
226+
var requests = adapter.buildRequests(bidRequests);
227+
expect(adapter.interpretResponse(serverResponse, requests)).to.length(2);
228+
});
188229
});
189230
});
190231
});

0 commit comments

Comments
 (0)