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

Remove duplicate FidesUpdated event and trigger FidesInitialized twice instead #4365

Merged
merged 5 commits into from
Oct 31, 2023

Conversation

NevilleS
Copy link
Contributor

@NevilleS NevilleS commented Oct 31, 2023

Closes PROD-1280

Description Of Changes

FidesUpdated is now only called when a user makes a change, not after initialization.

Screen.Recording.2023-10-31.at.4.23.37.PM.mov

Code Changes

  • Remove calls to FidesUpdated in initialization logic
  • Simplify FidesInitialized calls
  • Update tests

Steps to Confirm

  • Set up TCF or notices
  • Visit the demo page and open the console
  • You should see that FidesInitialized fired but no FidesUpdated fired
  • You should not see FidesUpdated until you save your preferences

Pre-Merge Checklist

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

Copy link

cypress bot commented Oct 31, 2023

Passing run #4938 ↗︎

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 8125b10 into fb1ccdc...
Project: fides Commit: 9468866ca3 ℹ️
Status: Passed Duration: 00:48 💡
Started: Oct 31, 2023 8:39 PM Ended: Oct 31, 2023 8:40 PM

Review all test suite changes for PR #4365 ↗︎

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.

Comments and thoughts

}
dispatchFidesEvent("FidesUpdated", cookie, config.options.debug);
// Dispatch the "FidesInitialized" event to update listeners with the initial state.
// TODO PROD-1280: Suppress duplicate event if the cookie state is unchanged from an early initialization?
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm really not sure about this yet. I like the simplicity of this code right now, but the double-triggering of the event doesn't "feel" great. Looking for opinions 😄

Comment on lines 1363 to 1364
// TODO PROD-1280: Suppress duplicate event if the cookie state is unchanged from an early initialization?
// .should("have.been.calledOnce")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note that we shouldn't check this in; need to decide what to do and then do it 👍

Comment on lines 1412 to 1413
// TODO PROD-1280: Suppress duplicate event if the cookie state is unchanged from an early initialization?
// .should("have.been.calledOnce")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note that we shouldn't check this in; need to decide what to do and then do it 👍

}
dispatchFidesEvent("FidesUpdated", cookie, config.options.debug);
// Dispatch the "FidesInitialized" event to update listeners with the initial state.
// TODO PROD-1280: Suppress duplicate event if the cookie state is unchanged from an early initialization?
Copy link
Contributor Author

Choose a reason for hiding this comment

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

TODO note 👍

@NevilleS NevilleS requested a review from allisonking October 31, 2023 15:41
@allisonking
Copy link
Contributor

We decided to move forward with this implementation for now, but perhaps we should suppress the duplicate FidesInitialized during our refactor of our initialization logic. Right now it's just complicated to figure out if the initialization should fire again.

@allisonking allisonking marked this pull request as ready for review October 31, 2023 20:41
@allisonking allisonking merged commit a57c06a into main Oct 31, 2023
@allisonking allisonking deleted the PROD-1280-ns-remove-fidesupdated-event branch October 31, 2023 20:53
Kelsey-Ethyca pushed a commit that referenced this pull request Nov 1, 2023
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