Skip to content

Commit

Permalink
chore: exposes analytics
Browse files Browse the repository at this point in the history
  • Loading branch information
amir20 committed Dec 15, 2024
1 parent bd0a81f commit 7e89691
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 4 deletions.
3 changes: 2 additions & 1 deletion internal/analytics/http_beacon.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ import (
"net/http"
"net/http/httputil"

"github.com/amir20/dozzle/types"
"github.com/rs/zerolog/log"
)

func SendBeacon(e BeaconEvent) error {
func SendBeacon(e types.BeaconEvent) error {
log.Trace().Interface("event", e).Msg("sending beacon")
jsonValue, err := json.Marshal(e)
if err != nil {
Expand Down
3 changes: 2 additions & 1 deletion internal/support/cli/analytics.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@ package cli
import (
"github.com/amir20/dozzle/internal/analytics"
"github.com/amir20/dozzle/internal/docker"
"github.com/amir20/dozzle/types"
"github.com/rs/zerolog/log"
)

func StartEvent(args Args, mode string, client docker.Client, subCommand string) {
if args.NoAnalytics {
return
}
event := analytics.BeaconEvent{
event := types.BeaconEvent{
Name: "start",
Version: args.Version(),
Mode: mode,
Expand Down
3 changes: 2 additions & 1 deletion internal/web/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/amir20/dozzle/internal/docker"
docker_support "github.com/amir20/dozzle/internal/support/docker"
support_web "github.com/amir20/dozzle/internal/support/web"
"github.com/amir20/dozzle/types"
"github.com/rs/zerolog/log"
)

Expand Down Expand Up @@ -111,7 +112,7 @@ func sendBeaconEvent(h *handler, r *http.Request, runningContainers int) {
if h.config.NoAnalytics {
return
}
b := analytics.BeaconEvent{
b := types.BeaconEvent{
AuthProvider: string(h.config.Authorization.Provider),
Browser: r.Header.Get("User-Agent"),
Clients: h.multiHostService.TotalClients(),
Expand Down
2 changes: 1 addition & 1 deletion internal/analytics/types.go → types/types.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package analytics
package types

type BeaconEvent struct {
Name string `json:"name"`
Expand Down

0 comments on commit 7e89691

Please sign in to comment.