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:
@@ -38,7 +38,6 @@ type (
|
||||
PrivacyPolicyURL *string `db:"privacy_policy_url"`
|
||||
CookiePolicyURL string `db:"cookie_policy_url"`
|
||||
ConsentExpiryDays int `db:"consent_expiry_days"`
|
||||
ConsentMode CookieConsentMode `db:"consent_mode"`
|
||||
ShowBranding bool `db:"show_branding"`
|
||||
DefaultLanguage string `db:"default_language"`
|
||||
PatternAnalysisRequestedAt *time.Time `db:"pattern_analysis_requested_at"`
|
||||
@@ -89,7 +88,6 @@ SELECT
|
||||
privacy_policy_url,
|
||||
cookie_policy_url,
|
||||
consent_expiry_days,
|
||||
consent_mode,
|
||||
show_branding,
|
||||
default_language,
|
||||
pattern_analysis_requested_at,
|
||||
@@ -142,7 +140,6 @@ SELECT
|
||||
privacy_policy_url,
|
||||
cookie_policy_url,
|
||||
consent_expiry_days,
|
||||
consent_mode,
|
||||
show_branding,
|
||||
default_language,
|
||||
pattern_analysis_requested_at,
|
||||
@@ -196,7 +193,6 @@ SELECT
|
||||
privacy_policy_url,
|
||||
cookie_policy_url,
|
||||
consent_expiry_days,
|
||||
consent_mode,
|
||||
show_branding,
|
||||
default_language,
|
||||
pattern_analysis_requested_at,
|
||||
@@ -254,7 +250,6 @@ SELECT
|
||||
privacy_policy_url,
|
||||
cookie_policy_url,
|
||||
consent_expiry_days,
|
||||
consent_mode,
|
||||
show_branding,
|
||||
default_language,
|
||||
pattern_analysis_requested_at,
|
||||
@@ -305,7 +300,6 @@ SELECT
|
||||
privacy_policy_url,
|
||||
cookie_policy_url,
|
||||
consent_expiry_days,
|
||||
consent_mode,
|
||||
show_branding,
|
||||
default_language,
|
||||
pattern_analysis_requested_at,
|
||||
@@ -392,7 +386,6 @@ INSERT INTO cookie_banners (
|
||||
privacy_policy_url,
|
||||
cookie_policy_url,
|
||||
consent_expiry_days,
|
||||
consent_mode,
|
||||
show_branding,
|
||||
default_language,
|
||||
pattern_analysis_requested_at,
|
||||
@@ -408,7 +401,6 @@ INSERT INTO cookie_banners (
|
||||
@privacy_policy_url,
|
||||
@cookie_policy_url,
|
||||
@consent_expiry_days,
|
||||
@consent_mode,
|
||||
@show_branding,
|
||||
@default_language,
|
||||
@pattern_analysis_requested_at,
|
||||
@@ -427,7 +419,6 @@ INSERT INTO cookie_banners (
|
||||
"privacy_policy_url": b.PrivacyPolicyURL,
|
||||
"cookie_policy_url": b.CookiePolicyURL,
|
||||
"consent_expiry_days": b.ConsentExpiryDays,
|
||||
"consent_mode": b.ConsentMode,
|
||||
"show_branding": b.ShowBranding,
|
||||
"default_language": b.DefaultLanguage,
|
||||
"pattern_analysis_requested_at": b.PatternAnalysisRequestedAt,
|
||||
@@ -461,7 +452,6 @@ SET
|
||||
privacy_policy_url = @privacy_policy_url,
|
||||
cookie_policy_url = @cookie_policy_url,
|
||||
consent_expiry_days = @consent_expiry_days,
|
||||
consent_mode = @consent_mode,
|
||||
show_branding = @show_branding,
|
||||
default_language = @default_language,
|
||||
updated_at = @updated_at
|
||||
@@ -479,7 +469,6 @@ WHERE
|
||||
"privacy_policy_url": b.PrivacyPolicyURL,
|
||||
"cookie_policy_url": b.CookiePolicyURL,
|
||||
"consent_expiry_days": b.ConsentExpiryDays,
|
||||
"consent_mode": b.ConsentMode,
|
||||
"show_branding": b.ShowBranding,
|
||||
"default_language": b.DefaultLanguage,
|
||||
"updated_at": b.UpdatedAt,
|
||||
@@ -581,7 +570,6 @@ SELECT
|
||||
privacy_policy_url,
|
||||
cookie_policy_url,
|
||||
consent_expiry_days,
|
||||
consent_mode,
|
||||
show_branding,
|
||||
default_language,
|
||||
pattern_analysis_requested_at,
|
||||
|
||||
@@ -33,7 +33,6 @@ type (
|
||||
PrivacyPolicyURL *string `json:"privacy_policy_url,omitempty"`
|
||||
CookiePolicyURL string `json:"cookie_policy_url"`
|
||||
ConsentExpiryDays int `json:"consent_expiry_days"`
|
||||
ConsentMode string `json:"consent_mode"`
|
||||
DefaultLanguage string `json:"default_language"`
|
||||
Categories []CookieBannerVersionSnapshotCategory `json:"categories"`
|
||||
}
|
||||
|
||||
@@ -42,6 +42,7 @@ type (
|
||||
SdkVersion string `db:"sdk_version"`
|
||||
Regulation *Regulation `db:"regulation"`
|
||||
CountryCode *CountryCode `db:"country_code"`
|
||||
ConsentMode *CookieConsentMode `db:"consent_mode"`
|
||||
CreatedAt time.Time `db:"created_at"`
|
||||
}
|
||||
|
||||
@@ -94,6 +95,7 @@ SELECT
|
||||
sdk_version,
|
||||
regulation,
|
||||
country_code,
|
||||
consent_mode,
|
||||
created_at
|
||||
FROM
|
||||
cookie_consent_records
|
||||
@@ -180,6 +182,7 @@ INSERT INTO cookie_consent_records (
|
||||
sdk_version,
|
||||
regulation,
|
||||
country_code,
|
||||
consent_mode,
|
||||
created_at
|
||||
) VALUES (
|
||||
@id,
|
||||
@@ -195,6 +198,7 @@ INSERT INTO cookie_consent_records (
|
||||
@sdk_version,
|
||||
@regulation,
|
||||
@country_code,
|
||||
@consent_mode,
|
||||
@created_at
|
||||
)
|
||||
`
|
||||
@@ -213,6 +217,7 @@ INSERT INTO cookie_consent_records (
|
||||
"sdk_version": r.SdkVersion,
|
||||
"regulation": r.Regulation,
|
||||
"country_code": r.CountryCode,
|
||||
"consent_mode": r.ConsentMode,
|
||||
"created_at": r.CreatedAt,
|
||||
}
|
||||
|
||||
@@ -244,6 +249,7 @@ SELECT
|
||||
sdk_version,
|
||||
regulation,
|
||||
country_code,
|
||||
consent_mode,
|
||||
created_at
|
||||
FROM
|
||||
cookie_consent_records
|
||||
@@ -297,6 +303,7 @@ SELECT
|
||||
sdk_version,
|
||||
regulation,
|
||||
country_code,
|
||||
consent_mode,
|
||||
created_at
|
||||
FROM
|
||||
cookie_consent_records
|
||||
|
||||
16
pkg/coredata/migrations/20260513T075812Z.sql
Normal file
16
pkg/coredata/migrations/20260513T075812Z.sql
Normal file
@@ -0,0 +1,16 @@
|
||||
-- Copyright (c) 2026 Probo Inc <hello@getprobo.com>.
|
||||
--
|
||||
-- Permission to use, copy, modify, and/or distribute this software for any
|
||||
-- purpose with or without fee is hereby granted, provided that the above
|
||||
-- copyright notice and this permission notice appear in all copies.
|
||||
--
|
||||
-- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
||||
-- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
-- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||
-- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
||||
-- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||
-- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
-- PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
ALTER TABLE cookie_consent_records ADD COLUMN consent_mode cookie_consent_mode;
|
||||
ALTER TABLE cookie_banners DROP COLUMN consent_mode;
|
||||
Reference in New Issue
Block a user