mirror of
https://github.com/NoFxAiOS/nofx.git
synced 2026-06-06 05:51:19 +08:00
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:
29
main.go
29
main.go
@@ -6,6 +6,7 @@ import (
|
||||
"nofx/backtest"
|
||||
"nofx/config"
|
||||
"nofx/crypto"
|
||||
"nofx/experience"
|
||||
"nofx/logger"
|
||||
"nofx/manager"
|
||||
"nofx/market"
|
||||
@@ -18,6 +19,7 @@ import (
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"github.com/joho/godotenv"
|
||||
)
|
||||
|
||||
@@ -58,6 +60,9 @@ func main() {
|
||||
defer st.Close()
|
||||
backtest.UseDatabase(st.DB())
|
||||
|
||||
// Initialize installation ID for experience improvement (anonymous statistics)
|
||||
initInstallationID(st)
|
||||
|
||||
// Initialize encryption service
|
||||
logger.Info("🔐 Initializing encryption service...")
|
||||
cryptoService, err := crypto.NewCryptoService()
|
||||
@@ -173,3 +178,27 @@ func newSharedMCPClient() mcp.AIClient {
|
||||
}
|
||||
return mcp.NewDeepSeekClient()
|
||||
}
|
||||
|
||||
// initInstallationID initializes the anonymous installation ID for experience improvement
|
||||
// This ID is persisted in database and used for anonymous usage statistics
|
||||
func initInstallationID(st *store.Store) {
|
||||
const key = "installation_id"
|
||||
|
||||
// Try to load from database
|
||||
installationID, err := st.GetSystemConfig(key)
|
||||
if err != nil {
|
||||
logger.Warnf("⚠️ Failed to load installation ID: %v", err)
|
||||
}
|
||||
|
||||
// Generate new ID if not exists
|
||||
if installationID == "" {
|
||||
installationID = uuid.New().String()
|
||||
if err := st.SetSystemConfig(key, installationID); err != nil {
|
||||
logger.Warnf("⚠️ Failed to save installation ID: %v", err)
|
||||
}
|
||||
logger.Infof("📊 Generated new installation ID: %s", installationID[:8]+"...")
|
||||
}
|
||||
|
||||
// Set installation ID in experience module
|
||||
experience.SetInstallationID(installationID)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user