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

[Backend] Further Deduplicate PrivacyExperience and PrivacyExperienceConfig #3470

Merged
merged 3 commits into from
Jun 6, 2023

Conversation

pattisdr
Copy link
Contributor

@pattisdr pattisdr commented Jun 6, 2023

Closes #3465

❗ Contains data migration; check downrev before merge

Code Changes

Continue to deduplicate info between PrivacyExperience and PrivacyExperienceConfig.

  • Remove common fields between the models like PrivacyExperience.disabled and PrivacyExperience.experience_config_history_id - these are at risk of getting out of sync
  • Now that we've removed most of the fields from PrivacyExperience and it is largely just a linking table, I don't think we need to version this. Remove PrivacyExperience.version, and the entire PrivacyExperienceHistory table.
  • PrivacyPreferenceHistory was referencing the PrivacyExperienceHistory id, but now that this doesn't exist, have it reference the PrivacyExperience id instead.
  • When filtering PrivacyExperiences on disabled, actually filter the corresponding field on the PrivacyExperienceConfig resource.

Steps to Confirm

  • nox -s dev -- shell
  • Get a privacy experience for a specific region, ex. {{host}}/privacy-experience/?region=eu_ee
  • Note that version, disabled, and experience_config_history_id have been removed from the response, (but version and disabled are still present in the embedded experience_config object)
  • Note both the "id" of that experience, and the historical id of one of the notices embedded in that experience
  • Save privacy preferences with {{host}}/privacy-preferences. Note that fides_user_device_id must be a valid uuid4. Note that a new field in this request is privacy_experience_id
{
   "browser_identity": {
       "ga_client_id": "UA-XXXXXXXXX",
       "ljt_readerID": "test_sovrn_id",
       "fides_user_device_id": "{{fides_user_device_id}}"
   },
   "preferences": [{
       "privacy_notice_history_id": "{{privacy_notice_history_id}}",
       "preference": "opt_out"
   }],
   "user_geography": "us_ca",
   "privacy_experience_id": "{{privacy_experience_id}}",
   "method": "button"
}
  • Get the historical preferences {{host}}/historical-privacy-preferences and verify both the privacy_notice_history_id and privacy_experience_id as well as the experience_config_history_id which was lifted from the experience and added here for record keeping

Pre-Merge Checklist

Description Of Changes

Further side effects of #3387

Now that we've relaxed a lot of the constraints around privacy experiences we no longer need as many fields on the PrivacyExperience table. There used to be necessary duplication between PrivacyExperience and PrivacyExperienceConfig but now this isn't required and we're just at risk of the tables getting out of sync. This surfaced when testing "creating experiences out of the box - as an area that had gotten out of sync). h/t to @adamsachs for also raising the importance of what tables were storing which information here: #3387 (comment)

Primarily I deduplicate all the info between the two tables except for "component" and stop tracking history of privacy experiences now that there's barely anything on this table.

Saving privacy preferences should now pass on the "experience id" instead of the "experience history id" (because it doesn't exist)

…ce and PrivacyExperienceConfig.

- Remove common fields between the models like PrivacyExperience.disabled and PrivacyExperience.experience_config_history_id - these are at risk of getting out of sync
- Now that we've removed most of the fields from PrivacyExperience and it is largely just a linking table, I don't think we need to version this. Remove PrivacyExperience.version, and the entire PrivacyExperienceHistory table.
- PrivacyPreferenceHistory was referencing the PrivacyExperienceHistory id, but now that this doesn't exist, have it reference the PrivacyExperience id instead.
- When filtering PrivacyExperiences on disabled, actually filter the corresponding field on the PrivacyExperienceConfig resource.
@cypress
Copy link

cypress bot commented Jun 6, 2023

Passing run #2447 ↗︎

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 cd742f8 into 12487ea...
Project: fides Commit: 2565a45d24 ℹ️
Status: Passed Duration: 01:13 💡
Started: Jun 6, 2023 2:35 PM Ended: Jun 6, 2023 2:36 PM

This comment has been generated by cypress-bot as a result of this project's GitHub integration settings.

@codecov
Copy link

codecov bot commented Jun 6, 2023

Codecov Report

Patch coverage: 95.45% and project coverage change: -0.02 ⚠️

Comparison is base (12487ea) 87.14% compared to head (cd742f8) 87.12%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3470      +/-   ##
==========================================
- Coverage   87.14%   87.12%   -0.02%     
==========================================
  Files         312      312              
  Lines       18787    18757      -30     
  Branches     2389     2389              
==========================================
- Hits        16371    16342      -29     
+ Misses       1992     1991       -1     
  Partials      424      424              
Impacted Files Coverage Δ
src/fides/api/db/base.py 100.00% <ø> (ø)
src/fides/api/schemas/privacy_experience.py 100.00% <ø> (ø)
...i/api/v1/endpoints/privacy_preference_endpoints.py 98.00% <90.00%> (-0.65%) ⬇️
...i/api/v1/endpoints/privacy_experience_endpoints.py 91.07% <100.00%> (ø)
src/fides/api/models/privacy_experience.py 99.40% <100.00%> (+0.92%) ⬆️
src/fides/api/models/privacy_preference.py 100.00% <100.00%> (ø)
src/fides/api/schemas/privacy_preference.py 100.00% <100.00%> (ø)

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@pattisdr pattisdr marked this pull request as ready for review June 6, 2023 04:11
@pattisdr pattisdr requested a review from adamsachs June 6, 2023 04:13
Copy link
Contributor

@adamsachs adamsachs left a comment

Choose a reason for hiding this comment

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

this looks great @pattisdr, nothing stood out to me as as a concern or in need of adjustment. i'm very happy to see things going in this direction, i think this has simplified the db models as well as the application logic significantly, and i don't think we lose any meaningful functionality as far as i can tell. nice job getting this in place before we roll it out 👍

@pattisdr
Copy link
Contributor Author

pattisdr commented Jun 6, 2023

appreciate the quick review @adamsachs 🙏

@pattisdr pattisdr merged commit 1b1abbb into main Jun 6, 2023
@pattisdr pattisdr deleted the fides_3465_remove_experience_duplication branch June 6, 2023 14:57
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.

Remove PrivacyExperienceHistory and Duplication b/t Experiences and Configs
2 participants