diff options
| author | Kyren223 <Kyren223@proton.me> | 2025-07-11 16:07:15 +0300 |
|---|---|---|
| committer | Kyren223 <Kyren223@proton.me> | 2025-07-19 18:32:12 +0300 |
| commit | dc6c10155c33033b386665e7882b91be9837f55a (patch) | |
| tree | 64ca15fdb2aec5a17c93bae99508f70e61b951a6 /internal/client/ui/core/core.go | |
| parent | 86c3f3f730dd8867f4d5df6fef428df36ff2d193 (diff) | |
Added anonymous_device_analytics option on the client and added cache
dir to store things like device ID and TOS hashes (only storing device
ID currently)
Diffstat (limited to 'internal/client/ui/core/core.go')
| -rw-r--r-- | internal/client/ui/core/core.go | 40 |
1 files changed, 25 insertions, 15 deletions
diff --git a/internal/client/ui/core/core.go b/internal/client/ui/core/core.go index 5a0f8db..11772fa 100644 --- a/internal/client/ui/core/core.go +++ b/internal/client/ui/core/core.go @@ -5,6 +5,8 @@ import ( "fmt" "log" "math" + "os" + "runtime" "slices" "time" @@ -13,6 +15,7 @@ import ( "github.com/charmbracelet/bubbles/timer" tea "github.com/charmbracelet/bubbletea" "github.com/charmbracelet/lipgloss" + "github.com/kyren223/eko/internal/client/config" "github.com/kyren223/eko/internal/client/gateway" "github.com/kyren223/eko/internal/client/ui" "github.com/kyren223/eko/internal/client/ui/colors" @@ -294,25 +297,11 @@ func (m *Model) updateConnected(message tea.Msg) tea.Cmd { combined := msg.Tos + "\n" + msg.PrivacyPolicy tos := tosscreen.New(combined) m.tos = &tos - // var setName tea.Cmd - // if m.name != "" { - // setName = gateway.Send(&packet.SetUserData{ - // Data: nil, - // User: &data.User{ - // Name: m.name, - // Description: "", - // IsPublicDM: true, - // }, - // }) - // m.name = "" - // } - // - // return tea.Batch(m.timer.Stop(), setName) case *packet.Error: if m.state == ConnectedAcceptedTos { if msg.Error == "success" { - return gateway.Send(&packet.GetNonce{}) + return tea.Batch(gateway.Send(&packet.GetNonce{}), SendAnalytics()) } else { log.Println("received error:", msg.Error) gateway.Disconnect() @@ -408,6 +397,7 @@ func (m *Model) updateAuthenticated(message tea.Msg) tea.Cmd { case *packet.Error: err := "new connection from another location, closing this one" if err == msg.Error { + gateway.Disconnect() return ui.Transition(ui.NewAuth()) } @@ -945,3 +935,23 @@ func getSignalNotification(signal snowflake.ID) int { func (m Model) ViewTos() string { return "TODO TOS" } + +func SendAnalytics() tea.Cmd { + if !config.ReadConfig().AnonymousDeviceAnalytics { + return nil // User disabled analytics + } + assert.Assert(config.ReadConfig().AnonymousDeviceAnalytics, "who is paranoid") + + osName := runtime.GOOS + arch := runtime.GOARCH + term := os.Getenv("TERM") + colorterm := os.Getenv("COLORTERM") + + return gateway.Send(&packet.DeviceAnalytics{ + DeviceID: config.ReadCache().DeviceID, + OS: osName, + Arch: arch, + Term: term, + Colorterm: colorterm, + }) +} |
