Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.PHONY: all setup build lint test install
.PHONY: all setup build run lint test

VERSION ?= $(shell git describe --tags --always --dirty 2>/dev/null | sed 's/^v//')
COMMIT ?= $(shell git rev-parse --short=12 HEAD 2>/dev/null || echo "unknown")
Expand All @@ -15,13 +15,11 @@ all: lint test build
setup: bin/golangci-lint
go mod download

dune-cli: lint
build: lint
go build -ldflags '$(LDFLAGS)' -o dune-cli ./cmd

build: dune-cli

install:
go build -ldflags '$(LDFLAGS)' -o $(shell go env GOPATH)/bin/dune ./cmd
run:
go run -ldflags '$(LDFLAGS)' ./cmd $(ARGS)

bin:
mkdir -p bin
Expand Down
16 changes: 16 additions & 0 deletions tracking/tracking.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ func New(cfg Config) *Tracker {
ampConfig.ServerZone = "EU"
ampConfig.FlushQueueSize = 1
ampConfig.FlushInterval = 1 * time.Second
if !isDevVersion(cfg.CLIVersion) {
ampConfig.Logger = silentLogger{}
}

return &Tracker{
client: amplitude.NewClient(ampConfig),
Expand Down Expand Up @@ -76,6 +79,19 @@ func (t *Tracker) Shutdown() {
}
}

// isDevVersion returns true for local / non-release builds.
func isDevVersion(v string) bool {
return v == "" || v == "dev"
}

// silentLogger suppresses all amplitude SDK log output.
type silentLogger struct{}

func (silentLogger) Debugf(string, ...interface{}) {}
func (silentLogger) Infof(string, ...interface{}) {}
func (silentLogger) Warnf(string, ...interface{}) {}
func (silentLogger) Errorf(string, ...interface{}) {}

const (
anonIDFile = "anonymous_id"
anonFallback = "anonymous"
Expand Down