feat: add experience improvement module and system config storage (#1248)

- Add experience module for product telemetry
- Add system_config table for persistent settings
- Update privacy policy documentation
This commit is contained in:
tinkle-community
2025-12-19 13:57:08 +08:00
committed by GitHub
parent c81e6b0094
commit 97f58b49f4
12 changed files with 409 additions and 4 deletions

View File

@@ -1,6 +1,7 @@
package config
import (
"nofx/experience"
"os"
"strconv"
"strings"
@@ -22,14 +23,20 @@ type Config struct {
// TransportEncryption enables browser-side encryption for API keys
// Requires HTTPS or localhost. Set to false for HTTP access via IP.
TransportEncryption bool
// Experience improvement (anonymous usage statistics)
// Helps us understand product usage and improve the experience
// Set EXPERIENCE_IMPROVEMENT=false to disable
ExperienceImprovement bool
}
// Init initializes global configuration (from .env)
func Init() {
cfg := &Config{
APIServerPort: 8080,
RegistrationEnabled: true,
MaxUsers: 1, // Default: only 1 user allowed
APIServerPort: 8080,
RegistrationEnabled: true,
MaxUsers: 1, // Default: only 1 user allowed
ExperienceImprovement: true, // Default: enabled to help improve the product
}
// Load from environment variables
@@ -62,7 +69,16 @@ func Init() {
cfg.TransportEncryption = strings.ToLower(v) == "true"
}
// Experience improvement: anonymous usage statistics
// Default enabled, set EXPERIENCE_IMPROVEMENT=false to disable
if v := os.Getenv("EXPERIENCE_IMPROVEMENT"); v != "" {
cfg.ExperienceImprovement = strings.ToLower(v) != "false"
}
global = cfg
// Initialize experience improvement (installation ID will be set after database init)
experience.Init(cfg.ExperienceImprovement, "")
}
// Get returns the global configuration