Cookie banner integrations - GCM & posthog#1102
Merged
Conversation
Stores the Google Consent Mode v2 consent type mapping per cookie category so each category can declare which GCM signals it controls (e.g. analytics_storage, ad_storage). Signed-off-by: Émile Ré <emile@getprobo.com>
Include gcm_consent_types in the published banner config so the cookie banner SDK can read category-to-GCM mappings from the config endpoint. Signed-off-by: Émile Ré <emile@getprobo.com>
Seed default categories with their Google Consent Mode v2 mappings (e.g. analytics -> analytics_storage, advertising -> ad_storage + ad_user_data + ad_personalization). New user-created categories default to an empty mapping. Signed-off-by: Émile Ré <emile@getprobo.com>
Expose gcmConsentTypes on CookieCategory type and accept it in UpdateCookieCategoryInput so the console can read and write GCM consent type mappings per category. Signed-off-by: Émile Ré <emile@getprobo.com>
Display Google Consent Mode mappings as badges on each category and add a checkbox selector in the edit form so users can configure which GCM signals each category controls. Signed-off-by: Émile Ré <emile@getprobo.com>
Set GCM defaults to denied on load, then push consent
updates via gtag('consent', 'update', ...) before
activating scripts. The mapping from category slugs to
GCM consent types comes from the banner config endpoint.
Signed-off-by: Émile Ré <emile@getprobo.com>
Add PostHog opt-in/opt-out consent support mirroring the existing Google Consent Mode integration: database column, GraphQL field, console UI toggle, and client-side posthog-js calls. Extract both GCM and PostHog logic from CookieBannerClient into a ConsentIntegration plugin interface so future integrations can be added without modifying the client core. Signed-off-by: Émile Ré <emile@getprobo.com>
Add a partial unique index ensuring only one category per banner can have posthog_consent enabled. Default it to the analytics category on banner creation, clear the previous mapping before setting a new one, and restrict the toggle to NORMAL categories in both the service layer and the console UI. Signed-off-by: Émile Ré <emile@getprobo.com>
Fall back to pushing consent commands onto window.dataLayer when window.gtag is not available, enabling compatibility with Google Tag Manager setups that don't define a global gtag function. Signed-off-by: Émile Ré <emile@getprobo.com>
cdc75a1 to
7a270f7
Compare
Signed-off-by: Émile Ré <emile@getprobo.com>
SachaProbo
approved these changes
Apr 24, 2026
Contributor
SachaProbo
left a comment
There was a problem hiding this comment.
Maybe add some e2e tests?
| if errors.Is(err, coredata.ErrResourceAlreadyExists) { | ||
| continue | ||
| } | ||
| ok, err := cookie.InsertIfNotExists(ctx, tx, scope) |
Contributor
There was a problem hiding this comment.
Why did you change this?
Contributor
Author
There was a problem hiding this comment.
ON CONFLICT clause to not rollback a transaction on the detect cookies endpoint of the REST API.
The usual insert stays there for feedback on conflict when adding cookies from the console
Contributor
Author
Will do on next PR |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes ENG-287
Summary by cubic
Adds Google Consent Mode v2 and PostHog consent integrations to the cookie banner with UI controls, GraphQL fields, DB schema updates, and an SDK plugin system. Categories map to GCM signals and can control PostHog; defaults apply on load and updates propagate automatically (via
gtagorwindow.dataLayer).New Features
gcm_consent_types; included in the published config, exposed via GraphQL; editable in the console with checkboxes and shown as badges.analytics_storage, Advertising →ad_storage/ad_user_data/ad_personalization, Necessary →security_storage, Functional →functionality_storage/personalization_storage).gtag('consent', ...)orwindow.dataLayer.posthog_consentper category with a partial unique index to allow only one per banner; enforced in the service and exposed via GraphQL; console toggle (NORMAL categories only).ConsentIntegrationplugin API; default integrations: GCM and PostHog.InsertIfNotExists.Migration
posthog_consent.Written for commit e48da4d. Summary will update on new commits.