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)
|
||||
|
||||
Reference in New Issue
Block a user