Skip to content

Commit

Permalink
Include us_privacy string in redirects (#8)
Browse files Browse the repository at this point in the history
* include us_privacy string in redirects

* added test cases for us_privacy and gdpr

* added test cases for  gdpr without usp

* updated test case when no privacy strings and fixed package-lock.json

* revert package-lock.json

Co-authored-by: EMXDigital <[email protected]>
  • Loading branch information
EMXDigital and rakeshbalakrishnan28 authored Jan 24, 2023
1 parent 68bf7e7 commit a1ef53e
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 2 deletions.
11 changes: 9 additions & 2 deletions modules/emx_digitalBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -354,16 +354,23 @@ export const spec = {
},
getUserSyncs: function (syncOptions, responses, gdprConsent, uspConsent) {
const syncs = [];
const consentParams = [];
if (syncOptions.iframeEnabled) {
let url = 'https://biddr.brealtime.com/check.html';
if (gdprConsent && typeof gdprConsent.consentString === 'string') {
// add 'gdpr' only if 'gdprApplies' is defined
if (typeof gdprConsent.gdprApplies === 'boolean') {
url += `?gdpr=${Number(gdprConsent.gdprApplies)}&gdpr_consent=${gdprConsent.consentString}`;
consentParams.push(`gdpr=${Number(gdprConsent.gdprApplies)}&gdpr_consent=${gdprConsent.consentString}`);
} else {
url += `?gdpr_consent=${gdprConsent.consentString}`;
consentParams.push(`?gdpr_consent=${gdprConsent.consentString}`);
}
}
if (uspConsent && typeof uspConsent.consentString === 'string') {
consentParams.push(`usp=${uspConsent.consentString}`);
}
if (consentParams.length > 0) {
url = url + '?' + consentParams.join('&');
}
syncs.push({
type: 'iframe',
url: url
Expand Down
29 changes: 29 additions & 0 deletions test/spec/modules/emx_digitalBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -724,6 +724,7 @@ describe('emx_digital Adapter', function () {
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.equal('https://biddr.brealtime.com/check.html')
});

it('should pass gdpr params', function () {
Expand All @@ -734,6 +735,34 @@ describe('emx_digital Adapter', function () {
expect(syncs).to.have.lengthOf(1);
expect(syncs[0].type).to.equal('iframe');
expect(syncs[0].url).to.contains('gdpr=0');
expect(syncs[0].url).to.equal('https://biddr.brealtime.com/check.html?gdpr=0&gdpr_consent=test')
});

it('should pass us_privacy string', function () {
let syncs = spec.getUserSyncs({ iframeEnabled: true }, {}, {}, {
consentString: 'test',
});
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('usp=test');
});

it('should pass us_privacy and gdpr strings', function () {
let syncs = spec.getUserSyncs({ iframeEnabled: true }, {},
{
gdprApplies: true,
consentString: 'test'
},
{
consentString: 'test'
});
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.equal('https://biddr.brealtime.com/check.html?gdpr=1&gdpr_consent=test&usp=test')
});
});
});

0 comments on commit a1ef53e

Please sign in to comment.