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 2 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);

navigator.globalPrivacyControl = { gpc: 1 };
Copy link
Collaborator

@dgirardi dgirardi Aug 30, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as I read the proposal this should be true or false. However, I have two objections:

  • aren't we doing this too early? none of my browsers set this, and it's not even mentioned on MDN. Is the proposal final and on its way to implementation?
  • Once the navigator does set this, this test will not work right, because it's going to be a read-only field. I think you need to mock it here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just updated my PR. somehow missed the true or false part thanks for pointing that out. i think the test is ok now.

correct, from what i gathered as well, this functionality does still seem to be in it's early stages, not 100% sure when it will be fully implemented. it does state here how detection will occur though: https://global-privacy-control.glitch.me/ (was taken from https://globalprivacycontrol.org/, from the faq at the bottom under "I’m a publisher, developer, or other service. How can I support GPC?")

i was aiming to be proactive, however, as you mentioned because this is still in the proposal phase should we hold off entirely for the time being in case specifications change?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's OK because as it's written the worst that can happen is that we don't pick up the gpc flag. I'm just surprised that we'd get here before MDN :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

haha i agree, MDN typically knows all. least the change on our end for this is pretty minimal/low-risk like you pointed out anyway

validated = processFpd({}, {}).global;
expect(validated.regs.ext.gpc).to.equal(1);
delete navigator.globalPrivacyControl;
});
});