Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
JulesFaucherre committed Aug 1, 2023
1 parent c6a3844 commit 299a285
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions telemetry/telemetry.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 {
Expand Down

0 comments on commit 299a285

Please sign in to comment.