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

Update privacy center patch call for new API response #4235

Merged

Conversation

allisonking
Copy link
Contributor

@allisonking allisonking commented Oct 6, 2023

Closes #4225

Description Of Changes

The privacy center uses the response of patching notices with user preferences in order to create/update its cookie. The response payload format changed in #4201 to nest preferences under an object. This PR allows the FE to handle this new expected payload type.

Code Changes

  • Update privacy center types
  • Minor code updates to handle new response type
  • Update cypress fixtures

Steps to Confirm

Everything should work as before! The main thing that changed is the API returns a new type, so now the FE handles that. To prove it's working, you'll want to observe that your cookie updates according to your saved preferences. This is for notices only, not TCF.

  • Enable "Data sales and sharing" for privacy notices in admin-ui
  • VPN to california
  • Visit the privacy center and click "Manage your consent"
  • Take a look at your cookie, if one exists. Data sales and sharing is default opt-in, but that might not be reflected in your cookie yet (esp if you don't have a cookie yet!)
  • Opt out of data sales and sharing
  • Your cookie value should now say {"consent":{"data_sales_and_sharing":false}}

Pre-Merge Checklist

  • All CI Pipelines Succeeded
  • Issue Requirements are Met
  • Update CHANGELOG.md

@@ -171,7 +171,7 @@ const NoticeDrivenConsent = () => {
(n) => n.privacy_notice_history_id === historyKey
);
const servedNotice = servedNotices?.find(
(sn) => sn.privacy_notice_history.id === historyKey
(sn) => sn.privacy_notice_history?.id === historyKey
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 is the only one with "actual" changes. there were two API changes we account for here:

  1. served notices now return optional privacy_notice_history (since TCF doesn't have those)
  2. the preferences patch now returns the data we expect nested under preferences (so that tcf data can be nested in its own subsections)

every other change in this PR is pretty much type wrangling

Copy link
Contributor

Choose a reason for hiding this comment

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

Nice, it looks like a lot of good type updates on the privacy center side made it into this PR

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, the privacy center types were a bit out of date 😓

@cypress
Copy link

cypress bot commented Oct 6, 2023

Passing run #4507 ↗︎

0 4 0 0 Flakiness 0

Details:

Merge fad6a78 into e730838...
Project: fides Commit: 7b8a069981 ℹ️
Status: Passed Duration: 00:52 💡
Started: Oct 6, 2023 8:30 PM Ended: Oct 6, 2023 8:31 PM

Review all test suite changes for PR #4235 ↗︎

@allisonking allisonking marked this pull request as ready for review October 6, 2023 18:50
Copy link
Contributor

@pattisdr pattisdr left a comment

Choose a reason for hiding this comment

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

Did a lot of testing and looked closely at this file: clients/privacy-center/components/consent/NoticeDrivenConsent.tsx

I just have one question really!

@@ -1565,7 +1565,7 @@ describe("Consent banner", () => {
cy.wait("@patchPrivacyPreference").then((preferenceInterception) => {
const { preferences } = preferenceInterception.request.body;
const expected = interception.response?.body.map(
(s: LastServedNoticeSchema) => s.served_notice_history_id
(s: LastServedConsentSchema) => s.served_notice_history_id
Copy link
Contributor

Choose a reason for hiding this comment

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

There's a similar LastServedNoticeSchema still being imported into clients/privacy-center/cypress/e2e/consent-notices.cy.ts - does that also need to be updated?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ahh good eye!! fixed: fad6a78

Comment on lines +30 to +40
tcf_purpose_consents?: Array<TCFPurposeConsentRecord>;
tcf_purpose_legitimate_interests?: Array<TCFPurposeLegitimateInterestsRecord>;
tcf_special_purposes?: Array<TCFSpecialPurposeRecord>;
tcf_features?: Array<TCFFeatureRecord>;
tcf_special_features?: Array<TCFSpecialFeatureRecord>;
tcf_vendor_consents?: Array<TCFVendorConsentRecord>;
tcf_vendor_legitimate_interests?: Array<TCFVendorLegitimateInterestsRecord>;
tcf_vendor_relationships?: Array<TCFVendorRelationships>;
tcf_system_consents?: Array<TCFVendorConsentRecord>;
tcf_system_legitimate_interests?: Array<TCFVendorLegitimateInterestsRecord>;
tcf_system_relationships?: Array<TCFVendorRelationships>;
Copy link
Contributor

Choose a reason for hiding this comment

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

How do you generate these?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I typically:

  1. tag fides
  2. Use that version in fidesplus
  3. in admin-ui, run npm run openapi:generate, then npm run format. This will autogenerate all the TS types based off of the backend's openapi.json file. we run it off of fidesplus since fidesplus has a superset of fides types
  4. that sets admin-ui up nicely for TS types (which I did in the branch this PR is based off of)
  5. unfortunately for apps other than admin-ui, we manually copy and paste the relevant files over 🥲 there should be a way to share types one day, but that's been an open issue for a while now

Copy link
Contributor

Choose a reason for hiding this comment

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

ahh thank you, I'll save this somewhere 👍

Comment on lines +10 to +21
export type SavePrivacyPreferencesResponse = {
preferences?: Array<CurrentPrivacyPreferenceSchema>;
purpose_consent_preferences?: Array<CurrentPrivacyPreferenceSchema>;
purpose_legitimate_interests_preferences?: Array<CurrentPrivacyPreferenceSchema>;
special_purpose_preferences?: Array<CurrentPrivacyPreferenceSchema>;
vendor_consent_preferences?: Array<CurrentPrivacyPreferenceSchema>;
vendor_legitimate_interests_preferences?: Array<CurrentPrivacyPreferenceSchema>;
feature_preferences?: Array<CurrentPrivacyPreferenceSchema>;
special_feature_preferences?: Array<CurrentPrivacyPreferenceSchema>;
system_consent_preferences?: Array<CurrentPrivacyPreferenceSchema>;
system_legitimate_interests_preferences?: Array<CurrentPrivacyPreferenceSchema>;
};
Copy link
Contributor

Choose a reason for hiding this comment

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

🎉

@@ -171,7 +171,7 @@ const NoticeDrivenConsent = () => {
(n) => n.privacy_notice_history_id === historyKey
);
const servedNotice = servedNotices?.find(
(sn) => sn.privacy_notice_history.id === historyKey
(sn) => sn.privacy_notice_history?.id === historyKey
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice, it looks like a lot of good type updates on the privacy center side made it into this PR

@allisonking allisonking merged commit 5f614aa into aking/4209/integrate-vendor-legal-basis Oct 6, 2023
7 checks passed
@allisonking allisonking deleted the aking/4225/update-pc-call branch October 6, 2023 20:38
@pattisdr pattisdr mentioned this pull request Nov 6, 2023
8 tasks
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