privacy

package
v0.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 5, 2026 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Overview

Package privacy provides consent management using Klaro with Google Consent Mode v2 support.

Index

Constants

This section is empty.

Variables

View Source
var PredefinedServices = []Service{
	{
		Name:        "klaro",
		Title:       "Consent Preferences",
		Description: "Stores your cookie consent choices (required)",
		Purposes:    []string{"functional"},
		Required:    true,
		Default:     true,
		Cookies: []Cookie{
			{Pattern: "^klaro"},
		},
	},
	{
		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 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 New

func New() *Module

New creates a new instance of the privacy module.

func (*Module) AdminURL

func (m *Module) AdminURL() string

AdminURL returns the admin dashboard URL for the module.

func (*Module) Init

func (m *Module) Init(ctx *module.Context) error

Init initializes the module with the given context.

func (*Module) IsEnabled

func (m *Module) IsEnabled() bool

IsEnabled returns whether privacy consent is enabled.

func (*Module) Migrations

func (m *Module) Migrations() []module.Migration

Migrations returns database migrations for the module.

func (*Module) RegisterAdminRoutes

func (m *Module) RegisterAdminRoutes(r chi.Router)

RegisterAdminRoutes registers admin routes for the module.

func (*Module) RegisterRoutes

func (m *Module) RegisterRoutes(_ chi.Router)

RegisterRoutes registers public routes for the module.

func (*Module) ReloadSettings

func (m *Module) ReloadSettings() error

ReloadSettings reloads settings from the database.

func (*Module) Shutdown

func (m *Module) Shutdown() error

Shutdown performs cleanup when the module is shutting down.

func (*Module) SidebarLabel

func (m *Module) SidebarLabel() string

SidebarLabel returns the display label for the admin sidebar.

func (*Module) TemplateFuncs

func (m *Module) TemplateFuncs() template.FuncMap

TemplateFuncs returns template functions provided by the module.

func (*Module) TranslationsFS

func (m *Module) TranslationsFS() embed.FS

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL