Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
15 changes: 14 additions & 1 deletion modules/startioBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@
imp.bidfloorcur = 'USD';
}

const placementId = bidRequest.params?.placementId;
if (placementId != null) {
imp.tagid = String(placementId);
}

return imp;
},
request(buildRequest, imps, bidderRequest, context) {
Expand All @@ -33,15 +38,19 @@
const bidParams = context?.bidParams;
const publisherId = bidParams?.publisherId;
if (request?.site) {
request.site.publisher = request.site.publisher || {};
request.site.publisher.id = publisherId;

Check warning on line 42 in modules/startioBidAdapter.js

View workflow job for this annotation

GitHub Actions / Coverage

41-42 lines are not covered with tests
} else if (request?.app) {
request.app.publisher = request.app.publisher || {};
request.app.publisher.id = publisherId;

Check warning on line 45 in modules/startioBidAdapter.js

View workflow job for this annotation

GitHub Actions / Coverage

44-45 lines are not covered with tests
}
request.ext = request.ext || {};
request.ext.prebid = request.ext.prebid || {};

if (bidParams?.test) {
request.test = 1;
}
Comment thread
IlliaMil marked this conversation as resolved.
Outdated
Comment thread
IlliaMil marked this conversation as resolved.
Outdated

const ortb = bidderRequest.ortb2;
request.regs ??= {};
request.regs.coppa = ortb?.regs?.coppa;
Expand Down Expand Up @@ -80,7 +89,7 @@
return buildBidResponse(bid, context);
}

logError('Bid type is incorrect for bid: ', bid['id'])

Check warning on line 92 in modules/startioBidAdapter.js

View workflow job for this annotation

GitHub Actions / Coverage

92 line is not covered with tests
},
context: {
netRevenue: true,
Expand All @@ -107,6 +116,10 @@
return !bid.ortb2Imp?.bidfloorcur || bid.ortb2Imp.bidfloorcur === 'USD';
}

function getEndpointUrl(bidRequest) {
return bidRequest.params?.testAdsEnabled ? `${ENDPOINT_URL}&testAdsEnabled=true` : ENDPOINT_URL;
}

export const spec = {
code: BIDDER_CODE,
supportedMediaTypes: [VIDEO, BANNER, NATIVE],
Expand All @@ -124,7 +137,7 @@

return {
method: METHOD,
url: ENDPOINT_URL,
url: getEndpointUrl(bidRequest),
options: {
contentType: 'text/plain',
withCredentials: true,
Expand All @@ -137,7 +150,7 @@

interpretResponse: ({ body }, req) => {
if (!body || !body.seatbid || body.seatbid.length === 0) {
return [];

Check warning on line 153 in modules/startioBidAdapter.js

View workflow job for this annotation

GitHub Actions / Coverage

153 line is not covered with tests
}
return converter.fromORTB({
response: body,
Expand All @@ -148,11 +161,11 @@
onTimeout: (data) => { },

onBidWon: (bid) => {
if (bid.nurl) {
const url = new URL(bid.nurl);
url.searchParams.set('cpm', bid.cpm);
fetch(url.toString(), { method: 'GET', keepalive: true }).catch(err =>
logError('Error triggering win notification', err)

Check warning on line 168 in modules/startioBidAdapter.js

View workflow job for this annotation

GitHub Actions / Coverage

164-168 lines are not covered with tests
);
}
},
Expand Down
33 changes: 33 additions & 0 deletions test/spec/modules/startioBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,39 @@ describe('Prebid Adapter: Startio', function () {
expect(request.imp[0].banner.battr).to.deep.equal([3, 4]);
});

it('should map params.placementId to imp.tagid', function () {
let bidRequest = deepClone(DEFAULT_REQUEST_DATA);
bidRequest.params.placementId = 'placement-abc';

const request = spec.buildRequests([bidRequest], DEFAULT_BIDDER_REQUEST)[0].data;

expect(request.imp[0].tagid).to.equal('placement-abc');
});

it('should set request.test only when params.test is truthy', function () {
let bidRequest = deepClone(DEFAULT_REQUEST_DATA);

let request = spec.buildRequests([bidRequest], DEFAULT_BIDDER_REQUEST)[0].data;
expect(request.test).to.equal(0);

bidRequest.params.test = true;
request = spec.buildRequests([bidRequest], DEFAULT_BIDDER_REQUEST)[0].data;
expect(request.test).to.equal(1);
});

it('should append testAdsEnabled=true to the endpoint only when params.testAdsEnabled is set', function () {
let bidRequest = deepClone(DEFAULT_REQUEST_DATA);

let request = spec.buildRequests([bidRequest], DEFAULT_BIDDER_REQUEST)[0];
expect(request.url).to.include('pbc-rtb.startappnetwork.com');
expect(request.url).to.not.include('testAdsEnabled');

bidRequest.params.testAdsEnabled = true;
request = spec.buildRequests([bidRequest], DEFAULT_BIDDER_REQUEST)[0];
expect(request.url).to.include('pbc-rtb.startappnetwork.com');
expect(request.url).to.include('testAdsEnabled=true');
});

if (FEATURES.VIDEO) {
it('should build request for video media type', function () {
const bidRequest = VALID_MEDIA_TYPES_REQUESTS[VIDEO][0];
Expand Down
Loading