Treat non-applicable keys as defaults which then get overridden#6090
Treat non-applicable keys as defaults which then get overridden#6090gilluminate merged 4 commits intomainfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
1 Skipped Deployment
|
| } | ||
|
|
||
| // Then override with actual consent values | ||
| if (consent) { |
There was a problem hiding this comment.
Small nit but I feel like we'd be better served by reducing the overall cyclomatic complexity of this code.
Instead of wrapping this in an if statement we could:
const nextConsent = consent ?? {}
if (privacyNotices && flagType === GtmFlagType.CONSENT_MECHANISM) {
Object.entries(nextConsent).forEach(([key, value]) => {
consentValues[key] = transformConsentToFidesUserPreference(
value,
privacyNotices.find((notice) => notice.notice_key === key)
?.consent_mechanism,
);
});
} else {
Object.entries(nextConsent).forEach(([key, value]) => {
consentValues[key] = value;
});
}There was a problem hiding this comment.
if there's no consent, it doesn't do anything else, which I think is less cyclomatic, no?
There was a problem hiding this comment.
Additionally, I'm betting the rollup algorithm is going to make this nice and clean anyway, and I'd favor readability in the source code.
There was a problem hiding this comment.
I find less if statements (well... really less execution branches) more readable personally. :)
Something that always happens is easier to reason about than something that sometimes happens.
if there's no consent, it doesn't do anything else, which I think is less cyclomatic, no?
No I don't believe so. At least to my understand cyclomatic complexity goes up with mutually exclusive execution paths in the code. If a path always executes it's less complex than one that does.
Let's take a simpler example case:
function trim(str) {
if (str) {
return str.trim();
}
return "";
}This code has two paths, one where a another function, .trim() will be executed and one where it will not. CC of 2.
function trim(str) {
var trimmedStr = str ?? "";
return trimmedStr.trim();
}This code has one path, .trim() is always called. Therefore (assuming I understand correctly) it has a lower cyclomatic complexity. CC of 1.
fides
|
||||||||||||||||||||||||||||||
| Project |
fides
|
| Branch Review |
main
|
| Run status |
|
| Run duration | 00m 52s |
| Commit |
|
| Committer | Jason Gill |
| View all properties for this run ↗︎ | |
| Test results | |
|---|---|
|
|
0
|
|
|
0
|
|
|
0
|
|
|
0
|
|
|
5
|
Upgrade your plan to view test results. | |
| View all changes introduced in this branch ↗︎ | |
Closes LJ-720
Description Of Changes
Fixed a bug in the GTM integration where duplicate notice keys between
privacy_noticesandnon_applicable_privacy_noticesarrays caused incorrect consent values to be reported. The issue occurred when custom notices were created with the samenotice_keyas existing notices.Code Changes
GTM Integration Fix: Completely reworked how consent values are initialized and applied in the GTM integration. Now it:
Admin UI Preview Improvement: Replaced the use of
systemsCountwith a propervendorCountthat is fetched from the vendor report API, providing more accurate vendor count data for previews.Steps to Confirm
notice_keyas an existing notice (e.g., "data_sales_and_sharing")dataLayerobjectPre-Merge Checklist
CHANGELOG.mdupdatedmaindowngrade()migration is correct and works