Skip to content

Commit 4e3dbea

Browse files
authored
Rubicon Bid Adapter: GPP support (prebid#10132)
* Rubicon Bid Adapter GPP support * Add gpp to ordered params * Unit test multiple sids
1 parent 39cc772 commit 4e3dbea

File tree

2 files changed

+54
-1
lines changed

2 files changed

+54
-1
lines changed

modules/rubiconBidAdapter.js

+13-1
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,8 @@ export const spec = {
383383
'gdpr',
384384
'gdpr_consent',
385385
'us_privacy',
386+
'gpp',
387+
'gpp_sid',
386388
'rp_schain',
387389
].concat(Object.keys(params).filter(item => containsUId.test(item)))
388390
.concat([
@@ -554,6 +556,11 @@ export const spec = {
554556
data['us_privacy'] = encodeURIComponent(bidderRequest.uspConsent);
555557
}
556558

559+
if (bidderRequest.gppConsent?.gppString) {
560+
data['gpp'] = bidderRequest.gppConsent.gppString;
561+
data['gpp_sid'] = bidderRequest.gppConsent?.applicableSections?.toString();
562+
}
563+
557564
data['rp_maxbids'] = bidderRequest.bidLimit || 1;
558565

559566
applyFPD(bidRequest, BANNER, data);
@@ -696,7 +703,7 @@ export const spec = {
696703
return (adB.cpm || 0.0) - (adA.cpm || 0.0);
697704
});
698705
},
699-
getUserSyncs: function (syncOptions, responses, gdprConsent, uspConsent) {
706+
getUserSyncs: function (syncOptions, responses, gdprConsent, uspConsent, gppConsent) {
700707
if (!hasSynced && syncOptions.iframeEnabled) {
701708
// data is only assigned if params are available to pass to syncEndpoint
702709
let params = {};
@@ -714,6 +721,11 @@ export const spec = {
714721
params['us_privacy'] = encodeURIComponent(uspConsent);
715722
}
716723

724+
if (gppConsent?.gppString) {
725+
params['gpp'] = gppConsent.gppString;
726+
params['gpp_sid'] = gppConsent.applicableSections?.toString();
727+
}
728+
717729
params = Object.keys(params).length ? `?${formatQS(params)}` : '';
718730

719731
hasSynced = true;

test/spec/modules/rubiconBidAdapter_spec.js

+41
Original file line numberDiff line numberDiff line change
@@ -825,6 +825,29 @@ describe('the rubicon adapter', function () {
825825
});
826826
});
827827

828+
describe('GPP Consent', function () {
829+
it('should send gpp information if bidderRequest has a value for gppConsent', function () {
830+
bidderRequest.gppConsent = {
831+
gppString: 'consent',
832+
applicableSections: 2
833+
};
834+
let [request] = spec.buildRequests(bidderRequest.bids, bidderRequest);
835+
let data = parseQuery(request.data);
836+
delete bidderRequest.gppConsent;
837+
838+
expect(data['gpp']).to.equal('consent');
839+
expect(data['gpp_sid']).to.equal('2');
840+
});
841+
842+
it('should not send gpp information if bidderRequest does not have a value for gppConsent', function () {
843+
let [request] = spec.buildRequests(bidderRequest.bids, bidderRequest);
844+
let data = parseQuery(request.data);
845+
846+
expect(data['gpp']).to.equal(undefined);
847+
expect(data['gpp_sid']).to.equal(undefined);
848+
});
849+
});
850+
828851
describe('first party data', function () {
829852
it('should not have any tg_v or tg_i params if all are undefined', function () {
830853
let params = {
@@ -3653,6 +3676,24 @@ describe('the rubicon adapter', function () {
36533676
type: 'iframe', url: `${emilyUrl}?gdpr=1&gdpr_consent=foo&us_privacy=1NYN`
36543677
});
36553678
});
3679+
3680+
it('should pass gpp params when gppConsent is present', function () {
3681+
expect(spec.getUserSyncs({iframeEnabled: true}, {}, {}, undefined, {
3682+
gppString: 'foo',
3683+
applicableSections: [2]
3684+
})).to.deep.equal({
3685+
type: 'iframe', url: `${emilyUrl}?gpp=foo&gpp_sid=2`
3686+
});
3687+
});
3688+
3689+
it('should pass multiple sid\'s when multiple are present', function () {
3690+
expect(spec.getUserSyncs({iframeEnabled: true}, {}, {}, undefined, {
3691+
gppString: 'foo',
3692+
applicableSections: [2, 5]
3693+
})).to.deep.equal({
3694+
type: 'iframe', url: `${emilyUrl}?gpp=foo&gpp_sid=2,5`
3695+
});
3696+
});
36563697
});
36573698

36583699
describe('get price granularity', function () {

0 commit comments

Comments
 (0)