-
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.
- Loading branch information
Showing
38 changed files
with
1,494 additions
and
187 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
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
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,119 @@ | ||
import { registerBidder } from '../src/adapters/bidderFactory.js'; | ||
import { deepClone, deepAccess } from '../src/utils.js'; | ||
import { ajax } from '../src/ajax.js'; | ||
import { VIDEO } from '../src/mediaTypes.js'; | ||
import { config } from '../src/config.js'; | ||
|
||
const BIDDER_CODE = 'alkimi'; | ||
export const ENDPOINT = 'https://exchange.alkimi-onboarding.com/bid?prebid=true'; | ||
|
||
export const spec = { | ||
code: BIDDER_CODE, | ||
supportedMediaTypes: ['banner', 'video'], | ||
|
||
isBidRequestValid: function (bid) { | ||
return !!(bid.params && bid.params.bidFloor && bid.params.token); | ||
}, | ||
|
||
buildRequests: function (validBidRequests, bidderRequest) { | ||
let bids = []; | ||
let bidIds = []; | ||
validBidRequests.forEach(bidRequest => { | ||
let sizes = prepareSizes(bidRequest.sizes) | ||
|
||
bids.push({ | ||
token: bidRequest.params.token, | ||
pos: bidRequest.params.pos, | ||
bidFloor: bidRequest.params.bidFloor, | ||
width: sizes[0].width, | ||
height: sizes[0].height, | ||
impMediaType: getFormatType(bidRequest) | ||
}) | ||
bidIds.push(bidRequest.bidId) | ||
}) | ||
|
||
const alkimiConfig = config.getConfig('alkimi'); | ||
|
||
let payload = { | ||
requestId: bidderRequest.auctionId, | ||
signRequest: { bids, randomUUID: alkimiConfig && alkimiConfig.randomUUID }, | ||
bidIds, | ||
referer: bidderRequest.refererInfo.referer, | ||
signature: alkimiConfig && alkimiConfig.signature | ||
} | ||
|
||
const options = { | ||
contentType: 'application/json', | ||
customHeaders: { | ||
'Rtb-Direct': true | ||
} | ||
} | ||
|
||
return { | ||
method: 'POST', | ||
url: ENDPOINT, | ||
data: payload, | ||
options | ||
}; | ||
}, | ||
|
||
interpretResponse: function (serverResponse, request) { | ||
const serverBody = serverResponse.body; | ||
if (!serverBody || typeof serverBody !== 'object') { | ||
return []; | ||
} | ||
|
||
const { prebidResponse } = serverBody; | ||
if (!prebidResponse || typeof prebidResponse !== 'object') { | ||
return []; | ||
} | ||
|
||
let bids = []; | ||
prebidResponse.forEach(bidResponse => { | ||
let bid = deepClone(bidResponse); | ||
bid.cpm = parseFloat(bidResponse.cpm); | ||
|
||
// banner or video | ||
if (VIDEO === bid.mediaType) { | ||
bid.vastXml = bid.ad; | ||
} | ||
|
||
bid.meta = {}; | ||
bid.meta.advertiserDomains = bid.adomain || []; | ||
|
||
bids.push(bid); | ||
}) | ||
|
||
return bids; | ||
}, | ||
|
||
onBidWon: function (bid) { | ||
let winUrl; | ||
if (bid.winUrl || bid.vastUrl) { | ||
winUrl = bid.winUrl ? bid.winUrl : bid.vastUrl; | ||
winUrl = winUrl.replace(/\$\{AUCTION_PRICE\}/, bid.cpm); | ||
} else if (bid.ad) { | ||
let trackImg = bid.ad.match(/(?!^)<img src=".+dsp-win.+">/); | ||
bid.ad = bid.ad.replace(trackImg[0], ''); | ||
winUrl = trackImg[0].split('"')[1]; | ||
winUrl = winUrl.replace(/\$%7BAUCTION_PRICE%7D/, bid.cpm); | ||
} else { | ||
return false; | ||
} | ||
|
||
ajax(winUrl, null); | ||
return true; | ||
} | ||
} | ||
|
||
function prepareSizes(sizes) { | ||
return sizes && sizes.map(size => ({ width: size[0], height: size[1] })); | ||
} | ||
|
||
const getFormatType = bidRequest => { | ||
if (deepAccess(bidRequest, 'mediaTypes.banner')) return 'Banner' | ||
if (deepAccess(bidRequest, 'mediaTypes.video')) return 'Video' | ||
if (deepAccess(bidRequest, 'mediaTypes.audio')) return 'Audio' | ||
} | ||
|
||
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,29 @@ | ||
# Overview | ||
|
||
``` | ||
Module Name: Alkimi Bidder Adapter | ||
Module Type: Bidder Adapter | ||
Maintainer: abogdanov@asteriosoft.com | ||
``` | ||
|
||
# Description | ||
|
||
Connects to Alkimi Bidder for bids. | ||
Alkimi bid adapter supports Banner and Video ads. | ||
|
||
# Test Parameters | ||
``` | ||
const adUnits = [ | ||
{ | ||
bids: [ | ||
{ | ||
bidder: 'alkimi', | ||
params: { | ||
bidFloor: 0.1, | ||
token: '?????????????????????', // Publisher Token provided by Alkimi | ||
} | ||
} | ||
] | ||
} | ||
]; | ||
``` |
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,90 @@ | ||
import adapter from '../src/AnalyticsAdapter.js'; | ||
import adapterManager from '../src/adapterManager.js'; | ||
import CONSTANTS from '../src/constants.json'; | ||
import { ajax } from '../src/ajax.js'; | ||
|
||
const analyticsType = 'endpoint'; | ||
const url = 'URL_TO_SERVER_ENDPOINT'; | ||
|
||
const { | ||
EVENTS: { | ||
AUCTION_END, | ||
BID_WON, | ||
} | ||
} = CONSTANTS; | ||
|
||
let allEvents = {} | ||
let initOptions = {} | ||
let endpoint = 'https://default' | ||
let objectToSearchForBidderCode = ['bidderRequests', 'bidsReceived', 'noBids'] | ||
|
||
function getAdapterNameForAlias(aliasName) { | ||
return adapterManager.aliasRegistry[aliasName] || aliasName; | ||
} | ||
|
||
function setOriginalBidder(arg) { | ||
Object.keys(arg).forEach(key => { | ||
arg[key]['originalBidder'] = getAdapterNameForAlias(arg[key]['bidderCode']); | ||
if (typeof arg[key]['creativeId'] == 'number') { arg[key]['creativeId'] = arg[key]['creativeId'].toString(); } | ||
}); | ||
return arg | ||
} | ||
|
||
function checkBidderCode(args) { | ||
if (typeof args == 'object') { | ||
for (let i = 0; i < objectToSearchForBidderCode.length; i++) { | ||
if (typeof args[objectToSearchForBidderCode[i]] == 'object') { args[objectToSearchForBidderCode[i]] = setOriginalBidder(args[objectToSearchForBidderCode[i]]) } | ||
} | ||
} | ||
if (typeof args['bidderCode'] == 'string') { args['originalBidder'] = getAdapterNameForAlias(args['bidderCode']); } else if (typeof args['bidder'] == 'string') { args['originalBidder'] = getAdapterNameForAlias(args['bidder']); } | ||
if (typeof args['creativeId'] == 'number') { args['creativeId'] = args['creativeId'].toString(); } | ||
return args | ||
} | ||
|
||
function addEvent(eventType, args) { | ||
if (allEvents[eventType] == undefined) { allEvents[eventType] = [] } | ||
if (eventType && args) { args = checkBidderCode(args); } | ||
allEvents[eventType].push(args); | ||
} | ||
|
||
function handleBidWon(args) { | ||
if (typeof allEvents.bidRequested == 'object' && allEvents.bidRequested.length > 0 && allEvents.bidRequested[0].gdprConsent) { args.gdpr = allEvents.bidRequested[0].gdprConsent; } | ||
ajax(endpoint + '.bidwatch.io/analytics/bid_won', null, JSON.stringify(args), {method: 'POST', withCredentials: true}); | ||
} | ||
|
||
function handleAuctionEnd() { | ||
ajax(endpoint + '.bidwatch.io/analytics/auctions', null, JSON.stringify(allEvents), {method: 'POST', withCredentials: true}); | ||
} | ||
|
||
let bidwatchAnalytics = Object.assign(adapter({url, analyticsType}), { | ||
track({ | ||
eventType, | ||
args | ||
}) { | ||
addEvent(eventType, args); | ||
switch (eventType) { | ||
case AUCTION_END: | ||
handleAuctionEnd(); | ||
break; | ||
case BID_WON: | ||
handleBidWon(args); | ||
break; | ||
} | ||
}}); | ||
|
||
// save the base class function | ||
bidwatchAnalytics.originEnableAnalytics = bidwatchAnalytics.enableAnalytics; | ||
|
||
// override enableAnalytics so we can get access to the config passed in from the page | ||
bidwatchAnalytics.enableAnalytics = function (config) { | ||
bidwatchAnalytics.originEnableAnalytics(config); // call the base class function | ||
initOptions = config.options; | ||
if (initOptions.domain) { endpoint = 'https://' + initOptions.domain; } | ||
}; | ||
|
||
adapterManager.registerAnalyticsAdapter({ | ||
adapter: bidwatchAnalytics, | ||
code: 'bidwatch' | ||
}); | ||
|
||
export default bidwatchAnalytics; |
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,21 @@ | ||
# Overview | ||
Module Name: bidwatch Analytics Adapter | ||
|
||
Module Type: Analytics Adapter | ||
|
||
Maintainer: tech@bidwatch.io | ||
|
||
# Description | ||
|
||
Analytics adapter for bidwatch.io. | ||
|
||
# Test Parameters | ||
|
||
``` | ||
{ | ||
provider: 'bidwatch', | ||
options : { | ||
domain: 'test.endpoint' | ||
} | ||
} | ||
``` |
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
Oops, something went wrong.