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

AdOcean Bid Adapter: send ids which are taking part in auction. #8694

Merged
merged 1 commit into from
Jul 18, 2022
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
13 changes: 10 additions & 3 deletions modules/adoceanBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,15 @@ import { _each, parseSizesInput, isStr, isArray } from '../src/utils.js';
import { registerBidder } from '../src/adapters/bidderFactory.js';

const BIDDER_CODE = 'adocean';
const URL_SAFE_FIELDS = {
schain: true,
slaves: true
};

function buildEndpointUrl(emiter, payloadMap) {
const payload = [];
_each(payloadMap, function(v, k) {
payload.push(k + '=' + (k === 'schain' ? v : encodeURIComponent(v)));
payload.push(k + '=' + (URL_SAFE_FIELDS[k] ? v : encodeURIComponent(v)));
});

const randomizedPart = Math.random().toString().slice(2);
Expand All @@ -17,7 +21,8 @@ function buildRequest(masterBidRequests, masterId, gdprConsent) {
let emiter;
const payload = {
id: masterId,
aosspsizes: []
aosspsizes: [],
slaves: []
};
if (gdprConsent) {
payload.gdpr_consent = gdprConsent.consentString || undefined;
Expand All @@ -29,7 +34,7 @@ function buildRequest(masterBidRequests, masterId, gdprConsent) {
}

const bidIdMap = {};

const uniquePartLength = 10;
_each(masterBidRequests, function(bid, slaveId) {
if (!emiter) {
emiter = bid.params.emiter;
Expand All @@ -38,11 +43,13 @@ function buildRequest(masterBidRequests, masterId, gdprConsent) {
const slaveSizes = parseSizesInput(bid.mediaTypes.banner.sizes).join('_');
const rawSlaveId = bid.params.slaveId.replace('adocean', '');
payload.aosspsizes.push(rawSlaveId + '~' + slaveSizes);
payload.slaves.push(rawSlaveId.slice(-uniquePartLength));

bidIdMap[slaveId] = bid.bidId;
});

payload.aosspsizes = payload.aosspsizes.join('-');
payload.slaves = payload.slaves.join(',');

return {
method: 'GET',
Expand Down
5 changes: 4 additions & 1 deletion test/spec/modules/adoceanBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,17 +136,20 @@ describe('AdoceanAdapter', function () {
expect(request.url).to.include('gdpr_consent=' + bidderRequest.gdprConsent.consentString);
});

it('should attach sizes information to url', function () {
it('should attach sizes and slaves information to url', function () {
let requests = spec.buildRequests(bidRequests, bidderRequest);
expect(requests[0].url).to.include('aosspsizes=myaozpniqismex~300x250_300x600');
expect(requests[0].url).to.include('slaves=zpniqismex');
expect(requests[1].url).to.include('aosspsizes=myaozpniqismex~300x200_600x250');
expect(requests[1].url).to.include('slaves=zpniqismex');

const differentSlavesBids = deepClone(bidRequests);
differentSlavesBids[1].params.slaveId = 'adoceanmyaowafpdwlrks';
requests = spec.buildRequests(differentSlavesBids, bidderRequest);
expect(requests.length).to.equal(1);
expect(requests[0].url).to.include('aosspsizes=myaozpniqismex~300x250_300x600-myaowafpdwlrks~300x200_600x250');
expect((requests[0].url.match(/aosspsizes=/g) || []).length).to.equal(1);
expect(requests[0].url).to.include('slaves=zpniqismex,wafpdwlrks');
});

it('should attach schain parameter if available', function() {
Expand Down