Fides Documentation – Ethyca
Interface: FidesEvent
FidesJS dispatches a variety of lifecycle events to the global window, making it easy to subscribe to an event stream to keep your application updated in real-time. Each of these events extends the standard CustomEvent interface and includes a detail object with various properties that can be used for inspecting current consent preferences, generating analytics, etc.
Example
window.addEventListener("FidesUpdated", (evt) => {
console.log("Received 'FidesUpdated' event! Current consent preferences: ", evt.detail.consent);
});
See the list below for information on what events are dispatched (and when!) and the detail reference for the available properties.
List of FidesEvent Types
FidesInitializing: Dispatched when initialization begins, which happens immediately once the FidesJS script is loaded. IfFides.init()is called multiple times, this event will also be dispatched each time.FidesConsentLoaded: If previously saved consent was found during initialization, we immediately set it on theFidesglobal object and dispatch this event. This event will only be dispatched if consent was found.FidesReady: Dispatched when initialization is complete and the current user's consent preferences - either previously saved or applicable defaults - have been set on theFidesglobal object. This event will always be dispatched, even if no previous consent was found.FidesInitialized: This event is dispatched based on thefidesInitializedEventModesetting. It has three possible modes: "once" (default), "multiple", and "disable".FidesUpdating: Dispatched when a user action (e.g., accepting all, saving changes, applying GPC) has started updating the user's consent preferences. This event is dispatched immediately once the changes are made, but before they are saved.FidesUpdated: Dispatched when a user action has finished updating the user's consent preferences. This event is dispatched once the changes are fully saved.FidesUIShown: Dispatched whenever a FidesJS UI component is rendered and shown to the current user (banner, modal, etc.). The specific component shown can be obtained from thedetail.extraDetails.servingComponentproperty on the event.FidesUIChanged: Dispatched whenever the current user changes their preferences in the FidesJS UI but has yet to save those changes.FidesModalClosed: Dispatched whenever the FidesJS modal is closed.
Properties
detail
detail:
object
Event properties passed by FidesJS when dispatched. Depending on the event type, some properties may or may not be set, so most of these are marked as optional.
- consent:
Record<string, boolean>User's current consent preferences. - fides_string?:
stringUser's current consent string. - timestamp?:
numberHigh-precision timestamp representing when this event was created. - extraDetails?:
object- servingComponent?: `