Skip to content

Commit

Permalink
chore(analytics): removes GA and only pings with beacon. also adds su…
Browse files Browse the repository at this point in the history
…pport actions (#2557)
  • Loading branch information
amir20 authored Dec 1, 2023
1 parent 23fbf36 commit 7da60ed
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 15 deletions.
2 changes: 2 additions & 0 deletions internal/analytics/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ type RequestEvent struct {
}

type BeaconEvent struct {
Name string `json:"name"`
Version string `json:"version"`
Browser string `json:"browser"`
AuthProvider string `json:"authProvider"`
Expand All @@ -28,4 +29,5 @@ type BeaconEvent struct {
HasCustomBase bool `json:"hasCustomBase"`
HasHostname bool `json:"hasHostname"`
RunningContainers int `json:"runningContainers"`
HasActions bool `json:"hasActions"`
}
2 changes: 2 additions & 0 deletions internal/web/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ func (h *handler) streamEvents(w http.ResponseWriter, r *http.Request) {

pages, _ := content.ReadAll()
b := analytics.BeaconEvent{
Name: "events",
Version: h.config.Version,
Browser: r.Header.Get("User-Agent"),
AuthProvider: string(h.config.Authorization.Provider),
Expand All @@ -43,6 +44,7 @@ func (h *handler) streamEvents(w http.ResponseWriter, r *http.Request) {
HasCustomAddress: h.config.Addr != ":8080",
Clients: len(h.clients),
HasDocumentation: len(pages) > 0,
HasActions: h.config.EnableActions,
}

{
Expand Down
19 changes: 4 additions & 15 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,24 +117,13 @@ func doStartEvent(arg args) {
log.Debug("Analytics disabled.")
return
}
host, err := os.Hostname()
if err != nil {
log.Debug(err)
return
}

event := analytics.StartEvent{
ClientId: host,
Version: version,
FilterLength: len(arg.Filter),
CustomAddress: arg.Addr != ":8080",
CustomBase: arg.Base != "/",
RemoteHostLength: len(arg.RemoteHost),
Protected: arg.Username != "",
HasHostname: arg.Hostname != "",
event := analytics.BeaconEvent{
Name: "start",
Version: version,
}

if err := analytics.SendStartEvent(event); err != nil {
if err := analytics.SendBeacon(event); err != nil {
log.Debug(err)
}
}
Expand Down

0 comments on commit 7da60ed

Please sign in to comment.