FAQ | This is a LIVE service | Changelog

Refactor CookieBanner for configurable cookie preferences and analytics initialization

As a developer, 
I want the `CookieBanner` to display and control cookie preferences based on a version-controlled configuration object, 
with the ability to re-trigger the banner when the configuration version changes. 
Additionally, I want the analytics initialization to be conditional and support different analytics functions 
based on the `CookieBanner` configuration and user choices, 
while ensuring Google Analytics initialization still works with the provided tracking ID.

Background

The current implementation of the CookieBanner handles cookie preferences and displays the banner based on hardcoded constants and logic tied directly to the existing setup. Additionally, Google Analytics initialization is tied to specific cookie choices without supporting alternative analytics configurations. To enhance flexibility, maintainability, and user experience, we need to refactor the system to be configuration-driven and capable of initializing analytics dynamically based on user preferences.

Acceptance Criteria

  • The CookieBanner preferences are defined as a version-controlled configuration object that can be set via code or passed as an initialization parameter.
  • The CookieBanner checks the configuration version; if the version changes, the banner is displayed to the user again to re-confirm choices.
  • Analytics initialization supports multiple analytics functions and initializes conditionally based on user-selected cookie preferences.
  • The initGoogleAnalytics function can still be called with a tracking ID string and initializes correctly when invoked.
  • Documentation is updated to explain the new configuration-driven approach and analytics initialization mechanism.

Implementation Notes

  • Refactor CookieBanner to accept a configuration object defining cookie categories, descriptions, and default behaviors.
  • Add a version-checking mechanism that re-displays the banner when the configuration version changes.
  • Implement a dynamic analytics initialization function that mounts the appropriate analytics based on user choices.
  • The configuration object should be type-safe and validated on initialization.