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

Optimize TCF bundle with just-in-time GVL translations #5074

Merged
merged 22 commits into from
Jul 17, 2024

Conversation

gilluminate
Copy link
Contributor

@gilluminate gilluminate commented Jul 9, 2024

Closes PROD-2281

Description Of Changes

In an effort to reduce initial payload size of TCF version of FidesJS, we now ignoring GVL translations in the experience until just as we're rendering the UI.

This is being tightened up by calling the dedicated endpoint for GVL translations.

Code Changes

  • A bit of general code maintenance, including removing a circular dependency in the Location switcher component
  • Remove gvl_translations from the initial fides.js payload.
  • When needed, fetch the gvl_translations from /api/v1/plus/gvl/translations to use just as the UI is rendering.
  • Update Cypress and unit tests to reflect the change.

Steps to Confirm

  • Visit demo page with TCF enabled /fides-js-demo.html?geolocation=fr-id
  • Inspect Network panel of devtools and note that the payload is ~300k smaller than before
  • As the page loads, Network panel should show a call to api/v1/privacy-experience
  • Console debug messages should include Calling Fides GET GVL translations API... and Recieved GVL languages response from Fides API
  • The Fides has been initialized! message should appear prior to the Recieved GVL languages response from Fides API message in the console. We don't want to delay the overall initialization for this.
  • Overlay should display with full expected text (no untranslated strings such as "exp.tcf.stacks.1.name")

image

Pre-Merge Checklist

  • All CI Pipelines Succeeded
  • Issue Requirements are Met
  • Relevant Follow-Up Issues Created
  • Update CHANGELOG.md

Copy link

vercel bot commented Jul 9, 2024

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

1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
fides-plus-nightly ⬜️ Ignored (Inspect) Visit Preview Jul 17, 2024 6:12pm

Copy link

cypress bot commented Jul 9, 2024

Passing run #8974 ↗︎

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 384a8ae into f390fc9...
Project: fides Commit: 668608c1c0 ℹ️
Status: Passed Duration: 00:35 💡
Started: Jul 17, 2024 6:22 PM Ended: Jul 17, 2024 6:23 PM

Review all test suite changes for PR #5074 ↗︎

Comment on lines +284 to +293
gvlVendors: activeChunk?.filter((v) => v.isGvl),
otherVendors: activeChunk?.filter((v) => !v.isGvl),
}),
[activeChunk]
);

if (!activeChunk) {
return null;
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

handling (unlikely) scenario of having 0 vendors configured for a given experience

@gilluminate gilluminate force-pushed the gill/PROD-2281_mediavine-optimize-tcf-bundle branch from 469e8c6 to efc0b1b Compare July 15, 2024 20:05
Comment on lines +535 to +537
"gvlSpecificationVersion": 3,
"vendorListVersion": 40,
"tcfPolicyVersion": 4,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

resolves a Typescript complaint that these were missing

@eastandwestwind eastandwestwind self-requested a review July 16, 2024 10:37
@eastandwestwind
Copy link
Contributor

Reviewing now...

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.

This is on the right track after testing locally. Let's re-test once BE is in place

@gilluminate gilluminate force-pushed the gill/PROD-2281_mediavine-optimize-tcf-bundle branch from 667139b to 8e1ebee Compare July 16, 2024 22:42
@eastandwestwind
Copy link
Contributor

eastandwestwind commented Jul 16, 2024

Just a note that after https://github.com/ethyca/fidesplus/pull/1510 is merged, lets remove the gvl_translations: Optional[Dict] = {} from src/fides/api/models/privacy_experience.py

@gilluminate gilluminate force-pushed the gill/PROD-2281_mediavine-optimize-tcf-bundle branch from ac24959 to 04673ff Compare July 17, 2024 00:06
@@ -483,49 +463,6 @@ describe("i18n-utils", () => {
expect(getRecordCounts(loadedMessagesEn)).toMatchObject(expectedCounts);
expect(getRecordCounts(loadedMessagesEs)).toMatchObject(expectedCounts);
});

it("handles a mismatch between the experience_config and gvl_translations APIs by returning only locales available in both", () => {
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 is all handled server-side now

@@ -224,13 +224,7 @@ export function loadMessagesFromFiles(i18n: I18n): Locale[] {

/**
* Parse the provided PrivacyExperience object and load all translated strings
* into the message catalog. Extracts translations from two sources:
* 1) experience.experience_config
* 2) experience.gvl_translations
Copy link
Contributor Author

Choose a reason for hiding this comment

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

#2 now happens as a separate process during initOverlay

Comment on lines -682 to -683
expect(data.signalStatus).to.eql("ready");
expect(data.applicableSections).to.eql([-1]);
Copy link
Contributor Author

@gilluminate gilluminate Jul 15, 2024

Choose a reason for hiding this comment

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

developer's local Admin UI config could make this behave differently because we're testing from /fides-js-demo.html instead of /fides-js-components-demo.html in this particular test. Removing these 2 extra, flaky checks in favor of the original intent of the test, which is to check that GPP loads and can be pinged. (The other gets tested elsewhere)

Comment on lines -465 to -467
data_sales: false,
tracking: false,
analytics: 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.

Again, because we're testing with /fides-js-demo.html here instead of /fides-js-components-demo.html, these fields can be different per developer's environment and don't relate to the actual intent of this particular test.

CHANGELOG.md Outdated Show resolved Hide resolved
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.

Looking good so far, just some notes to remove the gvl_translations obj later, including the gvl_translations: Optional[Dict] = {} we define on the SQLAlchemy obj

clients/fides-js/src/lib/consent-types.ts Outdated Show resolved Hide resolved
clients/fides-js/src/services/api.ts Outdated Show resolved Hide resolved
@gilluminate gilluminate force-pushed the gill/PROD-2281_mediavine-optimize-tcf-bundle branch from f7fa793 to 384a8ae Compare July 17, 2024 18:11
Copy link

codecov bot commented Jul 17, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 86.48%. Comparing base (f390fc9) to head (384a8ae).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5074      +/-   ##
==========================================
+ Coverage   86.47%   86.48%   +0.01%     
==========================================
  Files         357      357              
  Lines       22271    22270       -1     
  Branches     2944     2944              
==========================================
+ Hits        19258    19260       +2     
+ Misses       2498     2495       -3     
  Partials      515      515              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@gilluminate gilluminate merged commit 63ced02 into main Jul 17, 2024
51 checks passed
@gilluminate gilluminate deleted the gill/PROD-2281_mediavine-optimize-tcf-bundle branch July 17, 2024 18:42
Copy link

cypress bot commented Jul 17, 2024

Passing run #8978 ↗︎

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

Details:

Optimize TCF bundle with just-in-time GVL translations (#5074)
Project: fides Commit: 63ced02516
Status: Passed Duration: 00:35 💡
Started: Jul 17, 2024 6:53 PM Ended: Jul 17, 2024 6:53 PM

Review all test suite changes for PR #5074 ↗︎

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