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

TheMediaGrid Bid Adapter : support gpp #9629

Merged
merged 4 commits into from
Mar 10, 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
13 changes: 12 additions & 1 deletion modules/gridBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export const spec = {
let userExt = null;
let endpoint = null;
let forceBidderName = false;
let {bidderRequestId, auctionId, gdprConsent, uspConsent, timeout, refererInfo} = bidderRequest || {};
let {bidderRequestId, auctionId, gdprConsent, uspConsent, timeout, refererInfo, gppConsent} = bidderRequest || {};

const referer = refererInfo ? encodeURIComponent(refererInfo.page) : '';
const tmax = timeout || config.getConfig('bidderTimeout');
Expand Down Expand Up @@ -369,11 +369,22 @@ export const spec = {
}
};
}
const ortb2Regs = deepAccess(bidderRequest, 'ortb2.regs') || {};
if (gppConsent || ortb2Regs?.gpp) {
const gpp = {
gpp: gppConsent?.gppString ?? ortb2Regs?.gpp,
gpp_sid: gppConsent?.applicableSections ?? ortb2Regs?.gpp_sid
};
request.regs = mergeDeep(request?.regs ?? {}, gpp);
}

if (uspConsent) {
if (!request.regs) {
request.regs = {ext: {}};
}
if (!request.regs.ext) {
request.regs.ext = {};
}
request.regs.ext.us_privacy = uspConsent;
}

Expand Down
24 changes: 24 additions & 0 deletions test/spec/modules/gridBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -575,6 +575,30 @@ describe('TheMediaGrid Adapter', function () {
expect(payload.regs.ext).to.have.property('us_privacy', '1YNN');
});

it('should add gpp information to the request via bidderRequest.gppConsent', function () {
let consentString = 'abc1234';
const gppBidderRequest = Object.assign({gppConsent: {gppString: consentString, applicableSections: [8]}}, bidderRequest);

const [request] = spec.buildRequests(bidRequests, gppBidderRequest);
const payload = JSON.parse(request.data);

expect(payload.regs).to.exist;
expect(payload.regs.gpp).to.equal(consentString);
expect(payload.regs.gpp_sid).to.deep.equal([8]);
});

it('should add gpp information to the request via bidderRequest.ortb2.regs.gpp', function () {
let consentString = 'abc1234';
const gppBidderRequest = Object.assign({ortb2: {regs: {gpp: consentString, gpp_sid: [8]}}}, bidderRequest);

const [request] = spec.buildRequests(bidRequests, gppBidderRequest);
const payload = JSON.parse(request.data);

expect(payload.regs).to.exist;
expect(payload.regs.gpp).to.equal(consentString);
expect(payload.regs.gpp_sid).to.deep.equal([8]);
});

it('if userId is present payload must have user.ext param with right keys', function () {
const eids = [
{
Expand Down