How it works
This flow starts in the banner and ends with backend enforcement before tracking logic runs. When consent is unknown, the frontend treats tracking as denied by default. When consent is denied, backend middleware and resolver gates short-circuit analytics behavior. When consent is granted, normal analytics identity and event tracking continue.Extending this system
Use this recipe when you add a new consent category or another analytics-related entry point.- Add the new category flag in
apps/portal/src/utils/gdprConsentCookie.ts. - Render and wire that option in
apps/portal/src/components/GdprConsentBanner.tsx. - Parse and expose the new flag in
apps/backend/src/utilities/gdprConsent.ts. - Apply that flag to the relevant gate in
apps/backend/src/middleware/analyticsSession.tsorapps/backend/src/gql/mutations/trackFrontendEvent.ts. - Add tests in
apps/backend/src/gql/mutations/__tests__/trackFrontendEvent.spec.ts,apps/backend/src/utilities/__tests__/analyticsIdentification.spec.ts, andapps/portal/src/components/__tests__/gdprConsentBanner.spec.tsx. - Verify with:
What not to do
These anti-patterns are the most common ways consent enforcement drifts over time.
❌ Never default unknown consent to allowed.
❌ Never set analytics_aid when analytics consent is denied.
❌ Never skip consent checks in a new event mutation, webhook handler, or login identify flow.
