Skip to content

Commit

Permalink
consentManagementTcf: add flag to set dsarequired
Browse files Browse the repository at this point in the history
  • Loading branch information
dgirardi committed Jun 18, 2024
1 parent 03d4162 commit 2793c76
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
5 changes: 5 additions & 0 deletions modules/consentManagementTcf.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export let userCMP;
export let consentTimeout;
export let gdprScope;
export let staticConsentData;
let dsaPlatform = false;
let actionTimeout;

let consentData;
Expand Down Expand Up @@ -282,6 +283,7 @@ export function setConsentConfig(config) {

// if true, then gdprApplies should be set to true
gdprScope = config.defaultGdprScope === true;
dsaPlatform = !!config.dsaPlatform;

logInfo('consentManagement module has been activated...');

Expand Down Expand Up @@ -315,6 +317,9 @@ export function enrichFPDHook(next, fpd) {
}
deepSetValue(ortb2, 'user.ext.consent', consent.consentString);
}
if (dsaPlatform) {
deepSetValue(ortb2, 'regs.ext.dsa.dsarequired', 3);
}
return ortb2;
}));
}
Expand Down
26 changes: 24 additions & 2 deletions test/spec/fpd/gdpr_spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import {gdprDataHandler} from '../../../src/adapterManager.js';
import {enrichFPDHook} from '../../../modules/consentManagementTcf.js';
import {config} from 'src/config.js';
import 'src/prebid.js';

describe('GDPR FPD enrichment', () => {
let sandbox, consent;
Expand All @@ -12,9 +14,9 @@ describe('GDPR FPD enrichment', () => {
sandbox.restore();
})

function callHook() {
function callHook(ortb2 = {}) {
let result;
enrichFPDHook((res) => { result = res }, Promise.resolve({}));
enrichFPDHook((res) => { result = res }, Promise.resolve(ortb2));
return result;
}

Expand Down Expand Up @@ -44,4 +46,24 @@ describe('GDPR FPD enrichment', () => {
})
})
});

describe('dsa', () => {
describe('when dsaPlaform is set', () => {
beforeEach(() => {
config.setConfig({
consentManagement: {
gdpr: {
dsaPlatform: true
}
}
});
});

it('sets dsarequired', () => {
return callHook().then(ortb2 => {
expect(ortb2.regs.ext.dsa.dsarequired).to.equal(3);
});
});
});
});
});

0 comments on commit 2793c76

Please sign in to comment.