Skip to content

Commit

Permalink
Enrichment FPD Module: Support for GPC Detection (prebid#8925)
Browse files Browse the repository at this point in the history
* support for gpc detection

* updated test name and some other minor changes

* adjusted test

Co-authored-by: Jason Quaccia <[email protected]>
  • Loading branch information
2 people authored and jorgeluisrocha committed May 18, 2023
1 parent f4175a8 commit c0a0123
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
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();
});
});

0 comments on commit c0a0123

Please sign in to comment.