Default cookie consent to GDPR and track its source
When IP geolocation does not resolve a country, or resolves one with no known cookie-consent regulation (common on localhost and unmapped regions), the banner previously fell back to OPT_OUT with no recorded regulation. Apply GDPR (OPT_IN) as the safe default in that case so the strictest consent model wins when origin is unknown. To keep consent records auditable, stamp each one with a regulation source of DETECTED (resolved from geolocation) or DEFAULT (fell back to GDPR). The shared cookiebanner.ResolveRegulation helper centralizes the decision for both the config and consent endpoints, and the new value is exposed through GraphQL, MCP, the CLI, the n8n node, and the console consent-records views. Signed-off-by: Émile Ré <emile@probo.com>
This commit is contained in:
@@ -37,6 +37,7 @@ query($id: ID!, $first: Int, $after: CursorKey, $filter: CookieConsentRecordFilt
|
||||
action
|
||||
sdkVersion
|
||||
regulation
|
||||
regulationSource
|
||||
countryCode
|
||||
createdAt
|
||||
}
|
||||
@@ -52,13 +53,14 @@ query($id: ID!, $first: Int, $after: CursorKey, $filter: CookieConsentRecordFilt
|
||||
`
|
||||
|
||||
type consentRecord struct {
|
||||
ID string `json:"id"`
|
||||
VisitorID string `json:"visitorId"`
|
||||
Action string `json:"action"`
|
||||
SDKVersion string `json:"sdkVersion"`
|
||||
Regulation *string `json:"regulation"`
|
||||
CountryCode *string `json:"countryCode"`
|
||||
CreatedAt string `json:"createdAt"`
|
||||
ID string `json:"id"`
|
||||
VisitorID string `json:"visitorId"`
|
||||
Action string `json:"action"`
|
||||
SDKVersion string `json:"sdkVersion"`
|
||||
Regulation *string `json:"regulation"`
|
||||
RegulationSource *string `json:"regulationSource"`
|
||||
CountryCode *string `json:"countryCode"`
|
||||
CreatedAt string `json:"createdAt"`
|
||||
}
|
||||
|
||||
func NewCmdList(f *cmdutil.Factory) *cobra.Command {
|
||||
@@ -165,15 +167,20 @@ func NewCmdList(f *cmdutil.Factory) *cobra.Command {
|
||||
regulation = *r.Regulation
|
||||
}
|
||||
|
||||
regulationSource := "-"
|
||||
if r.RegulationSource != nil {
|
||||
regulationSource = *r.RegulationSource
|
||||
}
|
||||
|
||||
countryCode := "-"
|
||||
if r.CountryCode != nil {
|
||||
countryCode = *r.CountryCode
|
||||
}
|
||||
|
||||
rows = append(rows, []string{r.ID, r.VisitorID, r.Action, r.SDKVersion, regulation, countryCode, r.CreatedAt})
|
||||
rows = append(rows, []string{r.ID, r.VisitorID, r.Action, r.SDKVersion, regulation, regulationSource, countryCode, r.CreatedAt})
|
||||
}
|
||||
|
||||
t := cmdutil.NewTable("ID", "VISITOR ID", "ACTION", "SDK VERSION", "REGULATION", "COUNTRY", "CREATED AT").Rows(rows...)
|
||||
t := cmdutil.NewTable("ID", "VISITOR ID", "ACTION", "SDK VERSION", "REGULATION", "SOURCE", "COUNTRY", "CREATED AT").Rows(rows...)
|
||||
_, _ = fmt.Fprintln(f.IOStreams.Out, t)
|
||||
|
||||
if totalCount > len(records) {
|
||||
|
||||
@@ -37,6 +37,7 @@ query($id: ID!) {
|
||||
action
|
||||
sdkVersion
|
||||
regulation
|
||||
regulationSource
|
||||
countryCode
|
||||
createdAt
|
||||
}
|
||||
@@ -46,17 +47,18 @@ query($id: ID!) {
|
||||
|
||||
type viewResponse struct {
|
||||
Node *struct {
|
||||
Typename string `json:"__typename"`
|
||||
ID string `json:"id"`
|
||||
VisitorID string `json:"visitorId"`
|
||||
IPAddress *string `json:"ipAddress"`
|
||||
UserAgent *string `json:"userAgent"`
|
||||
ConsentData string `json:"consentData"`
|
||||
Action string `json:"action"`
|
||||
SdkVersion string `json:"sdkVersion"`
|
||||
Regulation *string `json:"regulation"`
|
||||
CountryCode *string `json:"countryCode"`
|
||||
CreatedAt string `json:"createdAt"`
|
||||
Typename string `json:"__typename"`
|
||||
ID string `json:"id"`
|
||||
VisitorID string `json:"visitorId"`
|
||||
IPAddress *string `json:"ipAddress"`
|
||||
UserAgent *string `json:"userAgent"`
|
||||
ConsentData string `json:"consentData"`
|
||||
Action string `json:"action"`
|
||||
SdkVersion string `json:"sdkVersion"`
|
||||
Regulation *string `json:"regulation"`
|
||||
RegulationSource *string `json:"regulationSource"`
|
||||
CountryCode *string `json:"countryCode"`
|
||||
CreatedAt string `json:"createdAt"`
|
||||
} `json:"node"`
|
||||
}
|
||||
|
||||
@@ -124,6 +126,10 @@ func NewCmdView(f *cmdutil.Factory) *cobra.Command {
|
||||
_, _ = fmt.Fprintf(out, "%s%s\n", label.Render("Regulation:"), *v.Regulation)
|
||||
}
|
||||
|
||||
if v.RegulationSource != nil {
|
||||
_, _ = fmt.Fprintf(out, "%s%s\n", label.Render("Regulation Source:"), *v.RegulationSource)
|
||||
}
|
||||
|
||||
if v.CountryCode != nil {
|
||||
_, _ = fmt.Fprintf(out, "%s%s\n", label.Render("Country Code:"), *v.CountryCode)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user