Documentation
¶
Overview ¶
Package privacy provides consent management using Klaro with Google Consent Mode v2 support.
Index ¶
- Variables
- type Cookie
- type Module
- func (m *Module) AdminURL() string
- func (m *Module) Init(ctx *module.Context) error
- func (m *Module) IsEnabled() bool
- func (m *Module) Migrations() []module.Migration
- func (m *Module) RegisterAdminRoutes(r chi.Router)
- func (m *Module) RegisterRoutes(_ chi.Router)
- func (m *Module) ReloadSettings() error
- func (m *Module) Shutdown() error
- func (m *Module) SidebarLabel() string
- func (m *Module) TemplateFuncs() template.FuncMap
- func (m *Module) TranslationsFS() embed.FS
- type Service
- type Settings
Constants ¶
This section is empty.
Variables ¶
var PredefinedServices = []Service{ { Name: "klaro", Title: "Essential Cookies", Description: "Stores consent choices and UI preferences (required)", Purposes: []string{"essential"}, Required: true, Default: true, Cookies: []Cookie{ {Pattern: "^klaro"}, {Pattern: "^ocms_lang$"}, {Pattern: "^(__Host-)?session$"}, {Pattern: "^ocms_informer_dismissed"}, }, }, { Name: "google-analytics", Title: "Google Analytics", Description: "Website traffic analysis and statistics", Purposes: []string{"analytics"}, GCMConsentType: "analytics_storage", Cookies: []Cookie{ {Pattern: "^_ga"}, {Pattern: "^_gid"}, {Pattern: "^_gat"}, }, }, { Name: "google-ads", Title: "Google Ads", Description: "Conversion tracking and personalized advertising", Purposes: []string{"marketing"}, GCMConsentType: "ad_storage,ad_user_data,ad_personalization", Cookies: []Cookie{ {Pattern: "^_gcl"}, {Pattern: "^_gac"}, }, }, { Name: "google-tag-manager", Title: "Google Tag Manager", Description: "Tag management system for analytics and marketing tags", Purposes: []string{"functional"}, }, { Name: "matomo", Title: "Matomo", Description: "Privacy-focused website analytics", Purposes: []string{"analytics"}, Cookies: []Cookie{ {Pattern: "^_pk_"}, {Pattern: "^mtm_"}, }, }, }
PredefinedServices provides common service configurations.
Functions ¶
This section is empty.
Types ¶
type Cookie ¶
type Cookie struct {
Pattern string `json:"pattern"`
Path string `json:"path,omitempty"`
Domain string `json:"domain,omitempty"`
ExpiresAfter string `json:"expiresAfter,omitempty"`
}
Cookie represents a cookie pattern for a service.
type Module ¶
type Module struct {
module.BaseModule
// contains filtered or unexported fields
}
Module implements the module.Module interface for the privacy/consent module.
func (*Module) Migrations ¶
Migrations returns database migrations for the module.
func (*Module) RegisterAdminRoutes ¶
RegisterAdminRoutes registers admin routes for the module.
func (*Module) RegisterRoutes ¶
RegisterRoutes registers public routes for the module.
func (*Module) ReloadSettings ¶
ReloadSettings reloads settings from the database.
func (*Module) SidebarLabel ¶
SidebarLabel returns the display label for the admin sidebar.
func (*Module) TemplateFuncs ¶
TemplateFuncs returns template functions provided by the module.
func (*Module) TranslationsFS ¶
TranslationsFS returns the embedded filesystem containing module translations.
type Service ¶
type Service struct {
Name string `json:"name"`
Title string `json:"title"`
Description string `json:"description"`
Purposes []string `json:"purposes"`
Required bool `json:"required"`
Default bool `json:"default"`
Cookies []Cookie `json:"cookies,omitempty"`
GCMConsentType string `json:"gcm_consent_type,omitempty"` // Maps to GCM parameters
}
Service represents a consent service configuration.
type Settings ¶
type Settings struct {
Enabled bool
Debug bool // Enable console logging for debugging
// Privacy Policy
PrivacyPolicyURL string
// Cookie Configuration
CookieName string
CookieExpiresDays int
// Appearance
Theme string // "light" or "dark"
Position string // "bottom-left", "bottom-right", "top-left", "top-right"
// Google Consent Mode v2
GCMEnabled bool
GCMDefaultAnalytics bool
GCMDefaultAdStorage bool
GCMDefaultAdUserData bool
GCMDefaultAdPersonalization bool
GCMWaitForUpdate int // milliseconds
// Services
Services []Service
}
Settings holds the privacy/consent configuration.