-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Valuad Bid Adapter: initial release #13016
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
52 commits
Select commit
Hold shift + click to select a range
3577f49
Migrate valuad prebid.js to 9.35.0 (bridgeupp requires 9.24+)
44409ef
Fix s2s config ad server currency
cf9479f
Add valuadBidAdapter with all enhancements from 9.14.0
4b20d4c
Remove rise adapter
natanavra 043d949
Remove s2s adapters in favor of valuad bid adapter
natanavra 6f59f66
Import 9.14.0 changes
natanavra c1472ed
Revert smart and yandex adServerCurrency wrong setting
natanavra 289bdc2
Added support for onBidWon + fix for Regs
pixelgroup-israel e14a0ba
Remove ad creative/html from the bid won event
natanavra 274639f
Fixed Coppa and uspConsent
pixelgroup-israel 37369f3
Replace smartadserver URL transform with a change in the adapter
natanavra c9ff3f6
Fix style
natanavra 5ed6cde
Fix setting _VALUAD.serverData wrong response field
natanavra 773f98b
Update bid won to send data to valuad analytics server
natanavra 10473be
Added support for schain
pixelgroup-israel 43f09a7
Added support for Eids
pixelgroup-israel d889fa8
Added support for extended ortb2 data
pixelgroup-israel b888061
Added support for video impressions
pixelgroup-israel e53c27a
Added support for native banners
pixelgroup-israel d141a58
Added timeout data to request
pixelgroup-israel bb26378
Added RTD data
pixelgroup-israel 2f5813b
Improved storage handeling
pixelgroup-israel 7d1e8a0
Added memory management for observers
pixelgroup-israel 9781b1d
Update code to most recent working copy live in maariv
natanavra 027b656
Organize functions for simplicity
natanavra 1716b6e
Added unit testing for the adapter + added try-catch on ortbConvertor…
pixelgroup-israel 97cb0af
Removed video and native and added a test ad unit
pixelgroup-israel 894fedb
Added md file for prebid website
pixelgroup-israel 3b8020d
Valuad bid adapter initial release
natanavra 7985dbe
Update window size calls to use utils
natanavra fa7d511
Update valuad.md based on adagio, adipolo and copper6ssp
natanavra f7a5e68
Removed checks for video and native
pixelgroup-israel 562f6fd
Merge branch '9.35.0-20250326' into 9.40.0-submit
natanavra 768dcae
Update window size calls to use util
natanavra 8ac1889
Remove irrelevant tests
natanavra 64d098f
Merge branch 'prebid:master' into master
natanavra 81d4506
Merge branch 'prebid:master' into master
natanavra 28eff2b
Merge branch 'prebid:master' into master
natanavra 269560d
Fixed tests to run without using global
pixelgroup-israel 54ddb74
Update tests to not pollute global space
natanavra f1eb854
Removed global window reference and removed un-required test
pixelgroup-israel 8b5bc25
Remove window reference and unused tests
natanavra a7d3e4d
Merge branch 'prebid:master' into master
natanavra 5f0b246
Fix test device language check
natanavra 88e6005
Removed session and pageview enrichment data
pixelgroup-israel 5b21493
Removed redundant enrichment functions
tal-px ab209f9
Updated the adapter to use information we already have in the request…
pixelgroup-israel 38b4983
Merge branch 'master' into master
natanavra 18b0d5d
Remove unused code
f45d486
Removed unnecessary viewabilty functions and used the percentInView l…
pixelgroup-israel fd26621
Removed redundant reassembling of the gdprConsent object
pixelgroup-israel 896253e
Merge branch '9.40.0-submit'
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,238 @@ | ||
| import { registerBidder } from '../src/adapters/bidderFactory.js'; | ||
| import { BANNER } from '../src/mediaTypes.js'; | ||
| import { ortbConverter } from '../libraries/ortbConverter/converter.js'; | ||
| import { | ||
| deepAccess, | ||
| deepSetValue, | ||
| logInfo, | ||
| triggerPixel, | ||
| getWindowSelf, | ||
| getWindowTop | ||
| } from '../src/utils.js'; | ||
| import { getGptSlotInfoForAdUnitCode } from '../libraries/gptUtils/gptUtils.js'; | ||
| import { config } from '../src/config.js'; | ||
| import { getBoundingBox, percentInView } from '../libraries/percentInView/percentInView.js'; | ||
|
|
||
| const BIDDER_CODE = 'valuad'; | ||
| const AD_URL = 'https://rtb.valuad.io/adapter'; | ||
| const WON_URL = 'https://hb-dot-valuad.appspot.com/adapter/win'; | ||
|
|
||
| function _isIframe() { | ||
| try { | ||
| return getWindowSelf() !== getWindowTop(); | ||
| } catch (e) { | ||
| return true; | ||
| } | ||
| } | ||
|
|
||
| function _isViewabilityMeasurable(element) { | ||
| return !_isIframe() && element !== null; | ||
| } | ||
|
|
||
| function _getViewability(element, topWin, { w, h } = {}) { | ||
| return topWin.document.visibilityState === 'visible' ? percentInView(element, { w, h }) : 0; | ||
| } | ||
|
|
||
| // Enhanced ORTBConverter with additional data | ||
| const converter = ortbConverter({ | ||
| context: { | ||
| netRevenue: true, | ||
| ttl: 30 | ||
| }, | ||
| request(buildRequest, imps, bidderRequest, context) { | ||
| const request = buildRequest(imps, bidderRequest, context); | ||
|
|
||
| const gdpr = deepAccess(bidderRequest, 'gdprConsent') || {}; | ||
| const uspConsent = deepAccess(bidderRequest, 'uspConsent') || ''; | ||
| const coppa = config.getConfig('coppa') === true ? 1 : 0; | ||
| const { gpp, gpp_sid: gppSid } = deepAccess(bidderRequest, 'ortb2.regs', {}); | ||
| const dsa = deepAccess(bidderRequest, 'ortb2.regs.ext.dsa'); | ||
|
|
||
| deepSetValue(request, 'regs', { | ||
| gdpr: gdpr.gdprApplies ? 1 : 0, | ||
| coppa: coppa, | ||
| us_privacy: uspConsent, | ||
| ext: { | ||
| gdpr_conset: gdpr.consentString || '', | ||
| gpp: gpp || '', | ||
| gppSid: gppSid || [], | ||
| dsa: dsa, | ||
| } | ||
| }); | ||
|
|
||
| deepSetValue(request, 'device.js', 1); | ||
| deepSetValue(request, 'device.geo', {}); | ||
|
|
||
| // Add bid parameters | ||
| if (bidderRequest && bidderRequest.bids && bidderRequest.bids.length) { | ||
| deepSetValue(request, 'ext.params', bidderRequest.bids[0].params); | ||
| } | ||
|
|
||
| // Set currency to USD | ||
| deepSetValue(request, 'cur', ['USD']); | ||
|
|
||
| // Add schain if present | ||
| const schain = deepAccess(bidderRequest.bids[0], 'schain'); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You won't need this in prebid 10, we're moving schain |
||
| if (schain) { | ||
| deepSetValue(request, 'source.ext.schain', schain); | ||
| } | ||
|
|
||
| // Add eids if present | ||
| const eids = deepAccess(bidderRequest.bids[0], 'userIdAsEids'); | ||
| if (eids) { | ||
| deepSetValue(request, 'user.ext.eids', eids); | ||
| } | ||
|
|
||
| const ortb2 = bidderRequest.ortb2 || {}; | ||
| if (ortb2.site?.ext?.data) { | ||
| deepSetValue(request, 'site.ext.data', { | ||
| ...request.site.ext.data, | ||
| ...ortb2.site.ext.data | ||
| }); | ||
| } | ||
|
|
||
| const tmax = bidderRequest.timeout; | ||
| if (tmax) { | ||
| deepSetValue(request, 'tmax', tmax); | ||
| } | ||
|
|
||
| return request; | ||
| }, | ||
|
|
||
| imp(buildImp, bid, context) { | ||
| const imp = buildImp(bid, context); | ||
|
|
||
| const mediaType = Object.keys(bid.mediaTypes)[0]; | ||
| let adSize; | ||
|
|
||
| if (mediaType === BANNER) { | ||
| adSize = bid.mediaTypes.banner.sizes && bid.mediaTypes.banner.sizes[0]; | ||
| } | ||
|
|
||
| if (!adSize) { adSize = [0, 0]; } | ||
|
|
||
| const size = {w: adSize[0], h: adSize[1]}; | ||
|
|
||
| const element = document.getElementById(bid.adUnitCode) || document.getElementById(getGptSlotInfoForAdUnitCode(bid.adUnitCode)?.divId); | ||
| const viewabilityAmount = _isViewabilityMeasurable(element) ? _getViewability(element, getWindowTop(), size) : 0; | ||
|
|
||
| const rect = getBoundingBox(element, size); | ||
| const position = `${Math.round(rect.left + window.pageXOffset)}x${Math.round(rect.top + window.pageYOffset)}`; | ||
|
|
||
| deepSetValue(imp, 'ext.data.viewability', viewabilityAmount); | ||
| deepSetValue(imp, 'ext.data.position', position); | ||
|
|
||
| // Handle price floors | ||
| if (typeof bid.getFloor === 'function') { | ||
| try { | ||
| let size; | ||
|
|
||
| if (mediaType === BANNER) { | ||
| size = bid.mediaTypes.banner.sizes && bid.mediaTypes.banner.sizes[0]; | ||
| } | ||
|
|
||
| if (size) { | ||
| const floor = bid.getFloor({ | ||
| currency: 'USD', | ||
| mediaType, | ||
| size | ||
| }); | ||
|
|
||
| if (floor && !isNaN(floor.floor) && floor.currency === 'USD') { | ||
| imp.bidfloor = floor.floor; | ||
| imp.bidfloorcur = 'USD'; | ||
| } | ||
| } | ||
| } catch (e) { | ||
| logInfo('Valuad: Error getting floor', e); | ||
| } | ||
| } | ||
|
|
||
| return imp; | ||
| }, | ||
|
|
||
| bidResponse(buildBidResponse, bid, context) { | ||
| let bidResponse; | ||
| try { | ||
| bidResponse = buildBidResponse(bid, context); | ||
|
|
||
| if (bidResponse) { | ||
| if (bid.vbid) { | ||
| bidResponse.vbid = bid.vbid; | ||
| } | ||
| if (context.bidRequest?.params?.placementId) { | ||
| bidResponse.vid = context.bidRequest.params.placementId; | ||
| } | ||
| } | ||
| } catch (e) { | ||
| logInfo('[VALUAD CONVERTER] Error calling buildBidResponse:', e, 'Bid:', bid); | ||
| return; | ||
| } | ||
| return bidResponse; | ||
| }, | ||
| }); | ||
|
|
||
| function isBidRequestValid(bid = {}) { | ||
| const { params, bidId, mediaTypes } = bid; | ||
|
|
||
| const foundKeys = bid && bid.params && bid.params.placementId; | ||
| let valid = Boolean(bidId && params && foundKeys); | ||
|
|
||
| if (mediaTypes && mediaTypes[BANNER]) { | ||
| valid = valid && Boolean(mediaTypes[BANNER] && mediaTypes[BANNER].sizes); | ||
| } else { | ||
| valid = false; | ||
| } | ||
|
|
||
| return valid; | ||
| } | ||
|
|
||
| function buildRequests(validBidRequests = [], bidderRequest = {}) { | ||
| const data = converter.toORTB({ validBidRequests, bidderRequest }); | ||
|
|
||
| return [{ | ||
| method: 'POST', | ||
| url: AD_URL, | ||
| data | ||
| }]; | ||
| } | ||
|
|
||
| function interpretResponse(response, request) { | ||
| // Restore original call, remove logging and safe navigation | ||
| const bidResponses = converter.fromORTB({response: response.body, request: request.data}).bids; | ||
|
|
||
| return bidResponses; | ||
| } | ||
|
|
||
| function getUserSyncs(syncOptions, serverResponses) { | ||
| if (!serverResponses.length || serverResponses[0].body === '' || !serverResponses[0].body.userSyncs) { | ||
| return false; | ||
| } | ||
|
|
||
| return serverResponses[0].body.userSyncs.map(sync => ({ | ||
| type: sync.type === 'iframe' ? 'iframe' : 'image', | ||
| url: sync.url | ||
| })); | ||
| } | ||
|
|
||
| function onBidWon(bid) { | ||
| const { | ||
| adUnitCode, adUnitId, auctionId, bidder, cpm, currency, originalCpm, originalCurrency, size, vbid, vid, | ||
| } = bid; | ||
| const bidStr = JSON.stringify({ | ||
| adUnitCode, adUnitId, auctionId, bidder, cpm, currency, originalCpm, originalCurrency, size, vbid, vid, | ||
| }); | ||
| const encodedBidStr = window.btoa(bidStr); | ||
| triggerPixel(WON_URL + '?b=' + encodedBidStr); | ||
| } | ||
|
|
||
| export const spec = { | ||
| code: BIDDER_CODE, | ||
| supportedMediaTypes: [BANNER], | ||
| isBidRequestValid, | ||
| buildRequests, | ||
| interpretResponse, | ||
| getUserSyncs, | ||
| onBidWon, | ||
| }; | ||
| registerBidder(spec); | ||
This file contains hidden or 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,30 @@ | ||
| # Overview | ||
|
|
||
| **Module Name**: Valuad Bid Adapter | ||
| **Module Type**: Bidder Adapter | ||
| **Maintainer**: natan@valuad.io | ||
|
|
||
| # Description | ||
|
|
||
|
|
||
| Module that connects to Valuad.io demand sources. | ||
| Valuad bid adapter supports Banner format only. | ||
|
|
||
| # Test Parameters | ||
|
|
||
| ```js | ||
| const adUnits = [{ | ||
| code: 'valuad-test-div', | ||
| mediaTypes: { | ||
| banner: { | ||
| sizes: [[300, 250]] | ||
| } | ||
| }, | ||
| bids: [{ | ||
| bidder: 'valuad', | ||
| params: { | ||
| placementId: '00000', // REQUIRED | ||
| } | ||
| }] | ||
| }]; | ||
| ``` |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.