Skip to content

Add support for consent mechanism string values and non-applicable notices in FidesJS#6115

Merged
gilluminate merged 17 commits intomainfrom
gill/LJ-628/update-all-of-fides-js-to
May 7, 2025
Merged

Add support for consent mechanism string values and non-applicable notices in FidesJS#6115
gilluminate merged 17 commits intomainfrom
gill/LJ-628/update-all-of-fides-js-to

Conversation

@gilluminate
Copy link
Copy Markdown
Contributor

@gilluminate gilluminate commented May 6, 2025

Closes LJ-628

Description Of Changes

Added support for configurable consent flag types and non-applicable notice handling. This introduces two new configuration options: fidesConsentFlagType (for choosing between boolean or consent mechanism string formats) and fidesConsentNonApplicableFlagMode (for controlling whether non-applicable notices are included or omitted). These changes take what was originally applied only to GTM, and made it available to all externally facing consent objects (Fides.consent, events, browser cookie).

Code Changes

  • Added configuration options in FidesOptions for flag type and non-applicable notice mode
  • Updated Fides interface to support both boolean and string consent values
  • Created utility functions to handle different consent flag types and non-applicable notices
  • Refactored GTM integration to use shared consent types
  • Modified NoticeOverlay component to handle string consent values
  • Added transformer functions to convert between different consent representation formats
  • Bonus: Added ESLint rule to prevent ~/ imports (excludes test files)
  • Bonus: Updated Rollup config to handle development mode more efficiently

Steps to Confirm

  1. Initialize Fides SDK with fidesConsentFlagType: "consent_mechanism" option and verify values use string format (/fides-js-demo.html?geolocation=us-ca&fides_consent_flag_type=consent_mechanism)
  2. Initialize with fidesConsentNonApplicableFlagMode: "include" and confirm non-applicable notices are included (/fides-js-demo.html?geolocation=us-ut&fides_consent_non_applicable_flag_mode=include)
  3. Test using both (/fides-js-demo.html?geolocation=us-ut&fides_consent_non_applicable_flag_mode=include&fides_consent_flag_type=consent_mechanism)
  4. Verify GTM integration works with both consent flag types
  5. Verify GPC works with both consent flag types

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
    • Updates unreleased work already in Changelog, no new entry necessary
  • Followup issues:
    • Followup issues created
    • 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

@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented May 6, 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 May 7, 2025 5:15pm
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
fides-plus-nightly ⬜️ Ignored (Inspect) Visit Preview May 7, 2025 5:15pm

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This has been causing problems for a while. Might push this further later.

Comment on lines +191 to +195
if (IS_DEV) {
rollupOptions.push(...[js, declaration]);
} else {
rollupOptions.push(...[js, mjs, declaration]);
}
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

we almost never use mjs during development, so this just speeds things up a bit

Comment on lines +45 to +52
const flagType =
options?.flag_type ??
window.Fides?.options?.fidesConsentFlagType ??
ConsentFlagType.BOOLEAN;
const nonApplicableFlagMode =
options?.non_applicable_flag_mode ??
window.Fides?.options?.fidesConsentNonApplicableFlagMode ??
ConsentNonApplicableFlagMode.OMIT;
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Maintains support for legacy GTM flags

Comment on lines +51 to +88

/**
* Parses a comma-separated string of notice keys into an array of strings.
* Handles undefined input, trims whitespace, and filters out empty strings.
*/
export const parseFidesDisabledNotices = (
value: string | undefined,
): string[] => {
if (!value) {
return [];
}

return value
.split(",")
.map((key) => key.trim())
.filter(Boolean);
};
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I moved this here from consent-utils.ts to resolve a circular dependency warning in Rollup.

Copy link
Copy Markdown
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.

I haven't yet tested locally, but code is mostly looking good! Just a couple requests

Comment thread clients/fides-js/src/components/notices/NoticeOverlay.tsx
Comment thread clients/fides-js/src/fides.ts Outdated
@gilluminate gilluminate force-pushed the gill/LJ-628/update-all-of-fides-js-to branch from 21b1f9d to dcdf1d7 Compare May 7, 2025 17:12
@gilluminate gilluminate force-pushed the gill/LJ-628/update-all-of-fides-js-to branch from dcdf1d7 to 28d3187 Compare May 7, 2025 17:13
@gilluminate gilluminate merged commit 968d2ca into main May 7, 2025
17 checks passed
@gilluminate gilluminate deleted the gill/LJ-628/update-all-of-fides-js-to branch May 7, 2025 17:33
@cypress
Copy link
Copy Markdown

cypress Bot commented May 7, 2025

fides    Run #12908

Run Properties:  status check passed Passed #12908  •  git commit 968d2ca9ed: Add support for consent mechanism string values and non-applicable notices in Fi...
Project fides
Branch Review main
Run status status check passed Passed #12908
Run duration 00m 54s
Commit git commit 968d2ca9ed: Add support for consent mechanism string values and non-applicable notices in Fi...
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