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

Initialize prefetched TCF experience preferences from cookie #4124

Merged
merged 19 commits into from
Sep 28, 2023

Conversation

allisonking
Copy link
Contributor

@allisonking allisonking commented Sep 20, 2023

Closes #4046
Closes #4011

Description Of Changes

Makes prefetch work for TCF—the thing that was making this not work was that we weren't saving TCF preferences to a cookie, and so we couldn't initialize a user's preferences from a cookie (since a prefetched experience won't have a user's individual preferences).

Code Changes

  • Adds function to help save TCF preferences to a cookie
  • Updates assigning cookie values to an experience object function handle the TCF parts
  • Re-enable prefetching with TCF in the privacy center endpoint (there was a protective if statement that made it not possible to do both prefetch and TCF)
  • Unit tests
  • Cypress tests

Steps to Confirm

  • Add the following to a .env file at the root of your fides repo (I'm actually not sure that all of these are needed, but this works!)
FIDES_SAMPLE_APP__PRIVACY_CENTER_URL="http://localhost:3001"
FIDES_PRIVACY_CENTER__DEBUG=true
FIDES_PRIVACY_CENTER__IS_OVERLAY_ENABLED=true
FIDES_PRIVACY_CENTER__IS_GEOLOCATION_ENABLED=true
FIDES_PRIVACY_CENTER__IS_PREFETCH_ENABLED=true
FIDES_PRIVACY_CENTER__TCF_ENABLED=true
FIDES_PRIVACY_CENTER__GEOLOCATION_API_URL="https://cdn-api.ethyca.com/location"
FIDES_PRIVACY_CENTER__PRIVACY_CENTER_URL="http://localhost:3001"
  • Run `nox -s "fides_env(test)"
  • Once everything comes up, visit localhost:8080/docs and turn TCF on via the PATCH to consent-settings. You'll need to authorize with these creds first
    image
  • Now that TCF is enabled, visit localhost:8080 and edit one of the existing systems.
  • Add a data use such as analytics.reporting.campaign_insights (which is one of the TCF data uses). Give it a legal basis of "Consent" and save.
  • Now visit cookie house at localhost:3000 and click on "Frankfurt" from the geolocation dropdown.
  • Open the network tab and refresh the page. You should not see a call to /privacy-experience since it is being prefetched by the privacy center! But you should still see the banner pop up
  • Click on "manage preferences" in the banner, then "manage preferences" again to move past the initial layer. Toggle the the purpose Understand audiences through statistics or combinations of data from different sources ON
  • Refresh the page. The banner should not pop up this time since there is nothing new to agree to
  • Open the modal by clicking "Manage preferences" at the bottom and "manage preferences" again in the modal to get to the second layer
  • Your preference should still be saved (opted in)
  • You can also look at your saved cookie, which should look something like
{
  "consent": {},
  "identity": {
    "fides_user_device_id": "9a82a38d-f5d4-477e-92c0-79e4233e2a2e"
  },
  "fides_meta": {
    "version": "0.9.0",
    "createdAt": "2023-09-21T15:21:31.361Z",
    "updatedAt": "2023-09-21T15:21:45.363Z"
  },
  "tcfConsent": {
    "purpose_preferences": { "9": true },
    "special_purpose_preferences": {},
    "feature_preferences": {},
    "special_feature_preferences": {},
    "vendor_preferences": {},
    "system_preferences": { "ctl_af18ae4b-8c7d-47e7-b3db-a13e5c319662": true }
  },
  "tcString": "CPyc0sAPyc0sAAMABBENASEAAACAAAAAAAAAAAAAAAAA.IgoMV_H3_bX9v8Tq16ft0eYFX99j77uQxBhfJs-4FyDvW_JwVn2EyNAUytqYKmRIEuzZBIQFsHJnURVChQogVryHsYkGMhTEAJ-BkgHMRa2dYCFxvmYtjEQIZ5_p_czf52R_9_dn-3czjT9lnnzVtO2dlcKidS59tH_l_bRKb-7Ied-7W_4v09tfrkW_eTVu_9evvp9-u_s_v__934AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQ"
}

Pre-Merge Checklist

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

@cypress
Copy link

cypress bot commented Sep 20, 2023

Passing run #4395 ↗︎

0 4 0 0 Flakiness 0
⚠️ You've recorded test results over your free plan limit.
Upgrade your plan to view test results.

Details:

Merge e9a879a into 7c34872...
Project: fides Commit: 6cb12d6ae0 ℹ️
Status: Passed Duration: 00:55 💡
Started: Sep 28, 2023 5:24 PM Ended: Sep 28, 2023 5:25 PM

Review all test suite changes for PR #4124 ↗︎

@allisonking allisonking force-pushed the aking/prod-1063/tcf-prefetch branch from de0d05f to 2ac9e66 Compare September 21, 2023 15:53
@allisonking allisonking force-pushed the aking/prod-1063/tcf-prefetch branch from 2ac9e66 to 4b452ed Compare September 21, 2023 15:57
@allisonking allisonking marked this pull request as ready for review September 21, 2023 16:38
@allisonking allisonking mentioned this pull request Sep 21, 2023
6 tasks
Copy link
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.

Overall looks good 👍 , main Q is around the switch from /fides.js to /fides-js on our test site. I want to be sure I understand that

clients/fides-js/src/fides.ts Show resolved Hide resolved
clients/privacy-center/pages/api/fides-js.ts Show resolved Hide resolved
clients/fides-js/src/lib/tcf/constants.ts Show resolved Hide resolved
clients/fides-js/src/lib/cookie.ts Show resolved Hide resolved
clients/privacy-center/public/fides-js-demo.html Outdated Show resolved Hide resolved
@allisonking allisonking merged commit 69766da into main Sep 28, 2023
@allisonking allisonking deleted the aking/prod-1063/tcf-prefetch branch September 28, 2023 19:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants