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

Adagio Bid Adapter: remove useless adrequest fields #10794

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
41 changes: 25 additions & 16 deletions modules/adagioBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -1020,6 +1020,9 @@ export const spec = {
}
}

// Enforce the organizationId param to be a string
bidRequest.params.organizationId = bidRequest.params.organizationId.toString();

// Force the Data Layer key and value to be a String
if (bidRequest.params.dataLayer) {
if (isStr(bidRequest.params.dataLayer) || isNumber(bidRequest.params.dataLayer) || isArray(bidRequest.params.dataLayer) || isFn(bidRequest.params.dataLayer)) {
Expand Down Expand Up @@ -1120,30 +1123,36 @@ export const spec = {
bidRequest.gpid = gpid;
}

// store the whole bidRequest (adUnit) object in the ADAGIO namespace.
storeRequestInAdagioNS(bidRequest);

// Remove these fields at the very end, so we can still use them before.
delete bidRequest.transactionId;
delete bidRequest.ortb2Imp;
delete bidRequest.ortb2;
delete bidRequest.sizes;
// Remove some params that are not needed on the server side.
delete bidRequest.params.siteId;

// whitelist the fields that are allowed to be sent to the server.
const adUnit = {
adUnitCode: bidRequest.adUnitCode,
auctionId: bidRequest.auctionId,
bidder: bidRequest.bidder,
bidId: bidRequest.bidId,
params: bidRequest.params,
features: bidRequest.features,
gpid: bidRequest.gpid,
mediaTypes: bidRequest.mediaTypes,
nativeParams: bidRequest.nativeParams,
score: bidRequest.score,
transactionId: bidRequest.transactionId,
}

return bidRequest;
return adUnit;
});

// Group ad units by organizationId
const groupedAdUnits = adUnits.reduce((groupedAdUnits, adUnit) => {
const adUnitCopy = deepClone(adUnit);
adUnitCopy.params.organizationId = adUnitCopy.params.organizationId.toString();

// remove useless props
delete adUnitCopy.floorData;
delete adUnitCopy.params.siteId;
delete adUnitCopy.userId;
delete adUnitCopy.userIdAsEids;
const organizationId = adUnit.params.organizationId

groupedAdUnits[adUnitCopy.params.organizationId] = groupedAdUnits[adUnitCopy.params.organizationId] || [];
groupedAdUnits[adUnitCopy.params.organizationId].push(adUnitCopy);
groupedAdUnits[organizationId] = groupedAdUnits[organizationId] || [];
groupedAdUnits[organizationId].push(adUnit);

return groupedAdUnits;
}, {});
Expand Down
11 changes: 0 additions & 11 deletions test/spec/modules/adagioBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -861,11 +861,6 @@ describe('Adagio bid adapter', () => {
}
const requests = spec.buildRequests([bid01], bidderRequest);

expect(requests[0].data.adUnits[0].floors.length).to.equal(3);
expect(requests[0].data.adUnits[0].floors[0]).to.deep.equal({f: 1, mt: 'banner', s: '300x250'});
expect(requests[0].data.adUnits[0].floors[1]).to.deep.equal({f: 1, mt: 'banner', s: '300x600'});
expect(requests[0].data.adUnits[0].floors[2]).to.deep.equal({f: 1, mt: 'video', s: '600x480'});

expect(requests[0].data.adUnits[0].mediaTypes.banner.sizes.length).to.equal(2);
expect(requests[0].data.adUnits[0].mediaTypes.banner.bannerSizes[0]).to.deep.equal({size: [300, 250], floor: 1});
expect(requests[0].data.adUnits[0].mediaTypes.banner.bannerSizes[1]).to.deep.equal({size: [300, 600], floor: 1});
Expand All @@ -890,10 +885,6 @@ describe('Adagio bid adapter', () => {
}
const requests = spec.buildRequests([bid01], bidderRequest);

expect(requests[0].data.adUnits[0].floors.length).to.equal(2);
expect(requests[0].data.adUnits[0].floors[0]).to.deep.equal({f: 1, mt: 'video'});
expect(requests[0].data.adUnits[0].floors[1]).to.deep.equal({f: 1, mt: 'native'});

expect(requests[0].data.adUnits[0].mediaTypes.video.floor).to.equal(1);
expect(requests[0].data.adUnits[0].mediaTypes.native.floor).to.equal(1);
});
Expand All @@ -913,8 +904,6 @@ describe('Adagio bid adapter', () => {
}
const requests = spec.buildRequests([bid01], bidderRequest);

expect(requests[0].data.adUnits[0].floors.length).to.equal(1);
expect(requests[0].data.adUnits[0].floors[0]).to.deep.equal({mt: 'video'});
expect(requests[0].data.adUnits[0].mediaTypes.video.floor).to.be.undefined;
});
});
Expand Down