Skip to content

Refactor consent context functions for clarity#7259

Merged
gilluminate merged 3 commits intomainfrom
gill/ENG-2385/consolidate-consent-context-and-update
Jan 28, 2026
Merged

Refactor consent context functions for clarity#7259
gilluminate merged 3 commits intomainfrom
gill/ENG-2385/consolidate-consent-context-and-update

Conversation

@gilluminate
Copy link
Copy Markdown
Contributor

@gilluminate gilluminate commented Jan 27, 2026

Ticket ENG-2385

Description Of Changes

Refactored consent context functions in FidesJS to improve clarity and make the API more intuitive. Renamed getConsentContext to getGpcContext (since it only returns GPC status) and renamed getAutomatedConsentContext to getConsentContext (since it returns the complete consent context).

Code Changes

  • Renamed getConsentContext() to getGpcContext() - returns only GPC status with no parameters
  • Renamed getAutomatedConsentContext(options, optionsOverrides) to getConsentContext(options, optionsOverrides) - returns full consent context
  • Updated all imports and function calls across FidesJS codebase (initialization files, UI components, and GPP/TCF integration)
  • Updated test suite with new function names, all tests passing

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
  • UX feedback:
    • All UX related changes have been reviewed by a designer
    • No UX review needed
  • Followup issues:
    • Followup issues created
    • No followup issues
  • Database migrations:
    • Ensure that your downrev is up to date with the latest revision on %60main%60
    • Ensure that your %60downgrade()%60 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 Jan 27, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

2 Skipped Deployments
Project Deployment Review Updated (UTC)
fides-plus-nightly Ignored Ignored Preview Jan 27, 2026 11:30pm
fides-privacy-center Ignored Ignored Jan 27, 2026 11:30pm

Request Review

@gilluminate gilluminate force-pushed the gill/ENG-2385/consolidate-consent-context-and-update branch from ce82300 to 30da067 Compare January 27, 2026 23:24
@gilluminate gilluminate marked this pull request as ready for review January 27, 2026 23:46
@gilluminate gilluminate requested a review from a team as a code owner January 27, 2026 23:46
@gilluminate gilluminate requested review from lucanovera and removed request for a team and lucanovera January 27, 2026 23:46
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Jan 27, 2026

Greptile Overview

Greptile Summary

This PR refactors the consent context API in FidesJS for better clarity and developer experience. The changes rename two functions to better reflect their actual behavior:

  • getConsentContext()getGpcContext() - Returns only GPC (Global Privacy Control) status
  • getAutomatedConsentContext()getConsentContext() - Returns the complete consent context including GPC, migrated consent from third-party providers, and notice consent strings

Key improvements:

  • More intuitive function naming - getGpcContext() clearly indicates it only returns GPC status, while getConsentContext() now represents the primary function for getting full consent context
  • All usages have been correctly updated across the codebase
  • Components that only need GPC status correctly use getGpcContext()
  • Initialization files that need full automated consent context correctly use getConsentContext()
  • Test suite fully updated with no behavioral changes

Analysis:
The refactoring is well-executed with proper distinction between the two use cases. Files like fides.ts, fides-headless.ts, and fides-tcf.ts correctly use the renamed getConsentContext() since they need access to migrated consent. UI components and GPP integration correctly use getGpcContext() since they only check GPC status for display purposes.

Confidence Score: 5/5

  • This PR is safe to merge with no risk - it's a clean, well-executed refactoring
  • Pure refactoring with consistent naming improvements across all files, no logic changes, and comprehensive test coverage. All function usages have been correctly updated to use the appropriate renamed function based on whether they need GPC-only or full consent context.
  • No files require special attention

Important Files Changed

Filename Overview
clients/fides-js/src/lib/consent-context.ts Renamed functions for clarity: getConsentContextgetGpcContext (GPC only) and getAutomatedConsentContextgetConsentContext (full context)
clients/fides-js/tests/lib/consent-context.test.ts Updated test suite to reflect renamed functions, all test logic remains unchanged
clients/fides-js/src/lib/initialize.ts Correctly uses getGpcContext() since only GPC status is needed for legacy consent defaults
clients/fides-js/src/fides.ts Correctly uses getConsentContext() to get full automated consent context including migrated consent
clients/fides-js/src/fides-headless.ts Correctly uses getConsentContext() to get full automated consent context including migrated consent
clients/fides-js/src/fides-tcf.ts Correctly uses getConsentContext() to get full automated consent context including migrated consent

Copy link
Copy Markdown
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

No files reviewed, no comments

Edit Code Review Agent Settings | Greptile

@gilluminate gilluminate added this pull request to the merge queue Jan 28, 2026
Merged via the queue into main with commit d771c8e Jan 28, 2026
41 of 42 checks passed
@gilluminate gilluminate deleted the gill/ENG-2385/consolidate-consent-context-and-update branch January 28, 2026 02:20
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