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

Enrichment FPD Module: Support for GPC Detection #8925

Merged
merged 3 commits into from
Aug 30, 2022
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
11 changes: 11 additions & 0 deletions modules/enrichmentFpdModule.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,16 @@ function setKeywords() {
if (keywords && keywords.content) mergeDeep(ortb2, { site: { keywords: keywords.content.replace(/\s/g, '') } });
}

/**
* Checks the Global Privacy Control status, and if exists and is true, merges into regs.ext.gpc
*/
function setGpc() {
const gpcValue = navigator.globalPrivacyControl;
if (gpcValue) {
mergeDeep(ortb2, { regs: { ext: { gpc: 1 } } })
}
}

/**
* Resets modules global ortb2 data
*/
Expand All @@ -135,6 +145,7 @@ function runEnrichments() {
setDomain();
setDimensions();
setKeywords();
setGpc();

return ortb2;
}
Expand Down
14 changes: 14 additions & 0 deletions test/spec/modules/enrichmentFpdModule_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,18 @@ describe('the first party data enrichment module', function() {
expect(validated.device).to.deep.equal({ w: 1200, h: 700 });
expect(validated.site.keywords).to.be.undefined;
});

it('should store a reference to gpc witin ortb2.regs.ext if it has been enabled', function() {
let validated;
width = 800;
height = 500;

validated = processFpd({}, {}).global;
expect(validated.regs).to.equal(undefined);

const globalPrivacyControlStub = sinon.stub(window, 'navigator').value({globalPrivacyControl: true});
validated = processFpd({}, {}).global;
expect(validated.regs.ext.gpc).to.equal(1);
globalPrivacyControlStub.restore();
});
});