Skip to content

Commit 649a6e9

Browse files
committed
Reused mixpanel token from command file
1 parent 0405d5a commit 649a6e9

3 files changed

Lines changed: 6 additions & 9 deletions

File tree

.goreleaser.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ builds:
3232
flags:
3333
- -mod=readonly
3434
ldflags:
35-
- -X github.com/onflow/flow-cli/build.semver={{ .Env.VERSION }} -X github.com/onflow/flow-cli/internal/command.mixpanelToken={{ .Env.MIXPANEL_PROJECT_TOKEN }} -X github.com/onflow/flow-cli/internal/accounts.accountToken={{ .Env.LILICO_TOKEN }} -X github.com/onflow/flow-cli/internal/emulator/start.mixpanelToken={{ .Env.MIXPANEL_PROJECT_TOKEN }}
35+
- -X github.com/onflow/flow-cli/build.semver={{ .Env.VERSION }} -X github.com/onflow/flow-cli/internal/command.mixpanelToken={{ .Env.MIXPANEL_PROJECT_TOKEN }} -X github.com/onflow/flow-cli/internal/accounts.accountToken={{ .Env.LILICO_TOKEN }}
3636

3737
archives:
3838
- id: golang-cross

internal/command/command.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -364,14 +364,14 @@ func initCrashReporting() {
364364
}
365365

366366
// The token is injected at build-time using ldflags
367-
var mixpanelToken = ""
367+
var MixpanelToken = ""
368368

369369
func UsageMetrics(command *cobra.Command, wg *sync.WaitGroup) {
370-
if !settings.MetricsEnabled() || mixpanelToken == "" {
370+
if !settings.MetricsEnabled() || MixpanelToken == "" {
371371
return
372372
}
373373
wg.Add(1)
374-
client := mixpanel.New(mixpanelToken, "")
374+
client := mixpanel.New(MixpanelToken, "")
375375

376376
// calculates a user ID that doesn't leak any personal information
377377
usr, _ := user.Current() // ignore err, just use empty string

internal/emulator/start.go

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,6 @@ import (
4646

4747
var Cmd *cobra.Command
4848

49-
// The token is injected at build-time using ldflags
50-
var mixpanelToken = ""
51-
5249
// Mixpanel client to be reused on each http request of the middleware
5350
var mixpanelClient mixpanel.Mixpanel
5451

@@ -137,8 +134,8 @@ func trackRequestMiddleware(next http.Handler) http.Handler {
137134

138135
func init() {
139136
// Initialize mixpanel client only if metrics are enabled and token is not empty
140-
if settings.MetricsEnabled() && mixpanelToken != "" {
141-
mixpanelClient = mixpanel.New(mixpanelToken, "")
137+
if settings.MetricsEnabled() && command.MixpanelToken != "" {
138+
mixpanelClient = mixpanel.New(command.MixpanelToken, "")
142139
Cmd = start.Cmd(start.StartConfig{
143140
GetServiceKey: configuredServiceKey,
144141
RestMiddlewares: []start.HttpMiddleware{trackRequestMiddleware},

0 commit comments

Comments
 (0)