Refactor init for better clarity + TCF separation#6173
Merged
gilluminate merged 3 commits intomainfrom May 29, 2025
Merged
Conversation
Contributor
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 2 Skipped Deployments
|
b24cff7 to
9a95077
Compare
NevilleS
approved these changes
May 29, 2025
Contributor
NevilleS
left a comment
There was a problem hiding this comment.
I think I'm following this, and from code inspection I see that the logic is intact.
Comment on lines
-166
to
-171
| // Register any configured consent migration providers | ||
| registerDefaultProviders(options); | ||
|
|
||
| // Check if there's consent available to migrate from any provider | ||
| const { consent: migratedConsent } = readConsentFromAnyProvider(options); | ||
| const hasMigratableConsent = !!migratedConsent; |
Contributor
There was a problem hiding this comment.
Were we doing this part twice before (registerDefaultProviders and readConsentFromAnyProvider)? Seems like it?
Contributor
Author
There was a problem hiding this comment.
yep! ...and only so we could form the if statement.
Comment on lines
+151
to
+160
| this.experience = config.experience; // pre-fetched experience if available | ||
| const hasExistingCookie = !isNewFidesCookie(this.cookie); | ||
| const hasMigratableConsent = !!migratedConsent; | ||
| if (hasExistingCookie || hasMigratableConsent) { | ||
| /* | ||
| * We have enough information to initialize the Fides object before we have a valid experience. | ||
| * In this case, the experience is less important because the user has already consented to something. | ||
| * The earlier we can communicate consent to the vendor, the better. | ||
| */ | ||
| const initialFides = getInitialFidesFromConsent({ |
Contributor
There was a problem hiding this comment.
OK, yeah, this is clearer; basically you've hoisted the internal if out of the getInitialFides code and placed it here.
de56a0d to
9120021
Compare
fides
|
||||||||||||||||||||||||||||
| Project |
fides
|
| Branch Review |
main
|
| Run status |
|
| Run duration | 00m 53s |
| Commit |
|
| Committer | Jason Gill |
| View all properties for this run ↗︎ | |
| Test results | |
|---|---|
|
|
0
|
|
|
0
|
|
|
0
|
|
|
0
|
|
|
5
|
| View all changes introduced in this branch ↗︎ | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description Of Changes
There was some developer confusion around when and how existing consent gets set and how it fits in to the initialization process. This refactor is meant to clear up confusion by moving some of the logic to the main
initthread. There's a different set of logic needed for regular fides vs. TCF vs. Headless, and this refactor helps make that clear without changing any of the existing functionality.Code Changes
getInitialFidestogetInitialFidesFromConsentCookiefor claritygetInitialFidesFromConsentwhere that context isn't obvious and can be confusing.Steps to Confirm
Pre-Merge Checklist
CHANGELOG.mdupdatedmaindowngrade()migration is correct and works