From 299a28575aa2b26d11636bec8977b4f2e9620690 Mon Sep 17 00:00:00 2001 From: JulesFaucherre Date: Mon, 24 Jul 2023 09:31:08 +0200 Subject: [PATCH] fix tests --- Makefile | 2 +- Taskfile.yml | 2 +- telemetry/telemetry.go | 7 +++++++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index f857e87a5..a51a58c4a 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,7 @@ GOOS=$(shell go env GOOS) GOARCH=$(shell go env GOARCH) build: always - go build -o build/$(GOOS)/$(GOARCH)/circleci -ldflags='-X github.com/CircleCI-Public/circleci-cli/telemetry.SegmentEndpoint=' + go build -o build/$(GOOS)/$(GOARCH)/circleci -ldflags='-X github.com/CircleCI-Public/circleci-cli/telemetry.SegmentEndpoint=https://api.segment.io' build-all: build/linux/amd64/circleci build/darwin/amd64/circleci diff --git a/Taskfile.yml b/Taskfile.yml index 54153650e..3cb8bfffc 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -49,7 +49,7 @@ tasks: cmds: # LDFlags sets the segment endpoint to an empty string thus letting the analytics library set the default endpoint on its own # Not setting the `SegmentEndpoint` variable would let the value in the code ie "http://localhost" - - go build -v -o build/$(go env GOOS)/$(go env GOARCH)/circleci -ldflags='-X github.com/CircleCI-Public/circleci-cli/telemetry.SegmentEndpoint=' . + - go build -v -o build/$(go env GOOS)/$(go env GOARCH)/circleci -ldflags='-X github.com/CircleCI-Public/circleci-cli/telemetry.SegmentEndpoint=https://api.segment.io' . build-linux: desc: Build main diff --git a/telemetry/telemetry.go b/telemetry/telemetry.go index 74a959be3..5ffe0f5c5 100644 --- a/telemetry/telemetry.go +++ b/telemetry/telemetry.go @@ -85,6 +85,12 @@ func (cli nullClient) Track(_ Event) error { return nil } // Segment client // Used when telemetry is enabled +// Nil segment logger +type nilSegmentEmptyLogger struct{} + +func (nilSegmentEmptyLogger) Logf(format string, args ...interface{}) {} +func (nilSegmentEmptyLogger) Errorf(format string, args ...interface{}) {} + type segmentClient struct { analyticsClient analytics.Client user User @@ -93,6 +99,7 @@ type segmentClient struct { func newSegmentClient(user User) Client { cli, err := analytics.NewWithConfig(segmentKey, analytics.Config{ Endpoint: SegmentEndpoint, + Logger: nilSegmentEmptyLogger{}, }) if err != nil {