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:
@@ -58,7 +58,6 @@ func NewCmdCreate(f *cmdutil.Factory) *cobra.Command {
|
||||
flagCookiePolicyUrl string
|
||||
flagPrivacyPolicyUrl string
|
||||
flagConsentExpiry int
|
||||
flagConsentMode string
|
||||
)
|
||||
|
||||
cmd := &cobra.Command{
|
||||
@@ -106,17 +105,6 @@ func NewCmdCreate(f *cmdutil.Factory) *cobra.Command {
|
||||
return err
|
||||
}
|
||||
}
|
||||
if flagConsentMode == "" {
|
||||
if err := huh.NewSelect[string]().
|
||||
Title("Consent mode").
|
||||
Options(
|
||||
huh.NewOption("Opt-In", "OPT_IN"),
|
||||
huh.NewOption("Opt-Out", "OPT_OUT"),
|
||||
).
|
||||
Value(&flagConsentMode).Run(); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if flagName == "" {
|
||||
@@ -128,9 +116,6 @@ func NewCmdCreate(f *cmdutil.Factory) *cobra.Command {
|
||||
if flagCookiePolicyUrl == "" {
|
||||
return fmt.Errorf("cookie-policy-url is required; pass --cookie-policy-url or run interactively")
|
||||
}
|
||||
if flagConsentMode == "" {
|
||||
return fmt.Errorf("consent-mode is required; pass --consent-mode or run interactively")
|
||||
}
|
||||
|
||||
input := map[string]any{
|
||||
"organizationId": flagOrg,
|
||||
@@ -138,7 +123,6 @@ func NewCmdCreate(f *cmdutil.Factory) *cobra.Command {
|
||||
"origin": flagOrigin,
|
||||
"cookiePolicyUrl": flagCookiePolicyUrl,
|
||||
"consentExpiryDays": flagConsentExpiry,
|
||||
"consentMode": flagConsentMode,
|
||||
}
|
||||
if flagPrivacyPolicyUrl != "" {
|
||||
input["privacyPolicyUrl"] = flagPrivacyPolicyUrl
|
||||
@@ -167,7 +151,6 @@ func NewCmdCreate(f *cmdutil.Factory) *cobra.Command {
|
||||
cmd.Flags().StringVar(&flagCookiePolicyUrl, "cookie-policy-url", "", "Cookie policy URL (required)")
|
||||
cmd.Flags().StringVar(&flagPrivacyPolicyUrl, "privacy-policy-url", "", "Privacy policy URL")
|
||||
cmd.Flags().IntVar(&flagConsentExpiry, "consent-expiry-days", 365, "Days until consent expires")
|
||||
cmd.Flags().StringVar(&flagConsentMode, "consent-mode", "", "Consent mode: OPT_IN or OPT_OUT (required)")
|
||||
|
||||
return cmd
|
||||
}
|
||||
|
||||
@@ -36,7 +36,6 @@ query($id: ID!, $first: Int, $after: CursorKey) {
|
||||
name
|
||||
origin
|
||||
state
|
||||
consentMode
|
||||
}
|
||||
}
|
||||
pageInfo {
|
||||
@@ -50,11 +49,10 @@ query($id: ID!, $first: Int, $after: CursorKey) {
|
||||
`
|
||||
|
||||
type banner struct {
|
||||
ID string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Origin string `json:"origin"`
|
||||
State string `json:"state"`
|
||||
ConsentMode string `json:"consentMode"`
|
||||
ID string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Origin string `json:"origin"`
|
||||
State string `json:"state"`
|
||||
}
|
||||
|
||||
func NewCmdList(f *cmdutil.Factory) *cobra.Command {
|
||||
@@ -140,10 +138,10 @@ func NewCmdList(f *cmdutil.Factory) *cobra.Command {
|
||||
|
||||
rows := make([][]string, 0, len(banners))
|
||||
for _, b := range banners {
|
||||
rows = append(rows, []string{b.ID, b.Name, b.Origin, b.State, b.ConsentMode})
|
||||
rows = append(rows, []string{b.ID, b.Name, b.Origin, b.State})
|
||||
}
|
||||
|
||||
t := cmdutil.NewTable("ID", "NAME", "ORIGIN", "STATE", "CONSENT MODE").Rows(rows...)
|
||||
t := cmdutil.NewTable("ID", "NAME", "ORIGIN", "STATE").Rows(rows...)
|
||||
_, _ = fmt.Fprintln(f.IOStreams.Out, t)
|
||||
|
||||
if totalCount > len(banners) {
|
||||
|
||||
@@ -49,7 +49,6 @@ func NewCmdUpdate(f *cmdutil.Factory) *cobra.Command {
|
||||
flagCookiePolicyUrl string
|
||||
flagPrivacyPolicyUrl string
|
||||
flagConsentExpiry int
|
||||
flagConsentMode string
|
||||
flagDefaultLanguage string
|
||||
)
|
||||
|
||||
@@ -90,9 +89,6 @@ func NewCmdUpdate(f *cmdutil.Factory) *cobra.Command {
|
||||
if cmd.Flags().Changed("consent-expiry-days") {
|
||||
input["consentExpiryDays"] = flagConsentExpiry
|
||||
}
|
||||
if cmd.Flags().Changed("consent-mode") {
|
||||
input["consentMode"] = flagConsentMode
|
||||
}
|
||||
if cmd.Flags().Changed("default-language") {
|
||||
input["defaultLanguage"] = flagDefaultLanguage
|
||||
}
|
||||
@@ -122,7 +118,6 @@ func NewCmdUpdate(f *cmdutil.Factory) *cobra.Command {
|
||||
cmd.Flags().StringVar(&flagCookiePolicyUrl, "cookie-policy-url", "", "Cookie policy URL")
|
||||
cmd.Flags().StringVar(&flagPrivacyPolicyUrl, "privacy-policy-url", "", "Privacy policy URL")
|
||||
cmd.Flags().IntVar(&flagConsentExpiry, "consent-expiry-days", 0, "Days until consent expires")
|
||||
cmd.Flags().StringVar(&flagConsentMode, "consent-mode", "", "Consent mode: OPT_IN or OPT_OUT")
|
||||
cmd.Flags().StringVar(&flagDefaultLanguage, "default-language", "", "Default language code")
|
||||
|
||||
return cmd
|
||||
|
||||
@@ -36,7 +36,6 @@ query($id: ID!) {
|
||||
cookiePolicyUrl
|
||||
privacyPolicyUrl
|
||||
consentExpiryDays
|
||||
consentMode
|
||||
showBranding
|
||||
defaultLanguage
|
||||
createdAt
|
||||
@@ -56,7 +55,6 @@ type viewResponse struct {
|
||||
CookiePolicyUrl string `json:"cookiePolicyUrl"`
|
||||
PrivacyPolicyUrl *string `json:"privacyPolicyUrl"`
|
||||
ConsentExpiryDays int `json:"consentExpiryDays"`
|
||||
ConsentMode string `json:"consentMode"`
|
||||
ShowBranding bool `json:"showBranding"`
|
||||
DefaultLanguage string `json:"defaultLanguage"`
|
||||
CreatedAt string `json:"createdAt"`
|
||||
@@ -122,7 +120,6 @@ func NewCmdView(f *cmdutil.Factory) *cobra.Command {
|
||||
_, _ = fmt.Fprintf(out, "%s%s\n", label.Render("ID:"), v.ID)
|
||||
_, _ = fmt.Fprintf(out, "%s%s\n", label.Render("Origin:"), v.Origin)
|
||||
_, _ = fmt.Fprintf(out, "%s%s\n", label.Render("State:"), v.State)
|
||||
_, _ = fmt.Fprintf(out, "%s%s\n", label.Render("Consent Mode:"), v.ConsentMode)
|
||||
_, _ = fmt.Fprintf(out, "%s%d days\n", label.Render("Consent Expiry:"), v.ConsentExpiryDays)
|
||||
_, _ = fmt.Fprintf(out, "%s%s\n", label.Render("Default Language:"), v.DefaultLanguage)
|
||||
_, _ = fmt.Fprintf(out, "%s%s\n", label.Render("Cookie Policy:"), v.CookiePolicyUrl)
|
||||
|
||||
@@ -134,8 +134,8 @@ func RegulationForCountry(cc coredata.CountryCode) Regulation {
|
||||
// the visitor gives explicit consent; OPT_OUT means cookies may fire
|
||||
// immediately but the visitor must be offered a way to opt out.
|
||||
//
|
||||
// When the regulation is unknown or RegulationNone, it returns an empty
|
||||
// string so the caller can fall back to the banner's configured default.
|
||||
// When the regulation is unknown or RegulationNone, it defaults to
|
||||
// OPT_OUT (cookies may fire immediately, visitor can opt out).
|
||||
func ConsentModeForRegulation(r Regulation) string {
|
||||
switch r {
|
||||
case RegulationGDPR,
|
||||
@@ -157,6 +157,6 @@ func ConsentModeForRegulation(r Regulation) string {
|
||||
return ConsentModeOptOut
|
||||
|
||||
default:
|
||||
return ""
|
||||
return ConsentModeOptOut
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,7 +51,6 @@ type (
|
||||
PrivacyPolicyURL *string
|
||||
CookiePolicyURL string
|
||||
ConsentExpiryDays int
|
||||
ConsentMode coredata.CookieConsentMode
|
||||
}
|
||||
|
||||
CreateCookieCategoryRequest struct {
|
||||
@@ -68,7 +67,6 @@ type (
|
||||
PrivacyPolicyURL *string
|
||||
CookiePolicyURL *string
|
||||
ConsentExpiryDays *int
|
||||
ConsentMode *coredata.CookieConsentMode
|
||||
DefaultLanguage *string
|
||||
}
|
||||
|
||||
@@ -107,6 +105,7 @@ type (
|
||||
SdkVersion string
|
||||
Regulation *Regulation
|
||||
CountryCode *coredata.CountryCode
|
||||
ConsentMode *coredata.CookieConsentMode
|
||||
}
|
||||
|
||||
DetectedCookie struct {
|
||||
@@ -231,7 +230,6 @@ func (r *CreateCookieBannerRequest) Validate() error {
|
||||
v.Check(r.PrivacyPolicyURL, "privacy_policy_url", validator.URL())
|
||||
v.Check(r.CookiePolicyURL, "cookie_policy_url", validator.Required(), validator.URL())
|
||||
v.Check(r.ConsentExpiryDays, "consent_expiry_days", validator.Required(), validator.Min(1))
|
||||
v.Check(r.ConsentMode, "consent_mode", validator.Required(), validator.OneOfSlice(coredata.CookieConsentModes()))
|
||||
|
||||
return v.Error()
|
||||
}
|
||||
@@ -244,7 +242,6 @@ func (r *UpdateCookieBannerRequest) Validate() error {
|
||||
v.Check(r.PrivacyPolicyURL, "privacy_policy_url", validator.URL())
|
||||
v.Check(r.CookiePolicyURL, "cookie_policy_url", validator.URL())
|
||||
v.Check(r.ConsentExpiryDays, "consent_expiry_days", validator.Min(1))
|
||||
v.Check(r.ConsentMode, "consent_mode", validator.OneOfSlice(coredata.CookieConsentModes()))
|
||||
v.Check(r.DefaultLanguage, "default_language", validator.OneOfSlice(SupportedLanguages))
|
||||
|
||||
return v.Error()
|
||||
@@ -581,7 +578,6 @@ func (s *Service) CreateCookieBanner(
|
||||
PrivacyPolicyURL: req.PrivacyPolicyURL,
|
||||
CookiePolicyURL: req.CookiePolicyURL,
|
||||
ConsentExpiryDays: req.ConsentExpiryDays,
|
||||
ConsentMode: req.ConsentMode,
|
||||
ShowBranding: s.showBranding,
|
||||
DefaultLanguage: "en",
|
||||
CreatedAt: now,
|
||||
@@ -857,10 +853,9 @@ func (s *Service) UpdateCookieBanner(
|
||||
privacyChanged := req.PrivacyPolicyURL != nil && !ptrEqual(req.PrivacyPolicyURL, banner.PrivacyPolicyURL)
|
||||
cookiePolicyChanged := req.CookiePolicyURL != nil && *req.CookiePolicyURL != banner.CookiePolicyURL
|
||||
expiryChanged := req.ConsentExpiryDays != nil && *req.ConsentExpiryDays != banner.ConsentExpiryDays
|
||||
consentModeChanged := req.ConsentMode != nil && *req.ConsentMode != banner.ConsentMode
|
||||
defaultLangChanged := req.DefaultLanguage != nil && *req.DefaultLanguage != banner.DefaultLanguage
|
||||
|
||||
snapshotChanged := privacyChanged || cookiePolicyChanged || expiryChanged || consentModeChanged || defaultLangChanged
|
||||
snapshotChanged := privacyChanged || cookiePolicyChanged || expiryChanged || defaultLangChanged
|
||||
|
||||
if !nameChanged && !snapshotChanged {
|
||||
return nil
|
||||
@@ -878,9 +873,6 @@ func (s *Service) UpdateCookieBanner(
|
||||
if req.ConsentExpiryDays != nil {
|
||||
banner.ConsentExpiryDays = *req.ConsentExpiryDays
|
||||
}
|
||||
if req.ConsentMode != nil {
|
||||
banner.ConsentMode = *req.ConsentMode
|
||||
}
|
||||
if req.DefaultLanguage != nil {
|
||||
banner.DefaultLanguage = *req.DefaultLanguage
|
||||
}
|
||||
@@ -1609,11 +1601,9 @@ func (s *Service) GetActiveBannerConfig(
|
||||
}
|
||||
|
||||
config.Regulation = regulation
|
||||
if cm := ConsentModeForRegulation(regulation); cm != "" {
|
||||
config.ConsentMode = cm
|
||||
}
|
||||
config.ConsentMode = ConsentModeForRegulation(regulation)
|
||||
if !isLegacySDK(sdkVersion) {
|
||||
remapTextsForConsentMode(config.Texts, config.ConsentMode, regulation)
|
||||
remapTextsForConsentMode(config.Texts, config.ConsentMode)
|
||||
}
|
||||
|
||||
return config, nil
|
||||
@@ -1677,7 +1667,6 @@ func buildBannerConfig(
|
||||
PrivacyPolicyURL: privacyPolicyURL,
|
||||
CookiePolicyURL: snapshot.CookiePolicyURL,
|
||||
ConsentExpiryDays: snapshot.ConsentExpiryDays,
|
||||
ConsentMode: snapshot.ConsentMode,
|
||||
ShowBranding: banner.ShowBranding,
|
||||
Categories: categories,
|
||||
Texts: texts,
|
||||
@@ -1687,25 +1676,17 @@ func buildBannerConfig(
|
||||
// remapTextsForConsentMode overrides the generic banner text keys with
|
||||
// mode-specific variants so the client renders the appropriate copy
|
||||
// without needing consent-mode awareness itself.
|
||||
func remapTextsForConsentMode(texts map[string]string, consentMode string, regulation Regulation) {
|
||||
func remapTextsForConsentMode(texts map[string]string, consentMode string) {
|
||||
if texts == nil {
|
||||
return
|
||||
}
|
||||
|
||||
switch {
|
||||
case consentMode == ConsentModeOptOut:
|
||||
if consentMode == ConsentModeOptOut {
|
||||
remapTextKey(texts, "banner_title_opt_out", "banner_title")
|
||||
remapTextKey(texts, "banner_description_opt_out", "banner_description")
|
||||
remapTextKey(texts, "button_acknowledge", "button_accept_all")
|
||||
remapTextKey(texts, "button_opt_out", "button_reject_all")
|
||||
texts["button_customize"] = ""
|
||||
|
||||
case regulation == RegulationNone:
|
||||
remapTextKey(texts, "banner_title_notice", "banner_title")
|
||||
remapTextKey(texts, "banner_description_notice", "banner_description")
|
||||
remapTextKey(texts, "button_dismiss", "button_accept_all")
|
||||
texts["button_reject_all"] = ""
|
||||
texts["button_customize"] = ""
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1964,6 +1945,7 @@ func (s *Service) RecordConsent(
|
||||
SdkVersion: req.SdkVersion,
|
||||
Regulation: req.Regulation,
|
||||
CountryCode: req.CountryCode,
|
||||
ConsentMode: req.ConsentMode,
|
||||
CreatedAt: time.Now(),
|
||||
}
|
||||
|
||||
|
||||
@@ -34,7 +34,6 @@ func TestSnapshotsEqual(t *testing.T) {
|
||||
PrivacyPolicyURL: &policy,
|
||||
CookiePolicyURL: "https://example.com/cookies",
|
||||
ConsentExpiryDays: 180,
|
||||
ConsentMode: "OPT_IN",
|
||||
DefaultLanguage: "en",
|
||||
Categories: []coredata.CookieBannerVersionSnapshotCategory{
|
||||
{
|
||||
@@ -248,7 +247,6 @@ func TestBuildSnapshot_RankInvariant(t *testing.T) {
|
||||
ID: bannerID,
|
||||
CookiePolicyURL: "https://example.com/cookies",
|
||||
ConsentExpiryDays: 365,
|
||||
ConsentMode: coredata.CookieConsentModeOptIn,
|
||||
DefaultLanguage: "en",
|
||||
}
|
||||
|
||||
@@ -298,14 +296,15 @@ func TestRemapTextsForConsentMode(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
t.Run("no regulation clears reject and customize", func(t *testing.T) {
|
||||
t.Run("opt in mode keeps all buttons", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
texts := baseTexts()
|
||||
remapTextsForConsentMode(texts, ConsentModeOptIn, RegulationNone)
|
||||
remapTextsForConsentMode(texts, ConsentModeOptIn)
|
||||
|
||||
assert.Empty(t, texts["button_reject_all"])
|
||||
assert.Empty(t, texts["button_customize"])
|
||||
assert.Equal(t, "Accept All", texts["button_accept_all"])
|
||||
assert.Equal(t, "Reject All", texts["button_reject_all"])
|
||||
assert.Equal(t, "Customize", texts["button_customize"])
|
||||
})
|
||||
|
||||
t.Run("opt out mode maps opt out to reject and clears customize", func(t *testing.T) {
|
||||
@@ -313,7 +312,7 @@ func TestRemapTextsForConsentMode(t *testing.T) {
|
||||
|
||||
texts := baseTexts()
|
||||
texts["button_opt_out"] = "Do Not Sell"
|
||||
remapTextsForConsentMode(texts, ConsentModeOptOut, RegulationCCPA)
|
||||
remapTextsForConsentMode(texts, ConsentModeOptOut)
|
||||
|
||||
assert.Equal(t, "Do Not Sell", texts["button_reject_all"])
|
||||
assert.Empty(t, texts["button_customize"])
|
||||
|
||||
@@ -116,7 +116,6 @@ func buildSnapshot(
|
||||
PrivacyPolicyURL: banner.PrivacyPolicyURL,
|
||||
CookiePolicyURL: banner.CookiePolicyURL,
|
||||
ConsentExpiryDays: banner.ConsentExpiryDays,
|
||||
ConsentMode: string(banner.ConsentMode),
|
||||
DefaultLanguage: banner.DefaultLanguage,
|
||||
Categories: snapshotCategories,
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
@@ -440,7 +440,6 @@ func (r *mutationResolver) CreateCookieBanner(ctx context.Context, input types.C
|
||||
PrivacyPolicyURL: input.PrivacyPolicyURL,
|
||||
CookiePolicyURL: input.CookiePolicyURL,
|
||||
ConsentExpiryDays: input.ConsentExpiryDays,
|
||||
ConsentMode: input.ConsentMode,
|
||||
},
|
||||
)
|
||||
if err != nil {
|
||||
@@ -476,7 +475,6 @@ func (r *mutationResolver) UpdateCookieBanner(ctx context.Context, input types.U
|
||||
PrivacyPolicyURL: input.PrivacyPolicyURL,
|
||||
CookiePolicyURL: input.CookiePolicyURL,
|
||||
ConsentExpiryDays: input.ConsentExpiryDays,
|
||||
ConsentMode: input.ConsentMode,
|
||||
DefaultLanguage: input.DefaultLanguage,
|
||||
},
|
||||
)
|
||||
|
||||
@@ -120,7 +120,6 @@ type CookieBanner implements Node {
|
||||
privacyPolicyUrl: String
|
||||
cookiePolicyUrl: String!
|
||||
consentExpiryDays: Int!
|
||||
consentMode: CookieConsentMode!
|
||||
showBranding: Boolean!
|
||||
defaultLanguage: String!
|
||||
|
||||
@@ -528,7 +527,6 @@ input CreateCookieBannerInput {
|
||||
privacyPolicyUrl: String
|
||||
cookiePolicyUrl: String!
|
||||
consentExpiryDays: Int!
|
||||
consentMode: CookieConsentMode!
|
||||
}
|
||||
|
||||
input UpdateCookieBannerInput {
|
||||
@@ -537,7 +535,6 @@ input UpdateCookieBannerInput {
|
||||
privacyPolicyUrl: String
|
||||
cookiePolicyUrl: String
|
||||
consentExpiryDays: Int
|
||||
consentMode: CookieConsentMode
|
||||
defaultLanguage: String
|
||||
}
|
||||
|
||||
|
||||
@@ -72,7 +72,6 @@ func NewCookieBanner(b *coredata.CookieBanner) *CookieBanner {
|
||||
PrivacyPolicyURL: b.PrivacyPolicyURL,
|
||||
CookiePolicyURL: b.CookiePolicyURL,
|
||||
ConsentExpiryDays: b.ConsentExpiryDays,
|
||||
ConsentMode: b.ConsentMode,
|
||||
ShowBranding: b.ShowBranding,
|
||||
DefaultLanguage: b.DefaultLanguage,
|
||||
CreatedAt: b.CreatedAt,
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -4720,7 +4720,6 @@ func (r *Resolver) AddCookieBannerTool(ctx context.Context, req *mcp.CallToolReq
|
||||
PrivacyPolicyURL: input.PrivacyPolicyURL,
|
||||
CookiePolicyURL: input.CookiePolicyURL,
|
||||
ConsentExpiryDays: input.ConsentExpiryDays,
|
||||
ConsentMode: coredata.CookieConsentMode(input.ConsentMode),
|
||||
})
|
||||
if err != nil {
|
||||
return nil, types.AddCookieBannerOutput{}, fmt.Errorf("cannot create cookie banner: %w", err)
|
||||
@@ -4745,10 +4744,6 @@ func (r *Resolver) UpdateCookieBannerTool(ctx context.Context, req *mcp.CallTool
|
||||
if v := UnwrapOmittable(input.ConsentExpiryDays); v != nil && *v != nil {
|
||||
updateReq.ConsentExpiryDays = *v
|
||||
}
|
||||
if v := UnwrapOmittable(input.ConsentMode); v != nil && *v != nil {
|
||||
mode := coredata.CookieConsentMode(**v)
|
||||
updateReq.ConsentMode = &mode
|
||||
}
|
||||
if v := UnwrapOmittable(input.DefaultLanguage); v != nil && *v != nil {
|
||||
updateReq.DefaultLanguage = *v
|
||||
}
|
||||
|
||||
@@ -9311,7 +9311,6 @@ components:
|
||||
- state
|
||||
- cookie_policy_url
|
||||
- consent_expiry_days
|
||||
- consent_mode
|
||||
- show_branding
|
||||
- default_language
|
||||
- created_at
|
||||
@@ -9344,10 +9343,6 @@ components:
|
||||
consent_expiry_days:
|
||||
type: integer
|
||||
description: Days until consent expires
|
||||
consent_mode:
|
||||
type: string
|
||||
enum: [OPT_IN, OPT_OUT]
|
||||
description: Consent mode
|
||||
show_branding:
|
||||
type: boolean
|
||||
description: Whether to show Probo branding
|
||||
@@ -9726,7 +9721,6 @@ components:
|
||||
- origin
|
||||
- cookie_policy_url
|
||||
- consent_expiry_days
|
||||
- consent_mode
|
||||
properties:
|
||||
organization_id:
|
||||
$ref: "#/components/schemas/GID"
|
||||
@@ -9746,10 +9740,6 @@ components:
|
||||
consent_expiry_days:
|
||||
type: integer
|
||||
description: Days until consent expires
|
||||
consent_mode:
|
||||
type: string
|
||||
enum: [OPT_IN, OPT_OUT]
|
||||
description: Consent mode
|
||||
|
||||
AddCookieBannerOutput:
|
||||
type: object
|
||||
@@ -9787,11 +9777,6 @@ components:
|
||||
- integer
|
||||
- "null"
|
||||
go.probo.inc/mcpgen/omittable: true
|
||||
consent_mode:
|
||||
type:
|
||||
- string
|
||||
- "null"
|
||||
go.probo.inc/mcpgen/omittable: true
|
||||
default_language:
|
||||
type:
|
||||
- string
|
||||
|
||||
@@ -29,7 +29,6 @@ func NewCookieBanner(b *coredata.CookieBanner) *CookieBanner {
|
||||
PrivacyPolicyURL: b.PrivacyPolicyURL,
|
||||
CookiePolicyURL: b.CookiePolicyURL,
|
||||
ConsentExpiryDays: b.ConsentExpiryDays,
|
||||
ConsentMode: CookieBannerConsentMode(b.ConsentMode),
|
||||
ShowBranding: b.ShowBranding,
|
||||
DefaultLanguage: b.DefaultLanguage,
|
||||
CreatedAt: b.CreatedAt,
|
||||
|
||||
Reference in New Issue
Block a user