Skip to content

Commit 4486b4f

Browse files
committed
convert bidders: iqm
1 parent f95f031 commit 4486b4f

File tree

2 files changed

+172
-29
lines changed

2 files changed

+172
-29
lines changed

modules/iqmBidAdapter.js

Lines changed: 7 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ export const spec = {
102102
imp.video = _buildVideoORTB(bid);
103103
imp.mediatype = 'video';
104104
}
105-
const site = getSite(bid);
105+
const site = getSite(bidderRequest);
106106
let device = getDevice(bid.params);
107107
finalRequest = {
108108
sizes: bid.sizes,
@@ -116,6 +116,8 @@ export const spec = {
116116
adUnitCode: bid.adUnitCode,
117117
bidderRequestId: bid.bidderRequestId,
118118
uuid: bid.bidId,
119+
// TODO: please do not send internal data structures over the network
120+
// I am not going to attempt to accomodate this, no way this is usable on their end, it changes way too frequently
119121
bidderRequest
120122
}
121123
const request = {
@@ -227,19 +229,10 @@ function getSite(bidderRequest) {
227229

228230
const {refererInfo} = bidderRequest;
229231

230-
if (canAccessTopWindow()) {
231-
const wt = getWindowTop();
232-
domain = wt.location.hostname;
233-
page = wt.location.href;
234-
referrer = wt.document.referrer || '';
235-
} else if (refererInfo.reachedTop) {
236-
const url = parseUrl(refererInfo.referer);
237-
domain = url.hostname;
238-
page = refererInfo.referer;
239-
} else if (refererInfo.stack && refererInfo.stack.length && refererInfo.stack[0]) {
240-
const url = parseUrl(refererInfo.stack[0]);
241-
domain = url.hostname;
242-
}
232+
// TODO: are these the right refererInfo values?
233+
domain = refererInfo.domain;
234+
page = refererInfo.page;
235+
referrer = refererInfo.ref;
243236

244237
return {
245238
domain,
@@ -249,16 +242,6 @@ function getSite(bidderRequest) {
249242
};
250243
};
251244

252-
function canAccessTopWindow() {
253-
try {
254-
if (getWindowTop().location.href) {
255-
return true;
256-
}
257-
} catch (error) {
258-
return false;
259-
}
260-
}
261-
262245
function _buildVideoORTB(bidRequest) {
263246
const videoAdUnit = deepAccess(bidRequest, 'mediaTypes.video');
264247
const videoBidderParams = deepAccess(bidRequest, 'params.video', {});

test/spec/modules/iqmBidAdapter_spec.js

Lines changed: 165 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,41 @@ describe('iqmAdapter', function () {
116116
bidderRequestsCount: 1,
117117
bidderWinsCount: 0}];
118118

119-
let bidderRequest = {bidderCode: 'iqm', auctionId: '565ab569-ab95-40d6-8b42-b9707a92062f', bidderRequestId: '13c05d264c7ffe', bids: [{bidder: 'iqm', params: {publisherId: 'df5fd732-c5f3-11e7-abc4-cec278b6b50a', placementId: 23451, bidfloor: 0.5}, crumbs: {pubcid: 'a0f51f64-6d86-41d0-abaf-7ece71404d94'}, fpd: {context: {pbAdSlot: '/19968336/header-bid-tag-0'}}, mediaTypes: {banner: {sizes: [[300, 250]]}}, adUnitCode: '/19968336/header-bid-tag-0', transactionId: '56fe8d92-ff6e-4c34-90ad-2f743cd0eae8', sizes: [[300, 250]], bidId: '266d810da21904', bidderRequestId: '13c05d264c7ffe', auctionId: '565ab569-ab95-40d6-8b42-b9707a92062f', src: 'client', bidRequestsCount: 1, bidderRequestsCount: 1, bidderWinsCount: 0}], auctionStart: 1615205942159, timeout: 7000, refererInfo: {referer: 'http://test.localhost:9999/integrationExamples/gpt/hello_world.html', reachedTop: true, isAmp: false, numIframes: 0, stack: ['http://test.localhost:9999/integrationExamples/gpt/hello_world.html'], canonicalUrl: null}, start: 1615205942162};
119+
let bidderRequest = {
120+
bidderCode: 'iqm',
121+
auctionId: '565ab569-ab95-40d6-8b42-b9707a92062f',
122+
bidderRequestId: '13c05d264c7ffe',
123+
bids: [{
124+
bidder: 'iqm',
125+
params: {publisherId: 'df5fd732-c5f3-11e7-abc4-cec278b6b50a', placementId: 23451, bidfloor: 0.5},
126+
crumbs: {pubcid: 'a0f51f64-6d86-41d0-abaf-7ece71404d94'},
127+
fpd: {context: {pbAdSlot: '/19968336/header-bid-tag-0'}},
128+
mediaTypes: {banner: {sizes: [[300, 250]]}},
129+
adUnitCode: '/19968336/header-bid-tag-0',
130+
transactionId: '56fe8d92-ff6e-4c34-90ad-2f743cd0eae8',
131+
sizes: [[300, 250]],
132+
bidId: '266d810da21904',
133+
bidderRequestId: '13c05d264c7ffe',
134+
auctionId: '565ab569-ab95-40d6-8b42-b9707a92062f',
135+
src: 'client',
136+
bidRequestsCount: 1,
137+
bidderRequestsCount: 1,
138+
bidderWinsCount: 0
139+
}],
140+
auctionStart: 1615205942159,
141+
timeout: 7000,
142+
refererInfo: {
143+
page: 'http://test.localhost:9999/integrationExamples/gpt/hello_world.html',
144+
domain: 'test.localhost.com:9999',
145+
ref: null,
146+
reachedTop: true,
147+
isAmp: false,
148+
numIframes: 0,
149+
stack: ['http://test.localhost:9999/integrationExamples/gpt/hello_world.html'],
150+
canonicalUrl: null
151+
},
152+
start: 1615205942162
153+
};
120154

121155
it('should parse out sizes', function () {
122156
let temp = [];
@@ -142,7 +176,52 @@ describe('iqmAdapter', function () {
142176
});
143177
it('should attach valid video params to the tag', function () {
144178
let validBidRequests_video = [{bidder: 'iqm', params: {publisherId: 'df5fd732-c5f3-11e7-abc4-cec278b6b50a', placementId: 23451, bidfloor: 0.5, video: {placement: 2, mimes: ['video/mp4'], protocols: [2, 5], skipppable: true, playback_method: ['auto_play_sound_off']}}, crumbs: {pubcid: '09b8f065-9d1b-4a36-bd0c-ea22e2dad807'}, fpd: {context: {pbAdSlot: 'video1'}}, mediaTypes: {video: {playerSize: [[640, 480]], context: 'instream'}}, adUnitCode: 'video1', transactionId: '86795c66-acf9-4dd5-998f-6d5362aaa541', sizes: [[640, 480]], bidId: '28bfb7e2d12897', bidderRequestId: '16e1ce8481bc6d', auctionId: '3140a2ec-d567-4db0-9bbb-eb6fa20ccb71', src: 'client', bidRequestsCount: 1, bidderRequestsCount: 1, bidderWinsCount: 0}];
145-
let bidderRequest_video = {bidderCode: 'iqm', auctionId: '3140a2ec-d567-4db0-9bbb-eb6fa20ccb71', bidderRequestId: '16e1ce8481bc6d', bids: [{bidder: 'iqm', params: {publisherId: 'df5fd732-c5f3-11e7-abc4-cec278b6b50a', placementId: 23451, bidfloor: 0.5, video: {placement: 2, mimes: ['video/mp4'], protocols: [2, 5], skipppable: true, playback_method: ['auto_play_sound_off']}}, crumbs: {pubcid: '09b8f065-9d1b-4a36-bd0c-ea22e2dad807'}, fpd: {context: {pbAdSlot: 'video1'}}, mediaTypes: {video: {playerSize: [[640, 480]], context: 'instream'}}, adUnitCode: 'video1', transactionId: '86795c66-acf9-4dd5-998f-6d5362aaa541', sizes: [[640, 480]], bidId: '28bfb7e2d12897', bidderRequestId: '16e1ce8481bc6d', auctionId: '3140a2ec-d567-4db0-9bbb-eb6fa20ccb71', src: 'client', bidRequestsCount: 1, bidderRequestsCount: 1, bidderWinsCount: 0}], auctionStart: 1615271191985, timeout: 3000, refererInfo: {referer: 'http://test.localhost:9999/integrationExamples/gpt/pbjs_video_adUnit.html', reachedTop: true, isAmp: false, numIframes: 0, stack: ['http://test.localhost:9999/integrationExamples/gpt/pbjs_video_adUnit.html'], canonicalUrl: null}, start: 1615271191988};
179+
let bidderRequest_video = {
180+
bidderCode: 'iqm',
181+
auctionId: '3140a2ec-d567-4db0-9bbb-eb6fa20ccb71',
182+
bidderRequestId: '16e1ce8481bc6d',
183+
bids: [{
184+
bidder: 'iqm',
185+
params: {
186+
publisherId: 'df5fd732-c5f3-11e7-abc4-cec278b6b50a',
187+
placementId: 23451,
188+
bidfloor: 0.5,
189+
video: {
190+
placement: 2,
191+
mimes: ['video/mp4'],
192+
protocols: [2, 5],
193+
skipppable: true,
194+
playback_method: ['auto_play_sound_off']
195+
}
196+
},
197+
crumbs: {pubcid: '09b8f065-9d1b-4a36-bd0c-ea22e2dad807'},
198+
fpd: {context: {pbAdSlot: 'video1'}},
199+
mediaTypes: {video: {playerSize: [[640, 480]], context: 'instream'}},
200+
adUnitCode: 'video1',
201+
transactionId: '86795c66-acf9-4dd5-998f-6d5362aaa541',
202+
sizes: [[640, 480]],
203+
bidId: '28bfb7e2d12897',
204+
bidderRequestId: '16e1ce8481bc6d',
205+
auctionId: '3140a2ec-d567-4db0-9bbb-eb6fa20ccb71',
206+
src: 'client',
207+
bidRequestsCount: 1,
208+
bidderRequestsCount: 1,
209+
bidderWinsCount: 0
210+
}],
211+
auctionStart: 1615271191985,
212+
timeout: 3000,
213+
refererInfo: {
214+
page: 'http://test.localhost:9999/integrationExamples/gpt/pbjs_video_adUnit.html',
215+
domain: 'test.localhost.com:9999',
216+
ref: null,
217+
reachedTop: true,
218+
isAmp: false,
219+
numIframes: 0,
220+
stack: ['http://test.localhost:9999/integrationExamples/gpt/pbjs_video_adUnit.html'],
221+
canonicalUrl: null
222+
},
223+
start: 1615271191988
224+
};
146225
const request = spec.buildRequests(validBidRequests_video, bidderRequest_video);
147226
const payload = request[0].data;
148227
expect(payload.imp.id).to.exist;
@@ -161,11 +240,13 @@ describe('iqmAdapter', function () {
161240
});
162241

163242
it('should add referer info to payload', function () {
243+
// TODO: this is wrong on multiple levels
244+
// The payload contains everything in `bidderRequest`; that is sometimes not even serializable
245+
// this should not be testing the validity of internal Prebid structures
164246
const request = spec.buildRequests(validBidRequests, bidderRequest);
165247
const payload = request[0].data;
166248

167249
expect(payload.bidderRequest.refererInfo).to.exist;
168-
expect(payload.bidderRequest.refererInfo).to.deep.equal({referer: 'http://test.localhost:9999/integrationExamples/gpt/hello_world.html', reachedTop: true, isAmp: false, numIframes: 0, stack: ['http://test.localhost:9999/integrationExamples/gpt/hello_world.html'], canonicalUrl: null});
169250
});
170251
})
171252

@@ -193,7 +274,41 @@ describe('iqmAdapter', function () {
193274
bidRequestsCount: 1,
194275
bidderRequestsCount: 1,
195276
bidderWinsCount: 0}];
196-
let bidderRequest = {bidderCode: 'iqm', auctionId: '565ab569-ab95-40d6-8b42-b9707a92062f', bidderRequestId: '13c05d264c7ffe', bids: [{bidder: 'iqm', params: {publisherId: 'df5fd732-c5f3-11e7-abc4-cec278b6b50a', placementId: 23451, bidfloor: 0.5}, crumbs: {pubcid: 'a0f51f64-6d86-41d0-abaf-7ece71404d94'}, fpd: {context: {pbAdSlot: '/19968336/header-bid-tag-0'}}, mediaTypes: {banner: {sizes: [[300, 250]]}}, adUnitCode: '/19968336/header-bid-tag-0', transactionId: '56fe8d92-ff6e-4c34-90ad-2f743cd0eae8', sizes: [[300, 250]], bidId: '266d810da21904', bidderRequestId: '13c05d264c7ffe', auctionId: '565ab569-ab95-40d6-8b42-b9707a92062f', src: 'client', bidRequestsCount: 1, bidderRequestsCount: 1, bidderWinsCount: 0}], auctionStart: 1615205942159, timeout: 7000, refererInfo: {referer: 'http://test.localhost:9999/integrationExamples/gpt/hello_world.html', reachedTop: true, isAmp: false, numIframes: 0, stack: ['http://test.localhost:9999/integrationExamples/gpt/hello_world.html'], canonicalUrl: null}, start: 1615205942162};
277+
let bidderRequest = {
278+
bidderCode: 'iqm',
279+
auctionId: '565ab569-ab95-40d6-8b42-b9707a92062f',
280+
bidderRequestId: '13c05d264c7ffe',
281+
bids: [{
282+
bidder: 'iqm',
283+
params: {publisherId: 'df5fd732-c5f3-11e7-abc4-cec278b6b50a', placementId: 23451, bidfloor: 0.5},
284+
crumbs: {pubcid: 'a0f51f64-6d86-41d0-abaf-7ece71404d94'},
285+
fpd: {context: {pbAdSlot: '/19968336/header-bid-tag-0'}},
286+
mediaTypes: {banner: {sizes: [[300, 250]]}},
287+
adUnitCode: '/19968336/header-bid-tag-0',
288+
transactionId: '56fe8d92-ff6e-4c34-90ad-2f743cd0eae8',
289+
sizes: [[300, 250]],
290+
bidId: '266d810da21904',
291+
bidderRequestId: '13c05d264c7ffe',
292+
auctionId: '565ab569-ab95-40d6-8b42-b9707a92062f',
293+
src: 'client',
294+
bidRequestsCount: 1,
295+
bidderRequestsCount: 1,
296+
bidderWinsCount: 0
297+
}],
298+
auctionStart: 1615205942159,
299+
timeout: 7000,
300+
refererInfo: {
301+
page: 'http://test.localhost:9999/integrationExamples/gpt/hello_world.html',
302+
domain: 'test.localhost.com:9999',
303+
ref: null,
304+
reachedTop: true,
305+
isAmp: false,
306+
numIframes: 0,
307+
stack: ['http://test.localhost:9999/integrationExamples/gpt/hello_world.html'],
308+
canonicalUrl: null
309+
},
310+
start: 1615205942162
311+
};
197312
let response = {
198313

199314
id: '5bdbab92aae961cfbdf7465d',
@@ -213,7 +328,52 @@ describe('iqmAdapter', function () {
213328

214329
let validBidRequests_temp_video =
215330
[{bidder: 'iqm', params: {publisherId: 'df5fd732-c5f3-11e7-abc4-cec278b6b50a', placementId: 23451, bidfloor: 0.5, video: {placement: 2, mimes: ['video/mp4'], protocols: [2, 5], skipppable: true, playback_method: ['auto_play_sound_off']}}, crumbs: {pubcid: 'cd86c3ff-d630-40e6-83ab-420e9e800594'}, fpd: {context: {pbAdSlot: 'video1'}}, mediaTypes: {video: {playerSize: [[640, 480]], context: 'instream'}}, adUnitCode: 'video1', transactionId: '8335b266-7a41-45f9-86a2-92fdc7cf0cd9', sizes: [[640, 480]], bidId: '26274beff25455', bidderRequestId: '17c5d8c3168761', auctionId: '2c592dcf-7dfc-4823-8203-dd1ebab77fe0', src: 'client', bidRequestsCount: 1, bidderRequestsCount: 1, bidderWinsCount: 0}];
216-
let bidderRequest_video = {bidderCode: 'iqm', auctionId: '3140a2ec-d567-4db0-9bbb-eb6fa20ccb71', bidderRequestId: '16e1ce8481bc6d', bids: [{bidder: 'iqm', params: {publisherId: 'df5fd732-c5f3-11e7-abc4-cec278b6b50a', placementId: 23451, bidfloor: 0.5, video: {placement: 2, mimes: ['video/mp4'], protocols: [2, 5], skipppable: true, playback_method: ['auto_play_sound_off']}}, crumbs: {pubcid: '09b8f065-9d1b-4a36-bd0c-ea22e2dad807'}, fpd: {context: {pbAdSlot: 'video1'}}, mediaTypes: {video: {playerSize: [[640, 480]], context: 'instream'}}, adUnitCode: 'video1', transactionId: '86795c66-acf9-4dd5-998f-6d5362aaa541', sizes: [[640, 480]], bidId: '28bfb7e2d12897', bidderRequestId: '16e1ce8481bc6d', auctionId: '3140a2ec-d567-4db0-9bbb-eb6fa20ccb71', src: 'client', bidRequestsCount: 1, bidderRequestsCount: 1, bidderWinsCount: 0}], auctionStart: 1615271191985, timeout: 3000, refererInfo: {referer: 'http://test.localhost:9999/integrationExamples/gpt/pbjs_video_adUnit.html', reachedTop: true, isAmp: false, numIframes: 0, stack: ['http://test.localhost:9999/integrationExamples/gpt/pbjs_video_adUnit.html'], canonicalUrl: null}, start: 1615271191988};
331+
let bidderRequest_video = {
332+
bidderCode: 'iqm',
333+
auctionId: '3140a2ec-d567-4db0-9bbb-eb6fa20ccb71',
334+
bidderRequestId: '16e1ce8481bc6d',
335+
bids: [{
336+
bidder: 'iqm',
337+
params: {
338+
publisherId: 'df5fd732-c5f3-11e7-abc4-cec278b6b50a',
339+
placementId: 23451,
340+
bidfloor: 0.5,
341+
video: {
342+
placement: 2,
343+
mimes: ['video/mp4'],
344+
protocols: [2, 5],
345+
skipppable: true,
346+
playback_method: ['auto_play_sound_off']
347+
}
348+
},
349+
crumbs: {pubcid: '09b8f065-9d1b-4a36-bd0c-ea22e2dad807'},
350+
fpd: {context: {pbAdSlot: 'video1'}},
351+
mediaTypes: {video: {playerSize: [[640, 480]], context: 'instream'}},
352+
adUnitCode: 'video1',
353+
transactionId: '86795c66-acf9-4dd5-998f-6d5362aaa541',
354+
sizes: [[640, 480]],
355+
bidId: '28bfb7e2d12897',
356+
bidderRequestId: '16e1ce8481bc6d',
357+
auctionId: '3140a2ec-d567-4db0-9bbb-eb6fa20ccb71',
358+
src: 'client',
359+
bidRequestsCount: 1,
360+
bidderRequestsCount: 1,
361+
bidderWinsCount: 0
362+
}],
363+
auctionStart: 1615271191985,
364+
timeout: 3000,
365+
refererInfo: {
366+
page: 'http://test.localhost:9999/integrationExamples/gpt/pbjs_video_adUnit.html',
367+
domain: 'test.localhost.com:9999',
368+
ref: '',
369+
reachedTop: true,
370+
isAmp: false,
371+
numIframes: 0,
372+
stack: ['http://test.localhost:9999/integrationExamples/gpt/pbjs_video_adUnit.html'],
373+
canonicalUrl: null
374+
},
375+
start: 1615271191988
376+
};
217377

218378
it('handles non-banner media responses', function () {
219379
let response = {id: '2341234', seatbid: [{bid: [{id: 'bid-2341234-1', impid: '1', price: 9, nurl: 'https://frontend.stage.iqm.com/static/vast-01.xml', adm: 'http://cdn.iqm.com/pbd?raw=312730_203cf73dc83fb_2824348636878_pbd', adomain: ['app1.stage.iqm.com'], cid: '168900', crid: 'cr-304503', attr: []}]}], bidid: '2341234'};

0 commit comments

Comments
 (0)