-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add code, test, and doc for Adikteev adapter (#3229)
* Add code, test, and doc for Adikteev adapter * Reflect comments on other PR http://prebid.org/dev-docs/bidder-adaptor.html#referrers #3230 (comment) * 'currency' isn't a bidder-specific param Update PR following this remark on another one: #3228 (comment) * Add integration example, fix bid requestId
- Loading branch information
1 parent
4c085b8
commit 50d5097
Showing
5 changed files
with
466 additions
and
2 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,93 @@ | ||
<html> | ||
|
||
<head> | ||
<link rel="icon" type="image/png" href="/favicon.png"> | ||
<script async src="//www.googletagservices.com/tag/js/gpt.js"></script> | ||
<script type="text/javascript" src="../../build/dev/prebid.js" async></script> | ||
<script> | ||
var sizes = [ | ||
[300, 250], | ||
[250, 300], | ||
[300, 600] | ||
]; | ||
var PREBID_TIMEOUT = 3000; | ||
var FAILSAFE_TIMEOUT = 3000; | ||
|
||
var adUnits = [{ | ||
code: '/19968336/header-bid-tag-1', | ||
mediaTypes: { | ||
banner: { | ||
sizes: sizes | ||
} | ||
}, | ||
bids: [{ | ||
bidder: 'adikteev', | ||
params: { | ||
placementId: 13144370, | ||
stagingEnvironment: true, | ||
bidFloorPrice: 0.1, | ||
} | ||
}] | ||
}]; | ||
|
||
// ======== DO NOT EDIT BELOW THIS LINE =========== // | ||
var googletag = googletag || {}; | ||
googletag.cmd = googletag.cmd || []; | ||
googletag.cmd.push(function () { | ||
googletag.pubads().disableInitialLoad(); | ||
}); | ||
|
||
var pbjs = pbjs || {}; | ||
pbjs.que = pbjs.que || []; | ||
|
||
pbjs.que.push(function () { | ||
pbjs.addAdUnits(adUnits); | ||
pbjs.requestBids({ | ||
bidsBackHandler: initAdserver, | ||
timeout: PREBID_TIMEOUT | ||
}); | ||
}); | ||
|
||
function initAdserver() { | ||
if (pbjs.initAdserverSet) return; | ||
pbjs.initAdserverSet = true; | ||
googletag.cmd.push(function () { | ||
pbjs.que.push(function () { | ||
pbjs.setTargetingForGPTAsync(); | ||
googletag.pubads().refresh(); | ||
}); | ||
}); | ||
} | ||
|
||
|
||
// in case PBJS doesn't load | ||
setTimeout(function () { | ||
console.log("prebid.js setTimeout"); | ||
initAdserver(); | ||
}, FAILSAFE_TIMEOUT); | ||
|
||
googletag.cmd.push(function () { | ||
googletag.defineSlot('/19968336/header-bid-tag-1', sizes, 'div-1') | ||
.addService(googletag.pubads()); | ||
googletag.pubads().enableSingleRequest(); | ||
googletag.enableServices(); | ||
}); | ||
|
||
</script> | ||
|
||
</head> | ||
|
||
<body> | ||
<h2>Basic Prebid.js Example</h2> | ||
<h5>Div-1</h5> | ||
<div id='div-1'> | ||
<script type='text/javascript'> | ||
googletag.cmd.push(function () { | ||
googletag.display('div-1'); | ||
}); | ||
|
||
</script> | ||
</div> | ||
</body> | ||
|
||
</html> |
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
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,94 @@ | ||
import {registerBidder} from 'src/adapters/bidderFactory'; | ||
import {BANNER} from 'src/mediaTypes'; | ||
import * as utils from '../src/utils'; | ||
import {config} from 'src/config'; | ||
|
||
export const BIDDER_CODE = 'adikteev'; | ||
export const ENDPOINT_URL = 'https://serve-adserver.adikteev.com/api/prebid/bid'; | ||
export const ENDPOINT_URL_STAGING = 'https://serve-adserver-staging.adikteev.com/api/prebid/bid'; | ||
export const USER_SYNC_IFRAME_URL = 'https://serve-adserver.adikteev.com/api/prebid/sync-iframe'; | ||
export const USER_SYNC_IFRAME_URL_STAGING = 'https://serve-adserver-staging.adikteev.com/api/prebid/sync-iframe'; | ||
export const USER_SYNC_IMAGE_URL = 'https://serve-adserver.adikteev.com/api/prebid/sync-image'; | ||
export const USER_SYNC_IMAGE_URL_STAGING = 'https://serve-adserver-staging.adikteev.com/api/prebid/sync-image'; | ||
|
||
export let stagingEnvironmentSwitch = false; // Don't use it. Allow us to make tests on staging | ||
|
||
export function setstagingEnvironmentSwitch(value) { | ||
stagingEnvironmentSwitch = value; | ||
} | ||
|
||
function validateSizes(sizes) { | ||
if (!utils.isArray(sizes) || typeof sizes[0] === 'undefined') { | ||
return false; | ||
} | ||
return sizes.every(size => utils.isArray(size) && size.length === 2); | ||
} | ||
|
||
export const spec = { | ||
code: BIDDER_CODE, | ||
supportedMediaTypes: [BANNER], | ||
|
||
isBidRequestValid: (bid) => { | ||
setstagingEnvironmentSwitch(stagingEnvironmentSwitch || !!bid.params.stagingEnvironment); | ||
return !!( | ||
bid && | ||
bid.params && | ||
bid.params.bidFloorPrice && | ||
bid.params.placementId && | ||
bid.bidder === BIDDER_CODE && | ||
validateSizes(bid.mediaTypes.banner.sizes) | ||
); | ||
}, | ||
|
||
buildRequests: (validBidRequests, bidderRequest) => { | ||
const payload = { | ||
validBidRequests, | ||
bidderRequest, | ||
refererInfo: bidderRequest.refererInfo, | ||
currency: config.getConfig('currency'), | ||
userAgent: navigator.userAgent, | ||
screen: { | ||
width: window.screen.width, | ||
height: window.screen.height | ||
}, | ||
language: navigator.language, | ||
cookies: document.cookie.split(';'), | ||
prebidUpdateVersion: '1.29.0', | ||
}; | ||
return { | ||
method: 'POST', | ||
url: stagingEnvironmentSwitch ? ENDPOINT_URL_STAGING : ENDPOINT_URL, | ||
data: JSON.stringify(payload), | ||
}; | ||
}, | ||
|
||
interpretResponse: (serverResponse, bidRequests) => { | ||
const returnedBids = []; | ||
const validBidRequests = JSON.parse(bidRequests.data).validBidRequests; | ||
serverResponse.body.forEach((value, index) => { | ||
const overrides = { | ||
requestId: validBidRequests[index].bidId, | ||
}; | ||
returnedBids.push(Object.assign({}, value, overrides)); | ||
}); | ||
return returnedBids; | ||
}, | ||
|
||
getUserSyncs: (syncOptions, serverResponses) => { | ||
const syncs = []; | ||
if (syncOptions.iframeEnabled) { | ||
syncs.push({ | ||
type: 'iframe', | ||
url: stagingEnvironmentSwitch ? USER_SYNC_IFRAME_URL_STAGING : USER_SYNC_IFRAME_URL, | ||
}); | ||
} | ||
if (syncOptions.pixelEnabled && serverResponses.length > 0) { | ||
syncs.push({ | ||
type: 'image', | ||
url: stagingEnvironmentSwitch ? USER_SYNC_IMAGE_URL_STAGING : USER_SYNC_IMAGE_URL, | ||
}); | ||
} | ||
return syncs; | ||
}, | ||
}; | ||
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,35 @@ | ||
# Overview | ||
|
||
``` | ||
Module Name: Adikteev Bidder Adapter | ||
Module Type: Bidder Adapter | ||
Maintainer: [email protected] | ||
``` | ||
|
||
# Description | ||
|
||
Module that connects to Adikteev's demand sources | ||
|
||
# Test Parameters | ||
|
||
``` javascript | ||
var adUnits = [ | ||
{ | ||
code: 'test-div', | ||
mediaTypes: { | ||
banner: { | ||
sizes: [[750, 200]], // a display size | ||
} | ||
}, | ||
bids: [ | ||
{ | ||
bidder: 'adikteev', | ||
params: { | ||
placementId: 12345, | ||
bidFloorPrice: 0.1, | ||
} | ||
} | ||
] | ||
} | ||
]; | ||
``` |
Oops, something went wrong.