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 TCF earlier and set gdpr to apply always #4453

Merged
merged 8 commits into from
Nov 22, 2023

Conversation

allisonking
Copy link
Contributor

Closes https://ethyca.atlassian.net/browse/PROD-1433

Description Of Changes

Write some things here about the changes and any potential caveats

Code Changes

  • list your code changes here

Steps to Confirm

  • list any manual steps for reviewers to confirm the changes

Pre-Merge Checklist

Copy link

vercel bot commented Nov 22, 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 Nov 22, 2023 9:40pm

Copy link

cypress bot commented Nov 22, 2023

Passing run #5355 ↗︎

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 5bc7311 into cb8089f...
Project: fides Commit: 148bbef878 ℹ️
Status: Passed Duration: 00:36 💡
Started: Nov 22, 2023 9:43 PM Ended: Nov 22, 2023 9:44 PM

Review all test suite changes for PR #4453 ↗︎

Copy link
Contributor

@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.

Thanks! Quick functionality ask for some future proofing

* Fides modification (PROD#1433): gdprApplies defaults to true
* since we only return TCF when gdpr does apply!
*/
let gdprApplies: boolean = true;
Copy link
Contributor

Choose a reason for hiding this comment

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

One ask: for our future benefit, let's do this as an override option fides_tcf_gdpr_applies and default it to true there. This gives us an out if we need one 👍

@@ -241,6 +242,7 @@ const updateFidesCookieFromString = (
* Initialize the global Fides object with the given configuration values
*/
const init = async (config: FidesConfig) => {
makeStub();
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

// Initialize api with TC str, we don't yet show UI, so we use false
// see https://github.com/InteractiveAdvertisingBureau/iabtcf-es/tree/master/modules/cmpapi#dont-show-ui--tc-string-does-not-need-an-update
window.addEventListener("FidesInitialized", (event) => {
const tcString = fidesEventToTcString(event);
cmpApi.update(tcString ?? null, false);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

fidesEventToTcString now does the work of defaulting to a value. since if there's a tc string at all (including an empty string) the library sets gdprApplies = true. so fidesEventToTcString additionally checks if gdpr applies first. this might not actually be what we want though since it can effectively turn off setting a tc string at all. perhaps the override should just be for the initial default value? I did this at first, but I couldn't actually test it since the period where there's a default value until this line was too short for cypress to catch

Copy link
Contributor Author

Choose a reason for hiding this comment

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

maybe only FidesInitialized should do the check for fides_tcf_gdpr_applies and the other events should stick to what they were?

Copy link
Contributor

Choose a reason for hiding this comment

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

Hmmm... a philosophical question eh?

I would recommend we check for that option override in one place, so I think it's OK to centralize into the helper function that extracts the string.

It's a bit weird that the CmpApi class sets GDPR applies based on a string though. Looking at their docs a bit to form a stronger POV

Copy link
Contributor

Choose a reason for hiding this comment

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

OK, their docs are super explicit: https://github.com/InteractiveAdvertisingBureau/iabtcf-es/blob/master/modules/cmpapi/README.md#trigger-change-event

update() may be called either an encoded TC string an empty string ('') or null.

  • Encoded TC string, CmpApi will decode the string and respond to TCData with the decoded values.
    • gdprApplies will be set to true
  • Empty string (''), CmpApi will respond to TCData with the correct structure but all primitive values will be empty.
    • gdprApplies will be set to true
  • null, CmpApi will respond to TCData with the correct structure but all primitive values will be empty.
    • gdprApplies will be set to false

In that case I think we can document this more clearly but I agree with your implementation 👍

@@ -102,6 +102,7 @@
"isGeolocationEnabled": false,
"geolocationApiUrl": "",
"privacyCenterUrl": "http://localhost:3000",
"fidesApiUrl": "http://localhost:8080/api/v1"
"fidesApiUrl": "http://localhost:8080/api/v1",
"fidesTcfGdprApplies": true
Copy link
Contributor Author

Choose a reason for hiding this comment

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

since this is an option that defaults to true, and because our test harness doesn't go through fides-js the API (which defaults this value to true), we set the default to true here.

@allisonking allisonking marked this pull request as ready for review November 22, 2023 16:34
Copy link
Contributor

@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.

Leaving a quick comment now but doing a bit more reading!

clients/privacy-center/app/server-environment.ts Outdated Show resolved Hide resolved
// Initialize api with TC str, we don't yet show UI, so we use false
// see https://github.com/InteractiveAdvertisingBureau/iabtcf-es/tree/master/modules/cmpapi#dont-show-ui--tc-string-does-not-need-an-update
window.addEventListener("FidesInitialized", (event) => {
const tcString = fidesEventToTcString(event);
cmpApi.update(tcString ?? null, false);
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmmm... a philosophical question eh?

I would recommend we check for that option override in one place, so I think it's OK to centralize into the helper function that extracts the string.

It's a bit weird that the CmpApi class sets GDPR applies based on a string though. Looking at their docs a bit to form a stronger POV

Copy link
Contributor

@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.

Nitpicks (including a renamed function!) but otherwise this looks good.

// Initialize api with TC str, we don't yet show UI, so we use false
// see https://github.com/InteractiveAdvertisingBureau/iabtcf-es/tree/master/modules/cmpapi#dont-show-ui--tc-string-does-not-need-an-update
window.addEventListener("FidesInitialized", (event) => {
const tcString = fidesEventToTcString(event);
cmpApi.update(tcString ?? null, false);
Copy link
Contributor

Choose a reason for hiding this comment

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

OK, their docs are super explicit: https://github.com/InteractiveAdvertisingBureau/iabtcf-es/blob/master/modules/cmpapi/README.md#trigger-change-event

update() may be called either an encoded TC string an empty string ('') or null.

  • Encoded TC string, CmpApi will decode the string and respond to TCData with the decoded values.
    • gdprApplies will be set to true
  • Empty string (''), CmpApi will respond to TCData with the correct structure but all primitive values will be empty.
    • gdprApplies will be set to true
  • null, CmpApi will respond to TCData with the correct structure but all primitive values will be empty.
    • gdprApplies will be set to false

In that case I think we can document this more clearly but I agree with your implementation 👍

clients/fides-js/src/lib/tcf/events.ts Outdated Show resolved Hide resolved
@allisonking allisonking merged commit fe31cb5 into main Nov 22, 2023
@allisonking allisonking deleted the aking/prod-1433/tcf-initialization branch November 22, 2023 21:46
}: {
gdprAppliesDefault?: boolean;
}) => {
console.log({ gdprAppliesDefault });
Copy link
Contributor

Choose a reason for hiding this comment

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

I missed this one...

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