Skip to content

Rubicon Bid Adapter: GPP support #10132

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

Merged
merged 3 commits into from
Jun 22, 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
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