Skip to content

Commit

Permalink
Put segment key in the code
Browse files Browse the repository at this point in the history
Moved the key inside the code because it was not possible not to add it to the Homebrew formula so we decided to write it in the code directly
  • Loading branch information
JulesFaucherre committed Aug 1, 2023
1 parent c2680d8 commit c6a3844
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 6 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=' -X 'github.com/CircleCI-Public/circleci-cli/telemetry.SegmentKey="`echo ${SEGMENT_KEY}`"'"
go build -o build/$(GOOS)/$(GOARCH)/circleci -ldflags='-X github.com/CircleCI-Public/circleci-cli/telemetry.SegmentEndpoint='

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=' -X 'github.com/CircleCI-Public/circleci-cli/telemetry.SegmentKey="`echo ${SEGMENT_KEY}`"'" .
- go build -v -o build/$(go env GOOS)/$(go env GOARCH)/circleci -ldflags='-X github.com/CircleCI-Public/circleci-cli/telemetry.SegmentEndpoint=' .

build-linux:
desc: Build main
Expand Down
2 changes: 1 addition & 1 deletion cmd/create_telemetry.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func CreateTelemetry(config *settings.Config) telemetry.Client {
return telemetry.CreateFileTelemetry(mockTelemetry)
}

if config.IsTelemetryDisabled {
if config.IsTelemetryDisabled || len(os.Getenv("CIRCLECI_CLI_TELEMETRY_OPTOUT")) != 0 {
return telemetry.CreateClient(telemetry.User{}, false)
}

Expand Down
1 change: 0 additions & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,6 @@ func MakeCommands() *cobra.Command {
flags.StringVar(&rootOptions.Endpoint, "endpoint", rootOptions.Endpoint, "URI to your CircleCI GraphQL API endpoint")
flags.StringVar(&rootOptions.GitHubAPI, "github-api", "https://api.github.com/", "Change the default endpoint to GitHub API for retrieving updates")
flags.BoolVar(&rootOptions.SkipUpdateCheck, "skip-update-check", skipUpdateByDefault(), "Skip the check for updates check run before every command.")
flags.BoolVar(&rootOptions.IsTelemetryDisabled, "disable-telemetry", false, "Do not show telemetry for the actual command")
flags.StringVar(&rootOptions.MockTelemetry, "mock-telemetry", "", "The path where telemetry must be written")

hidden := []string{"github-api", "debug", "endpoint", "mock-telemetry"}
Expand Down
4 changes: 2 additions & 2 deletions telemetry/telemetry.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ var (
CreateActiveTelemetry = newSegmentClient

SegmentEndpoint = "http://localhost"
SegmentKey = ""
segmentKey = "AbgkrgN4cbRhAVEwlzMkHbwvrXnxHh35"
)

type Approval string
Expand Down Expand Up @@ -91,7 +91,7 @@ type segmentClient struct {
}

func newSegmentClient(user User) Client {
cli, err := analytics.NewWithConfig(SegmentKey, analytics.Config{
cli, err := analytics.NewWithConfig(segmentKey, analytics.Config{
Endpoint: SegmentEndpoint,
})

Expand Down

0 comments on commit c6a3844

Please sign in to comment.