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

Cadent Aperture MX Bid Adapter: Include gpp consent in usersync endpoint #10404

Merged
merged 2 commits into from
Sep 5, 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
10 changes: 9 additions & 1 deletion modules/cadentApertureMXBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ export const spec = {
}
return cadentBidResponses;
},
getUserSyncs: function (syncOptions, responses, gdprConsent, uspConsent) {
getUserSyncs: function (syncOptions, responses, gdprConsent, uspConsent, gppConsent) {
const syncs = [];
const consentParams = [];
if (syncOptions.iframeEnabled) {
Expand All @@ -390,6 +390,14 @@ export const spec = {
if (uspConsent && typeof uspConsent.consentString === 'string') {
consentParams.push(`usp=${uspConsent.consentString}`);
}
if (gppConsent && typeof gppConsent === 'object') {
if (gppConsent.gppString && typeof gppConsent.gppString === 'string') {
consentParams.push(`gpp=${gppConsent.gppString}`);
}
if (gppConsent.applicableSections && typeof gppConsent.applicableSections === 'object') {
consentParams.push(`gpp_sid=${gppConsent.applicableSections}`);
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe these checks can be simplified since you already check that gppConsent is an object

if (typeof gppConsent.gppString === 'string') {
if (Array.isArray(gppConsent.applicableSections)) {

Or just use optional chaining

if (typeof gppConsent?.gppString === 'string') {
if (Array.isArray(gppConsent?.applicableSections)) {

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR is approved already. we have noted the suggested change and plan push it as part of another PR or maintenance change. @robertrmartinez

}
if (consentParams.length > 0) {
url = url + '?' + consentParams.join('&');
}
Expand Down
33 changes: 33 additions & 0 deletions test/spec/modules/cadentApertureMXBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -834,5 +834,38 @@ describe('cadent_aperture_mx Adapter', function () {
expect(syncs[0].url).to.contains('usp=test');
expect(syncs[0].url).to.equal('https://biddr.brealtime.com/check.html?gdpr=1&gdpr_consent=test&usp=test')
});

it('should pass gpp string and section id', function() {
let syncs = spec.getUserSyncs({iframeEnabled: true}, {}, {}, {}, {
gppString: 'abcdefgs',
applicableSections: [1, 2, 4]
});
expect(syncs).to.not.be.an('undefined');
expect(syncs[0].url).to.contains('gpp=abcdefgs')
expect(syncs[0].url).to.contains('gpp_sid=1,2,4')
});

it('should pass us_privacy and gdpr string and gpp string', function () {
let syncs = spec.getUserSyncs({ iframeEnabled: true }, {},
{
gdprApplies: true,
consentString: 'test'
},
{
consentString: 'test'
},
{
gppString: 'abcdefgs',
applicableSections: [1, 2, 4]
}
);
expect(syncs).to.not.be.an('undefined');
expect(syncs).to.have.lengthOf(1);
expect(syncs[0].type).to.equal('iframe');
expect(syncs[0].url).to.contains('gdpr=1');
expect(syncs[0].url).to.contains('usp=test');
expect(syncs[0].url).to.contains('gpp=abcdefgs');
expect(syncs[0].url).to.equal('https://biddr.brealtime.com/check.html?gdpr=1&gdpr_consent=test&usp=test&gpp=abcdefgs&gpp_sid=1,2,4');
});
});
});