Skip to content
Open
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
16 changes: 15 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,14 +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 || {};
request.ext.prebid.channel = { name: 'pbjs', version: '$prebid.version$' };

if (bidParams?.test) {
request.test = 1;
}
Comment thread
IlliaMil marked this conversation as resolved.
Comment on lines +51 to +53

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is bidParams.test different from bidRequest.params.testAdsEnabled on purpose?
It sounds like they should be the same variable (otherwise they might not be synced, and it'll cause an unexpected behavior)


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

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

Check warning on line 93 in modules/startioBidAdapter.js

View workflow job for this annotation

GitHub Actions / Coverage

93 line is not covered with tests
},
context: {
netRevenue: true,
Expand All @@ -107,6 +117,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 +138,7 @@

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

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

Check warning on line 154 in modules/startioBidAdapter.js

View workflow job for this annotation

GitHub Actions / Coverage

154 line is not covered with tests
}
return converter.fromORTB({
response: body,
Expand All @@ -148,11 +162,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 169 in modules/startioBidAdapter.js

View workflow job for this annotation

GitHub Actions / Coverage

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

it('should advertise the prebid channel (name + version) so the endpoint can identify the version', function () {
const request = spec.buildRequests([DEFAULT_REQUEST_DATA], DEFAULT_BIDDER_REQUEST)[0].data;

expect(request.ext.prebid.channel).to.be.an('object');
expect(request.ext.prebid.channel.name).to.equal('pbjs');
expect(request.ext.prebid.channel.version).to.be.a('string').that.is.not.empty;
});

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