mirror of https://github.com/docker/compose.git
Merge pull request #1118 from gtardif/metrics_not_send_if_cli_backend
Do not send metrics if executed as CLI backend
This commit is contained in:
commit
e658e1e531
|
@ -17,6 +17,7 @@
|
||||||
package metrics
|
package metrics
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/docker/compose-cli/utils"
|
"github.com/docker/compose-cli/utils"
|
||||||
|
@ -24,6 +25,9 @@ import (
|
||||||
|
|
||||||
// Track sends the tracking analytics to Docker Desktop
|
// Track sends the tracking analytics to Docker Desktop
|
||||||
func Track(context string, args []string, status string) {
|
func Track(context string, args []string, status string) {
|
||||||
|
if isInvokedAsCliBackend() {
|
||||||
|
return
|
||||||
|
}
|
||||||
command := GetCommand(args)
|
command := GetCommand(args)
|
||||||
if command != "" {
|
if command != "" {
|
||||||
c := NewClient()
|
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 {
|
func isCommand(word string) bool {
|
||||||
return utils.StringContains(commands, word) || isManagementCommand(word)
|
return utils.StringContains(commands, word) || isManagementCommand(word)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue