Skip to content

Refactor analytics consent flow and client; add Cookie banner context and catalog UI styles#76

Open
Andrey1771 wants to merge 8 commits into
feature_editors-picksfrom
codex/refactor-cookie-consent-flow-for-analytics
Open

Refactor analytics consent flow and client; add Cookie banner context and catalog UI styles#76
Andrey1771 wants to merge 8 commits into
feature_editors-picksfrom
codex/refactor-cookie-consent-flow-for-analytics

Conversation

@Andrey1771

Copy link
Copy Markdown
Owner

Motivation

  • Centralize analytics consent and lifecycle management to avoid duplicated logic across components and ensure scripts are only loaded when allowed.
  • Improve the Cookie banner UX and make cookie settings accessible from the footer while preventing analytics on admin routes.
  • Make analytics client initialization robust and support deferred page view tracking when consent is granted after navigation.
  • Introduce responsive catalog layout styles for the games listing page.

Description

  • Introduced a context-based provider AnalyticsProvider and hook useAnalyticsConsent to expose consent, banner visibility, settings state, and an updateConsent API, and wired it into TaleGameshopMainWindow wrapping the app; the provider now configures analyticsClient, tracks page views (excluding admin routes), and manages consent events.
  • Reworked analyticsClient to support configure, setConsent, deferred initialize with initializingPromise, pending page view buffering, provider availability checks via isAnalyticsAvailable, and resetForTests; tracking and event APIs now respect consent and initialization state.
  • Consolidated consent utilities in analytics-consent.ts with exported types, default values, event constants, hasSavedAnalyticsConsent, and emit helpers, and added analytics-state.ts with isAnalyticsAvailable and shouldShowCookieBanner helpers used by the provider.
  • Updated CookieBanner to use the context hook instead of local storage helpers and to call updateConsent; improved copy and settings UI; added ARIA attributes and refactored show/hide logic.
  • Added a footer button to open cookie settings when analytics are available and settings are loaded, and updated footer styles and CSS for a link-button.
  • Refactored the game list page layout to use new game-list-page.css catalog classes and updated markup/classNames for toolbar, grid, cards, and result summary with pagination-aware counts and a Clear filters action.
  • Added and updated CSS files: cookie-banner.css, game-list-page.css, and footer CSS tweaks.
  • Added tests: analytics-client.test.ts, analytics-consent.test.ts, analytics-state.test.ts, and a React integration test analytics-consent-flow.test.tsx for the consent flow and CookieBanner interactions.

Testing

  • Ran unit tests for analytics utilities and client with Jest including analytics-client.test.ts, analytics-consent.test.ts, and analytics-state.test.ts, and they passed locally against the mocked DOM/script loader setup.
  • Executed the integration test analytics-consent-flow.test.tsx using @testing-library/react and user-event to validate the banner visibility, accept/reject behavior, initialization calls, and reopening settings, and it passed.
  • All added tests ran in the test suite and succeeded (mocks used for inversify.config and analytics-client).

Codex Task

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant