Skip to content

Commit

Permalink
Missena: add format params and onBidWon pixel (#9517)
Browse files Browse the repository at this point in the history
  • Loading branch information
pdamoc authored Feb 24, 2023
1 parent 99ffff2 commit 9d252d4
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
23 changes: 22 additions & 1 deletion modules/missenaBidAdapter.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { formatQS, logInfo } from '../src/utils.js';
import { buildUrl, formatQS, logInfo, triggerPixel } from '../src/utils.js';
import { BANNER } from '../src/mediaTypes.js';
import { registerBidder } from '../src/adapters/bidderFactory.js';

const BIDDER_CODE = 'missena';
const ENDPOINT_URL = 'https://bid.missena.io/';
const EVENTS_DOMAIN = 'events.missena.io';
const EVENTS_DOMAIN_DEV = 'events.staging.missena.xyz';

export const spec = {
aliases: [BIDDER_CODE],
Expand All @@ -30,6 +32,7 @@ export const spec = {
buildRequests: function (validBidRequests, bidderRequest) {
return validBidRequests.map((bidRequest) => {
const payload = {
adunit: bidRequest.adUnitCode,
request_id: bidRequest.bidId,
timeout: bidderRequest.timeout,
};
Expand All @@ -48,6 +51,15 @@ export const spec = {
if (bidRequest.params.test) {
payload.test = bidRequest.params.test;
}
if (bidRequest.params.placement) {
payload.placement = bidRequest.params.placement;
}
if (bidRequest.params.formats) {
payload.formats = bidRequest.params.formats;
}
if (bidRequest.params.isInternal) {
payload.is_internal = bidRequest.params.isInternal;
}
return {
method: 'POST',
url: baseUrl + '?' + formatQS({ t: bidRequest.params.apiKey }),
Expand Down Expand Up @@ -109,6 +121,15 @@ export const spec = {
* @param {Bid} The bid that won the auction
*/
onBidWon: function (bid) {
const hostname = bid.params[0].baseUrl ? EVENTS_DOMAIN_DEV : EVENTS_DOMAIN;
triggerPixel(
buildUrl({
protocol: 'https',
hostname,
pathname: '/v1/bidsuccess',
search: { t: bid.params[0].apiKey },
})
);
logInfo('Missena - Bid won', bid);
},
};
Expand Down
10 changes: 10 additions & 0 deletions test/spec/modules/missenaBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ describe('Missena Adapter', function () {
sizes: [[1, 1]],
params: {
apiKey: 'PA-34745704',
placement: 'sticky',
formats: ['sticky-banner'],
},
};

Expand Down Expand Up @@ -70,6 +72,14 @@ describe('Missena Adapter', function () {
expect(payload.request_id).to.equal(bidId);
});

it('should send placement', function () {
expect(payload.placement).to.equal('sticky');
});

it('should send formats', function () {
expect(payload.formats).to.eql(['sticky-banner']);
});

it('should send referer information to the request', function () {
expect(payload.referer).to.equal('https://referer');
expect(payload.referer_canonical).to.equal('https://canonical');
Expand Down

0 comments on commit 9d252d4

Please sign in to comment.