Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 67 additions & 0 deletions .github/workflows/ci.yml
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"
3 changes: 3 additions & 0 deletions karma.conf.maker.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@ function setBrowsers(karmaConf, browserstack) {
module.exports = function(codeCoverage, browserstack, watchMode, file, disableFeatures) {
var webpackConfig = newWebpackConfig(codeCoverage, disableFeatures);
var plugins = newPluginsArray(browserstack);
if (file) {
file = file.split(',')
}

var files = file ? ['test/test_deps.js', file, 'test/helpers/hookSetup.js'].flatMap(f => f) : ['test/test_index.js'];
// This file opens the /debug.html tab automatically.
Expand Down
34 changes: 34 additions & 0 deletions modules.json
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"
]
254 changes: 254 additions & 0 deletions modules/dasBidAdapter.js
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,
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,
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',
url: getEndpoint(data.ext.network),
data,
options: {
withCredentials: true,
crossOrigin: true,
},
};
},

interpretResponse: function (serverResponse) {
return interpretResponse(serverResponse);
},
};

registerBidder(spec);
Loading
Loading