Skip to content

Commit 7a7e0d8

Browse files
added microsoft bidder
1 parent 3032afc commit 7a7e0d8

1 file changed

Lines changed: 73 additions & 99 deletions

File tree

modules/msftBidAdapter.js

Lines changed: 73 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -317,105 +317,78 @@ import {
317317
});
318318

319319
export const spec = {
320-
code: BIDDER_CODE,
321-
gvlid: GVLID,
322-
aliases: [], // TODO fill in after full transition or as seperately requested
323-
supportedMediaTypes: [BANNER, NATIVE, VIDEO],
324-
325-
isBidRequestValid: (bid) => {
326-
const params = bid.params;
327-
if (isStr(params.placement_id) && !isNaN(params.placement_id)) {
328-
params.placement_id = Number(params.placement_id);
329-
logMessage('[MSFT] placement_id coerced to number:', params.placement_id);
330-
}
331-
return !!(
332-
typeof params.placement_id === 'number' ||
333-
(typeof params.member === 'number' && isNotEmptyString(params?.inv_code))
334-
);
335-
},
336-
337-
buildRequests(bidRequests, bidderRequest) {
338-
// Temporary fix: remove native mediaType from msft bids until native support is resolved
339-
const filteredBidRequests = bidRequests
340-
.map((bid) => {
341-
if (bid.mediaTypes && bid.mediaTypes[NATIVE]) {
342-
const mediaTypes = { ...bid.mediaTypes };
343-
delete mediaTypes[NATIVE];
344-
if (Object.keys(mediaTypes).length === 0) {
345-
return null;
346-
}
347-
348-
const filteredBid = {
349-
...bid,
350-
mediaTypes
351-
};
352-
delete filteredBid.nativeParams;
353-
delete filteredBid.nativeOrtbRequest;
354-
logMessage('[MSFT] native stripped from bid:', filteredBid.adUnitCode);
355-
return filteredBid;
356-
}
357-
return bid;
358-
})
359-
.filter(Boolean);
360-
361-
if (filteredBidRequests.length === 0) return [];
362-
363-
const data = converter.toORTB({
364-
bidRequests: filteredBidRequests,
365-
bidderRequest
366-
});
367-
368-
const omidSupport = (bidRequests || []).find(hasOmidSupport);
369-
if (omidSupport) {
370-
mergeDeep(
371-
data,
372-
{
373-
source: {
374-
ext: {
375-
omidpn: 'AppNexus',
376-
omidpv: '$prebid.version$'
377-
}
378-
}
379-
},
380-
data
381-
);
382-
}
383-
384-
// TODO remove later
385-
logMessage('MSFT openRTB request', data);
386-
387-
return formatRequest(data, bidderRequest);
388-
},
389-
390-
interpretResponse(response, request) {
391-
const bids = converter.fromORTB({
392-
response: response.body,
393-
request: request.data
394-
}).bids;
395-
396-
return bids;
397-
},
398-
399-
getUserSyncs: function (syncOptions, responses, gdprConsent, uspConsent, gppConsent) {
400-
if (syncOptions.iframeEnabled && hasPurpose1Consent(gdprConsent)) {
401-
return [
402-
{
403-
type: 'iframe',
404-
url: 'https://acdn.adnxs.com/dmp/async_usersync.html'
405-
}
406-
];
407-
}
408-
409-
if (syncOptions.pixelEnabled) {
410-
// first attempt using static list
411-
const imgList = ['https://px.ads.linkedin.com/setuid?partner=appNexus'];
412-
return imgList.map((url) => ({
413-
type: 'image',
414-
url
415-
}));
416-
}
417-
}
418-
};
320+
code: BIDDER_CODE,
321+
gvlid: GVLID,
322+
aliases: [], // TODO fill in after full transition or as seperately requested
323+
supportedMediaTypes: [BANNER, NATIVE, VIDEO],
324+
325+
isBidRequestValid: (bid) => {
326+
const params = bid.params;
327+
return !!(
328+
(typeof params.placement_id === 'number') ||
329+
(typeof params.member === 'number' && isNotEmptyString(params?.inv_code))
330+
);
331+
},
332+
333+
buildRequests(bidRequests, bidderRequest) {
334+
const data = converter.toORTB({
335+
bidRequests,
336+
bidderRequest,
337+
});
338+
339+
const omidSupport = ((bidRequests) || []).find(hasOmidSupport);
340+
if (omidSupport) {
341+
mergeDeep(
342+
data, {
343+
source: {
344+
ext: {
345+
omidpn: 'AppNexus',
346+
omidpv: '$prebid.version$'
347+
}
348+
}
349+
},
350+
data);
351+
}
352+
353+
// TODO remove later
354+
logMessage("MSFT openRTB request", data);
355+
356+
return formatRequest(data, bidderRequest);
357+
},
358+
359+
interpretResponse(response, request) {
360+
const bids = converter.fromORTB({
361+
response: response.body,
362+
request: request.data,
363+
}).bids;
364+
365+
return bids;
366+
},
367+
368+
getUserSyncs: function (
369+
syncOptions,
370+
responses,
371+
gdprConsent,
372+
uspConsent,
373+
gppConsent
374+
) {
375+
if (syncOptions.iframeEnabled && hasPurpose1Consent(gdprConsent)) {
376+
return [{
377+
type: "iframe",
378+
url: "https://acdn.adnxs.com/dmp/async_usersync.html",
379+
}, ];
380+
}
381+
382+
if (syncOptions.pixelEnabled) {
383+
// first attempt using static list
384+
const imgList = ["https://px.ads.linkedin.com/setuid?partner=appNexus"];
385+
return imgList.map((url) => ({
386+
type: "image",
387+
url,
388+
}));
389+
}
390+
},
391+
};
419392

420393
function isNotEmptyString(value) {
421394
return isStr(value) && value !== '';
@@ -600,3 +573,4 @@ import {
600573
return hasOmid;
601574
}
602575
registerBidder(spec);
576+

0 commit comments

Comments
 (0)