Skip to content

Commit 925b299

Browse files
TheMediaGridStanyslav Glubyshev
andauthored
TheMediaGrid Bid Adapter : support gpp (#9629)
* TheMediaGrid: support gpp * TheMediaGrid: review fixes * TheMediaGrid: fix merge typo * TheMediaGrid: minor fix --------- Co-authored-by: Stanyslav Glubyshev <[email protected]>
1 parent fc92a6f commit 925b299

File tree

2 files changed

+36
-1
lines changed

2 files changed

+36
-1
lines changed

modules/gridBidAdapter.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ export const spec = {
9090
let userExt = null;
9191
let endpoint = null;
9292
let forceBidderName = false;
93-
let {bidderRequestId, auctionId, gdprConsent, uspConsent, timeout, refererInfo} = bidderRequest || {};
93+
let {bidderRequestId, auctionId, gdprConsent, uspConsent, timeout, refererInfo, gppConsent} = bidderRequest || {};
9494

9595
const referer = refererInfo ? encodeURIComponent(refererInfo.page) : '';
9696
const tmax = timeout || config.getConfig('bidderTimeout');
@@ -340,11 +340,22 @@ export const spec = {
340340
}
341341
};
342342
}
343+
const ortb2Regs = deepAccess(bidderRequest, 'ortb2.regs') || {};
344+
if (gppConsent || ortb2Regs?.gpp) {
345+
const gpp = {
346+
gpp: gppConsent?.gppString ?? ortb2Regs?.gpp,
347+
gpp_sid: gppConsent?.applicableSections ?? ortb2Regs?.gpp_sid
348+
};
349+
request.regs = mergeDeep(request?.regs ?? {}, gpp);
350+
}
343351

344352
if (uspConsent) {
345353
if (!request.regs) {
346354
request.regs = {ext: {}};
347355
}
356+
if (!request.regs.ext) {
357+
request.regs.ext = {};
358+
}
348359
request.regs.ext.us_privacy = uspConsent;
349360
}
350361

test/spec/modules/gridBidAdapter_spec.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -575,6 +575,30 @@ describe('TheMediaGrid Adapter', function () {
575575
expect(payload.regs.ext).to.have.property('us_privacy', '1YNN');
576576
});
577577

578+
it('should add gpp information to the request via bidderRequest.gppConsent', function () {
579+
let consentString = 'abc1234';
580+
const gppBidderRequest = Object.assign({gppConsent: {gppString: consentString, applicableSections: [8]}}, bidderRequest);
581+
582+
const [request] = spec.buildRequests(bidRequests, gppBidderRequest);
583+
const payload = JSON.parse(request.data);
584+
585+
expect(payload.regs).to.exist;
586+
expect(payload.regs.gpp).to.equal(consentString);
587+
expect(payload.regs.gpp_sid).to.deep.equal([8]);
588+
});
589+
590+
it('should add gpp information to the request via bidderRequest.ortb2.regs.gpp', function () {
591+
let consentString = 'abc1234';
592+
const gppBidderRequest = Object.assign({ortb2: {regs: {gpp: consentString, gpp_sid: [8]}}}, bidderRequest);
593+
594+
const [request] = spec.buildRequests(bidRequests, gppBidderRequest);
595+
const payload = JSON.parse(request.data);
596+
597+
expect(payload.regs).to.exist;
598+
expect(payload.regs.gpp).to.equal(consentString);
599+
expect(payload.regs.gpp_sid).to.deep.equal([8]);
600+
});
601+
578602
it('if userId is present payload must have user.ext param with right keys', function () {
579603
const eids = [
580604
{

0 commit comments

Comments
 (0)