Skip to content
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

Missena Bid Adapter: add format params and onBidWon pixel #9517

Merged
merged 1 commit into from
Feb 24, 2023
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
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