Derive consent mode from geolocation, not banner config

The consent mode is now determined dynamically by the visitor's
country and its applicable regulation. The configured consent_mode
column is dropped from cookie_banners and added to
cookie_consent_records to persist the geo-derived mode at
consent-recording time. When no regulation matches, the default
is OPT_OUT.

Signed-off-by: Émile Ré <emile@getprobo.com>
This commit is contained in:
Émile Ré
2026-05-13 12:17:34 +04:00
parent e9d786c5d6
commit e739473bcd
30 changed files with 68 additions and 246 deletions

View File

@@ -180,12 +180,17 @@ func (h *Handler) handlePostConsent(w http.ResponseWriter, r *http.Request) {
sdkVersion := r.Header.Get("X-SDK-Version")
cc := h.resolveCountryCode(r)
var regulation *cookiebanner.Regulation
var (
regulation *cookiebanner.Regulation
resolvedRegulation cookiebanner.Regulation
)
if cc != nil {
r := cookiebanner.RegulationForCountry(*cc)
regulation = &r
resolvedRegulation = cookiebanner.RegulationForCountry(*cc)
regulation = &resolvedRegulation
}
cm := coredata.CookieConsentMode(cookiebanner.ConsentModeForRegulation(resolvedRegulation))
req := cookiebanner.RecordConsentRequest{
Version: body.Version,
VisitorID: body.VisitorID,
@@ -196,6 +201,7 @@ func (h *Handler) handlePostConsent(w http.ResponseWriter, r *http.Request) {
SdkVersion: sdkVersion,
Regulation: regulation,
CountryCode: cc,
ConsentMode: &cm,
}
record, err := h.cookieBannerSvc.RecordConsent(r.Context(), bannerID, req)