From 924d92a817705ea5034f17c6237b544c0351353b Mon Sep 17 00:00:00 2001 From: Guillaume Tardif Date: Fri, 8 Jan 2021 17:58:03 +0100 Subject: [PATCH] Do not send metrics if executed as CLI backend Signed-off-by: Guillaume Tardif --- metrics/metrics.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/metrics/metrics.go b/metrics/metrics.go index 801c25bba..e73bc6f83 100644 --- a/metrics/metrics.go +++ b/metrics/metrics.go @@ -17,6 +17,7 @@ package metrics import ( + "os" "strings" "github.com/docker/compose-cli/utils" @@ -24,6 +25,9 @@ import ( // Track sends the tracking analytics to Docker Desktop func Track(context string, args []string, status string) { + if isInvokedAsCliBackend() { + return + } command := GetCommand(args) if command != "" { c := NewClient() @@ -36,6 +40,11 @@ func Track(context string, args []string, status string) { } } +func isInvokedAsCliBackend() bool { + executable := os.Args[0] + return strings.HasSuffix(executable, "-backend") +} + func isCommand(word string) bool { return utils.StringContains(commands, word) || isManagementCommand(word) }