Skip to content

Commit

Permalink
Rubicon Bid Adapter: GPP support (prebid#10132)
Browse files Browse the repository at this point in the history
* Rubicon Bid Adapter GPP support

* Add gpp to ordered params

* Unit test multiple sids
  • Loading branch information
spotxslagle authored Jun 22, 2023
1 parent 39cc772 commit 4e3dbea
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 1 deletion.
14 changes: 13 additions & 1 deletion modules/rubiconBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,8 @@ export const spec = {
'gdpr',
'gdpr_consent',
'us_privacy',
'gpp',
'gpp_sid',
'rp_schain',
].concat(Object.keys(params).filter(item => containsUId.test(item)))
.concat([
Expand Down Expand Up @@ -554,6 +556,11 @@ export const spec = {
data['us_privacy'] = encodeURIComponent(bidderRequest.uspConsent);
}

if (bidderRequest.gppConsent?.gppString) {
data['gpp'] = bidderRequest.gppConsent.gppString;
data['gpp_sid'] = bidderRequest.gppConsent?.applicableSections?.toString();
}

data['rp_maxbids'] = bidderRequest.bidLimit || 1;

applyFPD(bidRequest, BANNER, data);
Expand Down Expand Up @@ -696,7 +703,7 @@ export const spec = {
return (adB.cpm || 0.0) - (adA.cpm || 0.0);
});
},
getUserSyncs: function (syncOptions, responses, gdprConsent, uspConsent) {
getUserSyncs: function (syncOptions, responses, gdprConsent, uspConsent, gppConsent) {
if (!hasSynced && syncOptions.iframeEnabled) {
// data is only assigned if params are available to pass to syncEndpoint
let params = {};
Expand All @@ -714,6 +721,11 @@ export const spec = {
params['us_privacy'] = encodeURIComponent(uspConsent);
}

if (gppConsent?.gppString) {
params['gpp'] = gppConsent.gppString;
params['gpp_sid'] = gppConsent.applicableSections?.toString();
}

params = Object.keys(params).length ? `?${formatQS(params)}` : '';

hasSynced = true;
Expand Down
41 changes: 41 additions & 0 deletions test/spec/modules/rubiconBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -825,6 +825,29 @@ describe('the rubicon adapter', function () {
});
});

describe('GPP Consent', function () {
it('should send gpp information if bidderRequest has a value for gppConsent', function () {
bidderRequest.gppConsent = {
gppString: 'consent',
applicableSections: 2
};
let [request] = spec.buildRequests(bidderRequest.bids, bidderRequest);
let data = parseQuery(request.data);
delete bidderRequest.gppConsent;

expect(data['gpp']).to.equal('consent');
expect(data['gpp_sid']).to.equal('2');
});

it('should not send gpp information if bidderRequest does not have a value for gppConsent', function () {
let [request] = spec.buildRequests(bidderRequest.bids, bidderRequest);
let data = parseQuery(request.data);

expect(data['gpp']).to.equal(undefined);
expect(data['gpp_sid']).to.equal(undefined);
});
});

describe('first party data', function () {
it('should not have any tg_v or tg_i params if all are undefined', function () {
let params = {
Expand Down Expand Up @@ -3653,6 +3676,24 @@ describe('the rubicon adapter', function () {
type: 'iframe', url: `${emilyUrl}?gdpr=1&gdpr_consent=foo&us_privacy=1NYN`
});
});

it('should pass gpp params when gppConsent is present', function () {
expect(spec.getUserSyncs({iframeEnabled: true}, {}, {}, undefined, {
gppString: 'foo',
applicableSections: [2]
})).to.deep.equal({
type: 'iframe', url: `${emilyUrl}?gpp=foo&gpp_sid=2`
});
});

it('should pass multiple sid\'s when multiple are present', function () {
expect(spec.getUserSyncs({iframeEnabled: true}, {}, {}, undefined, {
gppString: 'foo',
applicableSections: [2, 5]
})).to.deep.equal({
type: 'iframe', url: `${emilyUrl}?gpp=foo&gpp_sid=2,5`
});
});
});

describe('get price granularity', function () {
Expand Down

0 comments on commit 4e3dbea

Please sign in to comment.