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: allow per page capping #10863

Merged
merged 1 commit into from
Jan 3, 2024
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
4 changes: 3 additions & 1 deletion modules/missenaBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,11 @@ export const spec = {
buildRequests: function (validBidRequests, bidderRequest) {
const capKey = `missena.missena.capper.remove-bubble.${validBidRequests[0]?.params.apiKey}`;
const capping = safeJSONParse(storage.getDataFromLocalStorage(capKey));
const referer = bidderRequest?.refererInfo?.topmostLocation;
if (
typeof capping?.expiry === 'number' &&
new Date().getTime() < capping?.expiry
new Date().getTime() < capping?.expiry &&
(!capping?.referer || capping?.referer == referer)
) {
logInfo('Missena - Capped');
return [];
Expand Down
41 changes: 39 additions & 2 deletions test/spec/modules/missenaBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ import { expect } from 'chai';
import { spec, storage } from 'modules/missenaBidAdapter.js';
import { BANNER } from '../../../src/mediaTypes.js';

const REFERRER = 'https://referer';
const REFERRER2 = 'https://referer2';

describe('Missena Adapter', function () {
$$PREBID_GLOBAL$$.bidderSettings = {
missena: {
Expand Down Expand Up @@ -50,7 +53,7 @@ describe('Missena Adapter', function () {
gdprApplies: true,
},
refererInfo: {
topmostLocation: 'https://referer',
topmostLocation: REFERRER,
canonicalUrl: 'https://canonical',
},
};
Expand Down Expand Up @@ -112,7 +115,7 @@ describe('Missena Adapter', function () {
});

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

Expand Down Expand Up @@ -146,6 +149,40 @@ describe('Missena Adapter', function () {
it('should not participate if capped', function () {
expect(cappedRequests.length).to.equal(0);
});

const localStorageDataSamePage = {
[`missena.missena.capper.remove-bubble.${bid.params.apiKey}`]:
JSON.stringify({
expiry: new Date().getTime() + 600_000, // 10 min into the future
referer: REFERRER,
}),
};

getDataFromLocalStorageStub.callsFake(
(key) => localStorageDataSamePage[key],
);
const cappedRequestsSamePage = spec.buildRequests(bids, bidderRequest);

it('should not participate if capped on same page', function () {
expect(cappedRequestsSamePage.length).to.equal(0);
});

const localStorageDataOtherPage = {
[`missena.missena.capper.remove-bubble.${bid.params.apiKey}`]:
JSON.stringify({
expiry: new Date().getTime() + 600_000, // 10 min into the future
referer: REFERRER2,
}),
};

getDataFromLocalStorageStub.callsFake(
(key) => localStorageDataOtherPage[key],
);
const cappedRequestsOtherPage = spec.buildRequests(bids, bidderRequest);

it('should participate if capped on a different page', function () {
expect(cappedRequestsOtherPage.length).to.equal(2);
});
});

describe('interpretResponse', function () {
Expand Down