forked from prebid/Prebid.js
-
Notifications
You must be signed in to change notification settings - Fork 0
added dasBidAdapter #43
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
20 commits
Select commit
Hold shift + click to select a range
173cf22
added dasBidAdapter
ODudek d0ac54b
add network to path
ODudek 17e6329
change version of artifact
ODudek a335fa8
added deploy
ODudek 9b75fe6
pass secrets in env
ODudek 6cf3026
test deploy
ODudek 230357d
Added tests
ODudek 6fb6140
fix workflow
ODudek ce794d9
change mtype logic
ODudek 0a20f62
fix test
ODudek 1240410
fix test with correct response
ODudek 8ae9657
Update modules/dasBidAdapter.js
ODudek 702af52
Update modules/dasBidAdapter.js
ODudek dfe026f
fixes after CR
ODudek c7f60de
Merge branch 'feature/added-DAS-adapter' of ssh://github.com/DreamLab…
ODudek 3332217
added missing params in response
ODudek 37d5640
fix missing ext
ODudek 98b3054
move gdpr to regs
ODudek b9ce827
add slot pos only when is available
ODudek c8686ac
fixes after CR
ODudek 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,67 @@ | ||
| name: CI | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - dreamlab-master | ||
| pull_request: | ||
| branches: | ||
| - "*" | ||
|
|
||
| jobs: | ||
| build: | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: 20 | ||
| - run: npm install && npm install -g gulp | ||
|
|
||
| - name: Run tests | ||
| run: node_modules/.bin/gulp test --file test/spec/modules/ringieraxelspringerBidAdapter_spec.js,test/spec/modules/dasBidAdapter_spec.js | ||
|
|
||
| - name: build | ||
| run: node_modules/.bin/gulp build --modules=modules.json | ||
|
|
||
| - name: version | ||
| run: cat package.json | grep -e "\"version.*\"" | grep -oP "\d\.\d+\.\d+" > version.txt | ||
|
|
||
| - name: Upload artifact | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: prebidjs | ||
| path: build/dist/prebid.js | ||
| - name: Upload version | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: version | ||
| path: version.txt | ||
| deploy: | ||
| needs: build | ||
| if: github.ref == 'refs/heads/dreamlab-master' | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - name: Download artifact | ||
| uses: actions/download-artifact@v4 | ||
| with: | ||
| name: prebidjs | ||
| - name: Download version | ||
| uses: actions/download-artifact@v4 | ||
| with: | ||
| name: version | ||
| - name: Deploy | ||
| env: | ||
| AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | ||
| AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | ||
| BUCKET: ${{ secrets.BUCKET }} | ||
| run: | | ||
| version="$(cat version.txt)" | ||
| mkdir "${version}" | ||
| cp prebid.js "${version}"/ | ||
| release="${version}_$(date +"%Y%m%d%H%M%S")" | ||
| echo "Uploading Prebid.js ver:${version} to OCDN" | ||
| echo -e "\e[32mRelease: ${release}\e[0m" | ||
| aws s3 sync "${version}" s3://${BUCKET}/prebid/prod/${release}/ --region ocdn --endpoint "https://ocdn.eu" |
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
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,34 @@ | ||
| [ | ||
| "consentManagement", | ||
| "rubiconBidAdapter", | ||
| "appnexusBidAdapter", | ||
| "openxBidAdapter", | ||
| "ixBidAdapter", | ||
| "adfBidAdapter", | ||
| "pubmaticBidAdapter", | ||
| "criteoBidAdapter", | ||
| "rtbhouseBidAdapter", | ||
| "categoryTranslation", | ||
| "dfpAdServerVideo", | ||
| "smartadserverBidAdapter", | ||
| "prebidServerBidAdapter", | ||
| "ringieraxelspringerAnalyticsAdapter", | ||
| "ringieraxelspringerBidAdapter", | ||
| "userId", | ||
| "pubProvidedIdSystem", | ||
| "id5IdSystem", | ||
| "sharedIdSystem", | ||
| "lotamePanoramaIdSystem", | ||
| "teadsIdSystem", | ||
| "teadsBidAdapter", | ||
| "invibesBidAdapter", | ||
| "carodaBidAdapter", | ||
| "fledgeForGpt", | ||
| "adqueryIdSystem", | ||
| "topicsFpdModule", | ||
| "priceFloors", | ||
| "visxBidAdapter", | ||
| "currency", | ||
| "justIdSystem", | ||
| "dasBidAdapter" | ||
| ] |
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,254 @@ | ||
| import { getAllOrtbKeywords } from '../libraries/keywords/keywords.js'; | ||
| import { getAdUnitSizes } from '../libraries/sizeUtils/sizeUtils.js'; | ||
| import { registerBidder } from '../src/adapters/bidderFactory.js'; | ||
| import { BANNER } from '../src/mediaTypes.js'; | ||
| import { deepAccess } from '../src/utils.js'; | ||
|
|
||
| const BIDDER_CODE = 'das'; | ||
|
|
||
| const getEndpoint = (network) => { | ||
| return `https://csr.onet.pl/${encodeURIComponent(network)}/bid`; | ||
| }; | ||
|
|
||
| function parseParams(params, bidderRequest) { | ||
| const customParams = {}; | ||
| const keyValues = {}; | ||
|
|
||
| if (params.site) { | ||
| customParams.site = params.site; | ||
| } | ||
|
|
||
| if (params.area) { | ||
| customParams.area = params.area; | ||
| } | ||
|
|
||
| if (params.network) { | ||
| customParams.network = params.network; | ||
| } | ||
|
|
||
| // Custom parameters | ||
| if (params.customParams && typeof params.customParams === 'object') { | ||
| Object.assign(customParams, params.customParams); | ||
| } | ||
|
|
||
| const pageContext = params.pageContext; | ||
| if (pageContext) { | ||
| // Document URL override | ||
| if (pageContext.du) { | ||
| customParams.du = pageContext.du; | ||
| } | ||
|
|
||
| // Referrer override | ||
| if (pageContext.dr) { | ||
| customParams.dr = pageContext.dr; | ||
| } | ||
|
|
||
| // Document virtual address | ||
| if (pageContext.dv) { | ||
| customParams.DV = pageContext.dv; | ||
| } | ||
|
|
||
| // Keywords | ||
| const keywords = getAllOrtbKeywords( | ||
| bidderRequest?.ortb2, | ||
| pageContext.keyWords, | ||
| ); | ||
| if (keywords.length > 0) { | ||
| customParams.kwrd = keywords.join('+'); | ||
| } | ||
|
|
||
| // Local capping | ||
| if (pageContext.capping) { | ||
| customParams.local_capping = pageContext.capping; | ||
| } | ||
|
|
||
| // Key values | ||
| if (pageContext.keyValues && typeof pageContext.keyValues === 'object') { | ||
| Object.entries(pageContext.keyValues).forEach(([key, value]) => { | ||
| keyValues[`kv${key}`] = value; | ||
| }); | ||
| } | ||
| } | ||
|
|
||
| const du = customParams.du || deepAccess(bidderRequest, 'refererInfo.page'); | ||
| const dr = customParams.dr || deepAccess(bidderRequest, 'refererInfo.ref'); | ||
|
|
||
| if (du) customParams.du = du; | ||
| if (dr) customParams.dr = dr; | ||
|
|
||
| const dsaRequired = deepAccess(bidderRequest, 'ortb2.regs.ext.dsa.required'); | ||
| if (dsaRequired !== undefined) { | ||
| customParams.dsainfo = dsaRequired; | ||
| } | ||
|
|
||
| return { | ||
| customParams, | ||
| keyValues, | ||
| }; | ||
| } | ||
|
|
||
| function buildUserIds(customParams) { | ||
| const userIds = {}; | ||
| if (customParams.lu) { | ||
| userIds.lu = customParams.lu; | ||
| } | ||
| if (customParams.aid) { | ||
| userIds.aid = customParams.aid; | ||
| } | ||
| return userIds; | ||
| } | ||
|
|
||
| function getNpaFromPubConsent(pubConsent) { | ||
| const params = new URLSearchParams(pubConsent); | ||
| return params.get('npa') == '1'; | ||
| } | ||
|
|
||
| function buildOpenRTBRequest(bidRequests, bidderRequest) { | ||
| const { customParams, keyValues } = parseParams( | ||
| bidRequests[0].params, | ||
ODudek marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| bidderRequest, | ||
| ); | ||
| const imp = bidRequests.map((bid, index) => { | ||
| const sizes = getAdUnitSizes(bid); | ||
| const imp = { | ||
| id: bid.bidId, | ||
| tagid: bid.params.slot, | ||
| secure: 1, | ||
| }; | ||
| if (bid.params.slotSequence) { | ||
| imp.ext = { | ||
| pos: bid.params.slotSequence | ||
| } | ||
| } | ||
|
|
||
| if (bid.mediaTypes?.banner) { | ||
| imp.banner = { | ||
| format: sizes.map((size) => ({ | ||
| w: size[0], | ||
| h: size[1], | ||
| })), | ||
| }; | ||
| } | ||
|
|
||
| return imp; | ||
| }); | ||
|
|
||
| const request = { | ||
| id: bidderRequest.bidderRequestId, | ||
| imp, | ||
| site: { | ||
| id: customParams.site, | ||
| page: customParams.du, | ||
| ref: customParams.dr, | ||
| ext: { | ||
| area: customParams.area, | ||
| kwrd: customParams.kwrd, | ||
| dv: customParams.DV | ||
| }, | ||
| ...bidderRequest.ortb2.site, | ||
| }, | ||
| device: bidderRequest.device, | ||
| user: { | ||
| ext: { | ||
| ids: buildUserIds(customParams), | ||
| }, | ||
| }, | ||
| ext: { | ||
| network: customParams.network, | ||
ODudek marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| keyvalues: keyValues, | ||
| }, | ||
| at: 1, | ||
| tmax: bidderRequest.timeout | ||
| }; | ||
|
|
||
| if (bidderRequest.gdprConsent) { | ||
| request.user = { | ||
| ext: { | ||
| npa: getNpaFromPubConsent(customParams.pubconsent), | ||
| localcapping: customParams.local_capping, | ||
| ...request.user.ext, | ||
| }, | ||
| }; | ||
| request.regs = { | ||
| gdpr: bidderRequest.gdprConsent.gdprApplies ? 1 : 0, | ||
| ext: { | ||
| dsa: customParams.dsainfo, | ||
| }, | ||
| } | ||
| } | ||
|
|
||
| return request; | ||
| } | ||
|
|
||
| function interpretResponse(serverResponse) { | ||
| const bidResponses = []; | ||
| const response = serverResponse.body; | ||
|
|
||
| if (!response || !response.seatbid || !response.seatbid.length) { | ||
| return bidResponses; | ||
| } | ||
|
|
||
| response.seatbid.forEach((seatbid) => { | ||
| seatbid.bid.forEach((bid) => { | ||
| const bidResponse = { | ||
| requestId: bid.impid, | ||
| cpm: bid.price, | ||
| currency: response.cur || 'USD', | ||
| width: bid.w, | ||
| height: bid.h, | ||
| creativeId: bid.crid || bid.id, | ||
| netRevenue: true, | ||
| dealId: bid.dealid || null, | ||
| actgMatch: bid.ext?.actgMatch || 0, | ||
| ttl: 300, | ||
| meta: { | ||
| advertiserDomains: bid.adomain || [], | ||
| }, | ||
| }; | ||
| // first implementation only supports banner | ||
| if (bid.mtype === 1) { | ||
| bidResponse.mediaType = BANNER; | ||
| bidResponse.ad = bid.adm; | ||
| bidResponses.push(bidResponse); | ||
| } | ||
| }); | ||
| }); | ||
|
|
||
| return bidResponses; | ||
| } | ||
|
|
||
| export const spec = { | ||
| code: BIDDER_CODE, | ||
| supportedMediaTypes: [BANNER], | ||
|
|
||
| isBidRequestValid: function (bid) { | ||
| if (!bid || !bid.params) { | ||
| return false; | ||
| } | ||
| return !!( | ||
| bid.params?.network && | ||
| bid.params?.site && | ||
| bid.params?.area && | ||
| bid.params?.slot | ||
| ); | ||
| }, | ||
|
|
||
| buildRequests: function (validBidRequests, bidderRequest) { | ||
| const data = buildOpenRTBRequest(validBidRequests, bidderRequest); | ||
| return { | ||
| method: 'POST', | ||
ODudek marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| url: getEndpoint(data.ext.network), | ||
| data, | ||
| options: { | ||
| withCredentials: true, | ||
| crossOrigin: true, | ||
| }, | ||
| }; | ||
| }, | ||
|
|
||
| interpretResponse: function (serverResponse) { | ||
| return interpretResponse(serverResponse); | ||
| }, | ||
| }; | ||
|
|
||
| registerBidder(spec); | ||
Oops, something went wrong.
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.