diff --git a/Dockerfile b/Dockerfile index d9eabecab527..6398c1f12b94 100644 --- a/Dockerfile +++ b/Dockerfile @@ -38,6 +38,7 @@ RUN go mod download # Copy all other files COPY internal ./internal +COPY types ./types COPY main.go ./ COPY protos ./protos COPY shared_key.pem shared_cert.pem ./ diff --git a/internal/analytics/http_beacon.go b/internal/analytics/http_beacon.go index 4bcf600e39de..4996c87a0c09 100644 --- a/internal/analytics/http_beacon.go +++ b/internal/analytics/http_beacon.go @@ -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 { diff --git a/internal/support/cli/analytics.go b/internal/support/cli/analytics.go index f12f4366d740..47013c6951ac 100644 --- a/internal/support/cli/analytics.go +++ b/internal/support/cli/analytics.go @@ -3,6 +3,7 @@ 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" ) @@ -10,7 +11,7 @@ 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, diff --git a/internal/web/events.go b/internal/web/events.go index d888e996db29..2ee1b9f22fcb 100644 --- a/internal/web/events.go +++ b/internal/web/events.go @@ -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" ) @@ -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(), diff --git a/internal/analytics/types.go b/types/types.go similarity index 97% rename from internal/analytics/types.go rename to types/types.go index a5f7400aadf5..792d9d449ec6 100644 --- a/internal/analytics/types.go +++ b/types/types.go @@ -1,4 +1,4 @@ -package analytics +package types type BeaconEvent struct { Name string `json:"name"`