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

Save consent method ("accept", "reject", "save", etc.) to fides_consent cookie as extra metadata #4529

Merged
merged 17 commits into from
Dec 20, 2023

Conversation

NevilleS
Copy link
Contributor

@NevilleS NevilleS commented Dec 19, 2023

Description Of Changes

This updates both fides.js and fides-privacy-center to record the "consent method" to the local cookie when preferences are saved, in the same way that we record this information on the server-side preference that is recorded. This'll allow us to inspect this on the frontend, both for troubleshooting (helpful!) but more importantly because I'd like to treat consentMethod: "dismiss" differently in a future release so I want to be recording that metadata now 👍

Code Changes

  • Fix ConsentMethod enum definition across all client applications
  • Update fides.js unit tests to check that extra details can be saved to fides_meta on cookie
  • Update Privacy Center E2E tests to check for consentMethod to be stored on cookie
  • Update consent banner E2E tests to check for consentMethod to be stored on cookie
  • Refactor the banner dismissal tests to DRY them up (a bit!)
  • Fix Privacy Center consent page to no longer record deprecated button consent method
  • Update Privacy Center consent page to record consent method to cookie on save action
  • Update fides.js overlay to record consent method to cookie on save, accept, reject, and dismiss

Steps to Confirm

  • Run all E2E tests for Privacy Center & Overlay
  • Run local test environment and inspect the fides_consent cookie on the Cookie House after using the overlay

Pre-Merge Checklist

Copy link

vercel bot commented Dec 19, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Ignored Deployment
Name Status Preview Comments Updated (UTC)
fides-plus-nightly ⬜️ Ignored (Inspect) Visit Preview Dec 20, 2023 4:53pm

Copy link

cypress bot commented Dec 19, 2023

Passing run #5713 ↗︎

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 1d0e7f4 into 6b66d42...
Project: fides Commit: ef64cabeee ℹ️
Status: Passed Duration: 00:33 💡
Started: Dec 19, 2023 4:56 PM Ended: Dec 19, 2023 4:56 PM

Review all test suite changes for PR #4529 ↗︎

@NevilleS NevilleS marked this pull request as ready for review December 19, 2023 16:25
Copy link
Contributor

@allisonking allisonking left a comment

Choose a reason for hiding this comment

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

code looks good! will UAT a bit later, unless @galvana can get to it first!

Copy link
Contributor Author

@NevilleS NevilleS left a comment

Choose a reason for hiding this comment

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

My own notes, for review help!

@@ -109,23 +111,47 @@ describe("getOrMakeFidesCookie", () => {
const SAVED_CONSENT = { data_sales: false, performance: true };

describe("in v0.9.0 format", () => {
const V090_COOKIE = JSON.stringify({
const V090_COOKIE_OBJECT: FidesCookie = {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added the type here to ensure we're keeping this test accurate - and then updated it to include the required tcf_consent field 👍

Copy link
Contributor

Choose a reason for hiding this comment

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

Would it be a good idea to make this change to other places in this test file that still use const V090_COOKIE = JSON.stringify({...?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good suggestion! Updated

clients/fides-js/__tests__/lib/cookie.test.ts Show resolved Hide resolved
clients/fides-js/src/lib/consent-types.ts Show resolved Hide resolved
clients/fides-js/src/lib/events.ts Show resolved Hide resolved
@NevilleS NevilleS changed the title Save consentMethod to fides_consent cookie as extra metadata Save consent method ("accept", "reject", "save", etc.) to fides_consent cookie as extra metadata Dec 19, 2023
@NevilleS NevilleS requested a review from galvana December 19, 2023 16:46
Copy link
Contributor

@galvana galvana left a comment

Choose a reason for hiding this comment

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

Thanks for the test cleanup! I just made a small comment on the cookie.test.ts file but overall this looks good 👍

@@ -109,23 +111,47 @@ describe("getOrMakeFidesCookie", () => {
const SAVED_CONSENT = { data_sales: false, performance: true };

describe("in v0.9.0 format", () => {
const V090_COOKIE = JSON.stringify({
const V090_COOKIE_OBJECT: FidesCookie = {
Copy link
Contributor

Choose a reason for hiding this comment

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

Would it be a good idea to make this change to other places in this test file that still use const V090_COOKIE = JSON.stringify({...?

@galvana
Copy link
Contributor

galvana commented Dec 19, 2023

UAT

@NevilleS I verified locally that the Fides cookie contains "consentMethod":"dismiss" for the following scenarios:

TCF dismiss banner

{"consent":{"data_sales":true,"tracking":true,"analytics":true},"identity":{"fides_user_device_id":"64b142b1-e273-4c70-ad06-b162e556fef8"},"fides_meta":{"version":"0.9.0","createdAt":"2023-12-14T18:15:44.748Z","updatedAt":"2023-12-19T23:06:31.614Z","consentMethod":"dismiss"},"tcf_consent":{"system_consent_preferences":{},"system_legitimate_interests_preferences":{}},"fides_string":"CP3CKIAP3CKIAGXABBENAfEgAAAAAAAAAAAAAAAAAAAA.Ig1NX_H__bX9v-Xr36ft0eY1f99j77sQxBhfJs-4FyLvW_JwX32EyNE26tqYKmRIEu3ZBIQFtHJnURVihaogVrzHsYkGcgTNKJ-BkgHMRe2dYCF5vmYtj-QKZ5_p_d3f52T_9_dv-3dzzz9Vnv3e9fudlcIida59tH_n_bRKb-7Ie9_7-_4v09N_rk2_eTVv_9evv71-u_t____9_9__-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAE,1~","tcf_version_hash":"3bc0df5c0987"}

TCF dismiss modal

{"consent":{"data_sales":true,"tracking":true,"analytics":true},"identity":{"fides_user_device_id":"8398a987-e667-4348-a853-88c67a71bb82"},"fides_meta":{"version":"0.9.0","createdAt":"2023-12-19T23:08:40.270Z","updatedAt":"2023-12-19T23:08:56.453Z","consentMethod":"dismiss"},"tcf_consent":{"system_consent_preferences":{},"system_legitimate_interests_preferences":{}},"fides_string":"CP3CKIAP3CKIAGXABBENAfEgAAAAAEPgAAAAAABBqhpAAIgAUABcADgAPgAoACoAFwAOAAeABAACSAFwAZQA0ADUAHgAPwAiABHACYAFCAKQApgBVgC2ALoAYgAzABoADeAHoAPwAhABDQCIAIkARwAlgBNACcAFGAMAAYcAygDLAGaANEAbIA5ABzwDuAO8AewA-IB9gH7AP8BAICDgIQAREAikBFgEYAI1ARwBHQCRAElAJSATQAnYBPwCgwFQAVEAq4BYgC5gF1gLyAvQBfQDFAGiANeAbQA3ABxADjgHSAOoAdsA9oB9gD_gImAReAj2BIgEigJUASsAmKBMgEygJtATsAoeBR4FIgKTgU0BTYCnwFQwKkAqUBVQCrAFcgK7AWFAsQCxQFlALRAWpAtgC2YFuAW6AuABcgC6AF2gLvgXkBeYC-gF_gMEAYMAw0BiADFgGPAMhgZGBkkDJgMnAZUAywBmYDOQGeANEAaMA00BqYDVYGrgayA14BtADbIG3AbfA3MDdQHAAOCAcWA48BycDlgOXAc6A58B1gDxQHjwPJA8oB8UD5APlAfSA-uB9oH3QP2A_cB_YEAQICAQMAgeBBECCYEGAINgQhAhQBCuCFoIXAQzghyCHUEPAQ9Ah-BFMCMAEaQI1gRvAjiBHQCOwEewI-gR_AkIBIoCRsEkASSgkwCTMEqASpAlgBLOCW4JcQS6BLsCX0EwATBAmGBMWCZgJnATUAmxBNsE3IJvAm-BOGCcoJzATpCDUAAA.Ig1NX_H__bX9v-Xr36ft0eY1f99j77sQxBhfJs-4FyLvW_JwX32EyNE26tqYKmRIEu3ZBIQFtHJnURVihaogVrzHsYkGcgTNKJ-BkgHMRe2dYCF5vmYtj-QKZ5_p_d3f52T_9_dv-3dzzz9Vnv3e9fudlcIida59tH_n_bRKb-7Ie9_7-_4v09N_rk2_eTVv_9evv71-u_t____9_9__-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAE,1~","tcf_version_hash":"3bc0df5c0987"}

Consent dismiss banner

{"consent":{"data_sales_and_sharing":true},"identity":{"fides_user_device_id":"7a6e5a92-134d-4b69-a1a5-3a66de68c3b0"},"fides_meta":{"version":"0.9.0","createdAt":"2023-12-19T23:11:11.905Z","updatedAt":"2023-12-19T23:11:24.790Z","consentMethod":"dismiss"},"tcf_consent":{}}

Consent dismiss modal

{"consent":{"data_sales_and_sharing":true},"identity":{"fides_user_device_id":"3ce759a7-86d3-4991-a831-382a1ca68b27"},"fides_meta":{"version":"0.9.0","createdAt":"2023-12-19T23:12:04.850Z","updatedAt":"2023-12-19T23:12:16.378Z","consentMethod":"dismiss"},"tcf_consent":{}}

@NevilleS NevilleS merged commit 3537d01 into main Dec 20, 2023
10 checks passed
@NevilleS NevilleS deleted the ns-save-consent-method-to-cookie branch December 20, 2023 16:54
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.

3 participants