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

Fides String Support for GPP #5845

Merged
merged 24 commits into from
Mar 10, 2025
Merged

Conversation

gilluminate
Copy link
Contributor

@gilluminate gilluminate commented Mar 5, 2025

Closes LJ-296

Description Of Changes

Fides.js must support a GPP string as a new section in the existing fides_string, so that GPP can be passed back and forth between the server and Fides.js and used to initialize the CMP with existing preferences.

Code Changes

  • Added support for GPP string handling in fides_string (now contains TC_STRING, AC_STRING, GPP_STRING)
  • Added functions for decoding and working with GPP strings
  • fides_string to consent Supports US National, US state-specific, and TCF GPP sections
  • Improved error handling and debugging
  • Added comprehensive both unit and Cypress test cases for fides_string to consent functionality
  • Updated developer docs with new fides_string format documentation including examples for different string formats.

Steps to Confirm

  1. In Admin UI set up US Modal and TCF experiences
  2. In the demo page, manually save various opt in and opt out, noting the Fides String for each by using the window.Fides.fides_string value and/or cookie. Fides.js should store GPP as part of the Fides string in a new section after the TCF and AC strings (Example: fides_string: ,,DBABLA~BVAUAAAAAWA.QA) The GPP string should be placed at a third index after TCF and AC, even if there are no values for those strings.
  3. Revisit the demo page with the fides_string=... query string, and use each GPP string noted above as the value
  4. Ensure that
  • ...the banner/modal never shows when the fides_string is passed to the correct experience (including for TCF)
  • ...the preferences are identical between the manual and automatic. Open the modal using the modal link after automatic has run to ensure the same preferences were saved (toggle switches match)
  • ...the cookies are the same
  • ...the payload of the api/v1/privacy-preferences endpoint is the same.

Pre-Merge Checklist

  • Issue requirements met
  • All CI pipelines succeeded
  • CHANGELOG.md updated
    • Add a db-migration This indicates that a change includes a database migration label to the entry if your change includes a DB migration
    • Add a high-risk This issue suggests changes that have a high-probability of breaking existing code label to the entry if your change includes a high-risk change (i.e. potential for performance impact or unexpected regression) that should be flagged
  • Followup issues:
    • Followup issues created (include link)
    • No followup issues
  • Database migrations:
    • Ensure that your downrev is up to date with the latest revision on main
    • Ensure that your downgrade() migration is correct and works
      • If a downgrade migration is not possible for this change, please call this out in the PR description!
    • No migrations
  • Documentation:
    • Documentation complete, PR opened in fidesdocs
    • Documentation issue created in fidesdocs
    • If there are any new client scopes created as part of the pull request, remember to update public-facing documentation that references our scope registry
    • No documentation updates required

Copy link

vercel bot commented Mar 5, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
fides-privacy-center ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 10, 2025 4:15pm
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
fides-plus-nightly ⬜️ Ignored (Inspect) Visit Preview Mar 10, 2025 4:15pm

@eastandwestwind
Copy link
Contributor

Are there corresponding docs changes or a ticket to capture this?

@gilluminate
Copy link
Contributor Author

Are there corresponding docs changes or a ticket to capture this?

Doc updates are in this same PR

@gilluminate
Copy link
Contributor Author

gilluminate commented Mar 5, 2025

@eastandwestwind As per my latest commit, I've been thinking about it and I have to agree with you on the region -> API mapping problem. I'm reverting that portion of the code but keeping the other part that relies on it so that it's still the source of truth for all Fides supported regions (only need to update this one place).

Comment on lines +335 to +337
not_available: "000",
opt_out: "111",
not_opt_out: "222",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

These were just incorrect, so cleaning them up. Doesn't affect the tests.

@@ -149,7 +149,7 @@ SCRIPTS.forEach(({ name, gzipErrorSizeKb, gzipWarnSizeKb, isExtension }) => {
file: `dist/${name}.js`,
name: isExtension ? undefined : "Fides",
format: isExtension ? undefined : "umd",
sourcemap: IS_DEV && !isExtension ? "inline" : false,
sourcemap: IS_DEV ? "inline" : false,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

note the new support for gpp=debug below ;)

Comment on lines -176 to -192
const createConsentPreferencesToSave = (
privacyNoticeList: PrivacyNoticeItem[],
enabledPrivacyNoticeKeys: string[],
): SaveConsentPreference[] =>
privacyNoticeList.map((item) => {
const userPreference = transformConsentToFidesUserPreference(
enabledPrivacyNoticeKeys.includes(item.notice.notice_key),
item.notice.consent_mechanism,
);
return new SaveConsentPreference(
item.notice,
userPreference,
item.bestTranslation?.privacy_notice_history_id,
);
});

Copy link
Contributor Author

Choose a reason for hiding this comment

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

moved to a util file for re-usability.

Comment on lines -308 to -329
const createConsentPreferencesToSave = (
privacyNoticeList: PrivacyNoticeWithBestTranslation[],
enabledPrivacyNoticeIds: string[],
): SaveConsentPreference[] => {
if (!privacyNoticeList || !enabledPrivacyNoticeIds) {
return [];
}
return privacyNoticeList.map((item) => {
const userPreference = transformConsentToFidesUserPreference(
enabledPrivacyNoticeIds.includes(item.id),
item.consent_mechanism,
);
return new SaveConsentPreference(
item,
userPreference,
item.bestTranslation?.privacy_notice_history_id,
);
});
};

Copy link
Contributor Author

Choose a reason for hiding this comment

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

moved to a util file for re-usability.

Comment on lines +53 to +59
const vendorIds = [
...tcStringPreferences.vendorsConsent,
...tcStringPreferences.vendorsLegint,
]
.filter(vendorIsAc)
.map((id) => decodeVendorId(id).id)
.sort((a, b) => Number(a) - Number(b))
.join(".");
Copy link
Contributor Author

Choose a reason for hiding this comment

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

a little AI assisted clean up here. No change in functionality. :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This file was actually moved from clients/fides-js/src/lib/tcf/fidesString.ts and updated to include GPP. GitHub is making it look like this is all brand new.

@@ -57,6 +58,24 @@ describe("Fides-js GPP extension", () => {
}).as("patchNoticesServed");
});

describe("with GPP forced", () => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

moved up from below just because it's more "global" and felt like it belonged here with the other "global" tests.

Comment on lines +22 to +24
if (gpp === "debug") {
document.write('<script src="/fides-ext-gpp.js"><\/script>');
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

when gpp=debug we're loading the js file instead of including it as part of the fides.js payload. That way we can benefit from the SourceMaps :)

Copy link
Contributor

@eastandwestwind eastandwestwind left a comment

Choose a reason for hiding this comment

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

Wow, nice work @gilluminate ! Lots of moving parts here, but the key changes look solid.

My comments / Qs above mostly deal with code readability / possible err cases

@gilluminate gilluminate force-pushed the gill/LJ-296/fides-string-support-for-gpp branch from e5524e4 to 106f1f2 Compare March 10, 2025 16:15
@gilluminate gilluminate merged commit 650f70d into main Mar 10, 2025
18 checks passed
@gilluminate gilluminate deleted the gill/LJ-296/fides-string-support-for-gpp branch March 10, 2025 16:34
Copy link

cypress bot commented Mar 10, 2025

fides    Run #12648

Run Properties:  status check passed Passed #12648  •  git commit 650f70dc58: Fides String Support for GPP (#5845)
Project fides
Branch Review main
Run status status check passed Passed #12648
Run duration 00m 52s
Commit git commit 650f70dc58: Fides String Support for GPP (#5845)
Committer Jason Gill
View all properties for this run ↗︎

Test results
Tests that failed  Failures 0
Tests that were flaky  Flaky 0
Tests that did not run due to a developer annotating a test with .skip  Pending 0
Tests that did not run due to a failure in a mocha hook  Skipped 0
Tests that passed  Passing 5
View all changes introduced in this branch ↗︎

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants