From c0a01237af978e7ac13e11f32b99067342dea8f1 Mon Sep 17 00:00:00 2001 From: Jason Quaccia Date: Tue, 30 Aug 2022 14:38:56 -0700 Subject: [PATCH] Enrichment FPD Module: Support for GPC Detection (#8925) * support for gpc detection * updated test name and some other minor changes * adjusted test Co-authored-by: Jason Quaccia --- modules/enrichmentFpdModule.js | 11 +++++++++++ test/spec/modules/enrichmentFpdModule_spec.js | 14 ++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/modules/enrichmentFpdModule.js b/modules/enrichmentFpdModule.js index 139b03d6189..ed9381f4e4d 100644 --- a/modules/enrichmentFpdModule.js +++ b/modules/enrichmentFpdModule.js @@ -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 */ @@ -135,6 +145,7 @@ function runEnrichments() { setDomain(); setDimensions(); setKeywords(); + setGpc(); return ortb2; } diff --git a/test/spec/modules/enrichmentFpdModule_spec.js b/test/spec/modules/enrichmentFpdModule_spec.js index 3cc18f952cc..6aff2d3ceff 100644 --- a/test/spec/modules/enrichmentFpdModule_spec.js +++ b/test/spec/modules/enrichmentFpdModule_spec.js @@ -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(); + }); });