forked from prebid/Prebid.js
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
new bid adapter: Logain (prebid#6312)
Co-authored-by: Aiholkin <[email protected]>
- Loading branch information
Showing
3 changed files
with
519 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
import { registerBidder } from '../src/adapters/bidderFactory.js'; | ||
import { BANNER, NATIVE, VIDEO } from '../src/mediaTypes.js'; | ||
import * as utils from '../src/utils.js'; | ||
|
||
const BIDDER_CODE = 'logan'; | ||
const AD_URL = 'https://USeast2.logan.ai/?c=o&m=multi'; | ||
const SYNC_URL = 'https://ssp-cookie.logan.ai/html?src=pbjs' | ||
|
||
function isBidResponseValid(bid) { | ||
if (!bid.requestId || !bid.cpm || !bid.creativeId || | ||
!bid.ttl || !bid.currency) { | ||
return false; | ||
} | ||
switch (bid.mediaType) { | ||
case BANNER: | ||
return Boolean(bid.width && bid.height && bid.ad); | ||
case VIDEO: | ||
return Boolean(bid.vastUrl); | ||
case NATIVE: | ||
return Boolean(bid.native && bid.native.impressionTrackers); | ||
default: | ||
return false; | ||
} | ||
} | ||
|
||
export const spec = { | ||
code: BIDDER_CODE, | ||
supportedMediaTypes: [BANNER, VIDEO, NATIVE], | ||
|
||
isBidRequestValid: (bid) => { | ||
return Boolean(bid.bidId && bid.params && !isNaN(parseInt(bid.params.placementId))); | ||
}, | ||
|
||
buildRequests: (validBidRequests = [], bidderRequest) => { | ||
const winTop = utils.getWindowTop(); | ||
const location = winTop.location; | ||
const placements = []; | ||
const request = { | ||
'deviceWidth': winTop.screen.width, | ||
'deviceHeight': winTop.screen.height, | ||
'language': (navigator && navigator.language) ? navigator.language.split('-')[0] : '', | ||
'secure': 1, | ||
'host': location.host, | ||
'page': location.pathname, | ||
'placements': placements | ||
}; | ||
|
||
if (bidderRequest) { | ||
if (bidderRequest.uspConsent) { | ||
request.ccpa = bidderRequest.uspConsent; | ||
} | ||
if (bidderRequest.gdprConsent) { | ||
request.gdpr = bidderRequest.gdprConsent | ||
} | ||
} | ||
|
||
const len = validBidRequests.length; | ||
for (let i = 0; i < len; i++) { | ||
const bid = validBidRequests[i]; | ||
const placement = { | ||
placementId: bid.params.placementId, | ||
bidId: bid.bidId, | ||
schain: bid.schain || {}, | ||
}; | ||
const mediaType = bid.mediaTypes | ||
|
||
if (mediaType && mediaType[BANNER] && mediaType[BANNER].sizes) { | ||
placement.sizes = mediaType[BANNER].sizes; | ||
placement.traffic = BANNER; | ||
} else if (mediaType && mediaType[VIDEO] && mediaType[VIDEO].playerSize) { | ||
placement.wPlayer = mediaType[VIDEO].playerSize[0]; | ||
placement.hPlayer = mediaType[VIDEO].playerSize[1]; | ||
placement.traffic = VIDEO; | ||
} else if (mediaType && mediaType[NATIVE]) { | ||
placement.native = mediaType[NATIVE]; | ||
placement.traffic = NATIVE; | ||
} | ||
placements.push(placement); | ||
} | ||
|
||
return { | ||
method: 'POST', | ||
url: AD_URL, | ||
data: request | ||
}; | ||
}, | ||
|
||
interpretResponse: (serverResponse) => { | ||
let response = []; | ||
for (let i = 0; i < serverResponse.body.length; i++) { | ||
let resItem = serverResponse.body[i]; | ||
if (isBidResponseValid(resItem)) { | ||
response.push(resItem); | ||
} | ||
} | ||
return response; | ||
}, | ||
|
||
getUserSyncs: (syncOptions, serverResponses, gdprConsent, uspConsent) => { | ||
let syncUrl = SYNC_URL | ||
if (gdprConsent && gdprConsent.consentString) { | ||
if (typeof gdprConsent.gdprApplies === 'boolean') { | ||
syncUrl += `&gdpr=${Number(gdprConsent.gdprApplies)}&gdpr_consent=${gdprConsent.consentString}`; | ||
} else { | ||
syncUrl += `&gdpr=0&gdpr_consent=${gdprConsent.consentString}`; | ||
} | ||
} | ||
if (uspConsent && uspConsent.consentString) { | ||
syncUrl += `&ccpa_consent=${uspConsent.consentString}`; | ||
} | ||
return [{ | ||
type: 'iframe', | ||
url: syncUrl | ||
}]; | ||
} | ||
}; | ||
|
||
registerBidder(spec); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
# Overview | ||
|
||
``` | ||
Module Name: logan Bidder Adapter | ||
Module Type: logan Bidder Adapter | ||
Maintainer: [email protected] | ||
``` | ||
|
||
# Description | ||
|
||
Module that connects to logan demand sources | ||
|
||
# Test Parameters | ||
``` | ||
var adUnits = [ | ||
{ | ||
code:'1', | ||
mediaTypes:{ | ||
banner: { | ||
sizes: [[300, 250]], | ||
} | ||
}, | ||
bids:[ | ||
{ | ||
bidder: 'logan', | ||
params: { | ||
placementId: 0 | ||
} | ||
} | ||
] | ||
}, | ||
{ | ||
code:'1', | ||
mediaTypes:{ | ||
video: { | ||
playerSize: [640, 480], | ||
context: 'instream' | ||
} | ||
}, | ||
bids:[ | ||
{ | ||
bidder: 'logan', | ||
params: { | ||
placementId: 0 | ||
} | ||
} | ||
] | ||
}, | ||
{ | ||
code:'1', | ||
mediaTypes:{ | ||
native: { | ||
title: { | ||
required: true | ||
}, | ||
icon: { | ||
required: true, | ||
size: [64, 64] | ||
} | ||
} | ||
}, | ||
bids:[ | ||
{ | ||
bidder: 'logan', | ||
params: { | ||
placementId: 0 | ||
} | ||
} | ||
] | ||
} | ||
]; | ||
``` |
Oops, something went wrong.